Search code examples
assembly68000

How to update address register?


I'm using Easy68k to make a simple program that includes a while loop.

Assume the register A0 is pointing to my data, which are words. Why does this not work?

 MOVE.W (A0) ,  D3  
 MOVE.W (A0)+, (A0) 
 MOVE.W (A0) ,  D3

If A0 points to the number 2 initially, and after that the number 4, the result I want is that after the first move, 2 is stored, after the increment and third move, 4 is stored. However, the last move has no effect.


Solution

  • I found the answer, and my instruction was incorrect.

    Basically, (A0)+ will increment the address register AFTER it completes whatever instruction it is part of.

    I thought it would increment first, then assign (which was a logical mistake as well).

    So all i need to do is:

    move (A0)+,D3;
    

    this will add the value in A0 to D3, and THEN increment A0 for the next time around.