From a256ef0d7b38b7026c396f2d90ec31fb2c816df2 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 22 Jun 2018 07:36:19 -0400 Subject: fix 5 more instructions --- ops.yaml | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/ops.yaml b/ops.yaml index fb0df29..4d82cce 100644 --- a/ops.yaml +++ b/ops.yaml @@ -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" @@ -9314,6 +9322,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, @@ -9535,6 +9563,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, @@ -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); -- cgit v1.2.3