Pointers and references: Difference between revisions
→{{header|68000 Assembly}}
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 39:
<lang 68000devpac>LEA myData,A0
MOVE.W #$0C,D0
LEA (4,A0,D0),A3</lang> ;A3 = address of myData + 4 + $0C
An address can be offset by an immediate value, a register, or both. Data register offsets are measured at 16 bit word length. Although the second LEA is in brackets, it does NOT dereference the pointer.
<lang 68000devpac>myPointers: dc.l myData, myData2
myData: dc.b $80,$81,$82,$83
myData2: dc.b $84,$85,$86,$87
</lang>
These two code snippets ARE NOT THE SAME:
<lang 68000devpac>LEA myData2,A1</lang>
<lang 68000devpac>LEA myPointers,A1
LEA (4,A1),A1</lang>
===References===
Line 51 ⟶ 62:
<lang 68000devpac>MOVE.L #$FFEEDDCC,myVar</lang>
There is nothing stopping you from clobbering nearby stored data. In the above example, the byte FF gets written to $100000, EE to $100001, DD to $100002, and CC to $100003. If you intended myVar to be of byte length, you need to make sure you only use MOVE.B to read/write to/from myVar.
=={{header|Ada}}==
|