Reputation:
For reference, the code is for the motorola 68008.
Say I have code such as the following:
org 200
sequenceO: ds.b 5
sequenceN: ds.b 5
move.w #sequenceO, A0
move.w #sequenceN, A1
Am I correct in thinking that A0 will hold the value 200 and A1 the value 205?
One of the exam questions in a past paper was: "What are the physical addresses of sequence0 and sequenceN?", would the answer be "200 and 205", or would it be "200-204 and 205-209"?
I've seen a few pieces of code with multiple org directives, eg;
org 100
array1: ds.b 4
org 300
Am I right in thinking that the last org directive is followed, eg in this case, array1 points to 300?
Upvotes: 2
Views: 4849
Reputation: 31
You're using: MOVE.W #sequenceO, A0
So, you're loading only the lower word (16 bits) of the address into A0
.
That'll only work in very low memory ( A0
under $00010000
)
In general using a MOVE.W
on an address register gets tricky.
Try: LEA #sequence0, A0
(loads a 32-bit address into A0
)
Most assemblers will also do:
MOVEA.L #sequence0, A0
Thanks, Dave Small
Upvotes: 1
Reputation: 364
Yes, 200 and 205
Sequence0 starts at 200 and extends for 5 bytes to 204
No, array1 starts at 100, anything after the org 300 would start at 300
Upvotes: 1
Reputation: 399999
sequenceN
is 5 bytes beyond sequence0
.org
s to just apply to the code following them, so in that case the array1
would be at $100. Since no code or data generation happens after the latter org
, it's basically ignored by the assembler.Upvotes: 2
Reputation: 161801
I assume that "ORG" means "origin" - the first address to be assigned to the code or data segment being emitted.
Upvotes: 2