all repos — mgba @ 301c07dda345f6c0c0bbed61eb61865333cbb425

mGBA Game Boy Advance Emulator

Implement ADC, SBC
Jeffrey Pfau jeffrey@endrift.com
Fri, 26 Apr 2013 01:25:31 -0700
commit

301c07dda345f6c0c0bbed61eb61865333cbb425

parent

c61812325c94ce54fb5674d574e66fa049137f60

2 files changed, 18 insertions(+), 9 deletions(-)

jump to
M src/arm/arm.hsrc/arm/arm.h

@@ -54,13 +54,13 @@ union PSR {

struct { enum PrivilegeMode priv : 5; enum ExecutionMode t : 1; - int f : 1; - int i : 1; - int : 20; - int v : 1; - int c : 1; - int z : 1; - int n : 1; + unsigned f : 1; + unsigned i : 1; + unsigned : 20; + unsigned v : 1; + unsigned c : 1; + unsigned z : 1; + unsigned n : 1; }; int32_t packed;
M src/arm/isa-thumb.csrc/arm/isa-thumb.c

@@ -247,8 +247,17 @@ }

} THUMB_NEUTRAL_S( , , cpu->gprs[rd])) -DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ADC, ARM_STUB) -DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(SBC, ARM_STUB) +DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ADC, + int n = cpu->gprs[rn] + cpu->cpsr.c; + int d = cpu->gprs[rd]; + cpu->gprs[rd] = d + n; + THUMB_ADDITION_S(d, n, cpu->gprs[rd]);) + +DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(SBC, + int n = cpu->gprs[rn] + !cpu->cpsr.c; + int d = cpu->gprs[rd]; + cpu->gprs[rd] = d - n; + THUMB_SUBTRACTION_S(d, n, cpu->gprs[rd]);) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ROR, int rs = cpu->gprs[rn] & 0xFF; if (rs) {