nand2tetris

Hack assembly: ADD R3,R1,R9, gives the error "expression expected"


I was able to get simple arithmetic operations going using real registers with the assembler, but I saw a code example in the book of

ADD R3,R1,R9

and when I try this line by itself as an *.asm file in the Assembler, I get an "expression expected" error. I pulled this line straight from the book, so I'm surprised there's an issue.

Any thoughts?

Thanks.


Solution

  • ADD R3,R1,R9 is not a valid assembly language instruction in the HACK assembly language. I believe you are referring to Chapter 4 of the book, which introduces the concept of a machine language and gives some generic examples of assembly language.

    Each machine architecture has its own specific assembly language tailored to its particular needs, and they are not interchangeable. In the case of the HACK machine, this assembly language is detailed in Chapter 6 if memory serves.