clean-up
This commit is contained in:
parent
a0630fd485
commit
d3bc4b5ff0
2 changed files with 20 additions and 11 deletions
6
cpu.cpp
6
cpu.cpp
|
@ -181,6 +181,9 @@ uint16_t cpu::addRegister(const int nr, const rm_selection_t mode_selection, con
|
||||||
|
|
||||||
void cpu::lowlevel_register_set(const uint8_t set, const uint8_t reg, const uint16_t value)
|
void cpu::lowlevel_register_set(const uint8_t set, const uint8_t reg, const uint16_t value)
|
||||||
{
|
{
|
||||||
|
assert(set < 2);
|
||||||
|
assert(reg < 8);
|
||||||
|
|
||||||
if (reg < 6)
|
if (reg < 6)
|
||||||
regs0_5[set][reg] = value;
|
regs0_5[set][reg] = value;
|
||||||
else if (reg == 6)
|
else if (reg == 6)
|
||||||
|
@ -191,6 +194,9 @@ void cpu::lowlevel_register_set(const uint8_t set, const uint8_t reg, const uint
|
||||||
|
|
||||||
uint16_t cpu::lowlevel_register_get(const uint8_t set, const uint8_t reg)
|
uint16_t cpu::lowlevel_register_get(const uint8_t set, const uint8_t reg)
|
||||||
{
|
{
|
||||||
|
assert(set < 2);
|
||||||
|
assert(reg < 8);
|
||||||
|
|
||||||
if (reg < 6)
|
if (reg < 6)
|
||||||
return regs0_5[set][reg];
|
return regs0_5[set][reg];
|
||||||
|
|
||||||
|
|
25
main.cpp
25
main.cpp
|
@ -54,7 +54,7 @@ void sw_handler(int s)
|
||||||
int run_cpu_validation(const std::string & filename)
|
int run_cpu_validation(const std::string & filename)
|
||||||
{
|
{
|
||||||
json_error_t error;
|
json_error_t error;
|
||||||
json_t *json = json_load_file(filename.c_str(), 0, &error);
|
json_t *json = json_load_file(filename.c_str(), JSON_REJECT_DUPLICATES, &error);
|
||||||
if (!json)
|
if (!json)
|
||||||
error_exit(false, "%s", error.text);
|
error_exit(false, "%s", error.text);
|
||||||
|
|
||||||
|
@ -69,8 +69,6 @@ int run_cpu_validation(const std::string & filename)
|
||||||
cpu *c = new cpu(b, &event);
|
cpu *c = new cpu(b, &event);
|
||||||
b->add_cpu(c);
|
b->add_cpu(c);
|
||||||
|
|
||||||
// {"memory-before": {"512": 51435, "514": 45610, "516": 15091, "518": 43544}, "registers-before": {"0": 64423, "1": 1, "2": 41733, "3": 14269, "4": 48972, "5": 42770, "6": 57736, "7": 512}, "registers-after": {"0": 64423, "1": 1, "2": 41733, "3": 14269, "4": 48972, "5": 42770, "6": 57736, "7": 512}, "memory-after": {"512": 51435, "514": 45610, "516": 15091, "518": 43544}}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// initialize
|
// initialize
|
||||||
json_t *memory_before = json_object_get(test, "memory-before");
|
json_t *memory_before = json_object_get(test, "memory-before");
|
||||||
|
@ -104,9 +102,10 @@ int run_cpu_validation(const std::string & filename)
|
||||||
json_t *b_pc = json_object_get(registers_before, "pc");
|
json_t *b_pc = json_object_get(registers_before, "pc");
|
||||||
assert(b_pc);
|
assert(b_pc);
|
||||||
c->setPC(json_integer_value(b_pc));
|
c->setPC(json_integer_value(b_pc));
|
||||||
// TODO PS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO SP[]
|
||||||
|
|
||||||
c->step_a();
|
c->step_a();
|
||||||
disassemble(c, nullptr, c->getPC(), false);
|
disassemble(c, nullptr, c->getPC(), false);
|
||||||
c->step_b();
|
c->step_b();
|
||||||
|
@ -146,7 +145,7 @@ int run_cpu_validation(const std::string & filename)
|
||||||
uint16_t should_be = json_integer_value(value);
|
uint16_t should_be = json_integer_value(value);
|
||||||
|
|
||||||
if (register_is != should_be) {
|
if (register_is != should_be) {
|
||||||
DOLOG(warning, true, "set %d register %s mismatch (is: %06o, should be: %06o)", set_nr, key, register_is, should_be);
|
DOLOG(warning, true, "set %d register %s mismatch (is: %06o (%d), should be: %06o (%d))", set_nr, key, register_is, register_is, should_be, should_be);
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,27 +156,31 @@ int run_cpu_validation(const std::string & filename)
|
||||||
assert(a_pc);
|
assert(a_pc);
|
||||||
uint16_t should_be_pc = json_integer_value(a_pc);
|
uint16_t should_be_pc = json_integer_value(a_pc);
|
||||||
if (c->getPC() != should_be_pc) {
|
if (c->getPC() != should_be_pc) {
|
||||||
DOLOG(warning, true, "PC register mismatch (is: %06o, should be: %06o)", c->getPC(), should_be_pc);
|
DOLOG(warning, true, "PC register mismatch (is: %06o (%d), should be: %06o (%d))", c->getPC(), c->getPC(), should_be_pc, should_be_pc);
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO check PS
|
// TODO check SP[]
|
||||||
|
|
||||||
{
|
{
|
||||||
json_t *a_psw = json_object_get(registers_after, "psw");
|
json_t *a_psw = json_object_get(registers_after, "psw");
|
||||||
assert(a_psw);
|
assert(a_psw);
|
||||||
uint16_t should_be_psw = json_integer_value(a_psw);
|
uint16_t should_be_psw = json_integer_value(a_psw);
|
||||||
if (should_be_psw != psw) {
|
if (should_be_psw != psw) {
|
||||||
DOLOG(warning, true, "PSW register mismatch (is: %06o, should be: %06o)", psw, should_be_psw);
|
DOLOG(warning, true, "PSW register mismatch (is: %06o (%d), should be: %06o (%d))", psw, psw, should_be_psw, should_be_psw);
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err)
|
if (err) {
|
||||||
DOLOG(warning, true, "%s\n", json_dumps(test, 0)); // also emit empty line(!)
|
char *js = json_dumps(test, 0);
|
||||||
else
|
DOLOG(warning, true, "%s\n", js); // also emit empty line(!)
|
||||||
|
free(js);
|
||||||
|
}
|
||||||
|
else {
|
||||||
n_ok++;
|
n_ok++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean-up
|
// clean-up
|
||||||
|
|
Loading…
Add table
Reference in a new issue