Skip to content

Instantly share code, notes, and snippets.

@torpedo87
Last active January 28, 2020 15:35
Show Gist options
  • Save torpedo87/fa5dab2f032e2b61c4bc53184eb5e621 to your computer and use it in GitHub Desktop.
Save torpedo87/fa5dab2f032e2b61c4bc53184eb5e621 to your computer and use it in GitHub Desktop.
(START)
@16383
D=A
@R0
M=D
@KBD
D=M
//if kbd != 0, go to black
@BLACK
D;JNE
//if kbd == 0, go to white
@WHITE
0;JMP
(BLACK)
@R0
M=M+1
AD=M
//black
M=-1
//16384 + 8191
@24575
D=D-A
// if < 0, go to black
@BLACK
D;JLT
// else go to start
@START
0;JMP
(WHITE)
@R0
M=M+1
AD=M
//white
M=0
//16384 + 8191
@24575
D=D-A
//if < 0, go to white
@WHITE
D;JLT
@START
0;JMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment