26 lines
1.0 KiB
Z80 Assembly
26 lines
1.0 KiB
Z80 Assembly
PrintChar equ &BB5A ;Amstrad CPC BIOS call, prints the ascii code in the accumulator to the screen.
|
|
|
|
org &8000
|
|
ld b,5 ; repeat 5 times
|
|
|
|
loop:
|
|
call PrintImmediate
|
|
byte "ha",0
|
|
djnz loop
|
|
|
|
ret ; return to basic
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
PrintImmediate:
|
|
pop hl ; get the return address into HL, it's the start of the embedded string.
|
|
call PrintString
|
|
; inc hl ; if your strings are null-terminated you can omit this, since a 0 equals the "NOP" instruction
|
|
jp (hl) ; acts as a ret, returning execution to the instruction just after the embedded string.
|
|
|
|
PrintString:
|
|
ld a,(hl) ; read in a character from the string
|
|
or a ; if your strings are null-terminated you can use this as a shortcut, otherwise use the compare instruction
|
|
ret z ; exit once the terminator is reached.
|
|
call PrintChar ; BIOS call, all regs are preserved.
|
|
inc hl ; next char
|
|
jr PrintString ; back to start.
|