29 lines
1,022 B
Text
29 lines
1,022 B
Text
myArray equ $240000
|
|
|
|
;insert a new element into the 2nd slot and push everything behind it back.
|
|
|
|
LEA myArray,A0 ;load the base address of the array into A0
|
|
MOVE.W #2,D0 ;offset into 2nd slot
|
|
LSL.W #2,D0 ;this array is intended for 32-bit values.
|
|
MOVE.L #46,D1 ;this is our new element.
|
|
|
|
|
|
|
|
MOVE.L (A0,D0),(4,A0,D0) ;store the 2nd element into the 3rd slot
|
|
ADDA.L #4,A0 ;increment to next slot.
|
|
MOVE.L (A0,D0),(4,A0,D0) ;store the 3nd element into the 4th slot
|
|
ADDA.L #4,A0 ;increment to next slot.
|
|
MOVE.L (A0,D0),(4,A0,D0) ;store the 4th element into the 5th slot
|
|
ADDA.L #4,A0 ;increment to next slot.
|
|
MOVE.L (A0,D0),(4,A0,D0) ;store the 5th element into the 6th slot
|
|
|
|
LEA myArray,A0 ;restore the base address
|
|
MOVE.L D1,(A0,D0) ;store the new 2nd element over the 2nd slot.
|
|
|
|
;for a larger array we can use the following loop:
|
|
MOVE.W #3,D2 ;array length minus starting offset minus 1
|
|
|
|
LOOP:
|
|
MOVE.L (A0,D0),(4,A0,D0)
|
|
ADDA.L #4,A0
|
|
DBRA D2,LOOP
|