Chapter 4

Machine Code

The numeric translation of asm instructions - each translated instruciton is called an "op code." The MIPS opcodes can be found on the "MIPS Green Sheet:" https://inst.eecs.berkeley.edu/~cs61c/resources/MIPS_Green_Sheet.pdf

Opcode format

Opcode type is stored as two numbers. The first is 2 bits and the second is four bits. Example: lw has an opcode of 23: 2 = 10, 3 = 0011, combined = 100011

ADD instruction example

add $t0, $t1, $t2 (r format since uses registers)

Result = 000000 (add) | 01001 ($t1) | 01010 ($t2) | 01000 ($t0) | 00000 (shamt) | 100000 (funct)

= 000000 01001 01010 01000 00000 100000

= 0x012a4020