Syscall Refactors & String Tokens | 32 Bit OS Dev (in C)
Channel: Queso Fuego
Date: 2023-05-11

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:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqajsw8Xh7SP9KJwjfpP8TNX

Git Repos:
Sourcehut: https://git.sr.ht/~queso_fuego/quesos
Github mirror: https://github.com/queso-fuego/amateuros

Repo state at the start of this video:
git clone -n https://github.com/queso-fuego/amateuros
cd amateuros
git checkout 0b351efc9dc090d19bffa788f6a89485dc91d0b5

Misc links:
https://en.wikipedia.org/wiki/X86_calling_conventions

Join the Community Discord: https://discord.gg/yKm4T89QFn

Contact:
email: fuegoqueso@gmail.com
twitter: @Queso_Fuego
twitch: https://www.twitch.tv/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: https://queso_fuego.srht.site/about.html

Music credits:
New Road by Ghostrifter Official | https://soundcloud.com/ghostrifter-official
Creative Commons — Attribution-NoDerivs 3.0 Unported — CC BY-ND 3.0
Music promoted by https://www.chosic.com/free-music/all/

#syscalls #kerneldev #cprogramming