instruction encoding and decoding working

This commit is contained in:
2026-07-15 17:31:10 +10:00
parent 9d0c1de3f5
commit c06f070921
8 changed files with 221 additions and 10 deletions

View File

@@ -8,8 +8,16 @@ int main() {
return 1;
}
Instruction inst = decodeInstruction(emu->mem, &emu->pc);
printf("%s\n", instructionToCStr(inst));
Instruction program[] = {
{INST_MVI, {REG_A, 0, 0}, 5, true},
{INST_MVI, {REG_B, 0, 0}, 3, true},
{INST_ADD, {REG_A, REG_B, 0}, 0, false}
};
memoryLoadProgram(emu->mem, program, sizeof(program)/sizeof(program[0]));
printf("%s\n", instructionToCStr(decodeInstruction(emu->mem, &emu->pc)));
printf("%s\n", instructionToCStr(decodeInstruction(emu->mem, &emu->pc)));
printf("%s\n", instructionToCStr(decodeInstruction(emu->mem, &emu->pc)));
freeEmulator(emu);