Loop over multiple arrays simultaneously: Difference between revisions
Loop over multiple arrays simultaneously (view source)
Revision as of 22:43, 3 October 2021
, 2 years ago→{{header|Z80 Assembly}}
m (→{{header|Quackery}}: typo) |
Puppydrum64 (talk | contribs) |
||
Line 4,196:
cC3
</pre>
=={{header|Z80 Assembly}}==
<lang z80>org &1000
ld b,3
ld ix,array1
loop:
ld a,(ix)
call &bb5a ;prints character to screen
ld a,(ix+3)
call &bb5a
ld a,(ix+6)
call &bb5a
ld a,13
call &bb5a
ld a,10
call &bb5a
inc ix
djnz loop
ret
array1:
db "abc"
array2:
db "ABC"
array3:
db "123"</lang>
{{out}}
<pre>
Ready
call &1000
aA1
bB2
cC3
Ready
</pre>
The program was only written to display the first 3 characters. If they were of different lengths, the wrong characters (or random bytes outside the program) would have been read, depending on which array "ran out" first. The three arrays defined with the <code>db</code> directive are stored sequentially.
=={{header|zkl}}==
|