D and A register manipulation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

D and A register manipulation

AndyGeo
This post was updated on .
I'm almost there but just need a few pointers. In figure 4.2...

@i        // set A-register to i
M=1     // M refers to the memory word whose address is the current value of the A-register.

I see how this is working, i =1.

Further down, I'm not too sure on the @sum part.

@i
D=M    //D=i

@sum
M=D+M   // sum =sum+i

so D register is set to i.
Then A register is set to sum,

It's the next line i'm not too sure on. I'm reading it as sum= i + sum.

They mean the same thing as the example but I'm just wondering if i'm on the right track.

Is M=M+D not valid?


--Andy



Reply | Threaded
Open this post in threaded view
|

Re: D and A register manipulation

cadet1620
Administrator
AndyGeo wrote
Further down, I'm not too sure on the @sum part.

@i
D=M    //D=i

@sum
M=D+M   // sum =sum+i

so D register is set to i.
Then A register is set to sum,

It's the next line i'm not too sure on. I'm reading it as sum= i + sum.

They mean the same thing as the example but I'm just wondering if i'm on the right track.

Is M=M+D not valid?
Yes, M=D+M and M=M+D mean the same thing. The assembler built in to the CPU Emulator accepts either, although it changes M=M+D into M=D+M. I think that earlier versions of the assembler may have been pickier and only accepted M=D+M which is why the code doesn't quite match the comment.

--Mark