From 4c04f44286a50c04445d0a3b546be3f73e889073 Mon Sep 17 00:00:00 2001 From: Themis Demetriades Date: Mon, 3 Jun 2024 17:29:45 +0100 Subject: [PATCH] Fixed endian-ness of readWord functions w/ S --- src/print.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/print.c b/src/print.c index c4e4f6c..3021356 100644 --- a/src/print.c +++ b/src/print.c @@ -31,7 +31,7 @@ word readWord(byte *memory, uint32_t address) { word result = 0; int bytesPerWord = WORD_BITS / BYTE_BITS - 1; for (int i = 0; i <= bytesPerWord; i++) - result |= (word) memory[address + i] << (BYTE_BITS * (bytesPerWord - i)); + result |= (word) memory[address + i] << (BYTE_BITS * i); return result; } @@ -40,7 +40,7 @@ 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)); + result |= (dword) memory[address + i] << (BYTE_BITS * i); return result; } @@ -55,5 +55,4 @@ void printMemory(Machine *state, FILE *stream) { fprintf(stream, "0x%08x: 0x%08x\n", addr, data); } } - }