From a4e1444d16195bc2b1d0c0bc2a0072cc18c786d7 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 25 Mar 2024 00:04:01 +0100 Subject: [PATCH] Fix some 8080 and Z80 code generation issues where DIV and REM weren't marking HL as being in use, resulting in occasional register corruption. --- src/cowbe/arch8080.cow.ng | 6 +++--- src/cowbe/archz80.cow.ng | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cowbe/arch8080.cow.ng b/src/cowbe/arch8080.cow.ng index 9d057ec9..034665e7 100644 --- a/src/cowbe/arch8080.cow.ng +++ b/src/cowbe/arch8080.cow.ng @@ -1085,16 +1085,16 @@ gen bc|de|hl := SUB2(bc|de|hl:lhs, CONSTANT():c) uses a aluop2i($lhs, $c.value as uint16, $$, "sui", "sbi"); } -gen de := DIVU2(de, bc) uses a +gen de := DIVU2(de, bc) uses a|hl { dvrmu2(); } gen hl := REMU2(de, bc) uses a { dvrmu2(); } -gen de := DIVS2(de, bc) uses a +gen de := DIVS2(de, bc) uses a|hl { dvrms2(); } -gen hl := REMS2(de, bc) uses a +gen hl := REMS2(de, bc) uses a|hl { dvrms2(); } gen hl := MUL2(hl, de) uses a|bc diff --git a/src/cowbe/archz80.cow.ng b/src/cowbe/archz80.cow.ng index 726d6a60..9060474a 100644 --- a/src/cowbe/archz80.cow.ng +++ b/src/cowbe/archz80.cow.ng @@ -1423,16 +1423,16 @@ gen hl := SUB2(hl:lhs, bc|de:rhs) %} -gen bc := DIVU2(bc, de) uses a +gen bc := DIVU2(bc, de) uses a|hl { E_dvrmu2(); } gen hl := REMU2(bc, de) uses a { E_dvrmu2(); } -gen bc := DIVS2(bc, de) uses a +gen bc := DIVS2(bc, de) uses a|hl { E_dvrms2(); } -gen de := REMS2(bc, de) uses a +gen de := REMS2(bc, de) uses a|hl { E_dvrms2(); } gen hl := MUL2(de, bc) uses a @@ -1550,7 +1550,7 @@ gen hlhl := REMU4(bcbc, dede) uses a gen bcbc := DIVS4(bcbc, dede) uses a|hlhl { E_callhelper("_dvrms4"); } -gen dede := REMS4(bcbc, dede) uses a +gen dede := REMS4(bcbc, dede) uses a|hlhl { E_callhelper("_dvrms4"); } gen hlhl := AND4(dede, hlhl) uses a