Syscall Refactors & String Tokens | 32 Bit OS Dev (in C)
Вставка
- Опубліковано 4 лип 2024
- Changing system calls to return ints and use a struct of register values from the stack to use less inline assembly, and adding quoted strings as tokens so the calculator can evaluate expressions from the command line.
Errata:
- Tokenizing strings should check for null in addition to the ending quote; it's probably quite buggy at the moment if you do not end with the 2nd dbl quote!
Notes:
- Since C passes all variables by value and x86 cdecl I think passes all struct members separately if not a struct pointer, those values are discarded on function exit. That is, if you set the value of a struct member, that member is going to be set back to what it was on function input. That would explain why setting "regs.edx = ptr" did not work, as the value in regs.edx is reset to what it was on input. It would have to be a pointer to the struct instead, or another way of keeping state between function calls. With that in mind, there is probably no reason to pop all the values back after the call in the syscall dispatcher, other than keeping the stack managed correctly.
Next video:
- Maybe redoing the editor to use open/close/read/write syscalls instead of the older file table way which doesn't work now, or making more of an ed-like editor. Or changing the makefile to be more straight forward and better for incremental builds, following the posix make standard. Or mkdir & chdir. Or other things...
OS Dev playlist:
• Amateur Makes an OS
Git Repos:
Sourcehut: git.sr.ht/~queso_fuego/quesos
Github mirror: github.com/queso-fuego/amateuros
Repo state at the start of this video:
git clone -n github.com/queso-fuego/amateuros
cd amateuros
git checkout 0b351efc9dc090d19bffa788f6a89485dc91d0b5
Misc links:
en.wikipedia.org/wiki/X86_cal...
Join the Community Discord: / discord
Contact:
email: fuegoqueso@gmail.com
twitter: @Queso_Fuego
twitch: / queso_fuego
- Let me know if there's anything specific you'd like to see!
Outline:
0:00 intro/plan
7:10 refactor syscalls to return int values
21:11 add input registers struct to syscalls
49:32 tokenize dbl quoted strings as 1 token
55:08 evaluate string arguments in calculator
Questions about setup/software/etc.?
Check the FAQ: queso_fuego.srht.site/about.html
Music credits:
New Road by Ghostrifter Official | / ghostrifter-official
Creative Commons - Attribution-NoDerivs 3.0 Unported - CC BY-ND 3.0
Music promoted by www.chosic.com/free-music/all/
#syscalls #kerneldev #cprogramming - Наука та технологія
please continue you are a hero!1
I'll try to get back to this a little these next couple weeks. I had good results testing with PIE back on, and loading programs as ELF instead of flat binary, so may do that.
Very good content interenting