What does ORG directive do in assembly code?
For your reference, the code is for motorola 68008.
Let's say I have some code like:
org 200
sequenceO: ds.b 5
sequenceN: ds.b 5
move.w #sequenceO, A0
move.w #sequenceN, A1
-
Am I correct in assuming that A0 will hold the value 200 and A1 the value 205?
-
One of the exam questions in the previous article, "What are the physical addresses of sequence 0 and sequence N?", The answer would be "200 and 205", or would it be "200-204 and 205 -209"?
-
I have seen several code snippets with multiple org directives, for example:
org 100
array1: ds.b 4
org 300
I understand correctly that the last org directive is executed, for example, in this case array1 points to 300?
- Yes, that sounds right. The address
sequenceN
is 5 bytes outsidesequence0
. - "It depends" I think ... Since these are plural "addresses" I think they wanted the whole range, in which case your last answer is correct.
- No, I would expect a few
org
to just apply to the following code, so itarray1
would cost $ 100 in that case . Sinceorg
no code or data generation occurs after the latter , it is mostly ignored by the assembler.
a source to share
You're using: MOVE.W #sequenceO, A0
So, you load only the bottom word (16 bits) of the address into A0
. This will only work on very low memory ( A0
under $00010000
)
In general, use MOVE.W
in the address register becomes difficult.
Try: LEA #sequence0, A0
(loads 32-bit address in A0
)
Most assemblers will also do:
MOVEA.L #sequence0, A0
Thanks, Dave Small
a source to share