Advanced examples:
(1a) Copy the value of a byte array element A[0] into register D0
A: DS.B 10 A byte array: int A[10]
MOVEA.L #A,A0 A0 = base address of array A
MOVE.B 0(A0), D0 Move element A[0] into reg. D0
(1b) Copy the value of a short array element A[0] into register D0
A: DS.W 10 A short array: int A[10]
MOVEA.L #A,A0 A0 = base address of array A
MOVE.W 0(A0), D0 Move element A[0] into reg. D0
(each element in a short array is 2 bytes long)
(1c) Copy the value of an int array element A[0] into register D0
A: DS.L 10 An integer array: int A[10]
MOVEA.L #A,A0 A0 = base address of array A
MOVE.L 0(A0), D0 Move element A[0] into reg. D0
(each element in a short array is 4 bytes long)
(2a) Copy the value of a byte array element A[3] into register D0
A: DS.B 10 A byte array: int A[10]
MOVEA.L #A,A0 A0 = base address of array A
MOVE.B 3(A0), D0 Move element A[3] into reg. D0
(2b) Copy the value of a short array element A[3] into register D0
A: DS.W 10 A short array: int A[10]
MOVEA.L #A,A0 A0 = base address of array A
MOVE.W 6(A0), D0 Move element A[3] into reg. D0
(each element in a short array is 2 bytes long)
(2c) Copy the value of an int array element A[3] into register D0
A: DS.L 10 An integer array: int A[10]
MOVEA.L #A,A0 A0 = base address of array A
MOVE.L 12(A0), D0 Move element A[3] into reg. D0
(each element in a short array is 4 bytes long)
(3) Suppose we define the class:
class MyClass
{
int x;
int y;
short z;
}
And an object of the type MyClass:
MyClass A;
Then the object A is defined in assembler using:
A: DS.B 10 * because object of MyClass has 2 int's
* 1 short variables, for a total of 10 bytes
And the following statements have the following
equivalent in M68000 assembler instructions:
A.x = 4000; -> MOVEA.L #A,A0
MOVE.L #4000,0(A0) because x has offset 0
A.y = 8100; -> MOVEA.L #A,A0
MOVE.L #8100,4(A0) because y has offset 4
A.z = 123; -> MOVEA.L #A,A0
MOVE.W #123,8(A0) because z has offset 8
Make sure you use the
right operand size !