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

View File

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