thumb: add execution of instructions
also arm: fix some instructions Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
42
tests/cpu/cpu-fixture.hh
Normal file
42
tests/cpu/cpu-fixture.hh
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "cpu/cpu-impl.hh"
|
||||
|
||||
using namespace matar;
|
||||
|
||||
class CpuFixture {
|
||||
public:
|
||||
CpuFixture()
|
||||
: bus(Memory(std::array<uint8_t, Memory::BIOS_SIZE>(),
|
||||
std::vector<uint8_t>(Header::HEADER_SIZE)))
|
||||
, cpu(bus) {}
|
||||
|
||||
protected:
|
||||
void exec(arm::InstructionData data, Condition condition = Condition::AL) {
|
||||
arm::Instruction instruction(condition, data);
|
||||
instruction.exec(cpu);
|
||||
}
|
||||
|
||||
void exec(thumb::InstructionData data) {
|
||||
thumb::Instruction instruction(data);
|
||||
instruction.exec(cpu);
|
||||
}
|
||||
|
||||
void reset(uint32_t value = 0) { setr(15, value + 8); }
|
||||
|
||||
uint32_t getr(uint8_t r) { return getr_(r, cpu); }
|
||||
|
||||
void setr(uint8_t r, uint32_t value) { setr_(r, value, cpu); }
|
||||
|
||||
Psr psr(bool spsr = false);
|
||||
|
||||
void set_psr(Psr psr, bool spsr = false);
|
||||
|
||||
Bus bus;
|
||||
CpuImpl cpu;
|
||||
|
||||
private:
|
||||
// hack to get a register
|
||||
uint32_t getr_(uint8_t r, CpuImpl& cpu);
|
||||
|
||||
// hack to set a register
|
||||
void setr_(uint8_t r, uint32_t value, CpuImpl& cpu);
|
||||
};
|
Reference in New Issue
Block a user