DYSTOPIANPIXEL

Labels and structure

Organise entry points and reusable routines with clear names.

Next Asset Lab concept artwork showing sprite patterns, palette colours and animation frames
Next Asset Lab concept artwork · Begin with Odin Dev.2k and the foundations of Z80 assembly.
TUTORIAL 2 / PART 09

Labels, names and the shape of a real programme

A label such as again: is a symbol that the assembler resolves to an address. Labels can identify entry points, alternate paths, data or callable subroutines. By naming the destination, they make source easier to change: move a block of code, and the assembler recalculates addresses and offsets.

Use descriptive names for real routines. done is fine in a tiny example, but a larger editor might prefer palette_done, file_error or editor_main_loop so that the reader does not confuse several unrelated ‘done’ paths. In a later multi-module build, we will decide how symbols are exported and whether any labels are local to a module; do not assume Odin Dev.2k supports a particular local-label syntax before checking its own guide.

The three sorts of movement we have met

Fall-throughContinues into the next instructionNo separate return address is needed
JR / JPChanges PC to a chosen targetNo
CALLChanges PC to a subroutine and stores the return addressYes, on the stack

A JR or JP is not a substitute for CALL when you expect to return. That difference explains why the stack exists and why we must understand it before structuring larger code.