refactor: reorganize everything

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-10-04 01:41:38 +05:30
parent 36d71a4ee2
commit e0f7f32699
28 changed files with 297 additions and 338 deletions

View File

@@ -1,5 +1,4 @@
#include "cpu/cpu-fixture.hh"
#include "cpu/cpu-impl.hh"
#include "util/bits.hh"
#include <catch2/catch_test_macros.hpp>

View File

@@ -3,7 +3,7 @@
Psr
CpuFixture::psr(bool spsr) {
Psr psr(0);
CpuImpl tmp = cpu;
Cpu tmp = cpu;
arm::Instruction instruction(
Condition::AL,
arm::PsrTransfer{ .operand = 0,
@@ -40,11 +40,11 @@ CpuFixture::set_psr(Psr psr, bool spsr) {
// fields. Assuming that these work correctly is necessary. Besides, all that
// matters is that the public API is correct.
uint32_t
CpuFixture::getr_(uint8_t r, CpuImpl& cpu) {
CpuFixture::getr_(uint8_t r, Cpu& cpu) {
size_t addr = 13000;
size_t offset = r == 15 ? 4 : 0;
uint32_t word = bus.read_word(addr + offset);
CpuImpl tmp = cpu;
Cpu tmp = cpu;
uint32_t ret = 0xFFFFFFFF;
uint8_t base = r ? 0 : 1;
@@ -82,7 +82,7 @@ CpuFixture::getr_(uint8_t r, CpuImpl& cpu) {
}
void
CpuFixture::setr_(uint8_t r, uint32_t value, CpuImpl& cpu) {
CpuFixture::setr_(uint8_t r, uint32_t value, Cpu& cpu) {
// set register
arm::Instruction set(
Condition::AL,

View File

@@ -1,4 +1,4 @@
#include "cpu/cpu-impl.hh"
#include "cpu/cpu.hh"
using namespace matar;
@@ -31,12 +31,12 @@ class CpuFixture {
void set_psr(Psr psr, bool spsr = false);
Bus bus;
CpuImpl cpu;
Cpu cpu;
private:
// hack to get a register
uint32_t getr_(uint8_t r, CpuImpl& cpu);
uint32_t getr_(uint8_t r, Cpu& cpu);
// hack to set a register
void setr_(uint8_t r, uint32_t value, CpuImpl& cpu);
void setr_(uint8_t r, uint32_t value, Cpu& cpu);
};

View File

@@ -1,5 +1,4 @@
#include "cpu/cpu-fixture.hh"
#include "cpu/cpu-impl.hh"
#include "cpu/thumb/instruction.hh"
#include "util/bits.hh"
#include <catch2/catch_test_macros.hpp>