Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Repeat-a-string/Z80-Assembly/repeat-a-string.z80
Normal file
25
Task/Repeat-a-string/Z80-Assembly/repeat-a-string.z80
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue