|
|
1.1 root 1: #include "defs"
2:
3: #ifdef SDB
4: # include <a.out.h>
5: extern int types2[];
6: #endif
7:
8: #include "pccdefs"
9:
10: /*
11: PDP11-780/VAX - SPECIFIC ROUTINES
12: */
13:
14:
15: int maxregvar = MAXREGVAR;
16: int regnum[] = { 11, 10, 9, 8, 7, 6 } ;
17: static int regmask[] = { 0, 0x800, 0xc00, 0xe00, 0xf00, 0xf80, 0xfc0 };
18:
19:
20:
21: ftnint intcon[14] =
22: { 2, 2, 2, 2,
23: 15, 31, 24, 56,
24: -128, -128, 127, 127,
25: 32767, 2147483647 };
26:
27: #if HERE == VAX
28: /* then put in constants in octal */
29: long realcon[6][2] =
30: {
31: { 0200, 0 },
32: { 0200, 0 },
33: { 037777677777, 0 },
34: { 037777677777, 037777777777 },
35: { 032200, 0 },
36: { 022200, 0 }
37: };
38: #else
39: double realcon[6] =
40: {
41: 2.9387358771e-39,
42: 2.938735877055718800e-39
43: 1.7014117332e+38,
44: 1.701411834604692250e+38
45: 5.960464e-8,
46: 1.38777878078144567e-17,
47: };
48: #endif
49:
50:
51:
52:
53: prsave()
54: {
55: int proflab;
56: p2pi("\t.word\t0x%x", regmask[highregvar]); /* register variable mask */
57: if(profileflag)
58: {
59: proflab = newlabel();
60: fprintf(asmfile, "L%d:\t.space\t4\n", proflab);
61: p2pi("\tmovab\tL%d,r0", proflab);
62: p2pass("\tjsb\tmcount");
63: }
64: p2pi("\tsubl2\t$.F%d,sp", procno);
65: }
66:
67:
68:
69: goret(type)
70: int type;
71: {
72: p2pass("\tret");
73: }
74:
75:
76:
77:
78: /*
79: * move argument slot arg1 (relative to ap)
80: * to slot arg2 (relative to ARGREG)
81: */
82:
83: mvarg(type, arg1, arg2)
84: int type, arg1, arg2;
85: {
86: p2pij("\tmovl\t%d(ap),%d(fp)", arg1+ARGOFFSET, arg2+argloc);
87: }
88:
89:
90:
91:
92: prlabel(fp, k)
93: FILEP fp;
94: int k;
95: {
96: fprintf(fp, "L%d:\n", k);
97: }
98:
99:
100:
101: prconi(fp, type, n)
102: FILEP fp;
103: int type;
104: ftnint n;
105: {
106: fprintf(fp, "\t%s\t%ld\n", (type==TYSHORT ? ".word" : ".long"), n);
107: }
108:
109:
110:
111: prcona(fp, a)
112: FILEP fp;
113: ftnint a;
114: {
115: fprintf(fp, "\t.long\tL%ld\n", a);
116: }
117:
118:
119:
120: #ifndef vax
121: prconr(fp, type, x)
122: FILEP fp;
123: int type;
124: float x;
125: {
126: fprintf(fp, "\t%s\t0f%e\n", (type==TYREAL ? ".float" : ".double"), x);
127: }
128: #endif
129:
130: #ifdef vax
131: prconr(fp, type, x)
132: FILEP fp;
133: int type;
134: double x;
135: {
136: long int *n;
137: n = &x; /* nonportable cheat */
138: if(type == TYREAL)
139: fprintf(fp, "\t.long\t0x%X\n", n[0]);
140: else
141: fprintf(fp, "\t.long\t0x%X,0x%X\n", n[0], n[1]);
142: }
143: #endif
144:
145:
146:
147:
148:
149:
150:
151: preven(k)
152: int k;
153: {
154: register int lg;
155:
156: if(k > 4)
157: lg = 3;
158: else if(k > 2)
159: lg = 2;
160: else if(k > 1)
161: lg = 1;
162: else
163: return;
164: fprintf(asmfile, "\t.align\t%d\n", lg);
165: }
166:
167:
168:
169: vaxgoto(index, nlab, labs)
170: expptr index;
171: register int nlab;
172: struct Labelblock *labs[];
173: {
174: register int i;
175: register int arrlab;
176:
177: putforce(TYINT, index);
178: p2pi("\tcasel\tr0,$1,$%d", nlab-1);
179: p2pi("L%d:", arrlab = newlabel() );
180: for(i = 0; i< nlab ; ++i)
181: if( labs[i] )
182: p2pij("\t.word\tL%d-L%d", labs[i]->labelno, arrlab);
183: }
184:
185:
186: prarif(p, neg, zer, pos)
187: expptr p;
188: int neg, zer, pos;
189: {
190: putforce(p->headblock.vtype, p);
191: if( ISINT(p->headblock.vtype) )
192: p2pass("\ttstl\tr0");
193: else
194: p2pass("\ttstd\tr0");
195: p2pi("\tjlss\tL%d", neg);
196: p2pi("\tjeql\tL%d", zer);
197: p2pi("\tjbr\tL%d", pos);
198: }
199:
200:
201:
202:
203: char *memname(stg, mem)
204: int stg, mem;
205: {
206: static char s[20];
207:
208: switch(stg)
209: {
210: case STGCOMMON:
211: case STGEXT:
212: sprintf(s, "_%s", varstr(XL, extsymtab[mem].extname) );
213: break;
214:
215: case STGBSS:
216: case STGINIT:
217: sprintf(s, "v.%d", mem);
218: break;
219:
220: case STGCONST:
221: sprintf(s, "L%d", mem);
222: break;
223:
224: case STGEQUIV:
225: sprintf(s, "q.%d", mem+eqvstart);
226: break;
227:
228: default:
229: fatali("memname: invalid vstg %d", stg);
230: }
231: return(s);
232: }
233:
234:
235:
236:
237: prlocvar(s, len)
238: char *s;
239: ftnint len;
240: {
241: fprintf(asmfile, "\t.lcomm\t%s,%ld\n", s, len);
242: }
243:
244:
245:
246: prext(name, leng, init)
247: char *name;
248: ftnint leng;
249: int init;
250: {
251: if(leng == 0)
252: fprintf(asmfile, "\t.globl\t_%s\n", name);
253: else
254: fprintf(asmfile, "\t.comm\t_%s,%ld\n", name, leng);
255: }
256:
257:
258:
259:
260:
261: prendproc()
262: {
263: }
264:
265:
266:
267:
268: prtail()
269: {
270: }
271:
272:
273:
274:
275:
276: prolog(ep, argvec)
277: struct Entrypoint *ep;
278: struct Addrblock *argvec;
279: {
280: int i, argslot, proflab;
281: int size;
282: register chainp p;
283: register struct Nameblock *q;
284: register struct Dimblock *dp;
285: expptr tp;
286:
287: if(procclass == CLMAIN)
288: p2pass( "_MAIN__:" );
289: if(ep->entryname)
290: p2ps("_%s:", varstr(XL, ep->entryname->extname));
291: if(procclass == CLBLOCK)
292: return;
293: prsave();
294: if(argvec)
295: {
296: argloc = argvec->memoffset->constblock.const.ci + SZINT;
297: /* first slot holds count */
298: if(proctype == TYCHAR)
299: {
300: mvarg(TYADDR, 0, chslot);
301: mvarg(TYLENG, SZADDR, chlgslot);
302: argslot = SZADDR + SZLENG;
303: }
304: else if( ISCOMPLEX(proctype) )
305: {
306: mvarg(TYADDR, 0, cxslot);
307: argslot = SZADDR;
308: }
309: else
310: argslot = 0;
311:
312: for(p = ep->arglist ; p ; p =p->nextp)
313: {
314: q = p->datap;
315: mvarg(TYADDR, argslot, q->vardesc.varno);
316: argslot += SZADDR;
317: }
318: for(p = ep->arglist ; p ; p = p->nextp)
319: {
320: q = p->datap;
321: if(q->vtype==TYCHAR || q->vclass==CLPROC)
322: {
323: if(q->vleng && q->vleng->headblock.tag!=TCONST)
324: mvarg(TYLENG, argslot,
325: q->vleng->nameblock.vardesc.varno);
326: argslot += SZLENG;
327: }
328: }
329: p2pi("\taddl3\t$%d,fp,ap", argloc-ARGOFFSET);
330: p2pi("\tmovl\t$%d,(ap)\n", lastargslot/SZADDR);
331: }
332:
333: for(p = ep->arglist ; p ; p = p->nextp)
334: {
335: q = p->datap;
336: if(dp = q->vdim)
337: {
338: for(i = 0 ; i < dp->ndim ; ++i)
339: if(dp->dims[i].dimexpr)
340: puteq( fixtype(cpexpr(dp->dims[i].dimsize)),
341: fixtype(cpexpr(dp->dims[i].dimexpr)));
342: size = typesize[ q->vtype ];
343: if(q->vtype == TYCHAR)
344: if( ISICON(q->vleng) )
345: size *= q->vleng->constblock.const.ci;
346: else
347: size = -1;
348:
349: /* on VAX, get more efficient subscripting if subscripts
350: have zero-base, so fudge the argument pointers for arrays.
351: Not done if array bounds are being checked.
352: */
353: if(dp->basexpr)
354: puteq( cpexpr(fixtype(dp->baseoffset)),
355: cpexpr(fixtype(dp->basexpr)));
356:
357: if(! checksubs)
358: {
359: if(dp->basexpr)
360: {
361: if(size > 0)
362: tp = ICON(size);
363: else
364: tp = cpexpr(q->vleng);
365: putforce(TYINT,
366: fixtype( mkexpr(OPSTAR, tp,
367: cpexpr(dp->baseoffset)) ));
368: p2pi("\tsubl2\tr0,%d(ap)",
369: p->datap->nameblock.vardesc.varno +
370: ARGOFFSET);
371: }
372: else if(dp->baseoffset->constblock.const.ci != 0)
373: {
374: char buff[25];
375: if(size > 0)
376: {
377: sprintf(buff, "\tsubl2\t$%ld,%d(ap)",
378: dp->baseoffset->constblock.const.ci * size,
379: p->datap->nameblock.vardesc.varno +
380: ARGOFFSET);
381: }
382: else {
383: putforce(TYINT, mkexpr(OPSTAR, cpexpr(dp->baseoffset),
384: cpexpr(q->vleng) ));
385: sprintf(buff, "\tsubl2\tr0,%d(ap)",
386: p->datap->nameblock.vardesc.varno +
387: ARGOFFSET);
388: }
389: p2pass(buff);
390: }
391: }
392: }
393: }
394:
395: if(typeaddr)
396: puteq( cpexpr(typeaddr), mkaddcon(ep->typelabel) );
397: /* replace to avoid long jump problem
398: putgoto(ep->entrylabel);
399: */
400: p2pi("\tjmp\tL%d", ep->entrylabel);
401: }
402:
403:
404:
405:
406: prhead(fp)
407: FILEP fp;
408: {
409: #if FAMILY==PCC
410: p2triple(P2LBRACKET, ARGREG-highregvar, procno);
411: p2word( (long) (BITSPERCHAR*autoleng) );
412: p2flush();
413: #endif
414: }
415:
416:
417:
418: prdbginfo()
419: {
420: }
421:
422: #ifdef SDB
423:
424:
425: # ifdef UCBVAXASM
426: char *stabdline(code, type)
427: int code;
428: int type;
429: {
430: static char buff[30];
431:
432: sprintf(buff, "\t.stabd\t0%o,0,0%o\n", code, type);
433: return(buff);
434: }
435: # endif
436:
437:
438: prstab(s, code, type, loc)
439: char *s, *loc;
440: int code, type;
441: {
442: char * stabline();
443:
444: if(sdbflag)
445: fprintf(asmfile, stabline(s,code,type,loc) );
446: }
447:
448:
449:
450: char *stabline(s, code, type, loc)
451: register char *s;
452: int code;
453: int type;
454: char *loc;
455: {
456: static char buff[50] = "\t.stab\t\t";
457: register char *t;
458: register int i = 0;
459:
460: #ifdef UCBVAXASM
461: t = buff + 8;
462: if(s == NULL)
463: buff[6] = 'n'; /* .stabn line */
464: else
465: {
466: buff[6] = 's'; /* .stabs line */
467: *t++ = '"';
468: while(*s!='\0' && *s!=' ' && i<8)
469: {
470: *t++ = *s++;
471: ++i;
472: }
473: *t++ = '"';
474: *t++ = ',';
475: }
476:
477: #else
478: t = buff + 7;
479: if(s)
480: while( *s!='\0' && *s!=' ' && i<8 )
481: {
482: *t++ = '\'';
483: *t++ = *s++;
484: *t++ = ',';
485: ++i;
486: }
487: for( ; i<8 ; ++i)
488: {
489: *t++ = '0';
490: *t++ = ',';
491: }
492: #endif
493:
494:
495: sprintf(t, "0%o,0,0%o,%s\n", code, type, (loc? loc : "0") );
496: return(buff);
497: }
498:
499:
500:
501: prstleng(np, leng)
502: register struct Nameblock *np;
503: ftnint leng;
504: {
505: ftnint iarrlen();
506:
507: prstab( varstr(XL,np->varname), N_LENG, 0, convic(leng) );
508: }
509:
510:
511:
512: stabtype(p)
513: register struct Nameblock *p;
514: {
515: register int type;
516: register int shift;
517: type = types2[p->vtype];
518: if(p->vdim)
519: {
520: type |= 060; /* .stab code for array */
521: shift = 2;
522: }
523: else if(p->vclass == CLPROC)
524: {
525: type |= 040; /* .stab code for function */
526: shift = 2;
527: }
528: else
529: shift = 0;
530:
531: if(p->vstg == STGARG)
532: type |= (020 << shift); /* code for pointer-to */
533:
534: return(type);
535: }
536:
537:
538:
539:
540: prstssym(np)
541: register struct Nameblock *np;
542: {
543: prstab(varstr(VL,np->varname), N_SSYM,
544: stabtype(np), convic(np->voffset) );
545: }
546: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.