Here are a few questions on the following Coldfire MOVEA instruction.
movea.w (%a2)+,%a3 #a3=mem[a2.w]; a2=a2+2
1. Does A3 load 16 or 32 bits? I suspect all 32-bits are loaded from the sign-extended memory location pointed to by A2.
2. Does A2 increment by 2?
3. What does the "%" represent? Is it assembler specific?
Is there overlap/redundency between instructions LEA & MOVEA? Are the following eqivalent?
lea.l (%a2),%a3 #a3=mem[a2]
movea.l (%a2),%a3 #a3=mem[a2]
Tim
已解决! 转到解答。
> movea.w (%a2)+,%a3 #a3=mem[a2.w]; a2=a2+2
>
> 1. Does A3 load 16 or 32 bits? I suspect all 32-bits are loaded from the sign-extended memory
> location pointed to by A2.
> 2. Does A2 increment by 2?
The lower 16 bit of the value, which is pointed by register A2, is sign extended to 32 bits and then is loaded to register A3. Then, register A2 is incremented by 2.
The original comment is correct.
> 3. What does the "%" represent? Is it assembler specific?
Prefix '%' is demanded by GNU assembler for registers.
> Is there overlap/redundency between instructions LEA & MOVEA? Are the following eqivalent?
>
> lea.l (%a2),%a3 #a3=mem[a2]
> movea.l (%a2),%a3 #a3=mem[a2]
Yes, above lines are equivalent.
See the below document for explicit explanation of ColdFire assembler. Notation of CodeWarrior is used in the document. The document can be downloaded from www.freescale.com
"ColdFire® Family
Programmer’s Reference Manual
Document Number: CFPRM
Rev. 3
03/2005
"
Sorry no, that's not correct !
LEA is not equivalent to MOVEA in the example you gave. It should read:
lea.l (%a2),%a3 #a3=a2
i.e. the LEA instruction copies the ADDRESS of the left operand into the A3 register, it doesn't do a memory read.
For a clearer example, consider the following:
lea.l 10(%a2),%a3
In this case, A3 gets the address A2+10, and not the contents of memory at this address. You would have to write "movea.l 10(%a2),%a3" for that.
Hope this helps
Simon
I changed the previous example of a movea instruction from indirect to direct address mode. Now I think these are the same. Can someone confirm?
lea.l (a2),a3 //a3=a2 (using indirect adr mode)
movea.l a2,a3 //a3=a2 (using direct adr mode)
Tim
pgo and Simon Marsden ,
you are right, and I was wrong.
Recently, I verified it with GNU compiler and some debugger.
Again, I am sorry for my confuse.
Dear all,
It's been a while since I've done 68000 assembler but I believe the last two instructions have different effects.
> lea.l (%a2),%a3 #a3=&mem[a2]
This loads the EFFECTIVE ADDRESS of the memory location indicated rather than the contents of the memory location.
> movea.l (%a2),%a3 #a3=mem[a2]
This loads the CONTENTS of the memory location. This is a move instruction that happens to have a address register as its destination i.e. MOVE with an A suffix. I suspect the assembler would also accept
> move.l (%a2),%a3 #a3=mem[a2]
but I don't have a gnu assembler to check.
The following few lines shows an example of using lea:
data: ds.b 200 // create an array of data somewhere
.....
lea.l data,a3 // a3 = &data[0] => point a3 at start of data array
move.l 100(a3),d0 // d0 = data[100] => access an element of the array
bye