1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <processor/processor.hpp>
#include "arm.hpp"
namespace Processor {
#include "registers.cpp"
#include "algorithms.cpp"
#include "instructions-arm.cpp"
#include "instructions-thumb.cpp"
#include "disassembler.cpp"
#include "serialization.cpp"
void ARM::power() {
processor.power();
vector(0x00000000, Processor::Mode::SVC);
pipeline.reload = true;
crash = false;
r(15).modify = [&] {
pipeline.reload = true;
};
trace = false;
instructions = 0;
}
void ARM::exec() {
cpsr().t ? thumb_step() : arm_step();
}
void ARM::idle() {
bus_idle(r(15));
}
uint32 ARM::read(uint32 addr, uint32 size) {
uint32 word = bus_read(addr, size);
sequential() = true;
return word;
}
uint32 ARM::load(uint32 addr, uint32 size) {
sequential() = false;
uint32 word = read(addr, size);
if(size == Half) { word &= 0xffff; word |= word << 16; }
if(size == Byte) { word &= 0xff; word |= word << 8; word |= word << 16; }
word = ror(word, 8 * (addr & 3));
idle();
if(size == Half) word &= 0xffff;
if(size == Byte) word &= 0xff;
return word;
}
void ARM::write(uint32 addr, uint32 size, uint32 word) {
bus_write(addr, size, word);
sequential() = true;
}
void ARM::store(uint32 addr, uint32 size, uint32 word) {
if(size == Half) { word &= 0xffff; word |= word << 16; }
if(size == Byte) { word &= 0xff; word |= word << 8; word |= word << 16; }
sequential() = false;
write(addr, size, word);
sequential() = false;
}
void ARM::vector(uint32 addr, Processor::Mode mode) {
auto psr = cpsr();
processor.setMode(mode);
spsr() = psr;
cpsr().i = 1;
cpsr().f |= mode == Processor::Mode::FIQ;
cpsr().t = 0;
r(14) = pipeline.decode.address;
r(15) = addr;
}
}
|