pub enum OpCode {
Show 31 variants
Add,
And,
Ashr,
Br,
Cmp,
Jsr,
Ldb,
Ldr,
Mfhi,
Mov,
Movr,
Movt,
Mul,
Not,
Or,
Pop,
Push,
Ret,
Ror,
Sc,
Seg,
Shl,
Shr,
Stb,
Str,
Sub,
Uadd,
Ucmp,
Umul,
Usub,
Xor,
// some variants omitted
}
Expand description
A mnemonic and associated binary value for encoding an Instruction. These are divided into three broad categories depending on the way they are encoded: Type C, Type I, Type J. These encoding patterns are described below. Additional documentation on the instructions associated with each opcode is provided on each variant.
Type-C Encoding: 0bOOOOODDD-CCISRRRR
Type-I Encoding: 0bOOOOODDD-IIIIIIII
Type-J Encoding: 0bOOOOOCCC-IIIIIIII
Variants§
Add
Adds the value in op2 into the register, interpreting both as signed quantities.
(Type-C Encoding)
ADD[S][C] <reg>, <op2>
And
Preforms a bit-wise and operation onto the value in the register.
(Type-C Encoding)
AND[S][C] <reg>, <uop2>
Ashr
Shifts the value in the register by the value in op2, while preserving the sign bit.
(Type-C Encoding)
ASHR[S][C] <reg>, <uop2>
Br
Branches to an offset of the current %ip. Takes extended condition codes (ge, gt, le, lt).
(Type-J Encoding)
BR[CC] <imm8>
Cmp
Compares two values as signed integers and sets corresponding bits in %s.
(Type-C Encoding)
CMP[C] <reg>, <op2>
Jsr
Changes the value of the instruction pointer to a value stored in one of the general-purpose registers.
(Type-C Encoding)
JSR[C] <reg>
Ldb
Loads a byte into regd from address in memory specified by regs. Fills the upper byte with zeroes when loading the value into the register.
(Type-C Encoding)
LDB[S][C] <regd>, (<regs>)
Ldr
Loads a word (2 bytes) from memory into regd from an address specified in regs.
(Type-C Encoding)
LDR[S][C] <regd>, (<regs>)
Mfhi
Moves the value in the %hi register resulting from a multiplication into reg.
(Type-C Encoding)
MFHI[S][C] <reg>
Mov
Moves an immediate value into the lower byte of reg, padding the upper byte with zeroes.
(Type-I Encoding)
MOV <reg>, <uimm8>
Movr
Moves the value of regs into regd.
(Type-C Encoding)
MOVR[S][C] <regd>, <regs>
Movt
Moves an immediate value into the upper byte of reg, doesn’t affect the lower byte.
(Type-I Encoding)
MOVT <reg>, <uimm8>
Mul
Multiplies two signed numbers, storing the lower word of the result in reg, while the rest goes in a special register %hi. Use mfhi to retrieve the value.
(Type-C Encoding)
MUL[S][C] <reg>, <op2>
Not
Performs a bit-wise not operation on the value in reg.
(Type-C Encoding)
NOT[S][C] <reg>
Or
Performs a bit-wise or operation on between the values in reg and uop2, storing the result in reg.
(Type-C Encoding)
OR[S][C] <reg>, <uop2>
Pop
Pops a value off the stack, and stores it in reg.
(Type-C Encoding)
POP[S][C] <reg>
Push
Pushes the value of reg onto the stack.
(Type-C Encoding)
PUSH[C] <uop2>
Ret
Moves the value in %r into the instruction pointer, effectively returning back from a subroutine.
(Type-J Encoding)
RET[CC]
Ror
Shifts the bits of reg by the value of uop2, placing the shifted out bit in the new most significant bit.
(Type-C Encoding)
ROR[S][C] <reg> <uop2>
Sc
Initiates a system call indexed at uimm8 in the interrupt jump table, switching the mode to supervisor.
(Type-J Encoding)
SC[CC] <uimm8>
Seg
Changes the segment portion of the status register to the value contained in uimm8, allowing a different part segment in the memory space to be accessed for data storage, inter-process communication, etc…
(Type-J Encoding)
SEG[CC] <uimm8>
Shl
Shifts the value contained in reg to the left by uop2.
(Type-C Encoding)
SHL[S][C] <reg>, <uop2>
Shr
Shifts the value contained in reg to the right by uop2.
(Type-C Encoding)
SHR[S][C] <reg>, <uop2>
Stb
Stores the lower byte of the value in regs to the address in memory contained in regd, with the segment corresponding to the value in the status register.
(Type-C Encoding)
STB[C] <regs>, (<regd>)
Str
Stores the value in regs to the address in memory contained in regd, with the segment corresponding to the value in the status register.
(Type-C Encoding)
STR[C] <regs>, (<regd>)
Sub
Subtracts the value of the op2 from the value in reg.
(Type-C Encoding)
SUB[S][C] <reg>, <op2>
Uadd
Adds the value of uop2 to the value in reg, treating both as unsigned values.
(Type-C Encoding)
UADD[S][C] <reg>, <uop2>
Ucmp
Compares the value in reg to the value in uop2, treating both as unsigned values.
(Type-C Encoding)
UCMP[C] <reg>, <uop2>
Umul
Multiplies the value in reg with uop2, treating both as unsigned values.
(Type-C Encoding)
UMUL[S][C] <reg>, <uop2>
Usub
Subtracts the value of uop2 from the value in reg, treating both as unsigned values.
(Type-C Encoding)
USUB[S][C] <reg>, <uop2>
Xor
Performs a bit-wise xor between the value in reg and uop2.
(Type-C Encoding)
XOR[S][C] <reg>, <uop2>