Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
MOVE.L #$00100000,A0 ;define an array at memory address $100000

View file

@ -0,0 +1,18 @@
;8-bit data
MyArray:
DC.B 1,2,3,4,5
DC.B 6,7,8,9,10
DC.B 11,12,13,14,15
EVEN ;needed to ensure proper alignment after a byte array with an odd number of entries.
;16-bit data
MyArrayW:
DC.W 1,2,3,4,5
DC.W 6,7,8,9,10
DC.W 11,12,13,14,15
;32-bit data
MyArrayL:
DC.L 1,2,3,4,5
DC.L 6,7,8,9,10
DC.L 11,12,13,14,15

View file

@ -0,0 +1,7 @@
MyString:
DC.B "Hello World",0
even
MyString2:
DC.B 'H','e','l','l','o',' ','W','o','r','l','d',0
even

View file

@ -0,0 +1,7 @@
myArray equ $240000
LEA myArray,A0 ;load the base address of the array into A0
MOVE.W #3,D0 ;load the desired offset into D0
LSL.W #2,D0 ;this array is intended for 32-bit values.
MOVE.L #23,D1 ;load decimal 23 into D1
MOVE.L D1,(A0,D0) ;store #23 into the 3rd slot of the array (arrays are zero-indexed in assembly)

View file

@ -0,0 +1,2 @@
int myArray[];
myArray[3] = 23;

View file

@ -0,0 +1,7 @@
myArray equ $240000
;load element 4
LEA myArray,A0 ;load the base address of the array into A0
MOVE.W #4,D0 ;load the desired offset into D0
LSL.W #2,D0 ;this array is intended for 32-bit values.
MOVE.L (A0,D0),D1 ;load the 4th element into D1.

View file

@ -0,0 +1,29 @@
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