MOVEA Adr Indirect Post Increment

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MOVEA Adr Indirect Post Increment

Jump to solution
3,641 Views
tupdegrove
Contributor III

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

Labels (1)
0 Kudos
Reply
1 Solution
1,625 Views
pgo
Senior Contributor V

Dear tupdegrove,

 

I believe the two examples you give are equivalent.

 

Obviously, the lea example does not really show the usefulness of the instruction.

 

bye

View solution in original post

0 Kudos
Reply
8 Replies
1,625 Views
admin
Specialist II

> 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

"

0 Kudos
Reply
1,625 Views
SimonMarsden_de
Contributor II

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

 

 

0 Kudos
Reply
1,625 Views
tupdegrove
Contributor III

Got it.  Thank-you all for the great help.  I'm sure I'll have more questions as I go through the programmer's reference manual.

 

Tim

0 Kudos
Reply
1,625 Views
tupdegrove
Contributor III

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

0 Kudos
Reply
1,626 Views
pgo
Senior Contributor V

Dear tupdegrove,

 

I believe the two examples you give are equivalent.

 

Obviously, the lea example does not really show the usefulness of the instruction.

 

bye

0 Kudos
Reply
1,625 Views
SimonMarsden_de
Contributor II

Aaargh. pgo and I posted at the same time!

 

I meant to say that yevgenit was not correct. I'm in agreement with pgo.

 

 

0 Kudos
Reply
1,625 Views
admin
Specialist II

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.

 

Message Edited by yevgenit on 2009-07-06 02:57 PM
Message Edited by yevgenit on 2009-07-06 02:58 PM
Message Edited by yevgenit on 2009-07-06 02:58 PM
0 Kudos
Reply
1,625 Views
pgo
Senior Contributor V

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

 

 

 

0 Kudos
Reply