Question

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?

Was it helpful?

Solution

  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.

OTHER TIPS

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

  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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top