From 448e8d5d3fd4e816a30a2abedb03ad4ff987adc4 Mon Sep 17 00:00:00 2001 From: Bruno Gouveia Date: Sat, 17 Nov 2018 02:11:30 +0000 Subject: [PATCH] T80: fixed ld hl,sp+dd and add sp,dd flags --- t80/T80.vhd | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/t80/T80.vhd b/t80/T80.vhd index f4a688f..d3c7197 100644 --- a/t80/T80.vhd +++ b/t80/T80.vhd @@ -151,7 +151,6 @@ architecture rtl of T80 is -- Help Registers signal TmpAddr : std_logic_vector(15 downto 0); -- Temporary address register signal TmpAddr2 : std_logic_vector(15 downto 0); -- Temporary address register - signal TmpAddr3 : std_logic_vector(15 downto 0); -- Temporary address register signal IR : std_logic_vector(7 downto 0); -- Instruction register signal ISet : std_logic_vector(1 downto 0); -- Instruction set selector signal RegBusA_r : std_logic_vector(15 downto 0); @@ -359,6 +358,8 @@ begin ALU_Q; process (RESET_n, CLK_n) + variable temp_c : unsigned(8 downto 0); + variable temp_h : unsigned(4 downto 0); begin if RESET_n = '0' then PC <= (others => '0'); -- Program Counter @@ -404,20 +405,22 @@ begin MCycles <= MCycles_d; - if LDHLSP = '1' and TState = 1 then - TmpAddr <= std_logic_vector(SP xor unsigned(Save_Mux) xor unsigned(TmpAddr2)); - F(Flag_Z) <= '0'; - F(Flag_N) <= '0'; - F(Flag_H) <= TmpAddr(4); - F(Flag_C) <= TmpAddr(8); - end if; - - if ADDSPdd = '1' and TState = 4 then - TmpAddr3 <= std_logic_vector(SP xor unsigned(Save_Mux) xor unsigned(TmpAddr)); + if LDHLSP = '1' and MCycle = "011" and TState = 1 then + temp_c := unsigned('0'&SP(7 downto 0))+unsigned('0'&Save_Mux); + temp_h := unsigned('0'&SP(3 downto 0))+unsigned('0'&Save_Mux(3 downto 0)); F(Flag_Z) <= '0'; F(Flag_N) <= '0'; - F(Flag_H) <= TmpAddr3(4); - F(Flag_C) <= TmpAddr3(8); + F(Flag_H) <= temp_h(4); + F(Flag_C) <= temp_c(8); + end if; + + if ADDSPdd = '1' and TState = 1 then + temp_c := unsigned('0'&SP(7 downto 0))+unsigned('0'&Save_Mux); + temp_h := unsigned('0'&SP(3 downto 0))+unsigned('0'&Save_Mux(3 downto 0)); + F(Flag_Z) <= '0'; + F(Flag_N) <= '0'; + F(Flag_H) <= temp_h(4); + F(Flag_C) <= temp_c(8); end if; if Mode = 3 then