Add storeMemory utility function and used it to fix a prev bug
This commit is contained in:
parent
b16fe2bee3
commit
8893b62a18
@ -397,7 +397,7 @@ void execute_SDT(Machine *state, a64inst_instruction *inst) {
|
||||
writeRegister(state, inst->data.SingleTransferData.processOpData.singleDataTransferData.base, inst->data.SingleTransferData.regType, result);
|
||||
}
|
||||
} else {
|
||||
*(word *)(state->memory + address) = state->registers[inst->data.SingleTransferData.target];
|
||||
storeMemory(state->memory, address, state->registers[inst->data.SingleTransferData.target]);
|
||||
|
||||
// Update base register if post indexed
|
||||
bool isSDT = inst->data.SingleTransferData.SingleTransferOpType == a64inst_SINGLE_TRANSFER_SINGLE_DATA_TRANSFER;
|
||||
|
||||
@ -44,6 +44,14 @@ dword readDoubleWord(byte *memory, uint32_t address) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Store into memory starting at address the given dword.
|
||||
void storeMemory(byte *memory, uint32_t address, dword data) {
|
||||
int bytesPerDword = DWORD_BITS / BYTE_BITS - 1;
|
||||
for (int i = 0; i <= bytesPerDword; i++) {
|
||||
memory[address + i] = (byte)((data >> (BYTE_BITS * i)) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
// Prints all non-zero memory locations into the provided stream
|
||||
void printMemory(Machine *state, FILE *stream) {
|
||||
fprintf(stream, "\nNon-zero memory:\n");
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
|
||||
word readWord(byte *memory, uint32_t address);
|
||||
dword readDoubleWord(byte *memory, uint32_t address);
|
||||
void storeMemory(byte *memory, uint32_t address, dword data);
|
||||
void printState(Machine *state, FILE *stream);
|
||||
void printRegisters(Machine *state, FILE *stream);
|
||||
void printMemory(Machine *state, FILE *stream);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user