RosettaCodeData/Task/Flow-control-structures/Z80-Assembly/flow-control-structures-1.z80

8 lines
477 B
Z80 Assembly

PrintString:
ld a,(hl) ;HL is our pointer to the string we want to print
cp 0 ;it's better to use OR A to compare A to zero, but for demonstration purposes this is easier to read.
ret z ;return if accumulator = zero
call PrintChar ;prints accumulator's ascii code to screen - on Amstrad CPC for example this label points to memory address &BB5A
inc hl ;next char
jr PrintString ;jump back to the start of the loop. RET Z is our only exit.