Loop over multiple arrays simultaneously: Difference between revisions

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}}==
1,489

edits