fillautomatic problem
Posted by karam on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/fillautomatic-problem-tp4034479.html
hello
my code below work with interactive fill file normaly but when i use
the fill automatically file it throw error and i have checked my code multiply time
and i cant undestand why it dosnt work
in my code im looping in infinit loop
and pushing 1 in screen memory block block
until its fild
and when done it return to the loop and check if key is presed or not
and keep the screen black or clear it acordingly
fill automatically file:
set RAM[24576] 0, // the keyboard is untouched
repeat 1000000 {
ticktock;
}
output; // test that the screen is white
set RAM[24576] 1, // a keyboard key is pressed
repeat 1000000 {
ticktock;
}
output; // test that the screen is black
set RAM[24576] 0, // they keyboard in untouched
repeat 1000000 {
ticktock;
}
output; // test that the screen is white
my code:
(loop)
@8191
D=A
@i
M=D
@KBD
D=M
@Black
D;JNE
@white
D;JEQ
@loop
0;JMP
(Black)
@i
D=M
@SCREEN
A=A+D
M=-1
@i
M=M-1
D=M
@Black
D;JNE
@loop
D;JEQ
(white)
@i
D=M
@SCREEN
A=A+D
M=0
@i
M=M-1
D=M
@white
D;JNE
@loop
0;JMP