xref: /csrg-svn/usr.bin/pascal/pc2/langpats.c (revision 22272)
1*22272Sdist /*
2*22272Sdist  * Copyright (c) 1979, 1984 Regents of the University of California
3*22272Sdist  * All rights reserved.  The Berkeley software License Agreement
4*22272Sdist  * specifies the terms and conditions for redistribution.
5*22272Sdist  */
62086Smckusick 
716964Smckusick #ifndef lint
8*22272Sdist static char sccsid[] = "@(#)langpats.c	5.1 (Berkeley) 06/05/85";
916964Smckusick #endif not lint
102086Smckusick 
1116964Smckusick #include "inline.h"
1216964Smckusick 
132086Smckusick /*
1416964Smckusick  * Pattern table for Pascal library routines.
152086Smckusick  */
1616964Smckusick struct pats language_ptab[] = {
172086Smckusick 
1811877Smckusick #ifdef vax
199141Smckusick /*
2016964Smckusick  * General Pascal library routines
219141Smckusick  */
222962Smckusic 	{ "2,_ROUND\n",
2316964Smckusick "	movd	(sp)+,r0\n\
2416964Smckusick 	cvtrdl	r0,r0\n" },
252086Smckusick 
262962Smckusic 	{ "2,_TRUNC\n",
2716964Smckusick "	movd	(sp)+,r0\n\
2816964Smckusick 	cvtdl	r0,r0\n" },
292086Smckusick 
309141Smckusick 	{ "1,_ACTFILE\n",
319141Smckusick "	movl	(sp)+,r1\n\
329141Smckusick 	movl	12(r1),r0\n" },
339141Smckusick 
343437Smckusic 	{ "2,_FCALL\n",
3516964Smckusick "	movl	(sp)+,r5\n\
3616964Smckusick 	movl	(sp),r0\n\
3716964Smckusick 	movc3	4(r0),__disply+8,(r5)\n\
383437Smckusic 	movl	(sp)+,r0\n\
394015Smckusic 	movc3	4(r0),8(r0),__disply+8\n" },
402086Smckusick 
412189Smckusic 	{ "2,_FRTN\n",
423437Smckusic "	movl	(sp)+,r0\n\
4316964Smckusick 	movl	(sp)+,r5\n\
4416964Smckusick 	movc3	4(r0),(r5),__disply+8\n" },
452086Smckusick 
462189Smckusic 	{ "3,_FSAV\n",
4716964Smckusick "	movl	(sp)+,r3\n\
4816964Smckusick 	movl	(sp)+,r4\n\
4916964Smckusick 	movl	(sp),r5\n\
5016964Smckusick 	movl	r3,(r5)\n\
5116964Smckusick 	ashl	$3,r4,4(r5)\n\
5216964Smckusick 	movc3	4(r5),__disply+8,8(r5)\n\
534015Smckusic 	movl	(sp)+,r0\n" },
542086Smckusick 
559141Smckusick /*
569141Smckusick  * Pascal relational comparisons
579141Smckusick  */
582189Smckusic 	{ "3,_RELEQ\n",
5916964Smckusick "	movl	(sp)+,r0\n\
6016964Smckusick 	movl	(sp)+,r1\n\
6116964Smckusick 	movl	(sp)+,r3\n\
624015Smckusic 	movl	r0,r4\n\
632102Smckusic 1:\n\
642102Smckusic 	movzwl	$65535,r0\n\
652102Smckusic 	cmpl	r4,r0\n\
662195Smckusic 	jleq	3f\n\
672102Smckusic 	subl2	r0,r4\n\
682102Smckusic 	cmpc3	r0,(r1),(r3)\n\
692102Smckusic 	jeql	1b\n\
702102Smckusic 2:\n\
712195Smckusic 	clrl	r0\n\
722195Smckusic 	jbr	4f\n\
732195Smckusic 3:\n\
742102Smckusic 	cmpc3	r4,(r1),(r3)\n\
752195Smckusic 	jneq	2b\n\
762102Smckusic 	incl	r0\n\
772102Smckusic 4:\n" },
782086Smckusick 
792189Smckusic 	{ "3,_RELNE\n",
8016964Smckusick "	movl	(sp)+,r0\n\
8116964Smckusick 	movl	(sp)+,r1\n\
8216964Smckusick 	movl	(sp)+,r3\n\
834015Smckusic 	movl	r0,r4\n\
842086Smckusick 1:\n\
852102Smckusic 	movzwl	$65535,r0\n\
862102Smckusic 	cmpl	r4,r0\n\
872195Smckusic 	jleq	3f\n\
882102Smckusic 	subl2	r0,r4\n\
892102Smckusic 	cmpc3	r0,(r1),(r3)\n\
902102Smckusic 	jeql	1b\n\
912102Smckusic 2:\n\
922195Smckusic 	movl	$1,r0\n\
932195Smckusic 	jbr	4f\n\
942195Smckusic 3:\n\
952102Smckusic 	cmpc3	r4,(r1),(r3)\n\
962195Smckusic 	jneq	2b\n\
972102Smckusic 4:\n" },
982086Smckusick 
992189Smckusic 	{ "3,_RELSLT\n",
10016964Smckusick "	movl	(sp)+,r0\n\
10116964Smckusick 	movl	(sp)+,r1\n\
10216964Smckusick 	movl	(sp)+,r3\n\
1034015Smckusic 	movl	r0,r4\n\
1042195Smckusic 	jbr	2f\n\
1052102Smckusic 1:\n\
1062102Smckusic 	subl2	r0,r4\n\
1072102Smckusic 	cmpc3	r0,(r1),(r3)\n\
1082195Smckusic 	jneq	3f\n\
1092102Smckusic 2:\n\
1102195Smckusic 	movzwl	$65535,r0\n\
1112195Smckusic 	cmpl	r4,r0\n\
1122195Smckusic 	jgtr	1b\n\
1132102Smckusic 	cmpc3	r4,(r1),(r3)\n\
1142102Smckusic 3:\n\
1152102Smckusic 	jlss	4f\n\
1162086Smckusick 	clrl	r0\n\
1172102Smckusic 	jbr	5f\n\
1182102Smckusic 4:\n\
1192086Smckusick 	movl	$1,r0\n\
1202102Smckusic 5:\n" },
1212086Smckusick 
1222189Smckusic 	{ "3,_RELSLE\n",
12316964Smckusick "	movl	(sp)+,r0\n\
12416964Smckusick 	movl	(sp)+,r1\n\
12516964Smckusick 	movl	(sp)+,r3\n\
1264015Smckusic 	movl	r0,r4\n\
1272195Smckusic 	jbr	2f\n\
1282102Smckusic 1:\n\
1292102Smckusic 	subl2	r0,r4\n\
1302102Smckusic 	cmpc3	r0,(r1),(r3)\n\
1312195Smckusic 	jneq	3f\n\
1322102Smckusic 2:\n\
1332195Smckusic 	movzwl	$65535,r0\n\
1342195Smckusic 	cmpl	r4,r0\n\
1352195Smckusic 	jgtr	1b\n\
1362102Smckusic 	cmpc3	r4,(r1),(r3)\n\
1372102Smckusic 3:\n\
1382102Smckusic 	jleq	4f\n\
1392086Smckusick 	clrl	r0\n\
1402102Smckusic 	jbr	5f\n\
1412102Smckusic 4:\n\
1422086Smckusick 	movl	$1,r0\n\
1432102Smckusic 5:\n" },
1442086Smckusick 
1452189Smckusic 	{ "3,_RELSGT\n",
14616964Smckusick "	movl	(sp)+,r0\n\
14716964Smckusick 	movl	(sp)+,r1\n\
14816964Smckusick 	movl	(sp)+,r3\n\
1494015Smckusic 	movl	r0,r4\n\
1502195Smckusic 	jbr	2f\n\
1512102Smckusic 1:\n\
1522102Smckusic 	subl2	r0,r4\n\
1532102Smckusic 	cmpc3	r0,(r1),(r3)\n\
1542195Smckusic 	jneq	3f\n\
1552102Smckusic 2:\n\
1562195Smckusic 	movzwl	$65535,r0\n\
1572195Smckusic 	cmpl	r4,r0\n\
1582195Smckusic 	jgtr	1b\n\
1592102Smckusic 	cmpc3	r4,(r1),(r3)\n\
1602102Smckusic 3:\n\
1612102Smckusic 	jgtr	4f\n\
1622086Smckusick 	clrl	r0\n\
1632102Smckusic 	jbr	5f\n\
1642102Smckusic 4:\n\
1652086Smckusick 	movl	$1,r0\n\
1662102Smckusic 5:\n" },
1672086Smckusick 
1682189Smckusic 	{ "3,_RELSGE\n",
16916964Smckusick "	movl	(sp)+,r0\n\
17016964Smckusick 	movl	(sp)+,r1\n\
17116964Smckusick 	movl	(sp)+,r3\n\
1724015Smckusic 	movl	r0,r4\n\
1732195Smckusic 	jbr	2f\n\
1742102Smckusic 1:\n\
1752102Smckusic 	subl2	r0,r4\n\
1762102Smckusic 	cmpc3	r0,(r1),(r3)\n\
1772195Smckusic 	jneq	3f\n\
1782102Smckusic 2:\n\
1792195Smckusic 	movzwl	$65535,r0\n\
1802195Smckusic 	cmpl	r4,r0\n\
1812195Smckusic 	jgtr	1b\n\
1822102Smckusic 	cmpc3	r4,(r1),(r3)\n\
1832102Smckusic 3:\n\
1842102Smckusic 	jgeq	4f\n\
1852086Smckusick 	clrl	r0\n\
1862102Smckusic 	jbr	5f\n\
1872102Smckusic 4:\n\
1882086Smckusick 	movl	$1,r0\n\
1892102Smckusic 5:\n" },
1902086Smckusick 
1919141Smckusick /*
1929141Smckusick  * Pascal set operations.
1939141Smckusick  */
1942189Smckusic 	{ "4,_ADDT\n",
19516964Smckusick "	movl	(sp)+,r0\n\
19616964Smckusick 	movl	(sp)+,r1\n\
19716964Smckusick 	movl	(sp)+,r2\n\
19816964Smckusick 	movl	(sp)+,r4\n\
1992086Smckusick 	movl	r0,r3\n\
2002086Smckusick 1:\n\
2012086Smckusick 	bisl3	(r1)+,(r2)+,(r3)+\n\
2022086Smckusick 	sobgtr	r4,1b\n" },
2032086Smckusick 
2042189Smckusic 	{ "4,_SUBT\n",
20516964Smckusick "	movl	(sp)+,r0\n\
20616964Smckusick 	movl	(sp)+,r1\n\
20716964Smckusick 	movl	(sp)+,r2\n\
20816964Smckusick 	movl	(sp)+,r4\n\
2092086Smckusick 	movl	r0,r3\n\
2102086Smckusick 1:\n\
2112086Smckusick 	bicl3	(r2)+,(r1)+,(r3)+\n\
2122086Smckusick 	sobgtr	r4,1b\n" },
2132086Smckusick 
2142189Smckusic 	{ "4,_MULT\n",
21516964Smckusick "	movl	(sp)+,r0\n\
21616964Smckusick 	movl	(sp)+,r1\n\
21716964Smckusick 	movl	(sp)+,r2\n\
21816964Smckusick 	movl	(sp)+,r4\n\
2192086Smckusick 	movl	r0,r3\n\
2202086Smckusick 1:\n\
2212086Smckusick 	mcoml	(r1)+,r5\n\
2222086Smckusick 	bicl3	r5,(r2)+,(r3)+\n\
2232086Smckusick 	sobgtr	r4,1b\n" },
2242086Smckusick 
2252189Smckusic 	{ "4,_IN\n",
22616964Smckusick "	movl	(sp)+,r1\n\
22716964Smckusick 	movl	(sp)+,r2\n\
22816964Smckusick 	movl	(sp)+,r3\n\
22916964Smckusick 	movl	(sp)+,r4\n\
2302230Smckusic 	clrl	r0\n\
2312195Smckusic 	subl2	r2,r1\n\
2322195Smckusic 	cmpl	r1,r3\n\
2332102Smckusic 	jgtru	1f\n\
2342195Smckusic 	jbc	r1,(r4),1f\n\
2352195Smckusic 	incl	r0\n\
2369141Smckusick 1:\n" },
2379141Smckusick 
2389141Smckusick /*
2399141Smckusick  * Pascal runtime checks
2409141Smckusick  */
2419141Smckusick 	{ "1,_ASRT\n",
24216964Smckusick "	movl	(sp)+,r0\n\
24316964Smckusick 	tstl	r0\n\
2449141Smckusick 	jneq	1f\n\
2459141Smckusick 	pushl	$0\n\
2469141Smckusick 	pushl	$_EASRT\n\
2479141Smckusick 	calls	$2,_ERROR\n\
2489141Smckusick 1:\n" },
2499141Smckusick 
2509141Smckusick 	{ "2,_ASRTS\n",
25116964Smckusick "	movl	(sp)+,r0\n\
25216964Smckusick 	movl	(sp)+,r1\n\
2539141Smckusick 	tstl	r0\n\
2549141Smckusick 	jneq	1f\n\
2559141Smckusick 	pushl	r1\n\
2569141Smckusick 	pushl	$_EASRTS\n\
2579141Smckusick 	calls	$2,_ERROR\n\
2589141Smckusick 1:\n" },
2599141Smckusick 
2609141Smckusick 	{ "1,_CHR\n",
2619141Smckusick "	movl	(sp)+,r0\n\
2629141Smckusick 	cmpl	r0,$127\n\
2639141Smckusick 	jlequ	1f\n\
2649141Smckusick 	pushl	r0\n\
2659141Smckusick 	pushl	$_ECHR\n\
2669141Smckusick 	calls	$2,_ERROR\n\
2679141Smckusick 1:\n" },
2689141Smckusick 
2699141Smckusick 	{ "0,_LINO\n",
2709141Smckusick "	incl	__stcnt\n\
2719141Smckusick 	cmpl	__stcnt,__stlim\n\
2729141Smckusick 	jlss	1f\n\
2739141Smckusick 	pushl	__stcnt\n\
2749141Smckusick 	pushl	$_ELINO\n\
2759141Smckusick 	calls	$2,_ERROR\n\
2769141Smckusick 1:\n" },
2779141Smckusick 
2789141Smckusick 	{ "1,_NIL\n",
2799141Smckusick "	movl	(sp)+,r0\n\
2809141Smckusick 	cmpl	r0,__maxptr\n\
2819141Smckusick 	jgtr	1f\n\
2829141Smckusick 	cmpl	r0,__minptr\n\
2839141Smckusick 	jgeq	2f\n\
2849141Smckusick 1:\n\
2859141Smckusick 	pushl	$0\n\
2869141Smckusick 	pushl	$_ENIL\n\
2879141Smckusick 	calls	$2,_ERROR\n\
2889141Smckusick 2:\n" },
2899141Smckusick 
2909141Smckusick 	{ "2,_RANDOM\n",
29116964Smckusick "	movd	(sp)+,r0\n\
2929141Smckusick 	emul	__seed,$1103515245,$0,r0\n\
2939141Smckusick 	ediv	$0x7fffffff,r0,r1,r0\n\
2949141Smckusick 	movl	r0,__seed\n\
2959141Smckusick 	cvtld	r0,r0\n\
2969141Smckusick 	divd2	$0d2.147483647e+09,r0\n" },
2979141Smckusick 
2989141Smckusick 	{ "3,_RANG4\n",
29916964Smckusick "	movl	(sp)+,r0\n\
30016964Smckusick 	movl	(sp)+,r1\n\
30116964Smckusick 	movl	(sp)+,r2\n\
3029141Smckusick 	cmpl	r0,r1\n\
3039141Smckusick 	jlss	1f\n\
3049141Smckusick 	cmpl	r0,r2\n\
3059141Smckusick 	jleq	2f\n\
3069141Smckusick 1:\n\
3079141Smckusick 	pushl	r0\n\
3089141Smckusick 	pushl	$_ERANG\n\
3099141Smckusick 	calls	$2,_ERROR\n\
3109141Smckusick 2:\n" },
3119141Smckusick 
3129141Smckusick 	{ "2,_RSNG4\n",
31316964Smckusick "	movl	(sp)+,r0\n\
31416964Smckusick 	movl	(sp)+,r1\n\
3159141Smckusick 	cmpl	r0,r1\n\
3169141Smckusick 	jlequ	1f\n\
3179141Smckusick 	pushl	r0\n\
3189141Smckusick 	pushl	$_ERANG\n\
3199141Smckusick 	calls	$2,_ERROR\n\
3209141Smckusick 1:\n" },
3219141Smckusick 
3229141Smckusick 	{ "1,_SEED\n",
32316964Smckusick "	movl	(sp)+,r1\n\
32416964Smckusick 	movl	__seed,r0\n\
32516964Smckusick 	movl	r1,__seed\n" },
3269141Smckusick 
3279141Smckusick 	{ "3,_SUBSC\n",
32816964Smckusick "	movl	(sp)+,r0\n\
32916964Smckusick 	movl	(sp)+,r1\n\
33016964Smckusick 	movl	(sp)+,r2\n\
3319141Smckusick 	cmpl	r0,r1\n\
3329141Smckusick 	jlss	1f\n\
3339141Smckusick 	cmpl	r0,r2\n\
3349141Smckusick 	jleq	2f\n\
3359141Smckusick 1:\n\
3369141Smckusick 	pushl	r0\n\
3379141Smckusick 	pushl	$_ESUBSC\n\
3389141Smckusick 	calls	$2,_ERROR\n\
3399141Smckusick 2:\n" },
3409141Smckusick 
3419141Smckusick 	{ "2,_SUBSCZ\n",
34216964Smckusick "	movl	(sp)+,r0\n\
34316964Smckusick 	movl	(sp)+,r1\n\
3449141Smckusick 	cmpl	r0,r1\n\
3459141Smckusick 	jlequ	1f\n\
3469141Smckusick 	pushl	r0\n\
3479141Smckusick 	pushl	$_ESUBSC\n\
3489141Smckusick 	calls	$2,_ERROR\n\
3499141Smckusick 1:\n" },
35011877Smckusick #endif vax
3519141Smckusick 
35211877Smckusick #ifdef mc68000
35312871Smckusick /*
35412871Smckusick  * General Pascal library routines
35512871Smckusick  */
35612871Smckusick 	{ "_ACTFILE\n",
35717204Smckusick "	movl	sp@+,a0\n\
35812871Smckusick 	movl	a0@(12),d0\n" },
35912871Smckusick 
36012871Smckusick 	{ "_ADDT\n",
36117204Smckusick "	movl	sp@+,a0\n\
36217204Smckusick 	movl	sp@+,d0\n\
36317204Smckusick 	movl	sp@+,a1\n\
36417204Smckusick 	movl	sp@+,d1\n\
36517204Smckusick 	movl	a0,sp@-\n\
36617204Smckusick 	movl	a2,sp@-\n\
36717204Smckusick 	movl	d0,a2\n\
36812871Smckusick 	subql	#1,d1\n\
36912871Smckusick 1:\n\
37012871Smckusick 	movl	a2@+,d0\n\
37112871Smckusick 	orl	a1@+,d0\n\
37212871Smckusick 	movl	d0,a0@+\n\
37312871Smckusick 	dbra	d1,1b\n\
37412871Smckusick 	movl	sp@+,a2\n\
37517204Smckusick 	movl	sp@+,d0\n" },
37612871Smckusick 
37712871Smckusick 	{ "_SUBT\n",
37817204Smckusick "	movl	sp@+,a0\n\
37917204Smckusick 	movl	sp@+,d0\n\
38017204Smckusick 	movl	sp@+,a1\n\
38117204Smckusick 	movl	sp@+,d1\n\
38217204Smckusick 	movl	a0,sp@-\n\
38317204Smckusick 	movl	a2,sp@-\n\
38417204Smckusick 	movl	d0,a2\n\
38512871Smckusick 	subql	#1,d1\n\
38612871Smckusick 1:\n\
38712871Smckusick 	movl	a1@+,d0\n\
38812871Smckusick 	notl	d0\n\
38912871Smckusick 	andl	a2@+,d0\n\
39012871Smckusick 	movl	d0,a0@+\n\
39112871Smckusick 	dbra	d1,1b\n\
39212871Smckusick 	movl	sp@+,a2\n\
39317204Smckusick 	movl	sp@+,d0\n" },
39412871Smckusick 
39512871Smckusick 	{ "_MULT\n",
39617204Smckusick "	movl	sp@+,a0\n\
39717204Smckusick 	movl	sp@+,d0\n\
39817204Smckusick 	movl	sp@+,a1\n\
39917204Smckusick 	movl	sp@+,d1\n\
40017204Smckusick 	movl	a0,sp@-\n\
40117204Smckusick 	movl	a2,sp@-\n\
40217204Smckusick 	movl	d0,a2\n\
40312871Smckusick 	subql	#1,d1\n\
40412871Smckusick 1:\n\
40512871Smckusick 	movl	a2@+,d0\n\
40612871Smckusick 	andl	a1@+,d0\n\
40712871Smckusick 	movl	d0,a0@+\n\
40812871Smckusick 	dbra	d1,1b\n\
40912871Smckusick 	movl	sp@+,a2\n\
41017204Smckusick 	movl	sp@+,d0\n" },
41112871Smckusick 
41212871Smckusick 	{ "_IN\n",
41317204Smckusick "	movl	sp@+,d0\n\
41417204Smckusick 	movl	sp@+,a0\n\
41517204Smckusick 	movl	sp@+,d1\n\
41617204Smckusick 	movl	sp@+,a1\n\
41717204Smckusick 	subl	a0,d0\n\
41817204Smckusick 	cmpl	d1,d0\n\
41915124Speter 	jhi	1f\n\
42017204Smckusick 	movl	d0,d1\n\
42117204Smckusick 	lsrl	#3,d1\n\
42217204Smckusick 	btst	d0,a1@(0,d1:l)\n\
42315124Speter 	jeq	1f\n\
42412871Smckusick 	moveq	#1,d0\n\
42515124Speter 	jra	2f\n\
42612871Smckusick 1:\n\
42712871Smckusick 	moveq	#0,d0\n\
42812871Smckusick 2:\n" },
42917204Smckusick 
43015840Saoki 	{ "_RANG4\n",
43117204Smckusick "	movl	sp@+,d0\n\
43217204Smckusick 	movl	sp@+,a0\n\
43317204Smckusick 	movl	sp@+,a1\n\
43417204Smckusick 	cmpl	a0,d0\n\
43515840Saoki 	jlt	1f\n\
43617204Smckusick 	cmpl	a1,d0\n\
43715840Saoki 	jle	2f\n\
43815840Saoki 1:\n\
43915840Saoki 	pea	_ERANG\n\
44015840Saoki 	jbsr	_ERROR\n\
44115840Saoki 	addqw	#4,sp\n\
44215840Saoki 2:\n" },
44315840Saoki 	{ "_RSNG4\n",
44417204Smckusick "	movl	sp@+,a0\n\
44517204Smckusick 	movl	sp@+,a1\n\
44617204Smckusick 	cmpl	a1,a0\n\
44715840Saoki 	jls	1f\n\
44815840Saoki 	pea	_ERANG\n\
44915840Saoki 	jbsr	_ERROR\n\
45015840Saoki 	addqw	#4,sp\n\
45115840Saoki 1:\n" },
45217204Smckusick 
45317204Smckusick 	{ "_SUBSC\n",
45417204Smckusick "	movl	sp@+,d0\n\
45517204Smckusick 	movl	sp@+,a0\n\
45617204Smckusick 	movl	sp@+,a1\n\
45717204Smckusick 	cmpl	a0,d0\n\
45817204Smckusick 	jlt	1f\n\
45917204Smckusick 	cmpl	a1,d0\n\
46017204Smckusick 	jle	2f\n\
46117204Smckusick 1:\n\
46217204Smckusick 	pea	_ESUBSC\n\
46317204Smckusick 	jbsr	_ERROR\n\
46417204Smckusick 	addqw	#4,sp\n\
46517204Smckusick 2:\n" },
46617204Smckusick 
46717204Smckusick 	{ "_SUBSCZ\n",
46817204Smckusick "	movl	sp@+,a0\n\
46917204Smckusick 	movl	sp@+,a1\n\
47017204Smckusick 	cmpl	a1,a0\n\
47117204Smckusick 	jls	1f\n\
47217204Smckusick 	pea	_ESUBSC\n\
47317204Smckusick 	jbsr	_ERROR\n\
47417204Smckusick 	addqw	#4,sp\n\
47517204Smckusick 1:\n" },
47617204Smckusick 
47711877Smckusick #endif mc68000
47811877Smckusick 
47916964Smckusick 	{ "", "" }
4802086Smckusick };
481