optimize Mult and Fill assembly

This commit is contained in:
Konarak 2021-12-07 21:48:15 +05:30
parent 04b283ccec
commit 6033b21c49
2 changed files with 14 additions and 37 deletions

View File

@ -29,11 +29,6 @@ M=D
@itr @itr
M=0 M=0
// black if pix = -1
// white if pix = 0
@pix
M=-1
// loop declaration // loop declaration
// D = reg - itr // D = reg - itr
// if 0 jump to @END // if 0 jump to @END
@ -72,33 +67,30 @@ M=M+1
// clear the screen if no key pressed: // clear the screen if no key pressed:
// pix = 0 // pix = 0
// itr = 0
// addr = 16384
// back to loop declaration // back to loop declaration
(CLEAR) (CLEAR)
@pix @pix
M=0 M=0
@itr
M=0
@SCREEN
D=A
@addr
M=D
@LOOP @LOOP
0;JMP 0;JMP
// paint the screen if no key pressed: // paint the screen if no key pressed:
// pix = -1 // pix = -1
// itr = 0
// addr = 16384
// back to loop declaration // back to loop declaration
(PAINT) (PAINT)
@pix @pix
M=-1 M=-1
@LOOP
0;JMP
// main feedback loop
// itr = 0
// addr = 16384
// jump to @CLEAR if no key pressed
// jump to @PAINT if any key pressed
(END)
@itr @itr
M=0 M=0
@ -107,13 +99,6 @@ D=A
@addr @addr
M=D M=D
@LOOP
0;JMP
// main feedback loop
// jump to @CLEAR if no key pressed
// jump to @PAINT if any key pressed
(END)
@KBD @KBD
D=M D=M
@CLEAR @CLEAR

View File

@ -13,10 +13,9 @@
// variable names are selfexplanatory // variable names are selfexplanatory
// itr temporary register at RAM[16] // itr temporary register at RAM[16]
// sum temporary register at RAM[17] @R2
@itr
M=0 M=0
@sum @itr
M=0 M=0
// loop declaration // loop declaration
@ -28,14 +27,14 @@ M=0
D=M D=M
@R1 @R1
D=D-M D=D-M
@STOP @END
D;JEQ D;JEQ
// sum = R0 + sum // R2 = R0 + R2
// itr = itr + 1 // itr = itr + 1
@R0 @R0
D=M D=M
@sum @R2
M=D+M M=D+M
@itr @itr
M=M+1 M=M+1
@ -44,13 +43,6 @@ M=M+1
@LOOP @LOOP
0;JMP 0;JMP
// R2 = sum
(STOP)
@sum
D=M
@R2
M=D
// loopy loop // loopy loop
(END) (END)
@END @END