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 four broad categories depending on the way they are encoded: Type C, Type S, 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: 0bMMMMMDDD-CCISOOOO
Type-S Encoding: 0bMMMMMCCI-OOOOOOOO
Type-I Encoding: 0bMMMMMDDD-IIIIIIII
Type-J Encoding: 0bMMMMMCCC-IIIIIIII
Variants§
Add
Adds the value in op8 into the register, interpreting both as signed quantities.
(Type-C Encoding)
ADD[S][C] <reg>, <op8>
And
Preforms a bit-wise and operation onto the value in the register.
(Type-C Encoding)
AND[S][C] <reg>, <uop8>
Ashr
Shifts the value in the register by the value in op8, while preserving the sign bit.
(Type-C Encoding)
ASHR[S][C] <reg>, <uop8>
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>, <op8>
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>, <op4>
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 uop8, storing the result in reg.
(Type-C Encoding)
OR[S][C] <reg>, <uop8>
Pop
Pops a value off the stack, and stores it in reg. Due to the encoding type, it is possible to pop %r off of the stack.
(Type-S Encoding)
POP[C] <reg>
Push
Pushes the value of uop16 onto the stack. If this value is a register, then even in user mode, %r can be pushed onto the stack.
(Type-S Encoding)
PUSH[C] <uop16>
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 uop8, placing the shifted out bit in the new most significant bit.
(Type-C Encoding)
ROR[S][C] <reg> <uop8>
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 uop16, allowing a different part segment in the memory space to be accessed for data storage, inter-process communication, etc…
(Type-S Encoding)
SEG[C] <uop16>
Shl
Shifts the value contained in reg to the left by uop8.
(Type-C Encoding)
SHL[S][C] <reg>, <uop8>
Shr
Shifts the value contained in reg to the right by uop8.
(Type-C Encoding)
SHR[S][C] <reg>, <uop8>
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 op8 from the value in reg.
(Type-C Encoding)
SUB[S][C] <reg>, <op8>
Uadd
Adds the value of uop8 to the value in reg, treating both as unsigned values.
(Type-C Encoding)
UADD[S][C] <reg>, <uop8>
Ucmp
Compares the value in reg to the value in uop8, treating both as unsigned values.
(Type-C Encoding)
UCMP[C] <reg>, <uop8>
Umul
Multiplies the value in reg with uop8, treating both as unsigned values.
(Type-C Encoding)
UMUL[S][C] <reg>, <uop8>
Usub
Subtracts the value of uop8 from the value in reg, treating both as unsigned values.
(Type-C Encoding)
USUB[S][C] <reg>, <uop8>
Xor
Performs a bit-wise xor between the value in reg and uop8.
(Type-C Encoding)
XOR[S][C] <reg>, <uop8>