开发者

How to update address register?

开发者 https://www.devze.com 2023-01-26 13:23 出处:网络
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.

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  
 MOV开发者_如何学CE.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.


I am not sure if I understod what you want, but if I am right your secord instruction should be

  ADDI.L #2,A0

or

  LEA (A0)+,A0


I am in no way a 68k jock but I did look up the addressing modes and I'm confused by this line:

MOVE.W  (A0)+,(A0) 

If i'm reading that right, it is copying the contents of the address where A0 points to where A0 points and then increments A0 by 2, right? Is that just an increment A0 instruction?

Or, does it take the value at A0, increment A0 by 2, and write that value to the new address? if so, it seems like it would by coping the '2' to successive memory locations on each loop iteration, which would explain why D3 keeps getting 2.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号