diff --git a/src/print.c b/src/print.c index f70eb86..874357d 100644 --- a/src/print.c +++ b/src/print.c @@ -34,6 +34,15 @@ word readWord(byte *memory, uint32_t address) { return result; } +// Returns the double word starting at the provided address +dword readDoubleWord(byte *memory, uint32_t address) { + dword result = 0; + int bytesPerDword = DWORD_BITS / BYTE_BITS - 1; + for (int i = 0; i <= bytesPerDword; i++) + result |= (dword) memory[address + i] << (BYTE_BITS * (bytesPerDword - i)); + return result; +} + // Prints all non-zero memory locations into the provided stream void printMemory(Machine *state, FILE *stream) { fprintf(stream, "\nNon-zero memory:\n"); diff --git a/src/print.h b/src/print.h index f3a411f..c84a3ea 100644 --- a/src/print.h +++ b/src/print.h @@ -2,6 +2,7 @@ #include "emulator.h" word readWord(byte *memory, uint32_t address); +dword readDoubleWord(byte *memory, uint32_t address); void printState(Machine *state, FILE *stream); void printRegisters(Machine *state, FILE *stream); void printMemory(Machine *state, FILE *stream);