-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFill.asm
More file actions
72 lines (59 loc) · 958 Bytes
/
Fill.asm
File metadata and controls
72 lines (59 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// 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/4/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.
//// Replace this comment with your code.
(LOOP)
@SCREEN
D=A
@j
M=D
@KBD
D=A
@i
D=D-M
@END
D;JEQ
@KBD
D=M
@END
D;JEQ
@i
D=M
@n
A=D
M=-1
@i
M=M+1
@LOOP
0;JMP
(END)
@SCREEN
D=A
@i
M=D
@KBD
D=A
@j
D=D-M
@LOOP
D;JEQ
@KBD
D=M
@LOOP
D;JNE
@j
D=M
@n
A=D
M=0
@j
D=M+1
@j
M=D
@END
0;JMP