2

I learned some 68k/Coldfire at the Uni, and having difficult understanding the more complex addressing modes (with the numbers near the parentheses of dereference).

I think example are the best here:

A) lea:
A1) lea $5(a1,a2.l), a0
A2) lea -1(a1,a2), a0

B) move:
B1) move.b 1(a1),d0
B2) move.b -2(a1),d0

Could anyone please explain me in plain words what happends in each instruction?

Please elaborate more if needed (pre/post incrementations, etc.).

Thanks!! ;)

Lala yoyo
  • 36
  • 3
  • `do` isn't a register name. I assume you meant `d0` so I fixed that while applying formatting. Your 2nd LEA omitted the destination operand, so I assumed that was supposed to be `a0`. Are you asking about 68000 or Coldfire here, or both? (In case it matters, I don't know much about Coldfire.) – Peter Cordes Mar 25 '19 at 02:15
  • https://en.wikibooks.org/wiki/68000_Assembly#Addressing_Modes – chtz Mar 25 '19 at 08:34

1 Answers1

7

Ad lea instructions:

  • A1) A0 will be set to A1+A2+5
  • A2) A0 will bet set to A1+A2-1

As the name of the lea instructions implies, it is used to load an address into an address register. It will not move data from indirect addressing. I haven't checked if those instructions are valid and my 68k skills are quite rusty now, so I assume they are. Not specifying the index register width in A2 introduces ambiguity. From the top of my head I cannot recollect if .W or .L was the default register width here, so specifying that might be a good idea.

Ad move instructions:

  • B1) D0 will be set to the byte that immediately follows the address stored in A1. E.g. if A1 is set to $1000, the byte that will be read is the one at address $1001.
  • B2) As in B1, but the content will be readm from 2-bytes ahead the A1 address. Again assuming A1 will be preloaded with $1000, the byte that will be read is the one at location $FFE.

For completeness, the addressing modes are:

  • A1) Register indirect with index and displacement
  • A2) dito
  • B1) Register indirect with displacement
  • B2) dito
Martin
  • 116
  • 2
  • 2
    It is not necessary to specify the width of the index register in Coldfire - Here, the index register is always `.l` - 68k supported word width as well. – tofro Mar 25 '19 at 16:36