Path: blob/master/libsnes/bsnes/snes/chip/armdsp/registers.hpp
2 views
//Exceptions:1//00000000 = reset2//00000004 = undefined instruction3//00000008 = software interrupt4//0000000c = prefetch abort5//00000010 = data abort6//00000018 = IRQ (interrupt)7//0000001c = FIQ (fast interrupt)89struct Bridge {10struct Buffer {11bool ready;12uint8 data;13};14Buffer cputoarm;15Buffer armtocpu;16uint32 timer;17uint32 timerlatch;18bool reset;19bool ready;20bool busy;2122uint8 status() const {23return (ready << 7) | (cputoarm.ready << 3) | (busy << 2) | (armtocpu.ready << 0);24}25} bridge;2627struct PSR {28bool n;29bool z;30bool c;31bool v;32bool i;33bool f;34uint5 m;3536uint32 getf() const {37return (n << 31) | (z << 30) | (c << 29) | (v << 28);38}3940uint32 gets() const {41return 0u;42}4344uint32 getx() const {45return 0u;46}4748uint32 getc() const {49return (i << 7) | (f << 6) | (m << 0);50}5152void setf(uint32 data) {53n = data & 0x80000000;54z = data & 0x40000000;55c = data & 0x20000000;56v = data & 0x10000000;57}5859void sets(uint32 data) {60}6162void setx(uint32 data) {63}6465void setc(uint32 data) {66i = data & 0x00000080;67f = data & 0x00000040;68m = data & 0x0000001f;69}7071operator uint32() const {72return getf() | gets() | getx() | getc();73}7475PSR& operator=(uint32 data) {76setf(data), sets(data), setx(data), setc(data);77return *this;78}79} cpsr, spsr;8081//r13 = SP (stack pointer)82//r14 = LR (link register)83//r15 = PC (program counter)84struct Register {85uint32 data;86function<void ()> write;8788operator unsigned() const {89return data;90}9192Register& operator=(uint32 n) {93data = n;94if(write) write();95return *this;96}9798Register& operator+=(uint32 n) { return operator=(data + n); }99Register& operator-=(uint32 n) { return operator=(data - n); }100Register& operator&=(uint32 n) { return operator=(data & n); }101Register& operator|=(uint32 n) { return operator=(data | n); }102Register& operator^=(uint32 n) { return operator=(data ^ n); }103104void step() {105data += 4;106}107} r[16];108109bool shiftercarry;110uint32 instruction;111bool exception;112113struct Pipeline {114bool reload;115struct Instruction {116uint32 opcode;117uint32 address;118};119Instruction instruction;120Instruction prefetch;121Instruction mdr;122} pipeline;123124125