Thumbulator optimizations.

Pre-decode ROM image and turn instruction dispatch into a switch.
This commit is contained in:
Christian Speckner 2019-02-20 00:32:48 +01:00
parent 9735806b2f
commit e80e15538b
5 changed files with 1885 additions and 1712 deletions

View File

@ -67,7 +67,7 @@ CartridgeBUS::CartridgeBUS(const BytePtr& image, uInt32 size,
// Create Thumbulator ARM emulator
bool devSettings = settings.getBool("dev.settings");
myThumbEmulator = make_unique<Thumbulator>(
reinterpret_cast<uInt16*>(myImage), reinterpret_cast<uInt16*>(myBUSRAM),
reinterpret_cast<uInt16*>(myImage), reinterpret_cast<uInt16*>(myBUSRAM), 32768,
devSettings ? settings.getBool("dev.thumb.trapfatal") : false, Thumbulator::ConfigureFor::BUS, this
);

View File

@ -70,7 +70,7 @@ CartridgeCDF::CartridgeCDF(const BytePtr& image, uInt32 size,
// Create Thumbulator ARM emulator
bool devSettings = settings.getBool("dev.settings");
myThumbEmulator = make_unique<Thumbulator>(
reinterpret_cast<uInt16*>(myImage), reinterpret_cast<uInt16*>(myCDFRAM),
reinterpret_cast<uInt16*>(myImage), reinterpret_cast<uInt16*>(myCDFRAM), 32768,
devSettings ? settings.getBool("dev.thumb.trapfatal") : false, myVersion ?
Thumbulator::ConfigureFor::CDF1 : Thumbulator::ConfigureFor::CDF, this);

View File

@ -58,6 +58,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const BytePtr& image, uInt32 size,
myThumbEmulator = make_unique<Thumbulator>
(reinterpret_cast<uInt16*>(myImage),
reinterpret_cast<uInt16*>(myDPCRAM),
32768,
devSettings ? settings.getBool("dev.thumb.trapfatal") : false,
Thumbulator::ConfigureFor::DPCplus,
this);

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ class Thumbulator
DPCplus // cartridges of type DPC+
};
Thumbulator(const uInt16* rom, uInt16* ram, bool traponfatal,
Thumbulator(const uInt16* rom, uInt16* ram, uInt32 romSize, bool traponfatal,
Thumbulator::ConfigureFor configurefor, Cartridge* cartridge);
/**
@ -88,6 +88,58 @@ class Thumbulator
*/
void setConsoleTiming(ConsoleTiming timing);
private:
enum class Op : uInt8 {
invalid,
adc,
add1, add2, add3, add4, add5, add6, add7,
and_,
asr1, asr2,
b1, b2,
bic,
bkpt,
blx1, blx2,
bx,
cmn,
cmp1, cmp2, cmp3,
cps,
cpy,
eor,
ldmia,
ldr1, ldr2, ldr3, ldr4,
ldrb1, ldrb2,
ldrh1, ldrh2,
ldrsb,
ldrsh,
lsl1, lsl2,
lsr1, lsr2,
mov1, mov2, mov3,
mul,
mvn,
neg,
orr,
pop,
push,
rev,
rev16,
revsh,
ror,
sbc,
setend,
stmia,
str1, str2, str3,
strb1, strb2,
strh1, strh2,
sub1, sub2, sub3, sub4,
swi,
sxtb,
sxth,
tst,
uxtb,
uxth
};
private:
uInt32 read_register(uInt32 reg);
void write_register(uInt32 reg, uInt32 data);
@ -100,6 +152,8 @@ class Thumbulator
void write32(uInt32 addr, uInt32 data);
void updateTimer(uInt32 cycles);
static Op decodeInstructionWord(uint16_t inst);
void do_zflag(uInt32 x);
void do_nflag(uInt32 x);
void do_cflag(uInt32 a, uInt32 b, uInt32 c);
@ -120,6 +174,8 @@ class Thumbulator
private:
const uInt16* rom;
uInt16 romSize;
const unique_ptr<Op[]> decodedRom;
uInt16* ram;
uInt32 reg_norm[16]; // normal execution mode, do not have a thread mode