Skip to content

Commit 56fd520

Browse files
committed
add example files
1 parent 26a3903 commit 56fd520

4 files changed

Lines changed: 52 additions & 0 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!*.*
3+
*.hi
4+
*.o
5+
*.mif

another_valid.asm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Test program for lab 3
2+
// Values provided below are in decimal
3+
4+
NOOP
5+
ADD ACC, M[65] // ACC = 0 + 7
6+
SUB ACC, M[66] // ACC = 7 - 2 = 5
7+
SB M[67], ACC // M[67] = 5
8+
LB ACC, M[73] // ACC = 245
9+
NOT ACC // ACC = 10
10+
AND ACC, M[67] // ACC = 10 AND 5 = 0
11+
NOT ACC // ACC = NOT ACC = 255
12+
SBI M[M[68]], ACC // M[M[68]]= M[7] = 255
13+
LBI ACC, M[M[69]] // ACC = M[M[69]] = M[67] = 5
14+
ADD ACC, M[71] // ACC = 5 + M[71] = 5 + 255 = 4 (overflow = 1)
15+
CMP ACC, M[72] // ACC = 4, M[72] = 4; --> EQ = 1
16+
JNE 114 // If NEQ = 1, then jump with offset +115
17+
IN M[70], IO_BUS // externalIn (extIn) was set to 7 in the testbench, so that M[70] = 7
18+
LB ACC, M[70] // ACC = 7
19+
CMP ACC, M[65] // ACC = 7, M[65] = 7; --> EQ = 1, NEQ = 0
20+
JEQ 1 // If EQ = 1, then jump with offset +2
21+
SB M[64], ACC // M[64] = ACC = 7
22+
JA 128 // Jump to address 129
23+
SB M[66], ACC // DM[66] = 7
24+
//.
25+
//.
26+
//.
27+
JA 128 // Jump for ever

invalid.asm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This is a test file
2+
3+
// This is a comment
4+
5+
noop
6+
noop
7+
NOOP
8+
add acc, M[-10] // This should fail
9+
hello world // This too

valid.asm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// this file explains the contents of memory.mif for lab 4
2+
// you can use this file when your design does not complete the testbench
3+
// to check if every instruction is executed correctly
4+
5+
LB ACC, M[65] // ACC = M[65]
6+
ADD ACC, M[64] // ACC = ACC + M[64]
7+
DS // Display Reg <= ACC
8+
SB M[65], ACC // DM[65] = acc
9+
SUB ACC, M[64] // ACC = ACC - M[64]
10+
SB M[64], ACC // DM[64] = ACC;
11+
JA 0x00 // JUMP to address 0x00

0 commit comments

Comments
 (0)