News for hackers. Stuff that matters.
Re:Snowdrop OS – a homebrew operating system from scratch, i... by drivers99 on Saturday January 25, 2025 @10:48AM (#42822304)
This might interest you: Writing a C Compiler by Nora Sandler (No Starch Press). You create a working C compiler that outputs x64 assembly language in the first chapter (as long as the program only returns an integer from main) and then you keep adding features one by one for the rest of the book. You can write the compiler in any language you like (I’m using Python) and you only write the compiler while using your system’s precompiler (the step that handles #include and #define etc and removes comments), linker, and assembler. You just read preprocessed C as text and output assembly as text.

The thing that makes it relevant for learning assembly is that’s what you’re outputting so you’ll be learning that as well as what’s going on with the stack when calling and returning from functions and using local variables and basically everything that corresponds to C. (I’m only on chapter 2.)

Some other reasons it might work out for you is that you are getting into C as well already, and you have a familiar language you could use for the compiler if you wanted: java (assuming it doesn’t take too long to compile and run a java program repeatedly)

Re:Snowdrop OS – a homebrew operating system from scratch, i... by fuzztester on Sunday January 26, 2025 @06:21PM (#42835359)
>precompiler

s/precompiler/preprocessor/g

, i guess.

Re:Snowdrop OS – a homebrew operating system from scratch, i... by drivers99 on Monday January 27, 2025 @02:13PM (#42844547)
Oops. Yes, you're correct.