Skip to content

01. Instruction Types

$\gdef \N{\mathbb{N}} \gdef \Z{\mathbb{Z}} \gdef \Q{\mathbb{Q}} \gdef \R{\mathbb{R}} \gdef \C{\mathbb{C}} \gdef \setcomp#1{\overline{#1}} \gdef \sseq{\subseteq} \gdef \pset#1{\mathcal{P}(#1)} \gdef \covariant{\operatorname{Cov}} \gdef \of{\circ} \gdef \p{^{\prime}} \gdef \pp{^{\prime\prime}} \gdef \ppp{^{\prime\prime\prime}} \gdef \pn#1{^{\prime\times{#1}}} $

I-Type

Excalidraw Excalidraw
The offset value is a signed 16-bit number in 2’s compliment.
Examples of I-type:

  • lw
  • sb
  • beq
  • andi

J-Type

Excalidraw Excalidraw
The only two J-type instructions are j and jal.
These commands work by extending the address by 2 bits (multiplying by four) and appending it to the most significant four bits of the PC (after incrementing), and then setting the PC to that address.

R-Type

Excalidraw Excalidraw
The opcode for all R-type commands is 0.

RS, RT, RD stand for Registers Source, Target, and Destination. The order can be remembered with the mnemonic S.T.D., which stands for Sexually Transmitted Disease, or Simcha’s To Do (app), whichever suits your fancy. Yeah, that might’ve been gross and unnecessary, but trust me, now you’re definitely not going to forget the order any time soon. 🙃

ShAmt is short for Shift Amount. This value is only used for the shift commands: sll, srl, and sra.

The function field tells the ALU what operation to do. We need this, since the opcode is zero. More on this later.