You must implement the TRAP instruction as the LC-3b ISA defines in Appendix A.
However, you do not need to implement the
TRAP routines. The trap vector table will be initialized
to all zeroes by the shell code provided. Thus, whenever a
TRAP instruction is processed, PC
will be set to 0. The shell code provided will halt the simulator whenever PC becomes 0.
You do not have to implement the
RTI instruction for this lab. You can assume that the input file to your simulator will not contain any
For this assignment, you can assume that the programmer will always give aligned addresses, and your simulator does not need to worry about unaligned cases.
If you decide to use any of the math functions in math.h, you also have to link the math library by using the command:
gcc -lm -ansi -o assemble assembler.c
You do not need to implement memory mapped I/O for this lab.
You may assume that the code running on your simulator has been assembled correctly and that the instructions your simulator sees comply with the ISA specification.
In your code that you write for lab 2, do not assign the current latches to the next latches. This is already done in the shell code.
Low16bits macro provided in the shell code zeroes out the top 16 bits of its argument, like so:
#define Low16bits(x) ((x) & 0xFFFF)
You may use this macro to avoid getting values like
xFFFFFFFF in architectural registers.
The variables in your C program are 32-bit values, so the number -1 is
xFFFFFFFF. However, the LC-3b is a
16-bit machine, in which -1 is represented as
xFFFF. Thus, you have to make sure that when you store a value
in a variable representing an LC-3b register, you mask it properly (for example, using the macro given above).
LEA should NOT set the machine's condition codes, despite what the current reference documents may say.