22 lines
1.0 KiB
Z80 Assembly
22 lines
1.0 KiB
Z80 Assembly
PrintString:
|
|
; HL contains the pointer to the string literal.
|
|
ld a,(hl)
|
|
or a ;compares to zero quicker than "CP 0"
|
|
ret z ;we're done printing the string, so exit.
|
|
cp '\' ; a single ascii character is specified in single quotes. This compares A to the backslash's ASCII value.
|
|
jr z,HandleSpecialChars ; if accumulator = '\' then goto "HandleSpecialChars"
|
|
call PrintChar ;unimplemented print routine, depending on the system this is either a BIOS call
|
|
; or a routine written by the programmer.
|
|
|
|
inc hl ;next character
|
|
jr PrintString ;back to top
|
|
|
|
|
|
HandleSpecialChars:
|
|
inc hl ;next char
|
|
ld a,(hl)
|
|
cp 'n'
|
|
call z,NewLine ;unimplemented routine, advances text cursor to next line. Only called if accumulator = 'n'.
|
|
inc hl ;advance past the 'n' to the next char.
|
|
jr PrintString ;jump back to top. Notice that neither the backslash nor the character after it were actually printed.
|