Relevant Classes: EECS 370
LC2K is a “fake” (albeit Turing Complete) Assembly Language designed by the EECS 370 staff to make learning the concepts of assembly easier (without the ridiculous number of opcodes and other functionality most real assembly languages have).
Instructions are 32 bits in size, registers are 32 bits. There are 8 registers, where register 0 is always 0. It supports words of memory (so there are only that many possible instructions and total pieces of memory).
LC2K ISA
(Copied and Pasted from the P1 Spec)
| Assembly language name for instruction | Instruction Opcode in binary | Action | 
|---|---|---|
| add(R-type instruction) | 0b000 | Add contents of regAwith contents ofregB, store results indestReg. | 
| nor(R-type instruction) | 0b001 | Nor contents of regAwith contents ofregB, store results indestReg. This is a bitwise nor; each bit is treated independently. | 
| lw(I-type instruction) | 0b010 | ”Load Word”; Load regBfrom memory. Memory address is formed by addingoffsetFieldwith the contents ofregA. Behavior is defined only for memory addresses in the range [0, 65535]. | 
| sw(I-type instruction) | 0b011 | ”Store Word”; Store regBinto memory. Memory address is formed by addingoffsetFieldwith the contents ofregA. Behavior is defined only for memory addresses in the range [0, 65535]. | 
| beq(I-type instruction) | 0b100 | ”Branch if equal” If the contents of regAandregBare the same, then branch to the addressPC+1+offsetField, wherePCis the address of this beq instruction. | 
| jalr(J-type instruction) | 0b101 | ”Jump and Link Registerç; First store the value PC+1intoregB, wherePCis the address where thisjalrinstruction is defined. Then branch (set PC) to the address contained inregA. Note that this implies ifregAandregBrefer to the same register, the net effect will be jumping toPC+1. | 
| halt(O-type instruction) | 0b110 | Increment the PC(as with all instructions), then halt the machine (let the simulator notice that the machine halted). | 
| noop(O-type instruction) | 0b111 | ”No Operation (pronounced no op)” Do nothing. | 
| Note: above, PCrefers to the Program Counter; andregA,regB, anddestRegrefer to Registers | 
| Instruction Type | Instructions in category | Description of required fields | 
|---|---|---|
| R-Type Instructions | add,nor | opcode,field0,field1, andfield2are required fields:field0is a register (regA)field1is a register (regB)field2is a register (destReg) | 
| I-Type instructions | lw,sw,beq | opcode,field0,field1andfield2are required fields:field0is a register (regA)field1is a register (regB)field2is either a numeric address, or a symbolic address (represented by a label) | 
| J-Type instructions | jalr | opcode,field0, andfield1are required fields:field0is a register (regA)field1is a register (regB) | 
| O-Type instructions | noop,halt | Only the opcodefield is required | 
| Instruction Type | Binary Representation | 
|---|---|
| R-type instructions ( add,nor) | bits 24-22: opcodebits 21-19: reg Abits 18-16: reg Bbits 15-3: unused(should all be 0)bits 2-0: destReg | 
| I-type instructions ( lw,sw,beq) | bits 24-22: opcodebits 21-19: reg Abits 18-16: reg Bbits 15-0: offsetField(a 16-bit, 2’s complement number with a range of -32768 to 32767) | 
| J-type instructions ( jalr) | bits 24-22: opcodebits 21-19: reg Abits 18-16: reg Bbits 15-0: unused(should all be 0) | 
| O-type instructions ( halt,noop) | bits 24-22: opcodebits 21-0: unused(should all be 0) | 
The offsetField above is a Two’s Complement Number
Labels
Labels make assembly code easier to read and write. They let us assign labels to instructions / data (memory locations) and then use them instead of absolute memory addresses (in beq instructions, lw/sw instructions).