4

I am currently trying to finish off the project found in Chapter 4 of the Nand to Tetris course (Fill.asm). However, Assembler is giving me the following error:

"In line 3, Expression Expected"

I'm not sure what I'm doing wrong... but below is the snippet of code I have:

@i
M=1
@sum
M=8192
(END)
@END
0,JMP

Can anyone tell me why I'm getting this error on Line 3 (@sum)?

zubergu
  • 3,646
  • 3
  • 25
  • 38
user1867675
  • 49
  • 1
  • 3

2 Answers2

8

I don't know why an error is showing up on line 3, but you can't directly set a value to a memory address on line 4. You can force a "1" out of the ALU like on line 2, but there is no way of forcing an "8192" out of it without first inputting it. You must first assign the value of "8192" to the A-register, then store the A-register to the D-register, then select the memory address, then store the D-register there.

Hobadee
  • 189
  • 1
  • 10
6

The error you're seeing is because you cannot put the value "8192" directly into @sum.

Here is the code I wrote to solve this:

@8192  // number of pixels on a screen divided by 16-bit address (256 x 512 / 16)
D=A    // D = total number of pixels
@sum
M=D    // assigns sum with value of 8192
punkrockpolly
  • 9,270
  • 6
  • 36
  • 37