Re-do Fill.asm (TODO optimize later)
x1phosura x1phosura@x1phosura.zone
Sun, 12 Dec 2021 02:00:54 -0800
1 files changed,
61 insertions(+),
1 deletions(-)
jump to
M
projects/04/fill/Fill.asm
→
projects/04/fill/Fill.asm
@@ -11,4 +11,64 @@ // When no key is pressed, the program clears the screen, i.e. writes
// "white" in every pixel; // the screen should remain fully clear as long as no key is pressed. -// Put your code here.+// Put your code here. + +// TODO: optimize better in the future + +(SET_SCREEN_PTR) + // R0 = SCREEN pointer + @SCREEN + D=A + @R0 + M=D + +// TODO: fix infinitely incrementing screen pointer bug +// end of screen: 0x5fff (dec 24575) + +(IS_KEYPRESSED) + // if R0 == 24575; goto SET_SCREEN_PTR + @R0 + D=M + @24575 + D=D-A + @SET_SCREEN_PTR + D;JEQ + + // D=KBD, goto WHITE_SCREEN if D == 0 + @KBD + D=M + @WHITE_SCREEN + D;JEQ + +(BLACK_SCREEN) + // *R0 = -1 + @R0 + A=M + M=-1 + + // ++R0 + @R0 + M=M+1 + + @IS_KEYPRESSED + 0;JMP + // TODO: replace with D;JLT or something + +(WHITE_SCREEN) + // *R0 = 0 + @R0 + A=M + M=0 + + // ++R0 + @R0 + M=M+1 + + @IS_KEYPRESSED + 0;JMP + // TODO: replace with D;JLT or something + +(END) + @END + 0;JMP +