1: /
   2: /
   3: 
   4: / a21 -- pdp-11 assembler pass 2
   5: 
   6: indir   = 0
   7: 
   8: main:
   9:         sys     signal; 2; 1
  10:         ror     r0
  11:         bcs     1f
  12:         sys     signal; 2; aexit
  13: 1:
  14:         jmp     start
  15: 
  16: / set up sizes and origins
  17: 
  18: go:
  19: 
  20: / read in symbol table
  21: 
  22:         mov     $usymtab,r1
  23: 1:
  24:         jsr     pc,getw
  25:         bvs     1f
  26:         add     $14,symsiz              / count symbols
  27:         jsr     pc,getw
  28:         jsr     pc,getw
  29:         jsr     pc,getw
  30:         jsr     pc,getw
  31:         mov     r4,r0
  32:         bic     $!37,r0
  33:         cmp     r0,$2                   /text
  34:         blo     2f
  35:         cmp     r0,$3                   /data
  36:         bhi     2f
  37:         add     $31,r4                  /mark "estimated"
  38:         mov     r4,(r1)+
  39:         jsr     pc,getw
  40:         mov     r4,(r1)+
  41:         br      3f
  42: 2:
  43:         clr     (r1)+
  44:         clr     (r1)+
  45:         jsr     pc,getw
  46: 3:
  47:         jsr     pc,setbrk
  48:         br      1b
  49: 1:
  50: 
  51: / read in f-b definitions
  52: 
  53:         mov     r1,fbbufp
  54:         movb    fbfil,fin
  55:         clr     ibufc
  56: 1:
  57:         jsr     pc,getw
  58:         bvs     1f
  59:         add     $31,r4                  / "estimated"
  60:         mov     r4,(r1)+
  61:         jsr     pc,getw
  62:         mov     r4,(r1)+
  63:         jsr     pc,setbrk
  64:         br      1b
  65: 1:
  66:         mov     r1,endtable
  67:         mov     $100000,(r1)+
  68: 
  69: / set up input text file; initialize f-b table
  70: 
  71:         jsr     pc,setup
  72: / do pass 1
  73: 
  74:         jsr     pc,assem
  75: 
  76: / prepare for pass 2
  77:         cmp     outmod,$777
  78:         beq     1f
  79:         jmp     aexit
  80: 1:
  81:         clr     dot
  82:         mov     $2,dotrel
  83:         mov     $..,dotdot
  84:         clr     brtabp
  85:         movb    fin,r0
  86:         sys     close
  87:         jsr     r5,ofile; a.tmp1
  88:         movb    r0,fin
  89:         clr     ibufc
  90:         jsr     pc,setup
  91:         inc     passno
  92:         inc     bsssiz
  93:         bic     $1,bsssiz
  94:         mov     txtsiz,r1
  95:         inc     r1
  96:         bic     $1,r1
  97:         mov     r1,txtsiz
  98:         mov     datsiz,r2
  99:         inc     r2
 100:         bic     $1,r2
 101:         mov     r2,datsiz
 102:         mov     r1,r3
 103:         mov     r3,datbase      / txtsiz
 104:         mov     r3,savdot+2
 105:         add     r2,r3
 106:         mov     r3,bssbase      / txtsiz+datsiz
 107:         mov     r3,savdot+4
 108:         asl     r3
 109:         add     $20,r3
 110:         mov     r3,symseek      / 2*txtsiz+2*datsiz+20
 111:         sub     r2,r3
 112:         mov     r3,drelseek     / 2*txtsiz+datsiz
 113:         sub     r1,r3
 114:         mov     r3,trelseek     / txtsiz+datsiz+20
 115:         sub     r2,r3
 116:         mov     r3,datseek      / txtsiz+20
 117:         mov     $usymtab,r1
 118: 1:
 119:         jsr     pc,doreloc
 120:         add     $4,r1
 121:         cmp     r1,endtable
 122:         blo     1b
 123:         clr     r0
 124:         jsr     r5,oset; txtp
 125:         mov     trelseek,r0
 126:         jsr     r5,oset; relp
 127:         mov     $8.,r2
 128:         mov     $txtmagic,r1
 129: 1:
 130:         mov     (r1)+,r0
 131:         jsr     r5,putw; txtp
 132:         dec     r2
 133:         bne     1b
 134:         jsr     pc,assem
 135: 
 136: /polish off text and relocation
 137: 
 138:         jsr     r5,flush; txtp
 139:         jsr     r5,flush; relp
 140: 
 141: / append full symbol table
 142: 
 143:         mov     symf,r0
 144:         mov     r0,fin
 145:         sys     seek; 0; 0;
 146:         clr     ibufc
 147:         mov     symseek,r0
 148:         jsr     r5,oset; txtp
 149:         mov     $usymtab,r1
 150: 1:
 151:         jsr     pc,getw
 152:         bvs     1f
 153:         mov     r4,r0
 154:         jsr     r5,putw; txtp
 155:         jsr     pc,getw
 156:         mov     r4,r0
 157:         jsr     r5,putw; txtp
 158:         jsr     pc,getw
 159:         mov     r4,r0
 160:         jsr     r5,putw; txtp
 161:         jsr     pc,getw
 162:         mov     r4,r0
 163:         jsr     r5,putw; txtp
 164:         mov     (r1)+,r0
 165:         jsr     r5,putw; txtp
 166:         mov     (r1)+,r0
 167:         jsr     r5,putw; txtp
 168:         jsr     pc,getw
 169:         jsr     pc,getw
 170:         br      1b
 171: 1:
 172:         jsr     r5,flush; txtp
 173:         jmp     aexit
 174: 
 175:         .data
 176: aexit:
 177:         mov     a.tmp1,0f
 178:         sys     unlink; 0:..
 179:         mov     a.tmp2,0f
 180:         sys     unlink; 0:..
 181:         mov     a.tmp3,0f
 182:         sys     unlink; 0:..
 183:         sys     chmod; a.out; outmod: 777
 184:         sys     exit
 185:         .text
 186: 
 187: filerr:
 188:         mov     *(r5),r5
 189: 1:
 190:         movb    (r5)+,ch
 191:         beq     1f
 192:         mov     $1,r0
 193:         sys     write; ch; 1
 194:         br      1b
 195: 1:
 196:         mov     $1,r0
 197:         sys     write; qnl; 2
 198:         jmp     aexit
 199: 
 200: doreloc:
 201:         movb    (r1),r0
 202:         bne     1f
 203:         bisb    defund,(r1)
 204: 1:
 205:         bic     $!37,r0
 206:         cmp     r0,$5
 207:         bhis    1f
 208:         cmp     r0,$3
 209:         blo     1f
 210:         beq     2f
 211:         add     bssbase,2(r1)
 212:         rts     pc
 213: 2:
 214:         add     datbase,2(r1)
 215: 1:
 216:         rts     pc
 217: 
 218: setbrk:
 219:         mov     r1,-(sp)
 220:         add     $20,r1
 221:         cmp     r1,0f
 222:         blo     1f
 223:         add     $512.,0f
 224:         sys     indir; 9f
 225:         .data
 226: 9:      sys     break; 0: end
 227:         .text
 228: 1:
 229:         mov     (sp)+,r1
 230:         rts     pc
 231: 
 232: setup:
 233:         mov     $curfb,r4
 234: 1:
 235:         clr     (r4)+
 236:         cmp     r4,$curfb+40.
 237:         blo     1b
 238:         mov     txtfil,fin
 239:         clr     ibufc
 240:         clr     r4
 241: 1:
 242:         jsr     pc,fbadv
 243:         tstb    (r4)+
 244:         cmp     r4,$10.
 245:         blt     1b
 246:         rts     pc
 247: 
 248: ofile:
 249:         mov     *(r5),0f
 250:         sys     indir; 9f
 251:         .data
 252: 9:      sys     open; 0:..; 0
 253:         .text
 254:         bes     1f
 255:         tst     (r5)+
 256:         rts     r5
 257: 1:
 258:         jmp     filerr

Defined functions

doreloc defined in line 200; used 1 times
filerr defined in line 187; used 1 times
go defined in line 18; never used
indir defined in line 6; used 2 times
main defined in line 8; never used
ofile defined in line 248; used 1 times
  • in line 87
setbrk defined in line 218; used 2 times
setup defined in line 232; used 2 times

Defined variables

aexit defined in line 176; used 4 times
outmod defined in line 183; used 1 times
  • in line 77
Last modified: 1975-07-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 679
Valid CSS Valid XHTML 1.0 Strict