Learned in CS241E.

MIPS is a family of RISC-V instruction set architectures (ISA)  developed by MIPS Computer Systems.

Basic Instructions

For lis, notice that it also increments pc by an additional 4. If we don’t do this, the word right after that we are supposed to load would be interpreted as an instruction, and that could be an unrecognized instruction.

  • lw Load Word copies a word from an address in memory into register
  • sw Store Word copies a word from register t into an address in memory
    • memory address is computed by adding constant to value of register makes it easy to access memory addresses at fixed constant offsets from some address held in register
  • The Jump Register copies the value of register s into the program counter (PC) register. The next instruction that will execute after the Jump Register instruction will be the instruction whose address was in register s
  • jalr The Jump And Link Register instruction does the same thing, but in addition, it saves the previous value of the program counter into register 31. Therefore, after performing a Jump And Link Register instruction, executing a Jump Register 31 instruction will restore the program counter back to the word immediately after the Jump And Link Register instruction. This instruction will later become our basic building block for implementing procedure calls, since a procedure must return to the point that it was called from when it finishes executing.

Technique 2: Variables

def compile(e1, op, e2): (Code, Variable) = {
	(c1, v1) = compile(e1)
	(c2, v2) = compile(e2)
	v3 = new Vraiable
	code = c1 ++ c2 :+ (v3 = v1 op v2)
	(code, v3)

Technique 3: Use temp variables

def compile(e1, op, e2): (Code, Variable) = {
	t1 = new Variable
		t1 = #4
		$4 = t1
		$3 = $4 op $3

in ECE222: MIPS = Millions of instructions per second