ORG address
(Virtual memory will be discussed in CS355)
Label EQU constant
123456789 (<---- column position in file) MAX EQU 100 - good EQU directive MAX: EQU 100 - good EQU directive MAX: EQU 100 - good EQU directive MAX EQU 100 - BAD EQU directive
JAVA: final int MAX = 100; C: #define MAX 100
The output listing looks like this:
MAX EQU 100 MIN EQU 10 SYMBOL TABLE ************ MAX = 000064 MIN = 00000A (Hint: hexadecimal numbers)The output listing indicate that the assembler has recorded the following 2 symbolic constant (that the assembler program can use):
(1) Label DS.B n - reserves n bytes of memory space (2) Label DS.W n - reserves n words of memory space (3) Label DS.L n - reserves n long words of memory space
a.lst: 1 000000 * Demonstrate the effect of DS directive 2 000000 * Assemble with: as255 ds 3 000000 * Look at the output file a.lst 4 001000 ORG $1000 5 001000 1200 move.b d0, d1 (1200 (hex) is the code 6 001002 1200 move.b d0, d1 for "move.b d0, d1" !) 7 001004 A: ds.b 10 8 00100E 1200 move.b d0, d1 9 001010 1200 move.b d0, d1 10 001012 B: ds.w 10 11 001026 1200 move.b d0, d1 12 001028 1200 move.b d0, d1 13 00102A C: ds.l 10 14 001052 1200 move.b d0, d1 15 001054 1200 move.b d0, d1 16 001056 end SYMBOL TABLE ************ A 001004 B 001012 C 00102A
100E(hex) - 1004(hex) = 10(decimal) 10 bytes reserved at A 1026(hex) - 1012(hex) = 20(decimal) 20 bytes reserved at B 1052(hex) - 102A(hex) = 40(decimal) 40 bytes reserved at C
Construct in Java/C/C++ Equivalent in M68000 ----------------------- -------------------- int i; i: DS.L 1 short s; s: DS.W 1 byte b; b: DS.B 1 Construct in C/C++ Equivalent in M68000 ----------------------- -------------------- int A[10]; A: DS.L 10 short B[100]; B: DS.W 100 Construct in C/C++ Equivalent in M68000 ----------------------- -------------------- class MyClass Remembers: { 1. a MyClass object occupies 10 bytes int x; 2. x's offset is 0 int y; 3. y's offset is 4 short z; 4. z's offset is 8 }; MyClass A; A: DS.B 10 Note: A marks the start of the memory location for the object You need to add the offset to A to get to the members x, y and z. That's why assembler remembers the offset for each member variable in an object
(1) Label DC.B <list of constant values (byte size)> (2) Label DC.W <list of constant values (word size)> (3) Label DC.L <list of constant values (long word size)>
|
Note:
|
a.lst: 1 000000 * Demonstrate the effect of DC directive 2 000000 * Assemble with: as255 dc 3 000000 * Look at the output file a.lst 4 001000 ORG $1000 5 001000 1200 move.b d0, d1 6 001002 1200 move.b d0, d1 7 001004 0A A: dc.b 10, 1, 2, 3 01 02 03 8 001008 1200 move.b d0, d1 9 00100A 1200 move.b d0, d1 10 00100C 000A B: dc.w 10, 1, 2, 3 0001 0002 0003 11 001014 1200 move.b d0, d1 12 001016 1200 move.b d0, d1 13 001018 0000 C: dc.l 10, 1, 2, 3 000A 0000 0001 0000 0002 0000 0003 14 001028 1200 move.b d0, d1 15 00102A 1200 move.b d0, d1 16 00102C end SYMBOL TABLE ************ A 001004 B 00100C C 001018
1008(hex) - 1004(hex) = 4(decimal) 4 bytes reserved at A 1014(hex) - 100C(hex) = 8(decimal) 8 bytes reserved at B 1028(hex) - 1018(hex) = 16(decimal) 16 bytes reserved at C
|
|
(A byte typed variable (= 1 byte in length) must be located anywhere in memory)
|
|