2

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
  1. Am I correct in thinking that A0 will hold the value 200 and A1 the value 205?

  2. 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"?

  3. 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?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203

4 Answers4

2

I assume that "ORG" means "origin" - the first address to be assigned to the code or data segment being emitted.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • That's was what I assumed as well. However, I've not been able to find any details in my lecture notes or on the internet, and I want to make sure I've fully grok how it works. I don't want to make a stupid mistake in the exam where I assume the SequenceO points to 200 when it points to 201. –  May 26 '09 at 13:28
  • And what does "organization directive" mean @dmor? – John Saunders Aug 02 '15 at 00:15
2
  1. Yes, that sounds right. The address of sequenceN is 5 bytes beyond sequence0.
  2. "That depends", I guess ... Since it's "addresses" in plural, I guess they wanted the entire range, in which case your latter answer is correct.
  3. No, I would expect multiple orgs 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.
unwind
  • 391,730
  • 64
  • 469
  • 606
1

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

shivam
  • 16,048
  • 3
  • 56
  • 71
Dave Small
  • 31
  • 1
1
  1. Yes, 200 and 205

  2. Sequence0 starts at 200 and extends for 5 bytes to 204

  3. No, array1 starts at 100, anything after the org 300 would start at 300

John Y
  • 354
  • 2
  • 8