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?

+1


a source to share


4 answers


  • Yes, that sounds right. The address sequenceN

    is 5 bytes outside sequence0

    .
  • "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 it array1

    would cost $ 100 in that case . Since org

    no code or data generation occurs after the latter , it is mostly ignored by the assembler.


+2


a source


I am assuming "ORG" stands for "origin" - the first address assigned to the generated code or data segment.



+2


a source


  • Yes, 200 and 205

  • Sequence 0 starts at 200 and continues from 5 to 204

  • No, array1 starts at 100, anything after org 300 starts at 300

+1


a source


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

+1


a source







All Articles