Assembler Changing Code

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

Assembler Changing Code

cjm4443
I'm attempting to run something I've assembled in the Assembler on the CPUEmulator. However, when I have the command "D = D + 1", the Assembler turns it into "D = D<A". I think it's what's messing up my program and I don't understand why this is happening.
Reply | Threaded
Open this post in threaded view
|

Re: Assembler Changing Code

ivant
First of all, you should not treat the Assembly instructions like D=D+1 as expressions. That is "D=D+1" is the name of the instruction, whereas "D = D + 1" is an error, because it has spaces.

Second, there is no "D=D<A" instruction. I'm perplexed where this can come from.

I suggest that you read Mark's Introduction to Hack Assembly Language: http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/Introduction-to-Hack-Assembly-Language-td4032232.html

(Strange, the forum software seems to have bugged. It doesn't show quotes, links, and other markup properly,)
Reply | Threaded
Open this post in threaded view
|

Re: Assembler Changing Code

WBahn
Administrator
In reply to this post by cjm4443
Which assembler? The one that you wrote?

What, exactly, do you mean by the assember is turning the command D = D + 1 into D = D<A? Where is it, exactly, that you are seeing the "D<A" appear?
Reply | Threaded
Open this post in threaded view
|

Re: Assembler Changing Code

WBahn
Administrator
In reply to this post by ivant
ivant wrote
First of all, you should not treat the Assembly instructions like D=D+1 as expressions. That is "D=D+1" is the name of the instruction, whereas "D = D + 1" is an error, because it has spaces.
The Hack Assembly Language spec allows the spaces, since it explicitly states that spaces are ignored. So a conforming assembler should assemble this just as if it had been "D=D+1".
Reply | Threaded
Open this post in threaded view
|

Re: Assembler Changing Code

ivant
WBahn wrote
The Hack Assembly Language spec allows the spaces, since it explicitly states that spaces are ignored. So a conforming assembler should assemble this just as if it had been "D=D+1".
WOW. I always thought of this as the white space around the command not. But you are right, the assembler does allow it.