add: MUL, DIV instructions

This commit is contained in:
xamidev
2024-10-23 20:21:02 +02:00
parent ff5e9c07d7
commit fd0d05003e
5 changed files with 84 additions and 5 deletions

12
cpu.c
View File

@@ -74,6 +74,16 @@ void cpu_exec(uint8_t opcode)
reg2 = cpu.memory[cpu.pc++];
cpu.reg[reg1] -= cpu.reg[reg2];
break;
case MUL:
reg1 = cpu.memory[cpu.pc++];
reg2 = cpu.memory[cpu.pc++];
cpu.reg[reg1] *= cpu.reg[reg2];
break;
case DIV:
reg1 = cpu.memory[cpu.pc++];
reg2 = cpu.memory[cpu.pc++];
cpu.reg[reg1] /= cpu.reg[reg2];
break;
case OR:
reg1 = cpu.memory[cpu.pc++];
reg2 = cpu.memory[cpu.pc++];
@@ -218,6 +228,8 @@ void mem_dump()
case 0xb0:
case 0xb1:
case 0xb2:
case 0xb3:
printf("\e[43m%02x\e[0m ", cpu.memory[i]);
break;