diff options
Diffstat (limited to 'projects/07/StackArithmetic')
4 files changed, 464 insertions, 0 deletions
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm new file mode 100644 index 0000000..faa8af7 --- /dev/null +++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm @@ -0,0 +1,32 @@ +@256 +D=A +@SP +M=D +@7 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@8 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +(END) +@END +0;JMP
\ No newline at end of file diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out new file mode 100644 index 0000000..6b3b20e --- /dev/null +++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.out @@ -0,0 +1,2 @@ +| RAM[0] | RAM[256] | +| 257 | 15 | diff --git a/projects/07/StackArithmetic/StackTest/StackTest.asm b/projects/07/StackArithmetic/StackTest/StackTest.asm new file mode 100644 index 0000000..560ec6c --- /dev/null +++ b/projects/07/StackArithmetic/StackTest/StackTest.asm @@ -0,0 +1,426 @@ +@256 +D=A +@SP +M=D +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@EQ2 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFEQ2 +0;JMP +(EQ2) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFEQ2) +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@16 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@EQ5 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFEQ5 +0;JMP +(EQ5) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFEQ5) +@16 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@EQ8 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFEQ8 +0;JMP +(EQ8) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFEQ8) +@892 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@LT11 +D;JLT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFLT11 +0;JMP +(LT11) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFLT11) +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@892 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@LT14 +D;JLT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFLT14 +0;JMP +(LT14) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFLT14) +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@LT17 +D;JLT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFLT17 +0;JMP +(LT17) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFLT17) +@32767 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@GT20 +D;JGT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFGT20 +0;JMP +(GT20) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFGT20) +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@32767 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@GT23 +D;JGT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFGT23 +0;JMP +(GT23) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFGT23) +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@GT26 +D;JGT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFGT26 +0;JMP +(GT26) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFGT26) +@57 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@31 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@53 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@112 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=-D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M&D +@SP +A=M +M=D +@SP +M=M+1 +@82 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M|D +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +(END) +@END +0;JMP
\ No newline at end of file diff --git a/projects/07/StackArithmetic/StackTest/StackTest.out b/projects/07/StackArithmetic/StackTest/StackTest.out new file mode 100644 index 0000000..cb182ec --- /dev/null +++ b/projects/07/StackArithmetic/StackTest/StackTest.out @@ -0,0 +1,4 @@ +| RAM[0] | RAM[256] | RAM[257] | RAM[258] | RAM[259] | RAM[260] | +| 266 | -1 | 0 | 0 | 0 | -1 | +| RAM[261] | RAM[262] | RAM[263] | RAM[264] | RAM[265] | +| 0 | -1 | 0 | 0 | -91 | |