
Handle Traps in RISC-V Machine Mode With mtvec, mepc and mcause
Write a RISC-V machine-mode trap handler in assembly: set mtvec, save registers, decode mcause, advance mepc past ecall and return with mret.
x86-64, ARM, AArch64 and RISC-V assembly, calling conventions, SIMD, pipelines, caches and memory ordering, and reading the disassembly your compiler wrote.

Write a RISC-V machine-mode trap handler in assembly: set mtvec, save registers, decode mcause, advance mepc past ecall and return with mret.

Move a NASM boot sector into 32-bit protected mode, set up a flat GDT and a stack, then call a freestanding C function that writes to VGA text memory.

Choose between legacy BIOS and UEFI for a hobby OS by comparing the CPU mode at entry, boot media, memory map, graphics and tooling, with a decision table.

Decode the 512-byte master boot record field by field, from 446 bytes of boot code to four 16-byte partition entries and the 0xAA55 signature, with xxd output.

Print strings and hex values in 16-bit real mode with BIOS int 0x10, using teletype function 0x0E and write-string function 0x13, in reusable NASM routines.

Boot a 512-byte boot sector in QEMU 9 with a raw drive option, then attach GDB to the emulated CPU to break at 0x7C00 and step real-mode instructions.

Write a 512-byte boot sector in NASM that sets up segments and a stack, prints a string with BIOS int 0x10 and ends with the 0xAA55 signature, line by line.

Load and store bytes, words, dwords and qwords on x86-64 with MOV, and widen small values correctly with MOVZX, MOVSX and MOVSXD. Worked examples included.

Learn the x86-64 memory operand form [base + index*scale + displacement], what each part may be, which combinations are illegal, and how arrays map onto it.

How the x86-64 carry, zero, sign and overflow flags are set by add, sub and cmp, with worked 8-bit examples and the conditional jumps that read them.

Write, assemble and link a complete x86-64 program with NASM on Linux. It prints a line, exits with a status code, and uses no C library at all.

The sixteen x86-64 general-purpose registers, their 32, 16 and 8-bit names, what each is conventionally for, and the write rules that trip up beginners.
We send one email when a new post is published. No spam.