Array: Difference between revisions

Content added Content deleted
Line 70: Line 70:


Iteration over the elements of an array is fairly straightforward.
Iteration over the elements of an array is fairly straightforward.
<lang 68000devpac>LEA myArray,A0
<lang 68000devpac>;68000 Assembly example
LEA myArray,A0
loop:
loop:
MOVE.B (A0)+,D0
MOVE.B (A0)+,D0
JMP loop</lang>
JMP loop</lang>


<lang z80>;z80 Assembly example
<lang z80>ld hl,myArray ;load the address of myArray into hl
ld hl,myArray ;load the address of myArray into hl
ld de,userRam ;load the address of work RAM into de
ld de,userRam ;load the address of work RAM into de
ld bc,myArrayEnd-myArray ;assembler directive that auto-calculates the array size using labels placed at the beginning and end.
ld bc,myArrayEnd-myArray ;assembler directive that auto-calculates the array size using labels placed at the beginning and end.