diff options
author | Paul Duncan <pabs@pablotron.org> | 2018-06-22 07:36:19 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2018-06-22 07:36:19 -0400 |
commit | a256ef0d7b38b7026c396f2d90ec31fb2c816df2 (patch) | |
tree | 78b57d94036c69004926f93e657369eb0d50b047 | |
parent | a0b061cb35905c1f09fb07e9ef851280b1663a5b (diff) | |
download | gb-c-a256ef0d7b38b7026c396f2d90ec31fb2c816df2.tar.bz2 gb-c-a256ef0d7b38b7026c396f2d90ec31fb2c816df2.zip |
fix 5 more instructions
-rw-r--r-- | ops.yaml | 47 |
1 files changed, 46 insertions, 1 deletions
@@ -3302,6 +3302,7 @@ ops: h: c: code: | + cpu_ww(ctx, RW_PC, cpu_rw(ctx, RW_PC) + 3); call_a16(ctx, old_pc + 1); - id: ADC A, d8 hex: 0xCE @@ -3420,6 +3421,7 @@ ops: h: c: code: | + cpu_ww(ctx, RW_PC, cpu_rw(ctx, RW_PC) + 3); if (!FLAG(ctx, C)) { call_a16(ctx, old_pc + 1); clock = 24; @@ -3781,6 +3783,8 @@ ops: n: h: c: + code: | + xor_d8(ctx, old_pc + 1); - id: RST 28H hex: 0xEF cat: "jumps/calls" @@ -3927,6 +3931,8 @@ ops: n: "0" h: H c: C + code: | + ld_hl_sp_r8(ctx, old_pc + 1); - id: LD SP, HL hex: 0xF9 cat: "16-bit load/store/move" @@ -3957,6 +3963,8 @@ ops: n: h: c: + code: | + cpu_wb(ctx, RB_A, mmu_rb(ctx, mmu_rw(ctx, old_pc + 1))); - id: EI hex: 0xFB cat: "misc" @@ -9315,6 +9323,26 @@ templates: } static void + ld_hl_sp_r8( + gb_t * const ctx, + const uint16_t addr + ) { + // get src values + const uint16_t a = cpu_rw(ctx, RW_SP); + const int8_t b = (int8_t) mmu_rb(ctx, addr); + const uint16_t v = a + b; + + // write dst value + cpu_ww(ctx, RW_HL, v); + + // set flags + cpu_wf(ctx, F_Z | F_N | F_H | F_C, ( + (((a & 0xF0) != (v & 0xF0)) ? F_H : 0) | + (((a & 0xF00) != (v & 0xF00)) ? F_C : 0) + )); + } + + static void adc_rb( gb_t * const ctx, const rb_t reg @@ -9536,6 +9564,23 @@ templates: } static void + xor_d8( + gb_t * const ctx, + const uint16_t addr + ) { + // get value + const uint8_t v = cpu_rb(ctx, RB_A) ^ mmu_rb(ctx, addr); + + // write value + cpu_wb(ctx, RB_A, v); + + // set flags + cpu_wf(ctx, F_Z | F_N | F_H | F_C, ( + (v ? 0 : F_Z) + )); + } + + static void or_rb( gb_t * const ctx, const rb_t reg @@ -9572,7 +9617,7 @@ templates: const uint16_t addr ) { // get value - const uint8_t v = cpu_rb(ctx, RB_A) ^ mmu_rb(ctx, addr); + const uint8_t v = cpu_rb(ctx, RB_A) | mmu_rb(ctx, addr); // write value cpu_wb(ctx, RB_A, v); |