+/TECS

git clone https://git.julia.blue/+/TECS

Joseph Ryanstart chapter 93311316

v1.0
692 B51 linesraw
1// This file is part of www.nand2tetris.org
2// and the book "The Elements of Computing Systems"
3// by Nisan and Schocken, MIT Press.
4// File name: projects/04/Fill.asm
5
6// Runs an infinite loop that listens to the keyboard input. 
7// When a key is pressed (any key), the program blackens the screen,
8// i.e. writes "black" in every pixel. When no key is pressed, the
9// program clears the screen, i.e. writes "white" in every pixel.
10
11	@24576
12	D=A
13	@R0
14	M=D
15	@START
16	0;JMP
17(CLEAR)
18	@R1
19	M=0
20	@START
21	0;JMP
22(FILL)
23	@R1
24	M=-1
25(START)
26	@SCREEN
27	D=A
28	@R2
29	M=D
30(LOOP)
31	@R1
32	D=M
33	@R2
34	A=M
35	M=D
36	@R2
37	M=M+1
38	D=M
39	@R0
40	D=D-M
41	@CHECK
42	D;JEQ
43	@LOOP
44	0;JMP
45(CHECK)
46	@KBD
47	D=M
48	@CLEAR
49	D;JEQ
50	@FILL
51	0;JMP