pub enum Opcode {
Show 16 variants
OP_BR = 0,
OP_ADD = 1,
OP_LD = 2,
OP_ST = 3,
OP_JSR = 4,
OP_AND = 5,
OP_LDR = 6,
OP_STR = 7,
OP_RTI = 8,
OP_NOT = 9,
OP_LDI = 10,
OP_STI = 11,
OP_JMP = 12,
OP_RES = 13,
OP_LEA = 14,
OP_TRAP = 15,
}
Expand description
Represents the LC3 opcodes
Variants§
OP_BR = 0
Branch Conditional branch based on condition codes (N, Z, P) Format: 0000 NZP PCoffset9
OP_ADD = 1
Add Add two values and store the result Format: 0001 DR SR1 000 SR2 (register mode) 0001 DR SR1 1 imm5 (immediate mode)
OP_LD = 2
Load Load a value from memory into a register Format: 0010 DR PCoffset9
OP_ST = 3
Store Store a value from a register into memory Format: 0011 SR PCoffset9
OP_JSR = 4
Jump to Subroutine Jump to a subroutine and save the return address Format: 0100 1 PCoffset11 (JSR) 0100 000 BaseR 000000 (JSRR)
OP_AND = 5
Bitwise AND Perform bitwise AND operation Format: 0101 DR SR1 000 SR2 (register mode) 0101 DR SR1 1 imm5 (immediate mode)
OP_LDR = 6
Load Register Load a value from memory using a base register and offset Format: 0110 DR BaseR offset6
OP_STR = 7
Store Register Store a value to memory using a base register and offset Format: 0111 SR BaseR offset6
OP_RTI = 8
Return from Interrupt Unused in LC3 Format: 1000 000000000000
OP_NOT = 9
Bitwise NOT Perform bitwise NOT operation Format: 1001 DR SR 111111
OP_LDI = 10
Load Indirect Load a value from memory using an address stored in memory Format: 1010 DR PCoffset9
OP_STI = 11
Store Indirect Store a value to memory using an address stored in memory Format: 1011 SR PCoffset9
OP_JMP = 12
Jump Jump to an address specified by a register Format: 1100 000 BaseR 000000
OP_RES = 13
Reserved Unused opcode Format: 1101 000000000000
OP_LEA = 14
Load Effective Address Load a memory address into a register Format: 1110 DR PCoffset9
OP_TRAP = 15
Execute Trap Execute a system call Format: 1111 0000 trapvect8