Browse Source

Implement SW

master
Forest Belton 2 years ago
parent
commit
4d057a79f3
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      src/insn.c

+ 10
- 0
src/insn.c View File

@ -80,9 +80,19 @@ void insn_addiu(cpu_t *cpu, uint32_t insn) {
cpu->regs[rt] = cpu->regs[rs] + imm; cpu->regs[rt] = cpu->regs[rs] + imm;
} }
void insn_sw(cpu_t *cpu, uint32_t insn) {
const uint8_t rt = RT(insn);
const uint8_t rs = RS(insn);
const uint16_t imm = IMM(insn);
debug("SW %s, [%s + %x]", REG_NAMES[rt], REG_NAMES[rt], imm);
cpu_write32(cpu, cpu->regs[rt], imm + cpu->regs[rs]);
}
static cpu_insn_handler primary_insn_handler[TABLE_SIZE] = { static cpu_insn_handler primary_insn_handler[TABLE_SIZE] = {
[LW] = insn_lw, [LW] = insn_lw,
[ADDIU] = insn_addiu, [ADDIU] = insn_addiu,
[SW] = insn_sw,
}; };
static cpu_insn_handler secondary_insn_handler[TABLE_SIZE] = { static cpu_insn_handler secondary_insn_handler[TABLE_SIZE] = {

Loading…
Cancel
Save