From 33a2fe7045731f071b849d18c7737accd005267f Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 8 Feb 2024 23:48:06 +0100 Subject: h8: like subx, addx does not modify Z flag if result is 0, h8: correct H8/300 opcode map (i suspect H8/300H also has opcodes in the map that belong to newer arch but didnt check) --- src/devices/cpu/h8/h8.cpp | 8 +++---- src/devices/cpu/h8/h8.h | 49 ++++++++++++++++++-------------------- src/devices/cpu/h8/h8.lst | 60 ++++++++++++++++++++--------------------------- src/devices/cpu/h8/h8h.h | 42 ++++++++++++++++----------------- 4 files changed, 74 insertions(+), 85 deletions(-) diff --git a/src/devices/cpu/h8/h8.cpp b/src/devices/cpu/h8/h8.cpp index e08adcfc2a8..0aba57b2527 100644 --- a/src/devices/cpu/h8/h8.cpp +++ b/src/devices/cpu/h8/h8.cpp @@ -514,16 +514,16 @@ int h8_device::trapa_setup() uint8_t h8_device::do_addx8(uint8_t v1, uint8_t v2) { uint16_t res = v1 + v2 + (m_CCR & F_C ? 1 : 0); - m_CCR &= ~(F_N|F_V|F_Z|F_C); + m_CCR &= ~(F_N|F_V|F_C); if(m_has_hc) { m_CCR &= ~F_H; if(((v1 & 0xf) + (v2 & 0xf) + (m_CCR & F_C ? 1 : 0)) & 0x10) m_CCR |= F_H; } - if(!uint8_t(res)) - m_CCR |= F_Z; - else if(int8_t(res) < 0) + if(uint8_t(res)) + m_CCR &= ~F_Z; + if(int8_t(res) < 0) m_CCR |= F_N; if(~(v1^v2) & (v1^res) & 0x80) m_CCR |= F_V; diff --git a/src/devices/cpu/h8/h8.h b/src/devices/cpu/h8/h8.h index 060b34595ec..4233f6767aa 100644 --- a/src/devices/cpu/h8/h8.h +++ b/src/devices/cpu/h8/h8.h @@ -308,49 +308,46 @@ protected: inline uint16_t r16_r(int reg) { return m_R[reg & 0xf]; } #define O(o) void o ## _full(); void o ## _partial() - O(add_b_imm8_r8u); O(add_b_r8h_r8l); O(add_w_imm16_r16l); O(add_w_r16h_r16l); - O(adds_l_one_r16l); O(adds_l_two_r16l); O(adds_l_four_r16l); + O(add_b_imm8_r8u); O(add_b_r8h_r8l); O(add_w_r16h_r16l); + O(adds_l_one_r16l); O(adds_l_two_r16l); O(addx_b_imm8_r8u); O(addx_b_r8h_r8l); - O(and_b_imm8_r8u); O(and_w_imm16_r16l); O(and_b_r8h_r8l); + O(and_b_imm8_r8u); O(and_b_r8h_r8l); O(andc_imm8_ccr); - O(band_imm3_abs16); O(band_imm3_abs8); O(band_imm3_r8l); O(band_imm3_r16ihh); + O(band_imm3_abs8); O(band_imm3_r8l); O(band_imm3_r16ihh); O(bcc_rel8); - O(bclr_imm3_abs16); O(bclr_imm3_abs8); O(bclr_imm3_r8l); O(bclr_imm3_r16ihh); O(bclr_r8h_abs16); O(bclr_r8h_abs8); O(bclr_r8h_r8l); O(bclr_r8h_r16ihh); + O(bclr_imm3_abs8); O(bclr_imm3_r8l); O(bclr_imm3_r16ihh); O(bclr_r8h_abs8); O(bclr_r8h_r8l); O(bclr_r8h_r16ihh); O(bcs_rel8); O(beq_rel8); O(bf_rel8); O(bge_rel8); O(bgt_rel8); O(bhi_rel8); - O(biand_imm3_abs16); O(biand_imm3_abs8); O(biand_imm3_r8l); O(biand_imm3_r16ihh); - O(bild_imm3_abs16); O(bild_imm3_abs8); O(bild_imm3_r8l); O(bild_imm3_r16ihh); - O(bior_imm3_abs16); O(bior_imm3_abs8); O(bior_imm3_r8l); O(bior_imm3_r16ihh); - O(bist_imm3_abs16); O(bist_imm3_abs8); O(bist_imm3_r8l); O(bist_imm3_r16ihh); - O(bixor_imm3_abs16); O(bixor_imm3_abs8); O(bixor_imm3_r8l); O(bixor_imm3_r16ihh); - O(bld_imm3_abs16); O(bld_imm3_abs8); O(bld_imm3_r8l); O(bld_imm3_r16ihh); + O(biand_imm3_abs8); O(biand_imm3_r8l); O(biand_imm3_r16ihh); + O(bild_imm3_abs8); O(bild_imm3_r8l); O(bild_imm3_r16ihh); + O(bior_imm3_abs8); O(bior_imm3_r8l); O(bior_imm3_r16ihh); + O(bist_imm3_abs8); O(bist_imm3_r8l); O(bist_imm3_r16ihh); + O(bixor_imm3_abs8); O(bixor_imm3_r8l); O(bixor_imm3_r16ihh); + O(bld_imm3_abs8); O(bld_imm3_r8l); O(bld_imm3_r16ihh); O(ble_rel8); O(bls_rel8); O(blt_rel8); O(bmi_rel8); O(bne_rel8); - O(bnot_imm3_abs16); O(bnot_imm3_abs8); O(bnot_imm3_r8l); O(bnot_imm3_r16ihh); - O(bnot_r8h_abs16); O(bnot_r8h_abs8); O(bnot_r8h_r8l); O(bnot_r8h_r16ihh); - O(bor_imm3_abs16); O(bor_imm3_abs8); O(bor_imm3_r8l); O(bor_imm3_r16ihh); + O(bnot_imm3_abs8); O(bnot_imm3_r8l); O(bnot_imm3_r16ihh); O(bnot_r8h_abs8); O(bnot_r8h_r8l); O(bnot_r8h_r16ihh); + O(bor_imm3_abs8); O(bor_imm3_r8l); O(bor_imm3_r16ihh); O(bpl_rel8); - O(bset_imm3_abs16); O(bset_imm3_abs8); O(bset_imm3_r8l); O(bset_imm3_r16ihh); - O(bset_r8h_abs16); O(bset_r8h_abs8); O(bset_r8h_r8l); O(bset_r8h_r16ihh); + O(bset_imm3_abs8); O(bset_imm3_r8l); O(bset_imm3_r16ihh); O(bset_r8h_abs8); O(bset_r8h_r8l); O(bset_r8h_r16ihh); O(bsr_rel8); - O(bst_imm3_abs16); O(bst_imm3_abs8); O(bst_imm3_r8l); O(bst_imm3_r16ihh); + O(bst_imm3_abs8); O(bst_imm3_r8l); O(bst_imm3_r16ihh); O(bt_rel8); - O(btst_imm3_abs16); O(btst_imm3_abs8); O(btst_imm3_r8l); O(btst_imm3_r16ihh); - O(btst_r8h_abs16); O(btst_r8h_abs8); O(btst_r8h_r8l); O(btst_r8h_r16ihh); + O(btst_imm3_abs8); O(btst_imm3_r8l); O(btst_imm3_r16ihh); O(btst_r8h_abs8); O(btst_r8h_r8l); O(btst_r8h_r16ihh); O(bvc_rel8); O(bvs_rel8); - O(bxor_imm3_abs16); O(bxor_imm3_abs8); O(bxor_imm3_r8l); O(bxor_imm3_r16ihh); - O(cmp_b_imm8_r8u); O(cmp_b_r8h_r8l); O(cmp_w_imm16_r16l); O(cmp_w_r16h_r16l); + O(bxor_imm3_abs8); O(bxor_imm3_r8l); O(bxor_imm3_r16ihh); + O(cmp_b_imm8_r8u); O(cmp_b_r8h_r8l); O(cmp_w_r16h_r16l); O(daa_b_r8l); O(das_b_r8l); - O(dec_b_one_r8l); O(dec_w_one_r16l); O(dec_w_two_r16l); + O(dec_b_one_r8l); O(divxu_b_r8h_r16l); O(eepmov_b); O(inc_b_one_r8l); @@ -365,7 +362,7 @@ protected: O(neg_b_r8l); O(nop); O(not_b_r8l); - O(or_b_imm8_r8u); O(or_b_r8h_r8l); O(or_w_imm16_r16l); + O(or_b_imm8_r8u); O(or_b_r8h_r8l); O(orc_imm8_ccr); O(rotl_b_r8l); O(rotr_b_r8l); @@ -379,10 +376,10 @@ protected: O(shlr_b_r8l); O(sleep); O(stc_ccr_r8l); O(stc_exr_r8l); - O(sub_b_r8h_r8l); O(sub_w_imm16_r16l); O(sub_w_r16h_r16l); - O(subs_l_one_r16l); O(subs_l_two_r16l); O(subs_l_four_r16l); + O(sub_b_r8h_r8l); O(sub_w_r16h_r16l); + O(subs_l_one_r16l); O(subs_l_two_r16l); O(subx_b_imm8_r8u); O(subx_b_r8h_r8l); - O(xor_b_imm8_r8u); O(xor_b_r8h_r8l); O(xor_w_imm16_r16l); + O(xor_b_imm8_r8u); O(xor_b_r8h_r8l); O(xorc_imm8_ccr); O(dispatch_0100); diff --git a/src/devices/cpu/h8/h8.lst b/src/devices/cpu/h8/h8.lst index 24a5c877c7f..3a9991707a3 100644 --- a/src/devices/cpu/h8/h8.lst +++ b/src/devices/cpu/h8/h8.lst @@ -997,10 +997,6 @@ macro jsr32 %opc %spreg r32_w(m_IR[0], r32_r(m_IR[0])+2); prefetch -0b90 fff8 0 adds.l four r16l o - r16_w(m_IR[0], r16_r(m_IR[0])+4); - prefetch - 0b90 fff8 0 adds.l four r32l h r32_w(m_IR[0], r32_r(m_IR[0])+4); prefetch @@ -1356,7 +1352,7 @@ macro jsr32 %opc %spreg r32_w(m_IR[0], r32_r(m_IR[0])-1); prefetch -1b50 fff0 0 dec.w one r16l +1b50 fff0 0 dec.w one r16l h r16_w(m_IR[0], do_dec16(r16_r(m_IR[0]), 1)); prefetch @@ -1372,15 +1368,11 @@ macro jsr32 %opc %spreg r32_w(m_IR[0], r32_r(m_IR[0])-2); prefetch -1b90 fff8 0 subs.l four r16l o - r16_w(m_IR[0], r16_r(m_IR[0])-4); - prefetch - 1b90 fff8 0 subs.l four r32l h r32_w(m_IR[0], r32_r(m_IR[0])-4); prefetch -1bd0 fff0 0 dec.w two r16l +1bd0 fff0 0 dec.w two r16l h r16_w(m_IR[0], do_dec16(r16_r(m_IR[0]), 2)); prefetch @@ -1874,67 +1866,67 @@ macro jsr32 %opc %spreg r8_w(m_IR[0], m_TMP1); prefetch_done(); -6a106300 ffffff0f 1 btst r8h abs16 +6a106300 ffffff0f 1 btst r8h abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); btst r8_r(m_IR[2] >> 4) prefetch -6a107300 ffffff8f 1 btst imm3 abs16 +6a107300 ffffff8f 1 btst imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); btst m_IR[2] >> 4 prefetch -6a107400 ffffff8f 1 bor imm3 abs16 +6a107400 ffffff8f 1 bor imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); bor m_IR[2] >> 4 prefetch -6a107480 ffffff8f 1 bior imm3 abs16 +6a107480 ffffff8f 1 bior imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); bior m_IR[2] >> 4 prefetch -6a107500 ffffff8f 1 bxor imm3 abs16 +6a107500 ffffff8f 1 bxor imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); bxor m_IR[2] >> 4 prefetch -6a107580 ffffff8f 1 bixor imm3 abs16 +6a107580 ffffff8f 1 bixor imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); bixor m_IR[2] >> 4 prefetch -6a107600 ffffff8f 1 band imm3 abs16 +6a107600 ffffff8f 1 band imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); band m_IR[2] >> 4 prefetch -6a107680 ffffff8f 1 biand imm3 abs16 +6a107680 ffffff8f 1 biand imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); biand m_IR[2] >> 4 prefetch -6a107700 ffffff8f 1 bld imm3 abs16 +6a107700 ffffff8f 1 bld imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); bld m_IR[2] >> 4 prefetch -6a107780 ffffff8f 1 bild imm3 abs16 +6a107780 ffffff8f 1 bild imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); bild m_IR[2] >> 4 prefetch -6a186000 ffffff0f 1 bset r8h abs16 +6a186000 ffffff0f 1 bset r8h abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -1942,7 +1934,7 @@ macro jsr32 %opc %spreg write8(m_TMP2, m_TMP1); prefetch_done(); -6a186100 ffffff0f 1 bnot r8h abs16 +6a186100 ffffff0f 1 bnot r8h abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -1950,7 +1942,7 @@ macro jsr32 %opc %spreg write8(m_TMP2, m_TMP1); prefetch_done(); -6a186200 ffffff0f 1 bclr r8h abs16 +6a186200 ffffff0f 1 bclr r8h abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -1958,7 +1950,7 @@ macro jsr32 %opc %spreg write8(m_TMP2, m_TMP1); prefetch_done(); -6a186700 ffffff8f 1 bst imm3 abs16 +6a186700 ffffff8f 1 bst imm3 abs16 h m_TMP2 = int16_t(m_IR[2]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -1966,7 +1958,7 @@ macro jsr32 %opc %spreg write8(m_TMP2, m_TMP1); prefetch_done(); -6a186780 ffffff8f 1 bist imm3 abs16 +6a186780 ffffff8f 1 bist imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -1974,7 +1966,7 @@ macro jsr32 %opc %spreg write8(m_TMP2, m_TMP1); prefetch_done(); -6a187000 ffffff8f 1 bset imm3 abs16 +6a187000 ffffff8f 1 bset imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -1982,7 +1974,7 @@ macro jsr32 %opc %spreg write8(m_TMP2, m_TMP1); prefetch_done(); -6a187100 ffffff8f 1 bnot imm3 abs16 +6a187100 ffffff8f 1 bnot imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -1990,7 +1982,7 @@ macro jsr32 %opc %spreg write8(m_TMP2, m_TMP1); prefetch_done(); -6a187200 ffffff8f 1 bclr imm3 abs16 +6a187200 ffffff8f 1 bclr imm3 abs16 h m_TMP2 = int16_t(m_IR[1]); m_TMP1 = read8(m_TMP2); prefetch_start @@ -2425,31 +2417,31 @@ macro jsr32 %opc %spreg r16_w(m_IR[0], m_IR[1]); prefetch -7910 fff0 0 add.w imm16 r16l +7910 fff0 0 add.w imm16 r16l h r16_w(m_IR[0], do_add16(r16_r(m_IR[0]), m_IR[1])); prefetch -7920 fff0 0 cmp.w imm16 r16l +7920 fff0 0 cmp.w imm16 r16l h do_sub16(r16_r(m_IR[0]), m_IR[1]); prefetch -7930 fff0 0 sub.w imm16 r16l +7930 fff0 0 sub.w imm16 r16l h r16_w(m_IR[0], do_sub16(r16_r(m_IR[0]), m_IR[1])); prefetch -7940 fff0 0 or.w imm16 r16l +7940 fff0 0 or.w imm16 r16l h m_TMP1 = m_IR[1] | r16_r(m_IR[0]); set_nzv16(m_TMP1); r16_w(m_IR[0], m_TMP1); prefetch -7950 fff0 0 xor.w imm16 r16l +7950 fff0 0 xor.w imm16 r16l h m_TMP1 = m_IR[1] ^ r16_r(m_IR[0]); set_nzv16(m_TMP1); r16_w(m_IR[0], m_TMP1); prefetch -7960 fff0 0 and.w imm16 r16l +7960 fff0 0 and.w imm16 r16l h m_TMP1 = m_IR[1] & r16_r(m_IR[0]); set_nzv16(m_TMP1); r16_w(m_IR[0], m_TMP1); diff --git a/src/devices/cpu/h8/h8h.h b/src/devices/cpu/h8/h8h.h index eff0b712300..17a7f1fe175 100644 --- a/src/devices/cpu/h8/h8h.h +++ b/src/devices/cpu/h8/h8h.h @@ -32,42 +32,42 @@ protected: #define O(o) void o ## _full(); void o ## _partial() - O(add_l_r32h_r32l); O(add_l_imm32_r32l); + O(add_w_imm16_r16l); O(add_l_r32h_r32l); O(add_l_imm32_r32l); O(adds_l_four_r32l); O(adds_l_one_r32l); O(adds_l_two_r32l); - O(and_l_r32h_r32l); O(and_l_imm32_r32l); O(and_w_r16h_r16l); - O(band_imm3_abs32); O(band_imm3_r32ihh); + O(and_w_imm16_r16l); O(and_l_r32h_r32l); O(and_l_imm32_r32l); O(and_w_r16h_r16l); + O(band_imm3_abs16); O(band_imm3_abs32); O(band_imm3_r32ihh); O(bcc_rel16); - O(bclr_imm3_abs32); O(bclr_imm3_r32ihh); O(bclr_r8h_abs32); O(bclr_r8h_r32ihh); + O(bclr_imm3_abs16); O(bclr_r8h_abs16); O(bclr_imm3_abs32); O(bclr_imm3_r32ihh); O(bclr_r8h_abs32); O(bclr_r8h_r32ihh); O(bcs_rel16); O(beq_rel16); O(bf_rel16); O(bge_rel16); O(bgt_rel16); O(bhi_rel16); - O(biand_imm3_abs32); O(biand_imm3_r32ihh); - O(bild_imm3_abs32); O(bild_imm3_r32ihh); - O(bior_imm3_abs32); O(bior_imm3_r32ihh); - O(bist_imm3_abs32); O(bist_imm3_r32ihh); - O(bixor_imm3_abs32); O(bixor_imm3_r32ihh); - O(bld_imm3_abs32); O(bld_imm3_r32ihh); + O(biand_imm3_abs16); O(biand_imm3_abs32); O(biand_imm3_r32ihh); + O(bild_imm3_abs16); O(bild_imm3_abs32); O(bild_imm3_r32ihh); + O(bior_imm3_abs16); O(bior_imm3_abs32); O(bior_imm3_r32ihh); + O(bist_imm3_abs16); O(bist_imm3_abs32); O(bist_imm3_r32ihh); + O(bixor_imm3_abs16); O(bixor_imm3_abs32); O(bixor_imm3_r32ihh); + O(bld_imm3_abs16); O(bld_imm3_abs32); O(bld_imm3_r32ihh); O(ble_rel16); O(bls_rel16); O(blt_rel16); O(bmi_rel16); O(bne_rel16); - O(bnot_imm3_abs32); O(bnot_imm3_r32ihh); O(bnot_r8h_abs32); O(bnot_r8h_r32ihh); - O(bor_imm3_abs32); O(bor_imm3_r32ihh); + O(bnot_imm3_abs16); O(bnot_r8h_abs16); O(bnot_imm3_abs32); O(bnot_imm3_r32ihh); O(bnot_r8h_abs32); O(bnot_r8h_r32ihh); + O(bor_imm3_abs16); O(bor_imm3_abs32); O(bor_imm3_r32ihh); O(bpl_rel16); - O(bset_imm3_abs32); O(bset_imm3_r32ihh); O(bset_r8h_abs32); O(bset_r8h_r32ihh); + O(bset_imm3_abs16); O(bset_r8h_abs16); O(bset_imm3_abs32); O(bset_imm3_r32ihh); O(bset_r8h_abs32); O(bset_r8h_r32ihh); O(bsr_rel16); O(bsr_rel8); - O(bst_imm3_abs32); O(bst_imm3_r32ihh); + O(bst_imm3_abs16); O(bst_imm3_abs32); O(bst_imm3_r32ihh); O(bt_rel16); - O(btst_imm3_abs32); O(btst_imm3_r32ihh); O(btst_r8h_abs32); O(btst_r8h_r32ihh); + O(btst_imm3_abs16); O(btst_r8h_abs16); O(btst_imm3_abs32); O(btst_imm3_r32ihh); O(btst_r8h_abs32); O(btst_r8h_r32ihh); O(bvc_rel16); O(bvs_rel16); - O(bxor_imm3_abs32); O(bxor_imm3_r32ihh); - O(cmp_l_r32h_r32l); O(cmp_l_imm32_r32l); - O(dec_l_one_r32l); O(dec_l_two_r32l); + O(bxor_imm3_abs16); O(bxor_imm3_abs32); O(bxor_imm3_r32ihh); + O(cmp_w_imm16_r16l); O(cmp_l_r32h_r32l); O(cmp_l_imm32_r32l); + O(dec_w_one_r16l); O(dec_w_two_r16l); O(dec_l_one_r32l); O(dec_l_two_r32l); O(divxs_b_r8h_r16l); O(divxs_w_r16h_r32l); O(divxu_w_r16h_r32l); O(eepmov_b); O(eepmov_w); @@ -84,7 +84,7 @@ protected: O(mulxu_w_r16h_r32l); O(neg_l_r32l); O(neg_w_r16l); O(not_l_r32l); O(not_w_r16l); - O(or_l_r32h_r32l); O(or_l_imm32_r32l); O(or_w_r16h_r16l); + O(or_w_imm16_r16l); O(or_l_r32h_r32l); O(or_l_imm32_r32l); O(or_w_r16h_r16l); O(rotl_l_r32l); O(rotl_w_r16l); O(rotr_l_r32l); O(rotr_w_r16l); O(rotxl_l_r32l); O(rotxl_w_r16l); @@ -96,10 +96,10 @@ protected: O(shll_l_r32l); O(shll_w_r16l); O(shlr_l_r32l); O(shlr_w_r16l); O(stc_w_ccr_abs16); O(stc_w_ccr_abs32); O(stc_w_ccr_pr32h); O(stc_w_ccr_r32d16h); O(stc_w_ccr_r32d32hh); O(stc_w_ccr_r32ih); - O(sub_l_r32h_r32l); O(sub_l_imm32_r32l); + O(sub_w_imm16_r16l); O(sub_l_r32h_r32l); O(sub_l_imm32_r32l); O(subs_l_four_r32l); O(subs_l_one_r32l); O(subs_l_two_r32l); O(trapa_imm2); - O(xor_l_r32h_r32l); O(xor_l_imm32_r32l); O(xor_w_r16h_r16l); + O(xor_w_imm16_r16l); O(xor_l_r32h_r32l); O(xor_l_imm32_r32l); O(xor_w_r16h_r16l); O(state_irq); #undef O -- cgit v1.2.3