Repeat a string: Difference between revisions
→{{header|Z80 Assembly}}
No edit summary |
Puppydrum64 (talk | contribs) |
||
Line 2,661:
=={{header|Yorick}}==
<lang yorick>array("ha", 5)(sum)</lang>
=={{header|Z80 Assembly}}==
<lang z80>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.</lang>
{{out}}
<pre>
hahahahaha
</pre>
=={{header|zig}}==
|