mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-22 12:33:29 +00:00
Attempt to catch illegal accesses ahead of time.
This commit is contained in:
parent
0d2af80f7f
commit
6808f2c778
@ -95,6 +95,7 @@ struct Registers {
|
||||
};
|
||||
struct Memory {
|
||||
enum class Tag {
|
||||
Seeded,
|
||||
Accessed,
|
||||
FlagsL,
|
||||
FlagsH
|
||||
@ -112,6 +113,11 @@ struct Memory {
|
||||
tags.clear();
|
||||
}
|
||||
|
||||
void seed(uint32_t address, uint8_t value) {
|
||||
memory[address] = value;
|
||||
tags[address] = Tag::Seeded;
|
||||
}
|
||||
|
||||
// Entry point used by the flow controller so that it can mark up locations at which the flags were written,
|
||||
// so that defined-flag-only masks can be applied while verifying RAM contents.
|
||||
template <typename IntT> IntT &access([[maybe_unused]] InstructionSet::x86::Source segment, uint16_t address, Tag tag) {
|
||||
@ -136,6 +142,9 @@ struct Memory {
|
||||
|
||||
// Entry point for the 8086; simply notes that memory was accessed.
|
||||
template <typename IntT> IntT &access([[maybe_unused]] InstructionSet::x86::Source segment, uint32_t address) {
|
||||
if(tags.find(address) == tags.end()) {
|
||||
printf("Access to uninitialised RAM area");
|
||||
}
|
||||
return access<IntT>(segment, address, Tag::Accessed);
|
||||
}
|
||||
};
|
||||
@ -399,7 +408,7 @@ struct FailedExecution {
|
||||
NSDictionary *const initial_state = test[@"initial"];
|
||||
InstructionSet::x86::Status initial_status;
|
||||
for(NSArray<NSNumber *> *ram in initial_state[@"ram"]) {
|
||||
execution_support.memory.memory[[ram[0] intValue]] = [ram[1] intValue];
|
||||
execution_support.memory.seed([ram[0] intValue], [ram[1] intValue]);
|
||||
}
|
||||
[self populate:execution_support.registers status:initial_status value:initial_state[@"regs"]];
|
||||
execution_support.status = initial_status;
|
||||
|
Loading…
Reference in New Issue
Block a user