Not mentioning much about the Nand2tetris course and uploading the assembly file which interacts with the keyboard.
Basically what this program does is when a key is pressed on the keyboard the screen turns black i.e. every pixel of the screen is supposed to turn black and when the keyboard is idle the screen stays white .
Here is my code and it works well on my computer's hardware simulator but fails when I upload it for submission on coursera.
@place
M=0
(LOOP)
@KBD
D=M
@WHITE
D; JEQ
@BLACK
0; JMP
(WHITE)
@place
D=M
@LOOP
D; JLT
@place
D=M
@SCREEN
A=A+D
M=0
@place
M=M-1
@LOOP
0;JMP
(BLACK)
@place
D=M
@LOOP
D; JGE
@SCREEN
A=A+D
M=-1
@place
M=M-1
@LOOP
0; JMP
Where am I getting wrong ? What is the reason for comparison failure and how can I sort it out ? Thanks in advance
I'm sorry, but the solution you posted does not solve the problem. I think this is why coursera is rejecting it.
When I run your solution through an assembler and then a cpu emulator I do not see the behavior required of
Fill.asm
. I'm comparing your solution to a solution I know to be correct and I am seeing different behavior.Here's a screenshot of the cpu emulator while pressing the keyboard using your solution:
Here's what I expect to see:
I suggest reviewing your solution.
Hint Something missing from your solution is code to fill the screen.
Here's why I think it's missing:
M=0
of your solution is where I believe the color is set to whiteM=-1
, setting the white color to blackHint: You have one loop (
(LOOP)
) that repeatedly listens for the keyboard. I expect to see another loop ((FILL)
, or whatever) which fills the entire section of memory dedicated to theSCREEN
with white or black.Good luck.