Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
// This file is part of the materials accompanying the book | |||
// "The Elements of Computing Systems" by Nisan and Schocken, | |||
// MIT Press. Book site: www.idc.ac.il/tecs | |||
// File name: projects/04/Fill.asm | |||
|
|||
// Runs an infinite loop that listens to the keyboard input. | |||
// When a key is pressed (any key), the program blackens the screen, | |||
// i.e. writes "black" in every pixel. When no key is pressed, | |||
// the screen should be cleared. | |||
|
|||
// Put your code here. | |||
|
|||
// R0 - loop counter | |||
(loop) | |||
@16384 | |||
D=A | |||
@0 | |||
M=D | |||
|
|||
@24576 | |||
D=M | |||
@keypressed | |||
D;JNE | |||
|
|||
(nokey) | |||
// [R0] = 0 | |||
@0 | |||
D=A | |||
@0 | |||
A=M | |||
M=D | |||
|
|||
// R0 += 1 | |||
D=A+1 | |||
@0 | |||
M=D | |||
|
|||
@24576 | |||
D=D-A | |||
@nokey | |||
D;JNE | |||
|
|||
@loop | |||
0;JMP | |||
|
|||
(keypressed) | |||
|
|||
// [R0] = 0xFFFF | |||
D=-1 | |||
@0 | |||
A=M | |||
M=D | |||
|
|||
// R0 += 1 | |||
D=A+1 | |||
@0 | |||
M=D | |||
|
|||
@24576 | |||
D=D-A | |||
@keypressed | |||
D;JNE | |||
|
|||
@loop | |||
0;JMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
0100000000000000 | |||
1110110000010000 | |||
0000000000000000 | |||
1110001100001000 | |||
0110000000000000 | |||
1111110000010000 | |||
0000000000010110 | |||
1110001100000101 | |||
0000000000000000 | |||
1110110000010000 | |||
0000000000000000 | |||
1111110000100000 | |||
1110001100001000 | |||
1110110111010000 | |||
0000000000000000 | |||
1110001100001000 | |||
0110000000000000 | |||
1110010011010000 | |||
0000000000001000 | |||
1110001100000101 | |||
0000000000000000 | |||
1110101010000111 | |||
1110111010010000 | |||
0000000000000000 | |||
1111110000100000 | |||
1110001100001000 | |||
1110110111010000 | |||
0000000000000000 | |||
1110001100001000 | |||
0110000000000000 | |||
1110010011010000 | |||
0000000000010110 | |||
1110001100000101 | |||
0000000000000000 | |||
1110101010000111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
// This file is part of the materials accompanying the book | |||
// "The Elements of Computing Systems" by Nisan and Schocken, | |||
// MIT Press. Book site: www.idc.ac.il/tecs | |||
// File name: projects/04/fill/Fill.tst | |||
|
|||
load Fill.hack; | |||
echo "First, make sure that 'No Animation' is selected. Then, select the Keyboard, click on any key and check the screen."; | |||
|
|||
repeat { | |||
ticktock; | |||
} |