Z80 Assembly 04: Memory, I/O Ports, and the Index Registers

Memory Management with 16-bit Pointers The Z80 is excellent at handling 16-bit memory addresses. The most common pairs for this are HL, DE, and BC. Moving Data to/from Memory: Remember that parentheses () mean “the contents of the address.” Instruction Action Analogy LD A, (HL) Loads the byte at the address in HL into A. Reads the note at the address in your address book. LD (DE), A Stores the byte in A into the address in DE. Writes a note at the address in your address book. Stepping Through Memory: ...

September 27, 2025

Z80 Assembly 03: Subroutines and The Stack (Saving Your Work)

Subroutines: Reusing Code A subroutine is a block of code designed to perform a specific task that can be called from anywhere in your program. This is how you avoid writing the same code repeatedly. The Two Commands: Command Action Analogy CALL NNNN Jumps to the address NNNN (the subroutine). Go to another room to perform a task. RET Jumps back to the instruction immediately following the CALL. Return to where you were before the task. The Stack: The LIFO Scratchpad The Stack is an area of memory managed by the Stack Pointer (SP). When you call a subroutine, the Z80 automatically uses the stack to save the return address. ...

September 27, 2025