This commit is contained in:
QkoSad
2025-07-16 13:00:37 +03:00
commit 7894b48931
806 changed files with 162532 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
@END //check if button is pressed
0;JMP
(BLACK)
//start= 16384 the start of the screen memory
@SCREEN
D=A
@start
M=D
//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen
@8192
D=A
@n
M=D
//i=0 this is the index for each group of pixels
@i
M=0
(LOOP1)
//if i==n goto end
@i
D=M
@n
D=D-M
@END
D;JEQ
//start+1=-1 set each group of pixels to -1 which is = 111111111111
@start
D=M
@i
A=D+M
M=-1
// increment i by 1
@i
M=M+1
// go back to the start of the loop
@LOOP1
0;JMP
(WHITE)
//start= 16384 the start of the screen memory
@SCREEN
D=A
@start
M=D
//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen
@8192
D=A
@n
M=D
//i=0 this is the index for each group of pixels
@i
M=0
(LOOP2)
//if i==n goto end
@i
D=M
@n
D=D-M
@END
D;JEQ
//start+1=-1 set each group of pixels to 0 which is = 00000000
@start
D=M
@i
A=D+M
M=0
// increment i by 1
@i
M=M+1
// go back to the start of the loop
@LOOP2
0;JMP
//check if button is pressed
(END)
@KBD
D=M
@WHITE
D;JEQ
@KBD
D=M
@BLACK
D;JNE
@END
0;JMP
+11
View File
@@ -0,0 +1,11 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/fill/Fill.tst
load Fill.asm;
echo "Make sure that 'No Animation' is selected. Then, select the keyboard, press any key for some time, and inspect the screen.";
repeat {
ticktock;
}
+4
View File
@@ -0,0 +1,4 @@
|RAM[16384]|RAM[17648]|RAM[18349]|RAM[19444]|RAM[20771]|RAM[21031]|RAM[22596]|RAM[23754]|RAM[24575]|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+37
View File
@@ -0,0 +1,37 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/fill/FillAutomatic
// This script can be used to test the Fill program automatically,
// rather than interactively. Specifically, the script sets the keyboard
// memory map (RAM[24576]) to 0, 1, and then again to 0. This simulates the
// acts of leaving the keyboard untouched, pressing some key, and then releasing
// the key. After each on of these simulated events, the script outputs the values
// of some selected registers from the screen memory map (RAM[16384]-RAM[24576]).
// This is done in order to test that these registers are set to 000...0 or 111....1,
// as mandated by how the Fill program should react to the keyboard events.
load Fill.asm,
output-file FillAutomatic.out,
compare-to FillAutomatic.cmp,
output-list RAM[16384]%D2.6.2 RAM[17648]%D2.6.2 RAM[18349]%D2.6.2 RAM[19444]%D2.6.2 RAM[20771]%D2.6.2 RAM[21031]%D2.6.2 RAM[22596]%D2.6.2 RAM[23754]%D2.6.2 RAM[24575]%D2.6.2;
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