Fixed register print representation and condition func check w/ S

This commit is contained in:
Themis Demetriades 2024-06-03 18:14:04 +01:00
parent 5fd5c512e6
commit d9276899e4
2 changed files with 6 additions and 2 deletions

View File

@ -1,3 +1,4 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "execute.h" #include "execute.h"
#include "print.h" #include "print.h"
@ -235,6 +236,9 @@ static bool isConditionMet(Machine* state, a64inst_ConditionType cond) {
return state->conditionCodes.Zero || (state->conditionCodes.Negative != state->conditionCodes.Overflow); return state->conditionCodes.Zero || (state->conditionCodes.Negative != state->conditionCodes.Overflow);
case AL: case AL:
return true; return true;
default:
fprintf(stderr, "Unknown condition specified!\n");
exit(1);
} }
} }

View File

@ -17,9 +17,9 @@ void printState(Machine *state, FILE *stream) {
void printRegisters(Machine *state, FILE *stream) { void printRegisters(Machine *state, FILE *stream) {
fprintf(stream, "Registers:\n"); fprintf(stream, "Registers:\n");
for (int i = 0; i < REGISTER_COUNT; i++) { for (int i = 0; i < REGISTER_COUNT; i++) {
fprintf(stream, "X%02d\t= %" PRIu64 "\n", i, state->registers[i]); fprintf(stream, "X%02d\t= %016x\n", i, (unsigned int)state->registers[i]);
} }
fprintf(stream, "PC\t= %" PRIu64 "\n", state->pc); fprintf(stream, "PC\t= %016x\n", (unsigned int)state->pc);
fprintf(stream, "PSTATE\t: %c%c%c%c", state->conditionCodes.Negative ? 'N' : UNSET_CONDITION_CODE_CHAR, fprintf(stream, "PSTATE\t: %c%c%c%c", state->conditionCodes.Negative ? 'N' : UNSET_CONDITION_CODE_CHAR,
state->conditionCodes.Zero ? 'Z' : UNSET_CONDITION_CODE_CHAR, state->conditionCodes.Zero ? 'Z' : UNSET_CONDITION_CODE_CHAR,
state->conditionCodes.Carry ? 'C' : UNSET_CONDITION_CODE_CHAR, state->conditionCodes.Carry ? 'C' : UNSET_CONDITION_CODE_CHAR,