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