2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_opcode(uint4 opcode, uint4 d, uint4 m) {
|
2012-03-22 11:47:25 +00:00
|
|
|
switch(opcode) {
|
2012-03-29 11:58:10 +00:00
|
|
|
case 0: r(d) = bit(r(d) & r(m)); break; //AND
|
|
|
|
case 1: r(d) = bit(r(d) ^ r(m)); break; //EOR
|
2012-04-15 06:49:56 +00:00
|
|
|
case 2: r(d) = bit(lsl(r(d), r(m))); break; //LSL
|
|
|
|
case 3: r(d) = bit(lsr(r(d), r(m))); break; //LSR
|
|
|
|
case 4: r(d) = bit(asr(r(d), r(m))); break; //ASR
|
2012-03-29 11:58:10 +00:00
|
|
|
case 5: r(d) = add(r(d), r(m), cpsr().c); break; //ADC
|
|
|
|
case 6: r(d) = sub(r(d), r(m), cpsr().c); break; //SBC
|
2012-04-15 06:49:56 +00:00
|
|
|
case 7: r(d) = bit(ror(r(d), r(m))); break; //ROR
|
2012-03-29 11:58:10 +00:00
|
|
|
case 8: bit(r(d) & r(m)); break; //TST
|
|
|
|
case 9: r(d) = sub(0, r(m), 1); break; //NEG
|
|
|
|
case 10: sub(r(d), r(m), 1); break; //CMP
|
|
|
|
case 11: add(r(d), r(m), 0); break; //CMN
|
|
|
|
case 12: r(d) = bit(r(d) | r(m)); break; //ORR
|
2015-06-24 13:21:24 +00:00
|
|
|
case 13: r(d) = mul(0, r(m), r(d)); break; //MUL
|
2012-03-29 11:58:10 +00:00
|
|
|
case 14: r(d) = bit(r(d) & ~r(m)); break; //BIC
|
|
|
|
case 15: r(d) = bit(~r(m)); break; //MVN
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//(add,sub) rd,rn,rm
|
|
|
|
//0001 10om mmnn nddd
|
|
|
|
//o = opcode
|
|
|
|
//m = rm
|
|
|
|
//n = rn
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_adjust_register() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint1 opcode = instruction() >> 9;
|
|
|
|
uint3 m = instruction() >> 6;
|
|
|
|
uint3 n = instruction() >> 3;
|
|
|
|
uint3 d = instruction() >> 0;
|
|
|
|
|
|
|
|
switch(opcode) {
|
2012-03-29 11:58:10 +00:00
|
|
|
case 0: r(d) = add(r(n), r(m), 0); break;
|
|
|
|
case 1: r(d) = sub(r(n), r(m), 1); break;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//(add,sub) rd,rn,#immediate
|
|
|
|
//0001 11oi iinn nddd
|
|
|
|
//o = opcode
|
|
|
|
//i = immediate
|
|
|
|
//n = rn
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_adjust_immediate() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint1 opcode = instruction() >> 9;
|
|
|
|
uint3 immediate = instruction() >> 6;
|
|
|
|
uint3 n = instruction() >> 3;
|
|
|
|
uint3 d = instruction() >> 0;
|
|
|
|
|
|
|
|
switch(opcode) {
|
2012-03-29 11:58:10 +00:00
|
|
|
case 0: r(d) = add(r(n), immediate, 0); break;
|
|
|
|
case 1: r(d) = sub(r(n), immediate, 1); break;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//(lsl,lsr,asr) rd,rm,#immediate
|
|
|
|
//000o oiii iimm mddd
|
|
|
|
//o = opcode
|
|
|
|
//i = immediate
|
|
|
|
//m = rm
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_shift_immediate() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint2 opcode = instruction() >> 11;
|
|
|
|
uint5 immediate = instruction() >> 6;
|
|
|
|
uint3 m = instruction() >> 3;
|
|
|
|
uint3 d = instruction() >> 0;
|
|
|
|
|
|
|
|
switch(opcode) {
|
2012-04-15 06:49:56 +00:00
|
|
|
case 0: r(d) = bit(lsl(r(m), immediate)); break;
|
Update to v099r13 release.
byuu says:
Changelog:
- GB core code cleanup completed
- GBA core code cleanup completed
- some more cleanup on missed processor/arm functions/variables
- fixed FC loading icarus bug
- "Load ROM File" icarus functionality restored
- minor code unification efforts all around (not perfect yet)
- MMIO->IO
- mmio.cpp->io.cpp
- read,write->readIO,writeIO
It's been a very long work in progress ... starting all the way back with
v094r09, but the major part of the higan code cleanup is now completed! Of
course, it's very important to note that this is only for the basic style:
- under_score functions and variables are now camelCase
- return-type function-name() are now auto function-name() -> return-type
- Natural<T>/Integer<T> replace (u)intT_n types where possible
- signed/unsigned are now int/uint
- most of the x==true,x==false tests changed to x,!x
A lot of spot improvements to consistency, simplicity and quality have
gone in along the way, of course. But we'll probably never fully finishing
beautifying every last line of code in the entire codebase. Still,
this is a really great start. Going forward, WIP diffs should start
being smaller and of higher quality once again.
I know the joke is, "until my coding style changes again", but ... this
was way too stressful, way too time consuming, and way too risky. I'm
too old and tired now for extreme upheavel like this again. The only
major change I'm slowly mulling over would be renaming the using
Natural<T>/Integer<T> = (u)intT; shorthand to something that isn't as
easily confused with the (u)int_t types ... but we'll see. I'll definitely
continue to change small things all the time, but for the larger picture,
I need to just accept the style I have and live with it.
2016-06-29 11:10:28 +00:00
|
|
|
case 1: r(d) = bit(lsr(r(m), immediate == 0 ? 32u : (uint)immediate)); break;
|
|
|
|
case 2: r(d) = bit(asr(r(m), immediate == 0 ? 32u : (uint)immediate)); break;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
2012-03-21 11:08:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//(mov,cmp,add,sub) (rd,rn),#immediate
|
|
|
|
//001o orrr iiii iiii
|
|
|
|
//o = opcode
|
|
|
|
//r = (rd,rn)
|
|
|
|
//i = immediate
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_immediate() {
|
2012-03-21 11:08:16 +00:00
|
|
|
uint2 opcode = instruction() >> 11;
|
|
|
|
uint3 d = instruction() >> 8;
|
|
|
|
uint8 immediate = instruction();
|
|
|
|
|
|
|
|
switch(opcode) {
|
2012-03-29 11:58:10 +00:00
|
|
|
case 0: r(d) = bit( immediate ); break;
|
|
|
|
case 1: sub(r(d), immediate, 1); break;
|
|
|
|
case 2: r(d) = add(r(d), immediate, 0); break;
|
|
|
|
case 3: r(d) = sub(r(d), immediate, 1); break;
|
2012-03-21 11:08:16 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-22 11:47:25 +00:00
|
|
|
|
|
|
|
//{opcode} rd,rm
|
|
|
|
//0100 00oo oomm mddd
|
|
|
|
//o = opcode
|
|
|
|
//m = rm
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_alu() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint4 opcode = instruction() >> 6;
|
|
|
|
uint3 m = instruction() >> 3;
|
|
|
|
uint3 d = instruction();
|
|
|
|
|
|
|
|
thumb_opcode(opcode, d, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
//bx rm
|
|
|
|
//0100 0111 0mmm m---
|
|
|
|
//m = rm
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_branch_exchange() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint4 m = instruction() >> 3;
|
|
|
|
|
|
|
|
cpsr().t = r(m) & 1;
|
2012-03-26 10:13:02 +00:00
|
|
|
r(15) = r(m);
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//{opcode} rd,rm
|
|
|
|
//0100 01oo DMmm mddd
|
|
|
|
//o = opcode
|
|
|
|
//M:m = rm
|
|
|
|
//D:d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_alu_hi() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint2 opcode = instruction() >> 8;
|
|
|
|
uint4 m = instruction() >> 3;
|
|
|
|
uint3 dl = instruction();
|
|
|
|
uint1 dh = instruction() >> 7;
|
|
|
|
|
|
|
|
uint4 d = (dh << 3) + (dl << 0);
|
|
|
|
switch(opcode) {
|
2012-03-29 11:58:10 +00:00
|
|
|
case 0: r(d) = r(d) + r(m); break; //ADD (does not modify flags)
|
|
|
|
case 1: sub(r(d), r(m), 1); break; //SUB
|
|
|
|
case 2: r(d) = r(m); break; //MOV (does not modify flags)
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//ldr rd,[pc,#+/-offset]
|
|
|
|
//0100 1ddd oooo oooo
|
|
|
|
//d = rd
|
|
|
|
//o = offset
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_load_literal() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint3 d = instruction() >> 8;
|
|
|
|
uint8 displacement = instruction();
|
|
|
|
|
Update to v099r13 release.
byuu says:
Changelog:
- GB core code cleanup completed
- GBA core code cleanup completed
- some more cleanup on missed processor/arm functions/variables
- fixed FC loading icarus bug
- "Load ROM File" icarus functionality restored
- minor code unification efforts all around (not perfect yet)
- MMIO->IO
- mmio.cpp->io.cpp
- read,write->readIO,writeIO
It's been a very long work in progress ... starting all the way back with
v094r09, but the major part of the higan code cleanup is now completed! Of
course, it's very important to note that this is only for the basic style:
- under_score functions and variables are now camelCase
- return-type function-name() are now auto function-name() -> return-type
- Natural<T>/Integer<T> replace (u)intT_n types where possible
- signed/unsigned are now int/uint
- most of the x==true,x==false tests changed to x,!x
A lot of spot improvements to consistency, simplicity and quality have
gone in along the way, of course. But we'll probably never fully finishing
beautifying every last line of code in the entire codebase. Still,
this is a really great start. Going forward, WIP diffs should start
being smaller and of higher quality once again.
I know the joke is, "until my coding style changes again", but ... this
was way too stressful, way too time consuming, and way too risky. I'm
too old and tired now for extreme upheavel like this again. The only
major change I'm slowly mulling over would be renaming the using
Natural<T>/Integer<T> = (u)intT; shorthand to something that isn't as
easily confused with the (u)int_t types ... but we'll see. I'll definitely
continue to change small things all the time, but for the larger picture,
I need to just accept the style I have and live with it.
2016-06-29 11:10:28 +00:00
|
|
|
uint rm = (r(15) & ~3) + displacement * 4;
|
2015-07-01 10:58:42 +00:00
|
|
|
r(d) = load(Word | Nonsequential, rm);
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//(ld(r,s),str){b,h} rd,[rn,rm]
|
|
|
|
//0101 ooom mmnn nddd
|
|
|
|
//o = opcode
|
|
|
|
//m = rm
|
|
|
|
//n = rn
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_move_register_offset() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint3 opcode = instruction() >> 9;
|
|
|
|
uint3 m = instruction() >> 6;
|
|
|
|
uint3 n = instruction() >> 3;
|
|
|
|
uint3 d = instruction() >> 0;
|
|
|
|
|
|
|
|
switch(opcode) {
|
Update to v095r03 release and icarus 20151107.
byuu says:
Note: you will need the new icarus (and please use the "no manifest"
system) to run GBA games with this WIP.
Changelog:
- fixed caching of r(d) to pass armwrestler tests [Jonas Quinn]
- DMA to/from GBA BIOS should fail [Cydrak]
- fixed sign-extend and rotate on ldrs instructions [Cydrak]
- fixed 8-bit SRAM reading/writing [byuu]
- refactored GBA/cartridge
- cartridge/rom,ram.type is now cartridge/mrom,sram,eeprom,flash
- things won't crash horribly if you specify a RAM size larger than
the largest legal size in the manifest
- specialized MROM / SRAM classes replace all the shared read/write
functions that didn't work right anyway
- there's a new ruby/video.glx2 driver, which is not enabled by default
- use this if you are running Linux/BSD, but don't have OpenGL 3.2 yet
- I'm not going to support OpenGL2 on Windows/OS X, because these OSes
don't ship ancient video card drivers
- probably more. What am I, clairvoyant? :P
For endrift's tests, this gets us to 1348/1552 memory and 1016/1260
timing. Overall, this puts us back in second place. Only no$ is ahead
on memory, but bgba is even more ahead on timing.
2015-11-08 09:09:18 +00:00
|
|
|
case 0: store(Word | Nonsequential, r(n) + r(m), r(d)); break; //STR
|
|
|
|
case 1: store(Half | Nonsequential, r(n) + r(m), r(d)); break; //STRH
|
|
|
|
case 2: store(Byte | Nonsequential, r(n) + r(m), r(d)); break; //STRB
|
|
|
|
case 3: r(d) = load(Byte | Nonsequential | Signed, r(n) + r(m)); break; //LDSB
|
|
|
|
case 4: r(d) = load(Word | Nonsequential, r(n) + r(m)); break; //LDR
|
|
|
|
case 5: r(d) = load(Half | Nonsequential, r(n) + r(m)); break; //LDRH
|
|
|
|
case 6: r(d) = load(Byte | Nonsequential, r(n) + r(m)); break; //LDRB
|
|
|
|
case 7: r(d) = load(Half | Nonsequential | Signed, r(n) + r(m)); break; //LDSH
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//(ldr,str) rd,[rn,#offset]
|
|
|
|
//0110 looo oonn nddd
|
|
|
|
//l = load
|
|
|
|
//o = offset
|
|
|
|
//n = rn
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_move_word_immediate() {
|
2012-04-15 06:49:56 +00:00
|
|
|
uint1 l = instruction() >> 11;
|
2012-03-22 11:47:25 +00:00
|
|
|
uint5 offset = instruction() >> 6;
|
|
|
|
uint3 n = instruction() >> 3;
|
|
|
|
uint3 d = instruction() >> 0;
|
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) r(d) = load(Word | Nonsequential, r(n) + offset * 4);
|
|
|
|
if(l == 0) store(Word | Nonsequential, r(n) + offset * 4, r(d));
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//(ldr,str)b rd,[rn,#offset]
|
|
|
|
//0111 looo oonn nddd
|
|
|
|
//l = load
|
|
|
|
//o = offset
|
|
|
|
//n = rn
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_move_byte_immediate() {
|
2012-04-15 06:49:56 +00:00
|
|
|
uint1 l = instruction() >> 11;
|
2012-03-22 11:47:25 +00:00
|
|
|
uint5 offset = instruction() >> 6;
|
|
|
|
uint3 n = instruction() >> 3;
|
2012-03-29 11:58:10 +00:00
|
|
|
uint3 d = instruction() >> 0;
|
2012-03-22 11:47:25 +00:00
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) r(d) = load(Byte | Nonsequential, r(n) + offset);
|
|
|
|
if(l == 0) store(Byte | Nonsequential, r(n) + offset, r(d));
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//(ldr,str)h rd,[rn,#offset]
|
|
|
|
//1000 looo oonn nddd
|
|
|
|
//l = load
|
|
|
|
//o = offset
|
|
|
|
//n = rn
|
|
|
|
//d = rd
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_move_half_immediate() {
|
2012-04-15 06:49:56 +00:00
|
|
|
uint1 l = instruction() >> 11;
|
2012-03-22 11:47:25 +00:00
|
|
|
uint5 offset = instruction() >> 6;
|
|
|
|
uint3 n = instruction() >> 3;
|
|
|
|
uint3 d = instruction() >> 0;
|
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) r(d) = load(Half | Nonsequential, r(n) + offset * 2);
|
|
|
|
if(l == 0) store(Half | Nonsequential, r(n) + offset * 2, r(d));
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 11:58:10 +00:00
|
|
|
//(ldr,str) rd,[sp,#immediate]
|
|
|
|
//1001 oddd iiii iiii
|
2012-04-15 06:49:56 +00:00
|
|
|
//l = load
|
2012-03-22 11:47:25 +00:00
|
|
|
//d = rd
|
2012-03-29 11:58:10 +00:00
|
|
|
//i = immediate
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_move_stack() {
|
2012-04-15 06:49:56 +00:00
|
|
|
uint1 l = instruction() >> 11;
|
2012-03-22 11:47:25 +00:00
|
|
|
uint3 d = instruction() >> 8;
|
2012-03-29 11:58:10 +00:00
|
|
|
uint8 immediate = instruction();
|
2012-03-22 11:47:25 +00:00
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) r(d) = load(Word | Nonsequential, r(13) + immediate * 4);
|
|
|
|
if(l == 0) store(Word | Nonsequential, r(13) + immediate * 4, r(d));
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//add rd,{pc,sp},#immediate
|
|
|
|
//1010 sddd iiii iiii
|
|
|
|
//s = sp (0 = pc)
|
|
|
|
//d = rd
|
|
|
|
//i = immediate
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_add_register_hi() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint1 sp = instruction() >> 11;
|
|
|
|
uint3 d = instruction() >> 8;
|
|
|
|
uint8 immediate = instruction();
|
|
|
|
|
2012-03-27 11:02:57 +00:00
|
|
|
if(sp == 0) r(d) = (r(15) & ~2) + immediate * 4;
|
|
|
|
if(sp == 1) r(d) = r(13) + immediate * 4;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//(add,sub) sp,#immediate
|
|
|
|
//1011 0000 oiii iiii
|
|
|
|
//o = opcode
|
|
|
|
//i = immediate
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_adjust_stack() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint1 opcode = instruction() >> 7;
|
|
|
|
uint7 immediate = instruction();
|
|
|
|
|
|
|
|
if(opcode == 0) r(13) += immediate * 4;
|
|
|
|
if(opcode == 1) r(13) -= immediate * 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
//push {r...{,lr}}
|
|
|
|
//pop {r...{,pc}}
|
|
|
|
//1011 o10r llll llll
|
|
|
|
//o = opcode (0 = push, 1 = pop)
|
|
|
|
//r = push lr -or- pop pc
|
|
|
|
//l = register list
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_stack_multiple() {
|
2012-04-15 06:49:56 +00:00
|
|
|
uint1 l = instruction() >> 11;
|
2012-03-22 11:47:25 +00:00
|
|
|
uint1 branch = instruction() >> 8;
|
|
|
|
uint8 list = instruction();
|
|
|
|
|
2012-03-26 10:13:02 +00:00
|
|
|
uint32 sp = 0;
|
2012-04-15 06:49:56 +00:00
|
|
|
if(l == 1) sp = r(13);
|
|
|
|
if(l == 0) sp = r(13) - (bit::count(list) + branch) * 4;
|
|
|
|
|
Update to v099r13 release.
byuu says:
Changelog:
- GB core code cleanup completed
- GBA core code cleanup completed
- some more cleanup on missed processor/arm functions/variables
- fixed FC loading icarus bug
- "Load ROM File" icarus functionality restored
- minor code unification efforts all around (not perfect yet)
- MMIO->IO
- mmio.cpp->io.cpp
- read,write->readIO,writeIO
It's been a very long work in progress ... starting all the way back with
v094r09, but the major part of the higan code cleanup is now completed! Of
course, it's very important to note that this is only for the basic style:
- under_score functions and variables are now camelCase
- return-type function-name() are now auto function-name() -> return-type
- Natural<T>/Integer<T> replace (u)intT_n types where possible
- signed/unsigned are now int/uint
- most of the x==true,x==false tests changed to x,!x
A lot of spot improvements to consistency, simplicity and quality have
gone in along the way, of course. But we'll probably never fully finishing
beautifying every last line of code in the entire codebase. Still,
this is a really great start. Going forward, WIP diffs should start
being smaller and of higher quality once again.
I know the joke is, "until my coding style changes again", but ... this
was way too stressful, way too time consuming, and way too risky. I'm
too old and tired now for extreme upheavel like this again. The only
major change I'm slowly mulling over would be renaming the using
Natural<T>/Integer<T> = (u)intT; shorthand to something that isn't as
easily confused with the (u)int_t types ... but we'll see. I'll definitely
continue to change small things all the time, but for the larger picture,
I need to just accept the style I have and live with it.
2016-06-29 11:10:28 +00:00
|
|
|
uint sequential = Nonsequential;
|
|
|
|
for(uint m : range(8)) {
|
2015-06-24 13:21:24 +00:00
|
|
|
if(list & 1 << m) {
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) r(m) = read(Word | sequential, sp); //POP
|
|
|
|
if(l == 0) write(Word | sequential, sp, r(m)); //PUSH
|
2012-03-26 10:13:02 +00:00
|
|
|
sp += 4;
|
2015-07-01 10:58:42 +00:00
|
|
|
sequential = Sequential;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-26 10:13:02 +00:00
|
|
|
if(branch) {
|
|
|
|
//note: ARMv5+ POP sets cpsr().t
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) r(15) = read(Word | Nonsequential, sp); //POP
|
|
|
|
if(l == 0) write(Word | Nonsequential, sp, r(14)); //PUSH
|
2012-03-26 10:13:02 +00:00
|
|
|
sp += 4;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
2012-03-26 10:13:02 +00:00
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) {
|
|
|
|
idle();
|
|
|
|
r(13) += (bit::count(list) + branch) * 4;
|
|
|
|
} else {
|
|
|
|
pipeline.nonsequential = true;
|
|
|
|
r(13) -= (bit::count(list) + branch) * 4;
|
|
|
|
}
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 10:13:02 +00:00
|
|
|
//(ldmia,stmia) rn!,{r...}
|
2012-03-22 11:47:25 +00:00
|
|
|
//1100 lnnn llll llll
|
|
|
|
//l = load (0 = save)
|
|
|
|
//n = rn
|
|
|
|
//l = register list
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_move_multiple() {
|
2012-04-15 06:49:56 +00:00
|
|
|
uint1 l = instruction() >> 11;
|
2012-03-22 11:47:25 +00:00
|
|
|
uint3 n = instruction() >> 8;
|
|
|
|
uint8 list = instruction();
|
2015-06-24 13:21:24 +00:00
|
|
|
uint32 rn = r(n); //rn may be in register list; so we must cache it
|
2012-03-22 11:47:25 +00:00
|
|
|
|
Update to v099r13 release.
byuu says:
Changelog:
- GB core code cleanup completed
- GBA core code cleanup completed
- some more cleanup on missed processor/arm functions/variables
- fixed FC loading icarus bug
- "Load ROM File" icarus functionality restored
- minor code unification efforts all around (not perfect yet)
- MMIO->IO
- mmio.cpp->io.cpp
- read,write->readIO,writeIO
It's been a very long work in progress ... starting all the way back with
v094r09, but the major part of the higan code cleanup is now completed! Of
course, it's very important to note that this is only for the basic style:
- under_score functions and variables are now camelCase
- return-type function-name() are now auto function-name() -> return-type
- Natural<T>/Integer<T> replace (u)intT_n types where possible
- signed/unsigned are now int/uint
- most of the x==true,x==false tests changed to x,!x
A lot of spot improvements to consistency, simplicity and quality have
gone in along the way, of course. But we'll probably never fully finishing
beautifying every last line of code in the entire codebase. Still,
this is a really great start. Going forward, WIP diffs should start
being smaller and of higher quality once again.
I know the joke is, "until my coding style changes again", but ... this
was way too stressful, way too time consuming, and way too risky. I'm
too old and tired now for extreme upheavel like this again. The only
major change I'm slowly mulling over would be renaming the using
Natural<T>/Integer<T> = (u)intT; shorthand to something that isn't as
easily confused with the (u)int_t types ... but we'll see. I'll definitely
continue to change small things all the time, but for the larger picture,
I need to just accept the style I have and live with it.
2016-06-29 11:10:28 +00:00
|
|
|
for(uint m : range(8)) {
|
2015-06-24 13:21:24 +00:00
|
|
|
if(list & 1 << m) {
|
2015-07-01 10:58:42 +00:00
|
|
|
if(l == 1) r(m) = read(Word | Nonsequential, rn); //LDMIA
|
|
|
|
if(l == 0) write(Word | Nonsequential, rn, r(m)); //STMIA
|
2015-06-24 13:21:24 +00:00
|
|
|
rn += 4;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-15 06:49:56 +00:00
|
|
|
|
2015-06-24 13:21:24 +00:00
|
|
|
if(l == 0 || (list & 1 << n) == 0) r(n) = rn; //update rn on save or when not in register list
|
2012-04-15 06:49:56 +00:00
|
|
|
if(l == 1) idle();
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//swi #immediate
|
|
|
|
//1101 1111 iiii iiii
|
|
|
|
//i = immediate
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_software_interrupt() {
|
2012-03-22 11:47:25 +00:00
|
|
|
uint8 immediate = instruction();
|
|
|
|
|
Update to v087r08 release.
byuu says:
Added some more ARM opcodes, hooked up MMIO. Bind it with mmio[(addr
000-3ff)] = this; inside CPU/PPU/APU, goes to read(), write().
Also moved the Hitachi HG51B core to processor/, and split it apart from
the snes/chip/hitachidsp implementation.
This one actually worked really well. Very clean split between MMIO/DMA
and the processor core. I may move a more generic DMA function inside
the core, not sure yet.
I still believe the HG51B169 to be a variant of the HG51BS family, but
given they're meant to be incredibly flexible microcontrollers, it's
possible that each variant gets its own instruction set.
So, who knows. We'll worry about it if we ever find another HG51B DSP,
I guess.
GBA BIOS is constantly reading from 04000300, but it never writes. If
I return prng()&1, I can get it to proceed until it hits a bad opcode
(stc opcode, which the GBA lacks a coprocessor so ... bad codepath.)
Without it, it just reads that register forever and keeps resetting the
system, or something ...
I guess we're going to have to try and get ARMwrestler working, because
the BIOS seems to need too much emulation code to do anything at all.
2012-03-24 07:52:36 +00:00
|
|
|
vector(0x00000008, Processor::Mode::SVC);
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//b{condition}
|
|
|
|
//1101 cccc dddd dddd
|
|
|
|
//c = condition
|
|
|
|
//d = displacement
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_branch_conditional() {
|
2012-03-27 11:02:57 +00:00
|
|
|
uint4 flagcondition = instruction() >> 8;
|
2012-03-22 11:47:25 +00:00
|
|
|
int8 displacement = instruction();
|
|
|
|
|
2012-03-27 11:02:57 +00:00
|
|
|
if(condition(flagcondition) == false) return;
|
2012-03-22 11:47:25 +00:00
|
|
|
r(15) = r(15) + displacement * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
//b address
|
|
|
|
//1110 0ooo oooo oooo
|
|
|
|
//o = offset
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_branch_short() {
|
2012-03-22 11:47:25 +00:00
|
|
|
int11 displacement = instruction();
|
|
|
|
|
|
|
|
r(15) += displacement * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
//bl address
|
|
|
|
//1111 0ooo oooo oooo
|
|
|
|
//o = offset
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_branch_long_prefix() {
|
2012-03-26 10:13:02 +00:00
|
|
|
int11 offsethi = instruction();
|
2012-03-22 11:47:25 +00:00
|
|
|
|
2012-03-26 10:13:02 +00:00
|
|
|
r(14) = r(15) + ((offsethi * 2) << 11);
|
2012-03-23 10:43:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//bl address
|
|
|
|
//1111 1ooo oooo oooo
|
|
|
|
//o = offset
|
2015-06-24 13:21:24 +00:00
|
|
|
auto ARM::thumb_op_branch_long_suffix() {
|
2012-03-23 10:43:39 +00:00
|
|
|
uint11 offsetlo = instruction();
|
|
|
|
|
2012-03-26 10:13:02 +00:00
|
|
|
r(15) = r(14) + (offsetlo * 2);
|
|
|
|
r(14) = pipeline.decode.address | 1;
|
2012-03-22 11:47:25 +00:00
|
|
|
}
|