Updated thumbulator code from latest in repo.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3290 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2016-02-27 19:58:20 +00:00
parent b02059dc5f
commit 983c6361f2
3 changed files with 1072 additions and 1006 deletions

View File

@ -18,6 +18,11 @@
character corresponding to the '`' key would be output in the
prompt area.
* Updated DPC+ Thumb ARM emulation code to latest from David Welch.
In particular, this fixes incorrect handling of the V flag when
adding and subtracting, but also fixes compile-time warnings that
I couldn't get rid of before.
-Have fun!

File diff suppressed because it is too large Load Diff

View File

@ -37,30 +37,10 @@
#define ROMSIZE (ROMADDMASK+1)
#define RAMSIZE (RAMADDMASK+1)
//0b10000 User PC, R14 to R0, CPSR
//0b10001 FIQ PC, R14_fiq to R8_fiq, R7 to R0, CPSR, SPSR_fiq
//0b10010 IRQ PC, R14_irq, R13_irq, R12 to R0, CPSR, SPSR_irq
//0b10011 Supervisor PC, R14_svc, R13_svc, R12 to R0, CPSR, SPSR_svc
//0b10111 Abort PC, R14_abt, R13_abt, R12 to R0, CPSR, SPSR_abt
//0b11011 Undefined PC, R14_und, R13_und, R12 to R0, CPSR, SPSR_und
//0b11111 System
#define MODE_USR 0x10
#define MODE_FIQ 0x11
#define MODE_IRQ 0x12
#define MODE_SVC 0x13
#define MODE_ABT 0x17
#define MODE_UND 0x1B
#define MODE_SYS 0x1F
#define CPSR_T (1<<5)
#define CPSR_F (1<<6)
#define CPSR_I (1<<7)
#define CPSR_N (1<<31)
#define CPSR_Z (1<<30)
#define CPSR_C (1<<29)
#define CPSR_V (1<<28)
#define CPSR_Q (1<<27)
class Thumbulator
{
@ -92,22 +72,21 @@ class Thumbulator
static void trapFatalErrors(bool enable) { trapOnFatal = enable; }
private:
uInt32 read_register ( uInt32 reg );
uInt32 write_register ( uInt32 reg, uInt32 data );
uInt32 fetch16 ( uInt32 addr );
//uInt32 fetch32 ( uInt32 addr );
uInt32 read16 ( uInt32 addr );
uInt32 read32 ( uInt32 );
void write16 ( uInt32 addr, uInt32 data );
void write32 ( uInt32 addr, uInt32 data );
uInt32 read_register(uInt32 reg);
void write_register(uInt32 reg, uInt32 data);
uInt32 fetch16(uInt32 addr);
uInt32 fetch32(uInt32 addr);
uInt32 read16(uInt32 addr);
uInt32 read32(uInt32 addr);
void write16(uInt32 addr, uInt32 data);
void write32(uInt32 addr, uInt32 data);
void do_zflag ( uInt32 x );
void do_nflag ( uInt32 x );
void do_cflag ( uInt32 a, uInt32 b, uInt32 c );
void do_sub_vflag ( uInt32 a, uInt32 b, uInt32 c );
void do_add_vflag ( uInt32 a, uInt32 b, uInt32 c );
void do_cflag_bit ( uInt32 x );
void do_vflag_bit ( uInt32 x );
void do_zflag(uInt32 x);
void do_nflag(uInt32 x);
void do_cflag(uInt32 a, uInt32 b, uInt32 c);
void do_vflag(uInt32 a, uInt32 b, uInt32 c);
void do_cflag_bit(uInt32 x);
void do_vflag_bit(uInt32 x);
// Throw a runtime_error exception containing an error referencing the
// given message and variables
@ -115,31 +94,20 @@ class Thumbulator
int fatalError(const char* opcode, uInt32 v1, const char* msg);
int fatalError(const char* opcode, uInt32 v1, uInt32 v2, const char* msg);
void dump_counters ( void );
void dump_regs( void );
int execute ( void );
int reset ( void );
void dump_counters();
void dump_regs();
int execute();
int reset();
private:
const uInt16* rom;
uInt16* ram;
//Int32 copydata;
uInt32 halfadd;
uInt32 cpsr;
//uInt32 reg_usr[16]; //User mode
uInt32 reg_sys[16]; //System mode
uInt32 reg_svc[16]; //Supervisor mode
//uInt32 reg_abt[16]; //Abort mode
//uInt32 reg_und[16]; //Undefined mode
//uInt32 reg_irq[16]; //Interrupt mode
//uInt32 reg_fiq[16]; //Fast Interrupt mode
uInt32 mamcr;
uInt64 instructions;
uInt64 fetches;
uInt64 reads;
uInt64 writes;
uInt32 reg_norm[16]; // normal execution mode, do not have a thread mode
uInt32 cpsr, mamcr;
bool handler_mode;
uInt32 systick_ctrl, systick_reload, systick_count, systick_calibrate;
uInt64 instructions, fetches, reads, writes, systick_ints;
ostringstream statusMsg;