diff options
Diffstat (limited to 'projects/04/misc')
-rw-r--r-- | projects/04/misc/arr.asm | 26 | ||||
-rw-r--r-- | projects/04/misc/iter.asm | 23 | ||||
-rw-r--r-- | projects/04/misc/rect.asm | 95 |
3 files changed, 144 insertions, 0 deletions
diff --git a/projects/04/misc/arr.asm b/projects/04/misc/arr.asm new file mode 100644 index 0000000..2766fa7 --- /dev/null +++ b/projects/04/misc/arr.asm @@ -0,0 +1,26 @@ +@100 +D=A +@arr +M=D +@10 +D=A +@n +M=D + +(LOOP) + @arr + A=M + M=-1 + @arr + M=M+1 + @n + M=M-1 + D=M + @END + D;JEQ + @LOOP + 0;JMP + +(END) + @END + 0;JMP diff --git a/projects/04/misc/iter.asm b/projects/04/misc/iter.asm new file mode 100644 index 0000000..c5b11a5 --- /dev/null +++ b/projects/04/misc/iter.asm @@ -0,0 +1,23 @@ +@R1 +M=0 // reset R1 +@i +M=1 // reset i + +(LOOP) + @i + D=M + @R1 + M=M+D // R1 += i + @i + M=M+1 // i++ + @R0 + M=M-1 + D=M + @END + D;JEQ + @LOOP + 0;JMP + +(END) + @END + 0;JMP diff --git a/projects/04/misc/rect.asm b/projects/04/misc/rect.asm new file mode 100644 index 0000000..3106f04 --- /dev/null +++ b/projects/04/misc/rect.asm @@ -0,0 +1,95 @@ +@R0 +D=M +@width +M=D // width (max 32) = RAM[0] words = 16 * RAM[0] px + +@32 +D=A +@width +D=D-M // D = 32 - width +@WIDTH_PASS +D;JGE // if (D >= 0, i.e. width <= 32) goto WIDTH_PASS + +@32 +D=A +@width +M=D // width = 32 + +(WIDTH_PASS) + +@R1 +D=M +@height +M=D // height (max 256) = RAM[1] px + +@256 +D=A +@height +D=D-M // D = 256 - height +@HEIGHT_PASS +D;JGE // if (D >= 0, i.e. height <= 256) goto HEIGHT_PASS + +@256 +D=A +@height +M=D + +(HEIGHT_PASS) + +@32 +D=A +@offset +M=D // offset = 32 +@width +D=M +@offset +M=M-D // offset -= width + +@x +M=0 // x = 0 + +@y +M=0 // y = 0 + +@SCREEN +D=A +@pos +M=D // pos = &SCREEN + +(DRAW_Y) + (DRAW_X) + @pos + A=M + M=-1 // *pos = 0xffff + @pos + M=M+1 // pos++ + @x + M=M+1 // x++ + D=M // D = x + @width + D=D-M // D = x - width + @EXIT_X + D;JEQ // if (x - width == 0) break + @DRAW_X + 0;JMP + (EXIT_X) + @x + M=0; + @offset + D=M + @pos + M=M+D // pos += offset + @y + M=M+1 // y++ + D=M // D = y + @height + D=D-M // D = y - height + @END + D;JEQ // if (y - height == 0) break + @DRAW_Y + 0;JMP + +(END) + @END + 0;JMP + |