In this project, we implemented simple assembler and simulator for LC-2K Instruction-Set Architecture.
The LC-2K is an 8-register, 32-bit computer. All addresses are word-addresses. The LC-2K has 65536 words of memory.
This simulator supportes 3 type instructions followed.
- R-type instructions (add, nor):
- bits 24-22: opcode
- bits 21-19: reg A
- bits 18-16: reg B
- bits 15-3: unused (should all be 0)
- bits 2-0: desgReg
- I-type instructions (lw, sw, beq):
- bits 24-22: opcode
- bits 21-19: reg A
- bits 18-16: reg B
- bits 15-0: offsetField (a 16-bit, 2's complement number with a range of -32768 to 32767)
- J-type instructions (jalr):
- bits 24-22: opcode
- bits 21-19: reg A
- bits 18-16: reg B
- bits 15-0: unused (should all be 0)
- O-type instructions (halt, noop):
- bits 24-22: opcode
- bits 21-0: unused (should all be 0)
First of all, you should clone this repository.
git clone https://github.com/JYPark09/ITE2031
And by using make, you can get assemble and simulate programs.
cd ITE2031
make
This test performs the same behavior as the C code below.
int i = 5;
do {
i = i + (-1);
} while (i != 0);
This test is designed to check offsetField overflow condition. This code cannot generate machine language file.
This test is designed to check undefined label using. This code cannot generate machine language file.
This test is designed to check unrecognized opcode. This code cannot generate machine language file.
This test is designed to check duplicated label. This code cannot generate machine language file.
This test is designed to check invalid arguments. This code cannot generate machine language file.
This test performs the same behavior as the C code below.
int i;
int res = 0;
for (i = 1; i < 10; ++i)
res += i;
This test is designed to ensure that the jalr instruction was implemented correctly.
This test is intended to ensure that the lw instruction was implemented correctly.
This test is designed to ensure that the nor instruction and lw/sw offset were implemented correctly. This test performs the same behavior as the C code followed.
int i, j;
int arr[10] = { 0 };
for (i = 0; i < 10; ++i) {
for (j = 0; j < i; ++j) {
arr[i] += i;
}
}
This test is the stress test. The simulator will execute a lots of instructions for calculate many matrix additions.