summaryrefslogtreecommitdiff
path: root/projects/06/hack-as/test
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-08-16 11:54:23 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-08-16 11:54:23 +0800
commit9542deeb483a00b6fabed7574720926ce97d7511 (patch)
tree0f2c1f72c03dd4693fd59df67544d2a4dddc5494 /projects/06/hack-as/test
parent9c0cb1d1c32724fc95ac9548e4f8d873d3adaccc (diff)
Projects, 01-06 completed
Diffstat (limited to 'projects/06/hack-as/test')
-rw-r--r--projects/06/hack-as/test/compare.hack25
-rw-r--r--projects/06/hack-as/test/conventional.asm32
-rw-r--r--projects/06/hack-as/test/valid.asm29
3 files changed, 86 insertions, 0 deletions
diff --git a/projects/06/hack-as/test/compare.hack b/projects/06/hack-as/test/compare.hack
new file mode 100644
index 0000000..f33a9d1
--- /dev/null
+++ b/projects/06/hack-as/test/compare.hack
@@ -0,0 +1,25 @@
+0000000000000000
+1111110000010000
+0000000000010111
+1110001100000110
+0000000000010000
+1110001100001000
+0100000000000000
+1110110000010000
+0000000000010001
+1110001100001000
+0000000000010001
+1111110000100000
+1110111010001000
+0000000000010001
+1111110000010000
+0000000000100000
+1110000010010000
+0000000000010001
+1110001100001000
+0000000000010000
+1111110010011000
+0000000000001010
+1110001100000001
+0000000000010111
+1110101010000111
diff --git a/projects/06/hack-as/test/conventional.asm b/projects/06/hack-as/test/conventional.asm
new file mode 100644
index 0000000..5510424
--- /dev/null
+++ b/projects/06/hack-as/test/conventional.asm
@@ -0,0 +1,32 @@
+// conventional asm a sane person would write
+// draw a rectangle on top left of screen
+// width 16px, height specified in RAM[0]
+@0
+D=M
+@INFINITE_LOOP
+D;JLE // reject if height is negative
+@counter
+M=D
+@SCREEN
+D=A
+@address
+M=D
+(LOOP)
+ @address
+ A=M
+ M=-1
+ @address
+ D=M
+ @32
+ D=D+A
+ @address
+ M=D
+ @counter
+ MD=M-1
+ @LOOP
+ D;JGT
+
+(INFINITE_LOOP)
+ @INFINITE_LOOP
+ 0;JMP
+
diff --git a/projects/06/hack-as/test/valid.asm b/projects/06/hack-as/test/valid.asm
new file mode 100644
index 0000000..d705f1e
--- /dev/null
+++ b/projects/06/hack-as/test/valid.asm
@@ -0,0 +1,29 @@
+// valid asm, but with unnecessary whitespace, = and ;
+@ 0 // unnecessary space
+D=M
+@INFINITE_LOOP
+=D;JLE // unnecessary =
+@counter
+M=D; // unnecessary ;
+@SCREEN
+D = A // unnecessary spaces
+@address
+M = D; // unnecessary spaces and ;
+( LOOP ) // unnecessary spaces
+ @address
+ A=M
+ M=-1
+ @address
+ D=M
+ @32
+ D=D+A
+ @address
+ M=D
+ @counter
+ MD=M-1
+ @LOOP
+ D;JGT
+
+(INFINITE_LOOP)
+ @INFINITE_LOOP
+ 0;JMP