From 0de5001f82653dc6b29e207e0beec5fac9e214c6 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 8 Feb 2019 23:16:57 +0100 Subject: [PATCH] Make sign extension much less horrible. --- mach/i80/ncg/table | 83 ++++++++++++++++------------- tests/plat/core/cii_e.e | 112 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 37 deletions(-) create mode 100644 tests/plat/core/cii_e.e diff --git a/mach/i80/ncg/table b/mach/i80/ncg/table index 7cff6f948..d1a9187fa 100644 --- a/mach/i80/ncg/table +++ b/mach/i80/ncg/table @@ -999,49 +999,58 @@ gen xra a pat loc loc cii $1==$2 pat loc loc cii $1==2 && $2==4 -with hl_or_de -uses hl_or_de={const2,0}, areg -gen mov a,%1.1 - ora a - jp {label,1f} - lxi %a,{const2,0-1} - 1: yields %a %1 + with hl_or_de + uses hl_or_de, areg + gen + mov a, %1.1 + ral. + sbb a + mov %a.1, a + mov %a.2, a + yields %a %1 pat loc loc cii $1==4 && $2==2 -with hl_or_de hl_or_de yields %1 + with hl_or_de hl_or_de + yields %1 pat loc loc cii $1==1 && $2==2 -with reg -uses reusing %1, areg=%1, hl_or_de -gen move {const1,0},%b.1 - move a,%b.2 - ora a - jp {label,1f} - mvi %b.1,{const1,255} - 1: yields %b -with hl_or_de -uses areg=%1.2 -gen move {const1,0},%1.1 - ora a - jp {label,1f} - mvi %1.1,{const1,255} - 1: yields %1 + with reg + uses reusing %1, areg=%1, hl_or_de + gen + mov %b.2, a + ral. + sbb a + mov %b.1, a + yields %b + with hl_or_de + uses areg=%1.2 + gen + ral. + sbb a + mov %1.1, a + yields %1 pat loc loc cii $1==1 && $2==4 -with reg - uses hlreg - gen move %1,l yields hl - leaving loc $1 loc $2 cii -with hlreg - uses dereg, areg - gen move {const1,0},%1.1 - move l,a - ora a - jp {label,1f} - mvi h,{const1,255} - 1: - mov e,h - mov d,h yields de hl + with areg + uses hl_or_de, hl_or_de + gen + mov %b.2, a + ral. + sbb a + mov %b.1, a + mov %a.2, a + mov %a.1, a + yields %a %b + with hlreg + uses dereg, areg + gen + mov a, l + ral. + sbb a + mov h, a + mov e, a + mov d, a + yields de hl pat cii kills ALL diff --git a/tests/plat/core/cii_e.e b/tests/plat/core/cii_e.e new file mode 100644 index 000000000..07b41684a --- /dev/null +++ b/tests/plat/core/cii_e.e @@ -0,0 +1,112 @@ +# + mes 2, EM_WSIZE, EM_PSIZE + + exp $_m_a_i_n + pro $_m_a_i_n, 0 + +oneshort +onebyte + rom 1 +moneshort + rom 65535 +monebyte + rom 255 + + /* Positive byte->word */ + + loe onebyte + loc 1 + loc EM_WSIZE + cii + loc 1 + cmu EM_WSIZE + zeq *1 + + loc __LINE__ + cal $fail + asp 4 +1 + + /* Negative byte->word */ + + loe monebyte + loc 1 + loc EM_WSIZE + cii + loc -1 + cmu EM_WSIZE + zeq *2 + + loc __LINE__ + cal $fail + asp 4 +2 + +#if EM_WSIZE == 2 + /* Positive byte->dword */ + + loe onebyte + loc 1 + loc 4 + cii + loc 0 + loc 1 + cmu 4 + zeq *3 + + loc __LINE__ + cal $fail + asp 4 +3 + + /* Negative byte->short */ + + loe monebyte + loc 1 + loc 4 + cii + loc -1 + loc -1 + cmu 4 + zeq *4 + + loc __LINE__ + cal $fail + asp 4 +4 + /* Positive word->dword */ + + loe oneshort + loc 2 + loc 4 + cii + loc 0 + loc 1 + cmu 4 + zeq *5 + + loc __LINE__ + cal $fail + asp 4 +5 + + /* Negative word->short */ + + loe moneshort + loc 2 + loc 4 + cii + loc -1 + loc -1 + cmu 4 + zeq *6 + + loc __LINE__ + cal $fail + asp 4 +6 +#endif + + cal $finished + end +