Add read double word utility, w/ T
This commit is contained in:
parent
07b2410a86
commit
10d89ecf91
@ -34,6 +34,15 @@ word readWord(byte *memory, uint32_t address) {
|
|||||||
return result;
|
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
|
// Prints all non-zero memory locations into the provided stream
|
||||||
void printMemory(Machine *state, FILE *stream) {
|
void printMemory(Machine *state, FILE *stream) {
|
||||||
fprintf(stream, "\nNon-zero memory:\n");
|
fprintf(stream, "\nNon-zero memory:\n");
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
|
|
||||||
word readWord(byte *memory, uint32_t address);
|
word readWord(byte *memory, uint32_t address);
|
||||||
|
dword readDoubleWord(byte *memory, uint32_t address);
|
||||||
void printState(Machine *state, FILE *stream);
|
void printState(Machine *state, FILE *stream);
|
||||||
void printRegisters(Machine *state, FILE *stream);
|
void printRegisters(Machine *state, FILE *stream);
|
||||||
void printMemory(Machine *state, FILE *stream);
|
void printMemory(Machine *state, FILE *stream);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user