Skip to content

Commit

Permalink
04 fill project
Browse files Browse the repository at this point in the history
  • Loading branch information
taw committed Oct 7, 2012
1 parent 5de645d commit 131c628
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
65 changes: 65 additions & 0 deletions 04/fill/Fill.asm
@@ -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
35 changes: 35 additions & 0 deletions 04/fill/Fill.hack
@@ -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
11 changes: 11 additions & 0 deletions 04/fill/Fill.tst
@@ -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;
}

0 comments on commit 131c628

Please sign in to comment.