.
This commit is contained in:
Executable
+97
@@ -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
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
@R2
|
||||
M=0
|
||||
@sum
|
||||
M=0
|
||||
(LOOP)
|
||||
@1
|
||||
D=M
|
||||
@END
|
||||
D;JEQ // if R1==0 goto end
|
||||
@R0
|
||||
D=M // D=R0
|
||||
@sum
|
||||
M=M+D // sum=sum+R0
|
||||
@R1
|
||||
M=M-1 //R1=R1-1
|
||||
@sum
|
||||
D=M
|
||||
@R2
|
||||
M=D
|
||||
@LOOP
|
||||
0;JMP
|
||||
(END)
|
||||
@END
|
||||
0;JMP
|
||||
Reference in New Issue
Block a user