mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-30 11:34:54 +00:00
Establish some proportion of state, ready to execute _something_.
This commit is contained in:
parent
90a8999b4b
commit
28c7d27cac
@ -287,7 +287,8 @@ template <
|
||||
// * return directly if there is definitely no possible write back to RAM;
|
||||
// * otherwise use the source() and destination() lambdas, and break in order to allow a writeback if necessary.
|
||||
switch(instruction.operation) {
|
||||
default: assert(false);
|
||||
default: return;
|
||||
//assert(false);
|
||||
|
||||
case Operation::AAA: Primitive::aaa(registers.axp(), status); return;
|
||||
case Operation::AAD: Primitive::aad(registers.axp(), instruction.operand(), status); return;
|
||||
|
@ -68,6 +68,12 @@ struct Status {
|
||||
|
||||
// Convenience getters.
|
||||
template <typename IntT> IntT carry_bit() { return carry ? 1 : 0; }
|
||||
|
||||
void set(uint16_t value) {
|
||||
carry = value & ConditionCode::Carry;
|
||||
|
||||
// TODO: the rest.
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -209,6 +209,7 @@ constexpr char TestSuiteHome[] = "/Users/tharte/Projects/ProcessorTests/8088/v1"
|
||||
uint16_t &di() { return di_; }
|
||||
|
||||
uint16_t es_, cs_, ds_, ss_;
|
||||
uint16_t ip_;
|
||||
};
|
||||
struct Memory {
|
||||
std::vector<uint8_t> memory;
|
||||
@ -222,10 +223,10 @@ constexpr char TestSuiteHome[] = "/Users/tharte/Projects/ProcessorTests/8088/v1"
|
||||
uint32_t physical_address;
|
||||
using Source = InstructionSet::x86::Source;
|
||||
switch(segment) {
|
||||
default: address = registers_.ds_; break;
|
||||
case Source::ES: address = registers_.es_; break;
|
||||
case Source::CS: address = registers_.cs_; break;
|
||||
case Source::DS: address = registers_.ds_; break;
|
||||
default: physical_address = registers_.ds_; break;
|
||||
case Source::ES: physical_address = registers_.es_; break;
|
||||
case Source::CS: physical_address = registers_.cs_; break;
|
||||
case Source::DS: physical_address = registers_.ds_; break;
|
||||
}
|
||||
physical_address = ((physical_address << 4) + address) & 0xf'ffff;
|
||||
return *reinterpret_cast<IntT *>(&memory[physical_address]);
|
||||
@ -242,6 +243,29 @@ constexpr char TestSuiteHome[] = "/Users/tharte/Projects/ProcessorTests/8088/v1"
|
||||
Memory memory(registers);
|
||||
IO io;
|
||||
|
||||
// Apply initial state.
|
||||
NSDictionary *const initial = test[@"initial"];
|
||||
for(NSArray<NSNumber *> *ram in initial[@"ram"]) {
|
||||
memory.memory[[ram[0] intValue]] = [ram[1] intValue];
|
||||
}
|
||||
NSDictionary *const initial_registers = initial[@"regs"];
|
||||
registers.ax_.full = [initial_registers[@"ax"] intValue];
|
||||
registers.bx_.full = [initial_registers[@"bx"] intValue];
|
||||
registers.cx_.full = [initial_registers[@"cx"] intValue];
|
||||
registers.dx_.full = [initial_registers[@"dx"] intValue];
|
||||
|
||||
registers.bp_ = [initial_registers[@"bp"] intValue];
|
||||
registers.cs_ = [initial_registers[@"cs"] intValue];
|
||||
registers.di_ = [initial_registers[@"di"] intValue];
|
||||
registers.ds_ = [initial_registers[@"ds"] intValue];
|
||||
registers.es_ = [initial_registers[@"es"] intValue];
|
||||
registers.si_ = [initial_registers[@"si"] intValue];
|
||||
registers.sp_ = [initial_registers[@"sp"] intValue];
|
||||
registers.ss_ = [initial_registers[@"ss"] intValue];
|
||||
registers.ip_ = [initial_registers[@"ip"] intValue];
|
||||
|
||||
status.set([initial_registers[@"flags"] intValue]);
|
||||
|
||||
InstructionSet::x86::perform<InstructionSet::x86::Model::i8086>(
|
||||
decoded.second,
|
||||
status,
|
||||
|
Loading…
x
Reference in New Issue
Block a user