r_type_asm = {
    "add":     (0b000000,0b100000, ["rd", "rs", "rt"]),
    "addu":    (0b000000,0b100001, ["rd", "rs", "rt"]),
    "and":     (0b000000,0b100100, ["rd", "rs", "rt"]),
    "break":   (0b000000,0b001101, []),
    "div":     (0b000000,0b011010, ["rd", "rs", "rt"]),
    "divu":    (0b000000,0b011011, ["rs", "rt"]),
    "jalr":    (0b000000,0b001001, ["rd", "rs"]),
    "jr":      (0b000000,0b001000, ["rs"]),
    "mfhi":    (0b000000,0b010000, ["rd"]),
    "mflo":    (0b000000,0b010010, ["rd"]),
    "mthi":    (0b000000,0b010001, ["rs"]),
    "mtlo":    (0b000000,0b010011, ["rs"]),
    "mult":    (0b000000,0b011000, ["rs", "rt"]),
    "multu":   (0b000000,0b011001, ["rs", "rt"]),
    "nor":     (0b000000,0b100111, ["rd", "rs", "rt"]),
    "or":      (0b000000,0b100101, ["rd", "rs", "rt"]),
    "sll":     (0b000000,0b000000, ["rd", "rt", "sa"]),
    "sllv":    (0b000000,0b000100, ["rd", "rt", "rs"]),
    "slt":     (0b000000,0b101010, ["rd", "rs", "rt"]),
    "sltu":    (0b000000,0b101011, ["rd", "rs", "rt"]),
    "sra":     (0b000000,0b000011, ["rd", "rt", "sa"]),
    "srav":    (0b000000,0b000111, ["rd", "rt", "rs"]),
    "srl":     (0b000000,0b000010, ["rd", "rt", "sa"]),
    "srlv":    (0b000000,0b000110, ["rd", "rt", "rs"]),
    "sub":     (0b000000,0b100010, ["rd", "rs", "rt"]),
    "subu":    (0b000000,0b100011, ["rd", "rs", "rt"]),
    "syscall": (0b000000,0b001100, []),
    "xor":     (0b000000,0b100110, ["rd", "rs", "rt"]),
}

i_type_asm = {
    "addi":  (0b001000,["rt", "rs", "immediate"]),
    "addiu": (0b001001,["rt", "rs", "immediate"]),
    "andi":  (0b001100,["rt", "rs", "immediate"]),
    "beq":   (0b000100,["rs", "rt", "offset"]),
    "bgez":  (0b000001,0b00001,["rs", "offset"]),
    "bgtz":  (0b000111,0b00000,["rs", "offset"]),
    "blez":  (0b000110,0b00000,["rs", "offset"]),
    "bltz":  (0b000001,0b00000,["rs", "offset"]),
    "bne":   (0b000101,["rs", "rt", "offset"]),
    "lb":    (0b100000,["rt", "offset(base)"]),
    "lbu":   (0b100100,["rt", "offset(base)"]),
    "lh":    (0b100001,["rt", "offset(base)"]),
    "lhu":   (0b100101,["rt", "offset(base)"]),
    "lui":   (0b001111,0b00000,["rt", "immediate"]),
    "lw":    (0b100011,["rt", "offset(base)"]),
    "ori":   (0b001101,["rt", "rs", "immediate"]),
    "sb":    (0b101000,["rt", "offset(base)"]),
    "sc":    (0b111000,["rt", "offset(base)"]),
    "slti":  (0b001010,["rt", "rs", "immediate"]),
    "sltiu": (0b001011,["rt", "rs", "immediate"]),
    "sh":    (0b101001,["rt", "offset(base)"]),
    "sw":    (0b101011,["rt", "offset(base)"]),
    "xori":  (0b001110,["rt", "rs", "immediate"]),
}

j_type_asm = {
    "j":     (0b000010, []),
    "jal":   (0b000011, []),
}