
Daniel McCarthy
@nibblebitsDragonZap administratorBest selling author in kernel development fields, I build C compilers and kernel modules frequently. I love teaching and helping the OSDEV community
Recent activity
Daniel McCarthy’s latest published contributions across the community.
Decode UTF-8 Safely in C Before Lexing Source
A compiler front end needs to track where a token came from. With UTF-8 source, one decoded value can occupy several bytes. If the lexer advances...
Lower Short-Circuit Boolean Expressions to Branches in C
If ready() returns zero, ready() && consume() leaves consume() uncalled. A compiler emitting code for that expression needs a path around...
Build a Single-Producer, Single-Consumer Ring Buffer in C11
A producer can have the next event ready while a consumer is still reading a previous one. A bounded ring lets the two threads pass fixed-size ev...
Calculate C Struct Padding and Alignment in a Tiny Compiler
The members of a C struct can occupy seven bytes while the struct itself occupies twelve. To generate code for a member access such as sample.seq...
Where Does the Fifth Argument Go? Calling NASM from C on Windows x64
A C call with five integer arguments is a useful way to see the boundary between registers and the stack. Under the Windows x64 calling conventio...
Read a Fragmented FAT16 File in C
A file's first cluster tells you where its first bytes live. The next part of the file might be several clusters away. To read a fragmented FAT16...
Build a Tiny x86-64 Assembler: Resolve Forward Jumps with Fixups
A forward jump refers to code you have not emitted yet. At the moment you write the jump instruction, you know the target's name, but its byte po...
Resolve Names Before Generating Code: A Scoped Symbol Table
Your parser can recognize an identifier without knowing which declaration it refers to. Once nested blocks can reuse a name, that distinction bec...
Build a Tiny Expression Parser with Precedence Climbing
A compiler front end has to answer a deceptively small question: what structure does an expression describe? Consider 7 + 2 * 5. If you combine e...
From ELF File to Running Process: Building an ELF64 Loader for Your Kernel
From ELF File to Running Process: Building an ELF64 Loader for Your Kernel Your kernel boots. Paging works. The scheduler can switch between task...