Reputation: 23
If I have:
0000 3304 alpha: dc.w 5,16,4,-2
and my instruction is: sub.w alpha+2,D0
Is my alpha at 0000 33004
or is it at 00 05 00 01 00 04 FE
?
Upvotes: 0
Views: 196
Reputation: 17402
dc.w a = define constant word, where a is the value to define
sb.w a,b = subtract word, where a is the source and b is the destination
Instruction
0000 3304 alpha: dc.w 5,16,4,-2
is equivalent to:
0000 3304 alpha: dc.w 05
alpha: dc.w 16
alpha: dc.w 04
alpha: dc.w -02
To break up a bit more, the first instruction is saying starting at address 0000 3304, define a value of 5 then define a value of 16, then a value of 4 and so on. Since each of these values are instructed as a word, whenever a new value is defined, you must increment the address for that value by hex 2 for two bytes/the length for a word.
After the constants have all been defined, the following values will live at the following addresses
0000 3304 -> 0x05
0000 3306 -> 0x10
0000 3308 -> 0x04
0000 330A -> 0xFE
What instruction sub.w alpha+2,D0
is saying, is to starting at alpha (address 0000 3304
) move 2 bytes and subtract that value at that address from the value in data register D0
.
so,
alpha+2
= address 0000 33006
which has a value of 0x10
.
Whatever value is in data register D0
, subtract 0x10
from it.
Upvotes: 3