Master the fundamental concepts of real mode programming through this focused micro-challenge.
The stack lives at SS:SP. PUSH decrements SP by two and stores a word; POP loads and increments. CALL pushes the return offset; RET pops it. For example, with SS=0x9000 and SP=0xFFFE, a PUSH AX stores AX at physical 0x9FFFE.
nasmLoading…
Stack overflow in boot code silently corrupts nearby sectors; place SS high in conventional memory.
Loading SS does not change SP; always set SP immediately after SS with interrupts disabled if you share the instruction stream with IRQs. A stack growing down from 0xFFFF in segment 0x9000 stays below most boot images loaded at 0x7C00. Far calls push only offset unless you use far proc directives; mismatched near/far return corrupts the stack in subtle ways.
You will set up SS:SP and use PUSH/POP, CALL/RET around a small function. This exercise requires computing physical stack addresses and avoiding overlap with your code at 0x7C00.
Implement a 16-bit stack simulator in C.
Requirements:
Test:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it works