From 7b01e4ee6f0e224a8c187b0844553a3ddc38819a Mon Sep 17 00:00:00 2001
From: garde <devnull@localhost>
Date: Tue, 22 Jan 1985 19:55:11 +0000
Subject: [PATCH] src1 and src2 extended. Errors in 'pat loc cmi teq' and 'pat
 loc cmi tne' recovered. Second stack-pattern for 'pat zlt' and 'pat zge'
 added. Patterns for 'lil loc adi sil', 'lil inc sil', 'lil dec sil' and 'sil
 lil' added.

---
 mach/i80/ncg/table | 94 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 81 insertions(+), 13 deletions(-)

diff --git a/mach/i80/ncg/table b/mach/i80/ncg/table
index 5f4c8fae..4ba08156 100644
--- a/mach/i80/ncg/table
+++ b/mach/i80/ncg/table
@@ -1,3 +1,4 @@
+
 /************************************************************/
 /************************************************************/
 /*******					       ******/
@@ -53,8 +54,9 @@ SETS
 reg1			= reg + lbreg + mem .
 bdhsp			= regpair + stackpointer .
 bdhpsw			= regpair + psword .
-src1			= reg .
-src2			= hlorde + const2 .
+immediate2		= const2 + label .
+src1			= reg + const1 .
+src2			= hlorde + const2 + label .
 src1or2			= src1 + src2 .
 
 INSTRUCTIONS
@@ -101,7 +103,7 @@ INSTRUCTIONS
    lda	label:ro 	kills a		cost(3,13) .
    ldax	regind:ro 	kills a		cost(1,7) .
    lhld	label:ro 	kills hl	cost(3,16) .
-   lxi	bdhsp:wo,const2+label:ro	cost(3,10) .
+   lxi	bdhsp:wo,immediate2:ro		cost(3,10) .
    mov	reg1:wo,reg1:ro			cost(1,5) .
    mvi	reg1:wo,const1:ro		cost(2,7) .
 /* nop					cost(1,0) .	*/
@@ -149,7 +151,7 @@ from reg to regpair
 gen mov %2.2,%1
     mvi %2.1,{const1,0}
 
-from const2 + label to bdhsp
+from immediate2 to bdhsp
 gen lxi %2,%1
 
 from const1 to reg
@@ -161,7 +163,7 @@ gen mov %2.1,%1.1
 
 TESTS
 
-to test areg
+to test areg		/* just a dummy test, never used */
 gen cmp %1
 
 STACKINGRULES
@@ -179,12 +181,12 @@ gen push hl
     move %1,hl
     xthl.
 
-from const2 + label to STACK
+from immediate2 to STACK
 uses hlorde
 gen lxi %a,%1
     push %a
 
-from const2 + label to STACK
+from immediate2 to STACK
 gen push hl
     move %1,hl
     xthl.
@@ -205,7 +207,7 @@ gen dcx sp
     pop psw
     inx sp				yields a
 
-from const2 + label
+from immediate2
 uses regpair
 gen move %1,%a				yields %a
 
@@ -332,10 +334,8 @@ with hlreg
   uses reg
   gen mov %a,m				yields %a
 with dereg
-  uses areg	/*** ??? ***/
   gen ldax de				yields a
 with exact label
-   uses areg	/*** ??? ***/
    gen lda %1				yields a
 
 pat loi $1==2
@@ -455,6 +455,65 @@ gen dad lb
     inx hl
     mov m,d
 
+pat sil lil $1==$2
+with dereg
+uses hlreg={const2,$1}, areg
+gen dad lb
+    mov a,m
+    inx hl
+    mov h,m
+    mov l,a
+    mov m,e
+    inx hl
+    mov m,d				yields de
+
+pat lil loc adi sil $1==$4 && $3==2
+with STACK
+uses hlreg={const2,$1}, dereg, areg
+gen dad lb
+    mov e,m
+    inx hl
+    mov h,m
+    mov l,e
+    mov e,m
+    inx hl
+    mov d,m
+    push hl
+    lxi hl,{const2,$2}
+    dad de
+    xchg.
+    pop hl
+    mov m,d
+    dcx hl
+    mov m,e
+
+pat lil inc sil $1==$3
+uses hlreg={const2,$1}
+gen dad lb
+    mov e,m
+    inx hl
+    mov h,m
+    mov l,e
+    inr m
+    jnz {label,"1f"}
+    inx hl
+    inr m
+    1:
+
+pat lil dec sil $1==$3
+uses hlreg={const2,$1}
+gen dad lb
+    mov e,m
+    inx hl
+    mov h,m
+    mov l,e
+    mov e,m
+    inx hl
+    mov d,m
+    dcx de
+    mov m,d
+    dcx hl
+    mov m,e
 
 pat stf
 with hlorde STACK
@@ -1197,7 +1256,6 @@ gen Call {label,".cmi4"}		yields de
 
 pat cmu $1==2
 with hlorde hlorde
-kills hlorde		/***** ?????? ******/
 uses areg
 gen mov a,%2.1
     cmp %1.1
@@ -1341,7 +1399,8 @@ with exact areg
 uses hlorde={const2,0}
 gen cpi {const1,$1}
     jnz {label,"1f"}
-    inx %a				yields %a
+    inx %a
+    1:					yields %a
 with					yields {const2,$1}
 						leaving cmi 2 teq
 
@@ -1351,7 +1410,8 @@ with exact areg
 uses hlorde={const2,0}
 gen cpi {const1,$1}
     jz {label,"1f"}
-    inx %a				yields %a
+    inx %a
+    1:					yields %a
 with					yields {const2,$1}
 						leaving cmi 2 tne
 
@@ -1440,6 +1500,10 @@ with STACK
 gen pop psw
     ral.
     jc {label,$1}
+with hlorde
+gen mov a,%1.1
+    ral.
+    jc {label,$1}
 
 pat zle
 with hlorde STACK
@@ -1472,6 +1536,10 @@ with STACK
 gen pop psw
     ral.
     jnc {label,$1}
+with hlorde
+gen mov a,%1.1
+    ral.
+    jnc {label,$1}
 
 pat zgt
 with hlorde STACK
