views:

666

answers:

3

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?

+3  A: 

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

John Saunders
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.
+2  A: 
  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
A: 
  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