1*5be0f76fSbostic /*-
2*5be0f76fSbostic * Copyright (c) 1980 The Regents of the University of California.
3*5be0f76fSbostic * All rights reserved.
4*5be0f76fSbostic *
5*5be0f76fSbostic * %sccs.include.proprietary.c%
69cb9da1cSmckusick */
79cb9da1cSmckusick
89cb9da1cSmckusick #ifndef lint
9*5be0f76fSbostic static char sccsid[] = "@(#)vax.c 5.4 (Berkeley) 04/12/91";
10*5be0f76fSbostic #endif /* not lint */
119cb9da1cSmckusick
129cb9da1cSmckusick /*
139cb9da1cSmckusick * vax.c
149cb9da1cSmckusick *
159cb9da1cSmckusick * VAX specific routines for the F77 compiler, pass 1
169cb9da1cSmckusick *
179cb9da1cSmckusick * University of Utah CS Dept modification history:
189cb9da1cSmckusick *
199cb9da1cSmckusick * $Log: vax.c,v $
2062df89bcSdonn * Revision 5.2 85/08/10 05:06:30 donn
2162df89bcSdonn * Deleted intcon[] and realcon[], since they are now made redundant by
2262df89bcSdonn * changes in intr.c. From Jerry Berkman.
2362df89bcSdonn *
2462df89bcSdonn * Revision 5.1 85/08/10 03:50:38 donn
2562df89bcSdonn * 4.3 alpha
2662df89bcSdonn *
279cb9da1cSmckusick * Revision 3.1 85/02/27 19:14:58 donn
289cb9da1cSmckusick * Changed to use pcc.h instead of pccdefs.h.
299cb9da1cSmckusick *
309cb9da1cSmckusick * Revision 2.3 85/02/22 01:09:22 donn
319cb9da1cSmckusick * memname() didn't know about intrinsic functions...
329cb9da1cSmckusick *
339cb9da1cSmckusick * Revision 2.2 85/02/12 17:56:44 donn
349cb9da1cSmckusick * Put the argument to the profiling routine in data space instead of
359cb9da1cSmckusick * constant space. From Jerry Berkman.
369cb9da1cSmckusick *
379cb9da1cSmckusick * Revision 2.1 84/07/19 12:05:08 donn
389cb9da1cSmckusick * Changed comment headers for UofU.
399cb9da1cSmckusick *
409cb9da1cSmckusick * Revision 1.2 84/02/26 06:41:04 donn
419cb9da1cSmckusick * Added Berkeley changes to move data around to produce shorter offsets.
429cb9da1cSmckusick *
439cb9da1cSmckusick */
449cb9da1cSmckusick
459cb9da1cSmckusick #include "defs.h"
469cb9da1cSmckusick
479cb9da1cSmckusick #ifdef SDB
489cb9da1cSmckusick # include <a.out.h>
499cb9da1cSmckusick extern int types2[];
509cb9da1cSmckusick # ifndef N_SO
519cb9da1cSmckusick # include <stab.h>
529cb9da1cSmckusick # endif
539cb9da1cSmckusick #endif
549cb9da1cSmckusick
559cb9da1cSmckusick #include <pcc.h>
569cb9da1cSmckusick
579cb9da1cSmckusick
589cb9da1cSmckusick
599cb9da1cSmckusick int maxregvar = MAXREGVAR;
609cb9da1cSmckusick int regnum[] = { 10, 9, 8, 7, 6 } ;
619cb9da1cSmckusick static int regmask[] = { 0x800, 0xc00, 0xe00, 0xf00, 0xf80, 0xfc0 };
629cb9da1cSmckusick
639cb9da1cSmckusick
649cb9da1cSmckusick /*
659cb9da1cSmckusick * The VAX assembler has a serious and not easily fixable problem
669cb9da1cSmckusick * with generating instructions that contain expressions of the form
679cb9da1cSmckusick * label1-label2 where there are .align's in-between the labels.
689cb9da1cSmckusick * Therefore, the compiler must keep track of the offsets and output
699cb9da1cSmckusick * .space where needed.
709cb9da1cSmckusick */
719cb9da1cSmckusick LOCAL int i_offset; /* initfile offset */
729cb9da1cSmckusick LOCAL int a_offset; /* asmfile offset */
739cb9da1cSmckusick
749cb9da1cSmckusick
759cb9da1cSmckusick
prsave(proflab)769cb9da1cSmckusick prsave(proflab)
779cb9da1cSmckusick int proflab;
789cb9da1cSmckusick {
799cb9da1cSmckusick if(profileflag)
809cb9da1cSmckusick {
819cb9da1cSmckusick pruse(asmfile, USEINIT); /* This is not a constant */
829cb9da1cSmckusick fprintf(asmfile, "L%d:\t.space\t4\n", proflab);
839cb9da1cSmckusick pruse(asmfile, USECONST);
849cb9da1cSmckusick p2pi("\tmovab\tL%d,r0", proflab);
859cb9da1cSmckusick p2pass("\tjsb\tmcount");
869cb9da1cSmckusick }
879cb9da1cSmckusick p2pi("\tsubl2\t$LF%d,sp", procno);
889cb9da1cSmckusick }
899cb9da1cSmckusick
909cb9da1cSmckusick
919cb9da1cSmckusick
goret(type)929cb9da1cSmckusick goret(type)
939cb9da1cSmckusick int type;
949cb9da1cSmckusick {
959cb9da1cSmckusick p2pass("\tret");
969cb9da1cSmckusick }
979cb9da1cSmckusick
989cb9da1cSmckusick
999cb9da1cSmckusick
1009cb9da1cSmckusick
1019cb9da1cSmckusick /*
1029cb9da1cSmckusick * move argument slot arg1 (relative to ap)
1039cb9da1cSmckusick * to slot arg2 (relative to ARGREG)
1049cb9da1cSmckusick */
1059cb9da1cSmckusick
mvarg(type,arg1,arg2)1069cb9da1cSmckusick mvarg(type, arg1, arg2)
1079cb9da1cSmckusick int type, arg1, arg2;
1089cb9da1cSmckusick {
1099cb9da1cSmckusick p2pij("\tmovl\t%d(ap),%d(fp)", arg1+ARGOFFSET, arg2+argloc);
1109cb9da1cSmckusick }
1119cb9da1cSmckusick
1129cb9da1cSmckusick
1139cb9da1cSmckusick
1149cb9da1cSmckusick
prlabel(fp,k)1159cb9da1cSmckusick prlabel(fp, k)
1169cb9da1cSmckusick FILEP fp;
1179cb9da1cSmckusick int k;
1189cb9da1cSmckusick {
1199cb9da1cSmckusick fprintf(fp, "L%d:\n", k);
1209cb9da1cSmckusick }
1219cb9da1cSmckusick
1229cb9da1cSmckusick
1239cb9da1cSmckusick
prconi(fp,type,n)1249cb9da1cSmckusick prconi(fp, type, n)
1259cb9da1cSmckusick FILEP fp;
1269cb9da1cSmckusick int type;
1279cb9da1cSmckusick ftnint n;
1289cb9da1cSmckusick {
1299cb9da1cSmckusick register int i;
1309cb9da1cSmckusick
1319cb9da1cSmckusick if(type == TYSHORT)
1329cb9da1cSmckusick {
1339cb9da1cSmckusick fprintf(fp, "\t.word\t%ld\n", n);
1349cb9da1cSmckusick i = SZSHORT;
1359cb9da1cSmckusick }
1369cb9da1cSmckusick else
1379cb9da1cSmckusick {
1389cb9da1cSmckusick fprintf(fp, "\t.long\t%ld\n", n);
1399cb9da1cSmckusick i = SZLONG;
1409cb9da1cSmckusick }
1419cb9da1cSmckusick if(fp == initfile)
1429cb9da1cSmckusick i_offset += i;
1439cb9da1cSmckusick else
1449cb9da1cSmckusick a_offset += i;
1459cb9da1cSmckusick }
1469cb9da1cSmckusick
1479cb9da1cSmckusick
1489cb9da1cSmckusick
prcona(fp,a)1499cb9da1cSmckusick prcona(fp, a)
1509cb9da1cSmckusick FILEP fp;
1519cb9da1cSmckusick ftnint a;
1529cb9da1cSmckusick {
1539cb9da1cSmckusick fprintf(fp, "\t.long\tL%ld\n", a);
1549cb9da1cSmckusick if(fp == initfile)
1559cb9da1cSmckusick i_offset += SZLONG;
1569cb9da1cSmckusick else
1579cb9da1cSmckusick a_offset += SZLONG;
1589cb9da1cSmckusick }
1599cb9da1cSmckusick
1609cb9da1cSmckusick
1619cb9da1cSmckusick
1629cb9da1cSmckusick #ifndef vax
prconr(fp,type,x)1639cb9da1cSmckusick prconr(fp, type, x)
1649cb9da1cSmckusick FILEP fp;
1659cb9da1cSmckusick int type;
1669cb9da1cSmckusick float x;
1679cb9da1cSmckusick {
1689cb9da1cSmckusick fprintf(fp, "\t%s\t0f%e\n", (type==TYREAL ? ".float" : ".double"), x);
1699cb9da1cSmckusick }
1709cb9da1cSmckusick #endif
1719cb9da1cSmckusick
1729cb9da1cSmckusick #ifdef vax
prconr(fp,type,x)1739cb9da1cSmckusick prconr(fp, type, x)
1749cb9da1cSmckusick FILEP fp;
1759cb9da1cSmckusick int type;
1769cb9da1cSmckusick double x;
1779cb9da1cSmckusick {
1789cb9da1cSmckusick /* non-portable cheat to preserve bit patterns */
1799cb9da1cSmckusick union { double xd; long int xl[2]; } cheat;
1809cb9da1cSmckusick register int i;
1819cb9da1cSmckusick
1829cb9da1cSmckusick cheat.xd = x;
1839cb9da1cSmckusick if(type == TYREAL)
1849cb9da1cSmckusick {
1859cb9da1cSmckusick float y = x;
1869cb9da1cSmckusick
1879cb9da1cSmckusick fprintf(fp, "\t.long\t0x%X\n", *(long *) &y);
1889cb9da1cSmckusick i = SZFLOAT;
1899cb9da1cSmckusick }
1909cb9da1cSmckusick else
1919cb9da1cSmckusick {
1929cb9da1cSmckusick fprintf(fp, "\t.long\t0x%X,0x%X\n", cheat.xl[0], cheat.xl[1]);
1939cb9da1cSmckusick i = SZDOUBLE;
1949cb9da1cSmckusick }
1959cb9da1cSmckusick if(fp == initfile)
1969cb9da1cSmckusick i_offset += i;
1979cb9da1cSmckusick else
1989cb9da1cSmckusick a_offset += i;
1999cb9da1cSmckusick }
2009cb9da1cSmckusick #endif
2019cb9da1cSmckusick
2029cb9da1cSmckusick
2039cb9da1cSmckusick
praddr(fp,stg,varno,offset)2049cb9da1cSmckusick praddr(fp, stg, varno, offset)
2059cb9da1cSmckusick FILE *fp;
2069cb9da1cSmckusick int stg, varno;
2079cb9da1cSmckusick ftnint offset;
2089cb9da1cSmckusick {
2099cb9da1cSmckusick char *memname();
2109cb9da1cSmckusick
2119cb9da1cSmckusick if(stg == STGNULL)
2129cb9da1cSmckusick fprintf(fp, "\t.long\t0\n");
2139cb9da1cSmckusick else
2149cb9da1cSmckusick {
2159cb9da1cSmckusick fprintf(fp, "\t.long\t%s", memname(stg,varno));
2169cb9da1cSmckusick if(offset)
2179cb9da1cSmckusick fprintf(fp, "+%ld", offset);
2189cb9da1cSmckusick fprintf(fp, "\n");
2199cb9da1cSmckusick }
2209cb9da1cSmckusick if(fp == initfile)
2219cb9da1cSmckusick i_offset += SZADDR;
2229cb9da1cSmckusick else
2239cb9da1cSmckusick a_offset += SZADDR;
2249cb9da1cSmckusick }
2259cb9da1cSmckusick
2269cb9da1cSmckusick
pralign(k)2279cb9da1cSmckusick pralign(k)
2289cb9da1cSmckusick int k;
2299cb9da1cSmckusick {
2309cb9da1cSmckusick register int lg = 0;
2319cb9da1cSmckusick
2329cb9da1cSmckusick if(k > 4)
2339cb9da1cSmckusick {
2349cb9da1cSmckusick if(i_offset & 7)
2359cb9da1cSmckusick lg = 8 - (i_offset & 7);
2369cb9da1cSmckusick }
2379cb9da1cSmckusick else if(k > 2)
2389cb9da1cSmckusick {
2399cb9da1cSmckusick if(i_offset & 3)
2409cb9da1cSmckusick lg = 4 - (i_offset & 3);
2419cb9da1cSmckusick }
2429cb9da1cSmckusick else if(k > 1)
2439cb9da1cSmckusick {
2449cb9da1cSmckusick if(i_offset & 1)
2459cb9da1cSmckusick lg = 1;
2469cb9da1cSmckusick }
2479cb9da1cSmckusick else
2489cb9da1cSmckusick return;
2499cb9da1cSmckusick if(lg > 0)
2509cb9da1cSmckusick {
2519cb9da1cSmckusick fprintf(initfile, "\t.space\t%d\n", lg);
2529cb9da1cSmckusick i_offset += lg;
2539cb9da1cSmckusick }
2549cb9da1cSmckusick }
2559cb9da1cSmckusick
2569cb9da1cSmckusick
2579cb9da1cSmckusick
prspace(n)2589cb9da1cSmckusick prspace(n)
2599cb9da1cSmckusick int n;
2609cb9da1cSmckusick {
2619cb9da1cSmckusick
2629cb9da1cSmckusick fprintf(initfile, "\t.space\t%d\n", n);
2639cb9da1cSmckusick i_offset += n;
2649cb9da1cSmckusick }
2659cb9da1cSmckusick
2669cb9da1cSmckusick
preven(k)2679cb9da1cSmckusick preven(k)
2689cb9da1cSmckusick int k;
2699cb9da1cSmckusick {
2709cb9da1cSmckusick register int lg = 0;
2719cb9da1cSmckusick
2729cb9da1cSmckusick if(k > 4)
2739cb9da1cSmckusick {
2749cb9da1cSmckusick if(a_offset & 7)
2759cb9da1cSmckusick lg = 8 - (a_offset & 7);
2769cb9da1cSmckusick }
2779cb9da1cSmckusick else if(k > 2)
2789cb9da1cSmckusick {
2799cb9da1cSmckusick if(a_offset & 3)
2809cb9da1cSmckusick lg = 4 - (a_offset & 3);
2819cb9da1cSmckusick }
2829cb9da1cSmckusick else if(k > 1)
2839cb9da1cSmckusick {
2849cb9da1cSmckusick if(a_offset & 1)
2859cb9da1cSmckusick lg = 1;
2869cb9da1cSmckusick }
2879cb9da1cSmckusick else
2889cb9da1cSmckusick return;
2899cb9da1cSmckusick if(lg > 0)
2909cb9da1cSmckusick {
2919cb9da1cSmckusick fprintf(asmfile, "\t.space\t%d\n", lg);
2929cb9da1cSmckusick a_offset += lg;
2939cb9da1cSmckusick }
2949cb9da1cSmckusick }
2959cb9da1cSmckusick
2969cb9da1cSmckusick
2979cb9da1cSmckusick
praspace(n)2989cb9da1cSmckusick praspace(n)
2999cb9da1cSmckusick int n;
3009cb9da1cSmckusick {
3019cb9da1cSmckusick
3029cb9da1cSmckusick fprintf(asmfile, "\t.space\t%d\n", n);
3039cb9da1cSmckusick a_offset += n;
3049cb9da1cSmckusick }
3059cb9da1cSmckusick
3069cb9da1cSmckusick
3079cb9da1cSmckusick
vaxgoto(index,nlab,labs)3089cb9da1cSmckusick vaxgoto(index, nlab, labs)
3099cb9da1cSmckusick expptr index;
3109cb9da1cSmckusick register int nlab;
3119cb9da1cSmckusick struct Labelblock *labs[];
3129cb9da1cSmckusick {
3139cb9da1cSmckusick register int i;
3149cb9da1cSmckusick register int arrlab;
3159cb9da1cSmckusick
3169cb9da1cSmckusick putforce(TYINT, index);
3179cb9da1cSmckusick p2pi("\tcasel\tr0,$1,$%d", nlab-1);
3189cb9da1cSmckusick p2pi("L%d:", arrlab = newlabel() );
3199cb9da1cSmckusick for(i = 0; i< nlab ; ++i)
3209cb9da1cSmckusick if( labs[i] )
3219cb9da1cSmckusick p2pij("\t.word\tL%d-L%d", labs[i]->labelno, arrlab);
3229cb9da1cSmckusick }
3239cb9da1cSmckusick
3249cb9da1cSmckusick
prarif(p,neg,zer,pos)3259cb9da1cSmckusick prarif(p, neg, zer, pos)
3269cb9da1cSmckusick expptr p;
3279cb9da1cSmckusick int neg, zer, pos;
3289cb9da1cSmckusick {
3299cb9da1cSmckusick int type;
3309cb9da1cSmckusick
3319cb9da1cSmckusick type = p->headblock.vtype;
3329cb9da1cSmckusick putforce(type, p);
3339cb9da1cSmckusick if(type == TYLONG)
3349cb9da1cSmckusick p2pass("\ttstl\tr0");
3359cb9da1cSmckusick else if (type == TYSHORT)
3369cb9da1cSmckusick p2pass("\ttstw\tr0");
3379cb9da1cSmckusick else
3389cb9da1cSmckusick p2pass("\ttstd\tr0");
3399cb9da1cSmckusick p2pi("\tjlss\tL%d", neg);
3409cb9da1cSmckusick p2pi("\tjeql\tL%d", zer);
3419cb9da1cSmckusick p2pi("\tjbr\tL%d", pos);
3429cb9da1cSmckusick }
3439cb9da1cSmckusick
3449cb9da1cSmckusick
3459cb9da1cSmckusick
3469cb9da1cSmckusick
memname(stg,mem)3479cb9da1cSmckusick char *memname(stg, mem)
3489cb9da1cSmckusick int stg, mem;
3499cb9da1cSmckusick {
3509cb9da1cSmckusick static char s[20];
3519cb9da1cSmckusick
3529cb9da1cSmckusick switch(stg)
3539cb9da1cSmckusick {
3549cb9da1cSmckusick case STGCOMMON:
3559cb9da1cSmckusick case STGEXT:
3569cb9da1cSmckusick case STGINTR:
3579cb9da1cSmckusick sprintf(s, "_%s", varstr(XL, extsymtab[mem].extname) );
3589cb9da1cSmckusick break;
3599cb9da1cSmckusick
3609cb9da1cSmckusick case STGBSS:
3619cb9da1cSmckusick case STGINIT:
3629cb9da1cSmckusick sprintf(s, "v.%d", mem);
3639cb9da1cSmckusick break;
3649cb9da1cSmckusick
3659cb9da1cSmckusick case STGCONST:
3669cb9da1cSmckusick sprintf(s, "L%d", mem);
3679cb9da1cSmckusick break;
3689cb9da1cSmckusick
3699cb9da1cSmckusick case STGEQUIV:
3709cb9da1cSmckusick sprintf(s, "q.%d", mem+eqvstart);
3719cb9da1cSmckusick break;
3729cb9da1cSmckusick
3739cb9da1cSmckusick default:
3749cb9da1cSmckusick badstg("memname", stg);
3759cb9da1cSmckusick }
3769cb9da1cSmckusick return(s);
3779cb9da1cSmckusick }
3789cb9da1cSmckusick
3799cb9da1cSmckusick
3809cb9da1cSmckusick
3819cb9da1cSmckusick
prlocvar(s,len)3829cb9da1cSmckusick prlocvar(s, len)
3839cb9da1cSmckusick char *s;
3849cb9da1cSmckusick ftnint len;
3859cb9da1cSmckusick {
3869cb9da1cSmckusick fprintf(asmfile, "\t.lcomm\t%s,%ld\n", s, len);
3879cb9da1cSmckusick }
3889cb9da1cSmckusick
3899cb9da1cSmckusick
3909cb9da1cSmckusick
3919cb9da1cSmckusick
3929cb9da1cSmckusick char *
packbytes(cp)3939cb9da1cSmckusick packbytes(cp)
3949cb9da1cSmckusick register Constp cp;
3959cb9da1cSmckusick {
3969cb9da1cSmckusick static char shrt[2];
3979cb9da1cSmckusick static char lng[4];
3989cb9da1cSmckusick static char quad[8];
3999cb9da1cSmckusick static char oct[16];
4009cb9da1cSmckusick
4019cb9da1cSmckusick register int type;
4029cb9da1cSmckusick register int *ip, *jp;
4039cb9da1cSmckusick
4049cb9da1cSmckusick switch (cp->vtype)
4059cb9da1cSmckusick {
4069cb9da1cSmckusick case TYSHORT:
4079e02124eSbostic *((short *) shrt) = (short) cp->constant.ci;
4089cb9da1cSmckusick return (shrt);
4099cb9da1cSmckusick
4109cb9da1cSmckusick case TYLONG:
4119cb9da1cSmckusick case TYLOGICAL:
4129cb9da1cSmckusick case TYREAL:
4139e02124eSbostic *((int *) lng) = cp->constant.ci;
4149cb9da1cSmckusick return (lng);
4159cb9da1cSmckusick
4169cb9da1cSmckusick case TYDREAL:
4179cb9da1cSmckusick ip = (int *) quad;
4189e02124eSbostic jp = (int *) &(cp->constant.cd[0]);
4199cb9da1cSmckusick ip[0] = jp[0];
4209cb9da1cSmckusick ip[1] = jp[1];
4219cb9da1cSmckusick return (quad);
4229cb9da1cSmckusick
4239cb9da1cSmckusick case TYCOMPLEX:
4249cb9da1cSmckusick ip = (int *) quad;
4259e02124eSbostic jp = (int *) &(cp->constant.cd[0]);
4269cb9da1cSmckusick ip[0] = jp[0];
4279cb9da1cSmckusick ip[1] = jp[2];
4289cb9da1cSmckusick return (quad);
4299cb9da1cSmckusick
4309cb9da1cSmckusick case TYDCOMPLEX:
4319cb9da1cSmckusick ip = (int *) oct;
4329e02124eSbostic jp = (int *) &(cp->constant.cd[0]);
4339cb9da1cSmckusick *ip++ = *jp++;
4349cb9da1cSmckusick *ip++ = *jp++;
4359cb9da1cSmckusick *ip++ = *jp++;
4369cb9da1cSmckusick *ip = *jp;
4379cb9da1cSmckusick return (oct);
4389cb9da1cSmckusick
4399cb9da1cSmckusick default:
4409cb9da1cSmckusick badtype("packbytes", cp->vtype);
4419cb9da1cSmckusick }
4429cb9da1cSmckusick }
4439cb9da1cSmckusick
4449cb9da1cSmckusick
4459cb9da1cSmckusick
4469cb9da1cSmckusick
prsdata(s,len)4479cb9da1cSmckusick prsdata(s, len)
4489cb9da1cSmckusick register char *s;
4499cb9da1cSmckusick register int len;
4509cb9da1cSmckusick {
4519cb9da1cSmckusick static char *longfmt = "\t.long\t0x%x\n";
4529cb9da1cSmckusick static char *wordfmt = "\t.word\t0x%x\n";
4539cb9da1cSmckusick static char *bytefmt = "\t.byte\t0x%x\n";
4549cb9da1cSmckusick
4559cb9da1cSmckusick register int i;
4569cb9da1cSmckusick
4579cb9da1cSmckusick i = 0;
4589cb9da1cSmckusick if ((len - i) >= 4)
4599cb9da1cSmckusick {
4609cb9da1cSmckusick fprintf(initfile, longfmt, *((int *) s));
4619cb9da1cSmckusick i += 4;
4629cb9da1cSmckusick }
4639cb9da1cSmckusick if ((len - i) >= 2)
4649cb9da1cSmckusick {
4659cb9da1cSmckusick fprintf(initfile, wordfmt, 0xffff & (*((short *) (s + i))));
4669cb9da1cSmckusick i += 2;
4679cb9da1cSmckusick }
4689cb9da1cSmckusick if ((len - i) > 0)
4699cb9da1cSmckusick fprintf(initfile,bytefmt, 0xff & s[i]);
4709cb9da1cSmckusick
4719cb9da1cSmckusick i_offset += len;
4729cb9da1cSmckusick return;
4739cb9da1cSmckusick }
4749cb9da1cSmckusick
4759cb9da1cSmckusick
4769cb9da1cSmckusick
prquad(s)4779cb9da1cSmckusick prquad(s)
4789cb9da1cSmckusick char *s;
4799cb9da1cSmckusick {
4809cb9da1cSmckusick static char *quadfmt1 = "\t.quad\t0x%x\n";
4819cb9da1cSmckusick static char *quadfmt2 = "\t.quad\t0x%x%08x\n";
4829cb9da1cSmckusick
4839cb9da1cSmckusick if ( *((int *) (s + 4)) == 0 )
4849cb9da1cSmckusick fprintf(initfile, quadfmt1, *((int *) s));
4859cb9da1cSmckusick else
4869cb9da1cSmckusick fprintf(initfile, quadfmt2, *((int *) (s + 4)), *((int *) s));
4879cb9da1cSmckusick
4889cb9da1cSmckusick i_offset += 8;
4899cb9da1cSmckusick return;
4909cb9da1cSmckusick }
4919cb9da1cSmckusick
4929cb9da1cSmckusick
4939cb9da1cSmckusick
4949cb9da1cSmckusick #ifdef NOTDEF
4959cb9da1cSmckusick
4969cb9da1cSmckusick /* The code for generating .fill directives has been */
4979cb9da1cSmckusick /* ifdefed out because of bugs in the UCB VAX assembler. */
4989cb9da1cSmckusick /* If those bugs are ever fixed (and it seems unlikely), */
4999cb9da1cSmckusick /* the NOTDEF's should be replaced by UCBVAXASM. */
5009cb9da1cSmckusick
5019cb9da1cSmckusick
prfill(n,s)5029cb9da1cSmckusick prfill(n, s)
5039cb9da1cSmckusick int n;
5049cb9da1cSmckusick register char *s;
5059cb9da1cSmckusick {
5069cb9da1cSmckusick static char *fillfmt1 = "\t.fill\t%d,8,0x%x\n";
5079cb9da1cSmckusick static char *fillfmt2 = "\t.fill\t%d,8,0x%x%08x\n";
5089cb9da1cSmckusick
5099cb9da1cSmckusick if (*((int *) (s + 4)) == 0)
5109cb9da1cSmckusick fprintf(initfile, fillfmt1, n, *((int *) s));
5119cb9da1cSmckusick else
5129cb9da1cSmckusick fprintf(initfile, fillfmt2, n, *((int *) (s + 4)), *((int *) s));
5139cb9da1cSmckusick
5149cb9da1cSmckusick return;
5159cb9da1cSmckusick }
5169cb9da1cSmckusick
5179cb9da1cSmckusick #endif
5189cb9da1cSmckusick
5199cb9da1cSmckusick
5209cb9da1cSmckusick
prext(ep)5219cb9da1cSmckusick prext(ep)
5229cb9da1cSmckusick register struct Extsym *ep;
5239cb9da1cSmckusick {
5249cb9da1cSmckusick static char *globlfmt = "\t.globl\t_%s\n";
5259cb9da1cSmckusick static char *commfmt = "\t.comm\t_%s,%ld\n";
5269cb9da1cSmckusick static char *labelfmt = "_%s:\n";
5279cb9da1cSmckusick
5289cb9da1cSmckusick static char *seekerror = "seek error on tmp file";
5299cb9da1cSmckusick static char *readerror = "read error on tmp file";
5309cb9da1cSmckusick
5319cb9da1cSmckusick char *tag;
5329cb9da1cSmckusick register int leng;
5339cb9da1cSmckusick long pos;
5349cb9da1cSmckusick register int i;
5359cb9da1cSmckusick char oldvalue[8];
5369cb9da1cSmckusick char newvalue[8];
5379cb9da1cSmckusick register int n;
5389cb9da1cSmckusick register int repl;
5399cb9da1cSmckusick
5409cb9da1cSmckusick tag = varstr(XL, ep->extname);
5419cb9da1cSmckusick leng = ep->maxleng;
5429cb9da1cSmckusick
5439cb9da1cSmckusick if (leng == 0)
5449cb9da1cSmckusick {
5459cb9da1cSmckusick fprintf(asmfile, globlfmt, tag);
5469cb9da1cSmckusick return;
5479cb9da1cSmckusick }
5489cb9da1cSmckusick
5499cb9da1cSmckusick if (ep->init == NO)
5509cb9da1cSmckusick {
5519cb9da1cSmckusick fprintf(asmfile, commfmt, tag, leng);
5529cb9da1cSmckusick return;
5539cb9da1cSmckusick }
5549cb9da1cSmckusick
5559cb9da1cSmckusick fprintf(asmfile, globlfmt, tag);
5569cb9da1cSmckusick pralign(ALIDOUBLE);
5579cb9da1cSmckusick fprintf(initfile, labelfmt, tag);
5589cb9da1cSmckusick
5599cb9da1cSmckusick pos = lseek(cdatafile, ep->initoffset, 0);
5609cb9da1cSmckusick if (pos == -1)
5619cb9da1cSmckusick {
5629cb9da1cSmckusick err(seekerror);
5639cb9da1cSmckusick done(1);
5649cb9da1cSmckusick }
5659cb9da1cSmckusick
5669cb9da1cSmckusick *((int *) oldvalue) = 0;
5679cb9da1cSmckusick *((int *) (oldvalue + 4)) = 0;
5689cb9da1cSmckusick n = read(cdatafile, oldvalue, 8);
5699cb9da1cSmckusick if (n < 0)
5709cb9da1cSmckusick {
5719cb9da1cSmckusick err(readerror);
5729cb9da1cSmckusick done(1);
5739cb9da1cSmckusick }
5749cb9da1cSmckusick
5759cb9da1cSmckusick if (leng <= 8)
5769cb9da1cSmckusick {
5779cb9da1cSmckusick i = leng;
5789cb9da1cSmckusick while (i > 0 && oldvalue[--i] == '\0') /* SKIP */;
5799cb9da1cSmckusick if (oldvalue[i] == '\0')
5809cb9da1cSmckusick prspace(leng);
5819cb9da1cSmckusick else if (leng == 8)
5829cb9da1cSmckusick prquad(oldvalue);
5839cb9da1cSmckusick else
5849cb9da1cSmckusick prsdata(oldvalue, leng);
5859cb9da1cSmckusick
5869cb9da1cSmckusick return;
5879cb9da1cSmckusick }
5889cb9da1cSmckusick
5899cb9da1cSmckusick repl = 1;
5909cb9da1cSmckusick leng -= 8;
5919cb9da1cSmckusick
5929cb9da1cSmckusick while (leng >= 8)
5939cb9da1cSmckusick {
5949cb9da1cSmckusick *((int *) newvalue) = 0;
5959cb9da1cSmckusick *((int *) (newvalue + 4)) = 0;
5969cb9da1cSmckusick
5979cb9da1cSmckusick n = read(cdatafile, newvalue, 8);
5989cb9da1cSmckusick if (n < 0)
5999cb9da1cSmckusick {
6009cb9da1cSmckusick err(readerror);
6019cb9da1cSmckusick done(1);
6029cb9da1cSmckusick }
6039cb9da1cSmckusick
6049cb9da1cSmckusick leng -= 8;
6059cb9da1cSmckusick
6069cb9da1cSmckusick if (*((int *) oldvalue) == *((int *) newvalue)
6079cb9da1cSmckusick && *((int *) (oldvalue + 4)) == *((int *) (newvalue + 4)))
6089cb9da1cSmckusick repl++;
6099cb9da1cSmckusick else
6109cb9da1cSmckusick {
6119cb9da1cSmckusick if (*((int *) oldvalue) == 0
6129cb9da1cSmckusick && *((int *) (oldvalue + 4)) == 0)
6139cb9da1cSmckusick prspace(8*repl);
6149cb9da1cSmckusick else if (repl == 1)
6159cb9da1cSmckusick prquad(oldvalue);
6169cb9da1cSmckusick else
6179cb9da1cSmckusick #ifdef NOTDEF
6189cb9da1cSmckusick prfill(repl, oldvalue);
6199cb9da1cSmckusick #else
6209cb9da1cSmckusick {
6219cb9da1cSmckusick while (repl-- > 0)
6229cb9da1cSmckusick prquad(oldvalue);
6239cb9da1cSmckusick }
6249cb9da1cSmckusick #endif
6259cb9da1cSmckusick *((int *) oldvalue) = *((int *) newvalue);
6269cb9da1cSmckusick *((int *) (oldvalue + 4)) = *((int *) (newvalue + 4));
6279cb9da1cSmckusick repl = 1;
6289cb9da1cSmckusick }
6299cb9da1cSmckusick }
6309cb9da1cSmckusick
6319cb9da1cSmckusick *((int *) newvalue) = 0;
6329cb9da1cSmckusick *((int *) (newvalue + 4)) = 0;
6339cb9da1cSmckusick
6349cb9da1cSmckusick if (leng > 0)
6359cb9da1cSmckusick {
6369cb9da1cSmckusick n = read(cdatafile, newvalue, leng);
6379cb9da1cSmckusick if (n < 0)
6389cb9da1cSmckusick {
6399cb9da1cSmckusick err(readerror);
6409cb9da1cSmckusick done(1);
6419cb9da1cSmckusick }
6429cb9da1cSmckusick }
6439cb9da1cSmckusick
6449cb9da1cSmckusick if (*((int *) (oldvalue + 4)) == 0
6459cb9da1cSmckusick && *((int *) oldvalue) == 0
6469cb9da1cSmckusick && *((int *) (newvalue + 4)) == 0
6479cb9da1cSmckusick && *((int *) newvalue) == 0)
6489cb9da1cSmckusick {
6499cb9da1cSmckusick prspace(8*repl + leng);
6509cb9da1cSmckusick return;
6519cb9da1cSmckusick }
6529cb9da1cSmckusick
6539cb9da1cSmckusick if (*((int *) (oldvalue + 4)) == 0
6549cb9da1cSmckusick && *((int *) oldvalue) == 0)
6559cb9da1cSmckusick prspace(8*repl);
6569cb9da1cSmckusick else if (repl == 1)
6579cb9da1cSmckusick prquad(oldvalue);
6589cb9da1cSmckusick else
6599cb9da1cSmckusick #ifdef NOTDEF
6609cb9da1cSmckusick prfill(repl, oldvalue);
6619cb9da1cSmckusick #else
6629cb9da1cSmckusick {
6639cb9da1cSmckusick while (repl-- > 0)
6649cb9da1cSmckusick prquad(oldvalue);
6659cb9da1cSmckusick }
6669cb9da1cSmckusick #endif
6679cb9da1cSmckusick
6689cb9da1cSmckusick prsdata(newvalue, leng);
6699cb9da1cSmckusick
6709cb9da1cSmckusick return;
6719cb9da1cSmckusick }
6729cb9da1cSmckusick
6739cb9da1cSmckusick
6749cb9da1cSmckusick
prlocdata(sname,leng,type,initoffset,inlcomm)6759cb9da1cSmckusick prlocdata(sname, leng, type, initoffset, inlcomm)
6769cb9da1cSmckusick char *sname;
6779cb9da1cSmckusick ftnint leng;
6789cb9da1cSmckusick int type;
6799cb9da1cSmckusick long initoffset;
6809cb9da1cSmckusick char *inlcomm;
6819cb9da1cSmckusick {
6829cb9da1cSmckusick static char *seekerror = "seek error on tmp file";
6839cb9da1cSmckusick static char *readerror = "read error on tmp file";
6849cb9da1cSmckusick
6859cb9da1cSmckusick static char *labelfmt = "%s:\n";
6869cb9da1cSmckusick
6879cb9da1cSmckusick register int k;
6889cb9da1cSmckusick register int i;
6899cb9da1cSmckusick register int repl;
6909cb9da1cSmckusick register int first;
6919cb9da1cSmckusick register long pos;
6929cb9da1cSmckusick register long n;
6939cb9da1cSmckusick char oldvalue[8];
6949cb9da1cSmckusick char newvalue[8];
6959cb9da1cSmckusick
6969cb9da1cSmckusick *inlcomm = NO;
6979cb9da1cSmckusick
6989cb9da1cSmckusick k = leng;
6999cb9da1cSmckusick first = YES;
7009cb9da1cSmckusick
7019cb9da1cSmckusick pos = lseek(vdatafile, initoffset, 0);
7029cb9da1cSmckusick if (pos == -1)
7039cb9da1cSmckusick {
7049cb9da1cSmckusick err(seekerror);
7059cb9da1cSmckusick done(1);
7069cb9da1cSmckusick }
7079cb9da1cSmckusick
7089cb9da1cSmckusick *((int *) oldvalue) = 0;
7099cb9da1cSmckusick *((int *) (oldvalue + 4)) = 0;
7109cb9da1cSmckusick n = read(vdatafile, oldvalue, 8);
7119cb9da1cSmckusick if (n < 0)
7129cb9da1cSmckusick {
7139cb9da1cSmckusick err(readerror);
7149cb9da1cSmckusick done(1);
7159cb9da1cSmckusick }
7169cb9da1cSmckusick
7179cb9da1cSmckusick if (k <= 8)
7189cb9da1cSmckusick {
7199cb9da1cSmckusick i = k;
7209cb9da1cSmckusick while (i > 0 && oldvalue[--i] == '\0')
7219cb9da1cSmckusick /* SKIP */ ;
7229cb9da1cSmckusick if (oldvalue[i] == '\0')
7239cb9da1cSmckusick {
7249cb9da1cSmckusick if (SMALLVAR(leng))
7259cb9da1cSmckusick {
7269cb9da1cSmckusick pralign(typealign[type]);
7279cb9da1cSmckusick fprintf(initfile, labelfmt, sname);
7289cb9da1cSmckusick prspace(leng);
7299cb9da1cSmckusick }
7309cb9da1cSmckusick else
7319cb9da1cSmckusick {
7329cb9da1cSmckusick preven(ALIDOUBLE);
7339cb9da1cSmckusick prlocvar(sname, leng);
7349cb9da1cSmckusick *inlcomm = YES;
7359cb9da1cSmckusick }
7369cb9da1cSmckusick }
7379cb9da1cSmckusick else
7389cb9da1cSmckusick {
7399cb9da1cSmckusick fprintf(initfile, labelfmt, sname);
7409cb9da1cSmckusick if (leng == 8)
7419cb9da1cSmckusick prquad(oldvalue);
7429cb9da1cSmckusick else
7439cb9da1cSmckusick prsdata(oldvalue, leng);
7449cb9da1cSmckusick }
7459cb9da1cSmckusick return;
7469cb9da1cSmckusick }
7479cb9da1cSmckusick
7489cb9da1cSmckusick repl = 1;
7499cb9da1cSmckusick k -= 8;
7509cb9da1cSmckusick
7519cb9da1cSmckusick while (k >=8)
7529cb9da1cSmckusick {
7539cb9da1cSmckusick *((int *) newvalue) = 0;
7549cb9da1cSmckusick *((int *) (newvalue + 4)) = 0;
7559cb9da1cSmckusick
7569cb9da1cSmckusick n = read(vdatafile, newvalue, 8);
7579cb9da1cSmckusick if (n < 0)
7589cb9da1cSmckusick {
7599cb9da1cSmckusick err(readerror);
7609cb9da1cSmckusick done(1);
7619cb9da1cSmckusick }
7629cb9da1cSmckusick
7639cb9da1cSmckusick k -= 8;
7649cb9da1cSmckusick
7659cb9da1cSmckusick if (*((int *) oldvalue) == *((int *) newvalue)
7669cb9da1cSmckusick && *((int *) (oldvalue + 4)) == *((int *) (newvalue + 4)))
7679cb9da1cSmckusick repl++;
7689cb9da1cSmckusick else
7699cb9da1cSmckusick {
7709cb9da1cSmckusick if (first == YES)
7719cb9da1cSmckusick {
7729cb9da1cSmckusick pralign(typealign[type]);
7739cb9da1cSmckusick fprintf(initfile, labelfmt, sname);
7749cb9da1cSmckusick first = NO;
7759cb9da1cSmckusick }
7769cb9da1cSmckusick
7779cb9da1cSmckusick if (*((int *) oldvalue) == 0
7789cb9da1cSmckusick && *((int *) (oldvalue + 4)) == 0)
7799cb9da1cSmckusick prspace(8*repl);
7809cb9da1cSmckusick else
7819cb9da1cSmckusick {
7829cb9da1cSmckusick while (repl-- > 0)
7839cb9da1cSmckusick prquad(oldvalue);
7849cb9da1cSmckusick }
7859cb9da1cSmckusick *((int *) oldvalue) = *((int *) newvalue);
7869cb9da1cSmckusick *((int *) (oldvalue + 4)) = *((int *) (newvalue + 4));
7879cb9da1cSmckusick repl = 1;
7889cb9da1cSmckusick }
7899cb9da1cSmckusick }
7909cb9da1cSmckusick
7919cb9da1cSmckusick *((int *) newvalue) = 0;
7929cb9da1cSmckusick *((int *) (newvalue + 4)) = 0;
7939cb9da1cSmckusick
7949cb9da1cSmckusick if (k > 0)
7959cb9da1cSmckusick {
7969cb9da1cSmckusick n = read(vdatafile, newvalue, k);
7979cb9da1cSmckusick if (n < 0)
7989cb9da1cSmckusick {
7999cb9da1cSmckusick err(readerror);
8009cb9da1cSmckusick done(1);
8019cb9da1cSmckusick }
8029cb9da1cSmckusick }
8039cb9da1cSmckusick
8049cb9da1cSmckusick if (*((int *) (oldvalue + 4)) == 0
8059cb9da1cSmckusick && *((int *) oldvalue) == 0
8069cb9da1cSmckusick && *((int *) (newvalue + 4)) == 0
8079cb9da1cSmckusick && *((int *) newvalue) == 0)
8089cb9da1cSmckusick {
8099cb9da1cSmckusick if (first == YES && !SMALLVAR(leng))
8109cb9da1cSmckusick {
8119cb9da1cSmckusick prlocvar(sname, leng);
8129cb9da1cSmckusick *inlcomm = YES;
8139cb9da1cSmckusick }
8149cb9da1cSmckusick else
8159cb9da1cSmckusick {
8169cb9da1cSmckusick if (first == YES)
8179cb9da1cSmckusick {
8189cb9da1cSmckusick pralign(typealign[type]);
8199cb9da1cSmckusick fprintf(initfile, labelfmt, sname);
8209cb9da1cSmckusick }
8219cb9da1cSmckusick prspace(8*repl + k);
8229cb9da1cSmckusick }
8239cb9da1cSmckusick return;
8249cb9da1cSmckusick }
8259cb9da1cSmckusick
8269cb9da1cSmckusick if (first == YES)
8279cb9da1cSmckusick {
8289cb9da1cSmckusick pralign(typealign[type]);
8299cb9da1cSmckusick fprintf(initfile, labelfmt, sname);
8309cb9da1cSmckusick }
8319cb9da1cSmckusick
8329cb9da1cSmckusick if (*((int *) (oldvalue + 4)) == 0
8339cb9da1cSmckusick && *((int *) oldvalue) == 0)
8349cb9da1cSmckusick prspace(8*repl);
8359cb9da1cSmckusick else
8369cb9da1cSmckusick {
8379cb9da1cSmckusick while (repl-- > 0)
8389cb9da1cSmckusick prquad(oldvalue);
8399cb9da1cSmckusick }
8409cb9da1cSmckusick
8419cb9da1cSmckusick prsdata(newvalue, k);
8429cb9da1cSmckusick
8439cb9da1cSmckusick return;
8449cb9da1cSmckusick }
8459cb9da1cSmckusick
8469cb9da1cSmckusick
8479cb9da1cSmckusick
8489cb9da1cSmckusick
prendproc()8499cb9da1cSmckusick prendproc()
8509cb9da1cSmckusick {
8519cb9da1cSmckusick }
8529cb9da1cSmckusick
8539cb9da1cSmckusick
8549cb9da1cSmckusick
8559cb9da1cSmckusick
prtail()8569cb9da1cSmckusick prtail()
8579cb9da1cSmckusick {
8589cb9da1cSmckusick }
8599cb9da1cSmckusick
8609cb9da1cSmckusick
8619cb9da1cSmckusick
8629cb9da1cSmckusick
8639cb9da1cSmckusick
8649cb9da1cSmckusick prolog(ep, argvec)
8659cb9da1cSmckusick struct Entrypoint *ep;
8669cb9da1cSmckusick Addrp argvec;
8679cb9da1cSmckusick {
8689cb9da1cSmckusick int i, argslot, proflab;
8699cb9da1cSmckusick int size;
8709cb9da1cSmckusick register chainp p;
8719cb9da1cSmckusick register Namep q;
8729cb9da1cSmckusick register struct Dimblock *dp;
8739cb9da1cSmckusick expptr tp;
8749cb9da1cSmckusick
8759cb9da1cSmckusick p2pass("\t.align\t1");
8769cb9da1cSmckusick
8779cb9da1cSmckusick
8789cb9da1cSmckusick if(procclass == CLMAIN) {
8799cb9da1cSmckusick if(fudgelabel)
8809cb9da1cSmckusick {
8819cb9da1cSmckusick if(ep->entryname) {
8829cb9da1cSmckusick p2ps("_%s:", varstr(XL, ep->entryname->extname));
8839cb9da1cSmckusick p2pi("\t.word\tLWM%d", procno);
8849cb9da1cSmckusick }
8859cb9da1cSmckusick putlabel(fudgelabel);
8869cb9da1cSmckusick fudgelabel = 0;
8879cb9da1cSmckusick fixlwm();
8889cb9da1cSmckusick }
8899cb9da1cSmckusick else
8909cb9da1cSmckusick {
8919cb9da1cSmckusick p2pass( "_MAIN_:" );
8929cb9da1cSmckusick if(ep->entryname == NULL)
8939cb9da1cSmckusick p2pi("\t.word\tLWM%d", procno);
8949cb9da1cSmckusick }
8959cb9da1cSmckusick
8969cb9da1cSmckusick } else if(ep->entryname)
8979cb9da1cSmckusick if(fudgelabel)
8989cb9da1cSmckusick {
8999cb9da1cSmckusick putlabel(fudgelabel);
9009cb9da1cSmckusick fudgelabel = 0;
9019cb9da1cSmckusick fixlwm();
9029cb9da1cSmckusick }
9039cb9da1cSmckusick else
9049cb9da1cSmckusick {
9059cb9da1cSmckusick p2ps("_%s:", varstr(XL, ep->entryname->extname));
9069cb9da1cSmckusick p2pi("\t.word\tLWM%d", procno);
9079cb9da1cSmckusick prsave(newlabel());
9089cb9da1cSmckusick }
9099cb9da1cSmckusick
9109cb9da1cSmckusick if(procclass == CLBLOCK)
9119cb9da1cSmckusick return;
9129cb9da1cSmckusick if (anylocals == YES)
9139cb9da1cSmckusick {
9149cb9da1cSmckusick char buff[30];
9159cb9da1cSmckusick sprintf(buff, "\tmovl\t$v.%d,r11", bsslabel);
9169cb9da1cSmckusick p2pass(buff);
9179cb9da1cSmckusick }
9189cb9da1cSmckusick if(argvec)
9199cb9da1cSmckusick {
9209cb9da1cSmckusick if (argvec->tag != TADDR) badtag ("prolog",argvec->tag);
9219e02124eSbostic argloc = argvec->memoffset->constblock.constant.ci + SZINT;
9229cb9da1cSmckusick /* first slot holds count */
9239cb9da1cSmckusick if(proctype == TYCHAR)
9249cb9da1cSmckusick {
9259cb9da1cSmckusick mvarg(TYADDR, 0, chslot);
9269cb9da1cSmckusick mvarg(TYLENG, SZADDR, chlgslot);
9279cb9da1cSmckusick argslot = SZADDR + SZLENG;
9289cb9da1cSmckusick }
9299cb9da1cSmckusick else if( ISCOMPLEX(proctype) )
9309cb9da1cSmckusick {
9319cb9da1cSmckusick mvarg(TYADDR, 0, cxslot);
9329cb9da1cSmckusick argslot = SZADDR;
9339cb9da1cSmckusick }
9349cb9da1cSmckusick else
9359cb9da1cSmckusick argslot = 0;
9369cb9da1cSmckusick
9379cb9da1cSmckusick for(p = ep->arglist ; p ; p =p->nextp)
9389cb9da1cSmckusick {
9399cb9da1cSmckusick q = (Namep) (p->datap);
9409cb9da1cSmckusick mvarg(TYADDR, argslot, q->vardesc.varno);
9419cb9da1cSmckusick argslot += SZADDR;
9429cb9da1cSmckusick }
9439cb9da1cSmckusick for(p = ep->arglist ; p ; p = p->nextp)
9449cb9da1cSmckusick {
9459cb9da1cSmckusick q = (Namep) (p->datap);
9469cb9da1cSmckusick if(q->vtype==TYCHAR && q->vclass!=CLPROC)
9479cb9da1cSmckusick {
9489cb9da1cSmckusick if(q->vleng && ! ISCONST(q->vleng) )
9499cb9da1cSmckusick mvarg(TYLENG, argslot,
9509cb9da1cSmckusick q->vleng->addrblock.memno);
9519cb9da1cSmckusick argslot += SZLENG;
9529cb9da1cSmckusick }
9539cb9da1cSmckusick }
9549cb9da1cSmckusick p2pi("\taddl3\t$%d,fp,ap", argloc-ARGOFFSET);
9559cb9da1cSmckusick p2pi("\tmovl\t$%d,(ap)\n", lastargslot/SZADDR);
9569cb9da1cSmckusick }
9579cb9da1cSmckusick
9589cb9da1cSmckusick for(p = ep->arglist ; p ; p = p->nextp)
9599cb9da1cSmckusick {
9609cb9da1cSmckusick q = (Namep) (p->datap);
9619cb9da1cSmckusick if(dp = q->vdim)
9629cb9da1cSmckusick {
9639cb9da1cSmckusick for(i = 0 ; i < dp->ndim ; ++i)
9649cb9da1cSmckusick if(dp->dims[i].dimexpr)
9659cb9da1cSmckusick puteq( fixtype(cpexpr(dp->dims[i].dimsize)),
9669cb9da1cSmckusick fixtype(cpexpr(dp->dims[i].dimexpr)));
9679cb9da1cSmckusick #ifdef SDB
9689cb9da1cSmckusick if(sdbflag) {
9699cb9da1cSmckusick for(i = 0 ; i < dp->ndim ; ++i) {
9709cb9da1cSmckusick if(dp->dims[i].lbaddr)
9719cb9da1cSmckusick puteq( fixtype(cpexpr(dp->dims[i].lbaddr)),
9729cb9da1cSmckusick fixtype(cpexpr(dp->dims[i].lb)));
9739cb9da1cSmckusick if(dp->dims[i].ubaddr)
9749cb9da1cSmckusick puteq( fixtype(cpexpr(dp->dims[i].ubaddr)),
9759cb9da1cSmckusick fixtype(cpexpr(dp->dims[i].ub)));
9769cb9da1cSmckusick
9779cb9da1cSmckusick }
9789cb9da1cSmckusick }
9799cb9da1cSmckusick #endif
9809cb9da1cSmckusick size = typesize[ q->vtype ];
9819cb9da1cSmckusick if(q->vtype == TYCHAR)
9829cb9da1cSmckusick if( ISICON(q->vleng) )
9839e02124eSbostic size *= q->vleng->constblock.constant.ci;
9849cb9da1cSmckusick else
9859cb9da1cSmckusick size = -1;
9869cb9da1cSmckusick
9879cb9da1cSmckusick /* on VAX, get more efficient subscripting if subscripts
9889cb9da1cSmckusick have zero-base, so fudge the argument pointers for arrays.
9899cb9da1cSmckusick Not done if array bounds are being checked.
9909cb9da1cSmckusick */
9919cb9da1cSmckusick if(dp->basexpr)
9929cb9da1cSmckusick puteq( cpexpr(fixtype(dp->baseoffset)),
9939cb9da1cSmckusick cpexpr(fixtype(dp->basexpr)));
9949cb9da1cSmckusick #ifdef SDB
9959cb9da1cSmckusick if( (! checksubs) && (! sdbflag) )
9969cb9da1cSmckusick #else
9979cb9da1cSmckusick if(! checksubs)
9989cb9da1cSmckusick #endif
9999cb9da1cSmckusick {
10009cb9da1cSmckusick if(dp->basexpr)
10019cb9da1cSmckusick {
10029cb9da1cSmckusick if(size > 0)
10039cb9da1cSmckusick tp = (expptr) ICON(size);
10049cb9da1cSmckusick else
10059cb9da1cSmckusick tp = (expptr) cpexpr(q->vleng);
10069cb9da1cSmckusick putforce(TYINT,
10079cb9da1cSmckusick fixtype( mkexpr(OPSTAR, tp,
10089cb9da1cSmckusick cpexpr(dp->baseoffset)) ));
10099cb9da1cSmckusick p2pi("\tsubl2\tr0,%d(ap)",
10109cb9da1cSmckusick p->datap->nameblock.vardesc.varno +
10119cb9da1cSmckusick ARGOFFSET);
10129cb9da1cSmckusick }
10139e02124eSbostic else if(dp->baseoffset->constblock.constant.ci != 0)
10149cb9da1cSmckusick {
10159cb9da1cSmckusick char buff[25];
10169cb9da1cSmckusick if(size > 0)
10179cb9da1cSmckusick {
10189cb9da1cSmckusick sprintf(buff, "\tsubl2\t$%ld,%d(ap)",
10199e02124eSbostic dp->baseoffset->constblock.constant.ci * size,
10209cb9da1cSmckusick p->datap->nameblock.vardesc.varno +
10219cb9da1cSmckusick ARGOFFSET);
10229cb9da1cSmckusick }
10239cb9da1cSmckusick else {
10249cb9da1cSmckusick putforce(TYINT, mkexpr(OPSTAR, cpexpr(dp->baseoffset),
10259cb9da1cSmckusick cpexpr(q->vleng) ));
10269cb9da1cSmckusick sprintf(buff, "\tsubl2\tr0,%d(ap)",
10279cb9da1cSmckusick p->datap->nameblock.vardesc.varno +
10289cb9da1cSmckusick ARGOFFSET);
10299cb9da1cSmckusick }
10309cb9da1cSmckusick p2pass(buff);
10319cb9da1cSmckusick }
10329cb9da1cSmckusick }
10339cb9da1cSmckusick }
10349cb9da1cSmckusick }
10359cb9da1cSmckusick
10369cb9da1cSmckusick if(typeaddr)
10379cb9da1cSmckusick puteq( cpexpr(typeaddr), mkaddcon(ep->typelabel) );
10389cb9da1cSmckusick /* replace to avoid long jump problem
10399cb9da1cSmckusick putgoto(ep->entrylabel);
10409cb9da1cSmckusick */
10419cb9da1cSmckusick p2pi("\tjbr\tL%d", ep->entrylabel);
10429cb9da1cSmckusick }
10439cb9da1cSmckusick
fixlwm()10449cb9da1cSmckusick fixlwm()
10459cb9da1cSmckusick {
10469cb9da1cSmckusick extern lwmno;
10479cb9da1cSmckusick if (lwmno == procno)
10489cb9da1cSmckusick return;
10499cb9da1cSmckusick fprintf(asmfile, "\t.set\tLWM%d,0x%x\n",
10509cb9da1cSmckusick procno, regmask[highregvar]);
10519cb9da1cSmckusick lwmno = procno;
10529cb9da1cSmckusick }
10539cb9da1cSmckusick
10549cb9da1cSmckusick
prhead(fp)10559cb9da1cSmckusick prhead(fp)
10569cb9da1cSmckusick FILEP fp;
10579cb9da1cSmckusick {
10589cb9da1cSmckusick #if FAMILY==PCC
10599cb9da1cSmckusick p2triple(PCCF_FLBRAC, ARGREG-highregvar, procno);
10609cb9da1cSmckusick p2word( (long) (BITSPERCHAR*autoleng) );
10619cb9da1cSmckusick p2flush();
10629cb9da1cSmckusick #endif
10639cb9da1cSmckusick }
1064