|
|
1.1 root 1: /* a3 -- pdp-11 assembler pass 2 */
2: #include "as2.h"
3: #define checkeos() (LAST('\n') || LAST(';') || LAST('\004'))
4:
5: int brdelt;
6: struct expr *curfb[20];
7:
8: assem()
9: {
10: OP op1,op2;
11: struct expr x;
12:
13: for (;;) {
14: op1=readop();
15: if (op1.v==5 || op1.v=='<') {
16: opline(op1); goto dotmax;
17: } else if (!checkeos()) {
18: if (op1.v==T_ABS) {op1.v=2; numval=getw();}
19: op2=readop();
20: if (LAST('=')) {
21: x=expres(readop());
22: if ((&op1.xp->typ)==dotrel) { /* as in ".=.+2" */
23: if ((x.typ&=~T_EXTERN)!=*dotrel) error('.');
24: else if (x.typ==T_BSS) {*dot=x.val; goto dotmax;}
25: else {
26: register short t = x.val-*dot;
27: if (t<0) error('.');
28: else {while (--t>=0) outb(T_ABS,0); goto dotmax;}
29: }
30: } else {
31: if (x.typ==T_EXTERN) error('r');
32: op1.xp->typ&=~037;
33: if ((x.typ&=037)==0) x.val=0;
34: op1.xp->typ |= x.typ; op1.xp->val=x.val;
35: }
36: } else if (LAST(':')) {
37: register int t;
38: if (ISCHAR(op1)) {
39: if (op1.v!=2) {error('x'); continue;}
40: t=fbadv(numval);
41: curfb[t]->typ= (curfb[t]->typ&~037) | *dotrel;
42: brdelt=curfb[t]->val-*dot;
43: curfb[t]->val= *dot;
44: } else {
45: if (passno==0) {
46: if ((t=op1.xp->typ&037)!=0 && t!=T_ESTTXT && t!=T_ESTDAT) error('m');
47: op1.xp->typ=(op1.xp->typ&~037)|*dotrel;
48: brdelt=op1.xp->val-*dot;
49: op1.xp->val= *dot;
50: } else if (*dot!=op1.xp->val) error('p');
51: }
52: continue;
53: } else {
54: register short *psiz;
55: savop=op2; opline(op1);
56: dotmax:
57: psiz=(&hdr.txtsiz)+(*dotrel-T_TEXT);
58: if (passno==0 && *dot>*psiz) *psiz= *dot;
59: }
60: }
61: if (LAST('\n')) ++line;
62: else if (LAST('\004')) return; /* sole exit */
63: }
64: }
65:
66: fbadv(t)
67: {
68: register struct expr *p;
69: extern struct expr *fbbuf;
70:
71: if (curfb[t]=p=curfb[t+10]) p++;
72: else p=fbbuf;
73: for (;;) {
74: if ((p->typ>>8)==t || p->typ<0) break;
75: p++;
76: }
77: curfb[t+10]=p;
78: return(t);
79: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.