Improved style of main emulate loop w/ S

This commit is contained in:
Themis Demetriades 2024-06-02 21:52:14 +01:00
parent 46c1b42c53
commit fd3ef3453c

View File

@ -31,21 +31,23 @@ int main(int argc, char **argv) {
state->conditionCodes = (PState){0, 1, 0, 0};
state->pc = 0x0;
// get
// Fetch-decode-execute cycle
word wrd;
a64inst_instruction *inst;
do {
word instruction = readWord(state, state->pc);
inst = decode(instruction);
// Step 1: Fetch instruction at PC's address
wrd = readWord(state, state->pc);
// Step 2: Decode instruction to internal representation
inst = decode(wrd);
// Step 3: Update processor state to reflect executing the instruction, and increment PC
execute(state, inst);
state->pc += 1;
} while (inst->type != a64inst_HALT);
printState(state, out);
free(state->memory);
return EXIT_SUCCESS;