1: HZ = 60. 2: / 3: / Berkeley Pascal Assembler Kernel 4: / 5: .globl _interpret 6: .globl _pcttot, _pdattim, _alloc, _free, _error, _fflush, _maxstk 7: .globl _pputch, _pmessage, _pwrite, _pwril 8: .globl _atan, _cos, _exp, _log, _sin, _sqrt 9: .globl _display, _dp, _lino, _draino 10: .globl _seed, _randa, _randc, _randm, _randim 11: .globl _atof 12: .globl _argc, _argv, _errno 13: .globl _file, _nodump, _pxpbuf, _pmflush 14: / 15: return = 115 / jmp (lp) 16: times = 43. 17: lp = r5 18: lc = r4 19: error = 104000 ^ sys 20: / 21: ONE = 040200 /$1.0 22: HALF = 040000 /$.5 23: / 24: SIGILL = 4. 25: SIGEMT = 7. 26: SIG_DFL = 0. 27: / 28: _interpret: 29: setl 30: mov $onemt,-(sp) 31: mov $SIGEMT,-(sp) 32: jsr pc,_signal 33: cmp (sp)+,(sp)+ 34: clr -(sp) / SIG_DFL 35: mov $SIGILL,-(sp) 36: jsr pc,_signal 37: cmp (sp)+,(sp)+ 38: mov $_display,_dp 39: mov $loop,lp 40: mov 2(sp),lc 41: mov sp,*_dp 42: mov $_unit0,-(sp) 43: mov $_unit1,-(sp) 44: / 45: / main interpreter loop 46: / the pseudo-op 'return' 47: / transfers here 48: / 49: loop: 50: movb (lc)+,r0 51: add r0,r0 52: movb (lc)+,r3 53: jmp *optab(r0) 54: badop: 55: mov $EBADOP,_perrno 56: error EBADOP 57: /cloop: 58: / movb (lc)+,r0 59: / mov r0,r1 60: / add r0,r0 61: / add $128.,r1 62: / ash $2,r1 63: / add $cntab,r1 64: / add $1,2(r1) 65: / adc (r1) 66: / movb (lc)+,r3 67: / jmp *optab(r0) 68: /.bss 69: /cntab: 70: / .=.+1024. 71: /.text 72: .bss 73: _perrno: .=.+2 74: .text 75: onemt: 76: setd 77: / mov (sp)+,r0 78: / sub $2,r0 79: /.if SEPID 80: / mov r0,-(sp) 81: / jsr pc,_fetchi 82: / tst (sp)+ 83: /.endif 84: /.if !SEPID 85: / mov (r0),r0 86: /.endif 87: / bic $!377,r0 88: / mov r0,-(sp) 89: mov _perrno,-(sp) 90: jsr pc,_error 91: / 92: _ABORT: 93: 4 94: _HALT: 95: mov $EHALT,_perrno 96: error EHALT 97: _NODUMP: 98: inc _nodump 99: _BEG: 100: mov (lc)+,r3 101: add $2,_dp 102: mov *_dp,-(sp) 103: mov lc,-(sp) 104: add $10.,lc 105: mov buf,-(sp) 106: mov _file,-(sp) 107: tst -(sp) 108: mov sp,*_dp 109: mov sp,r0 110: add r3,r0 111: cmp r0,sp 112: bhi 9f 113: cmp r0,_maxstk 114: blos 9f 115: tst r3 116: beq 2f 117: 1: 118: clr -(sp) 119: cmp sp,r0 120: bhi 1b 121: 2: 122: mov *_dp,r1 123: mov sp,(r1) 124: return 125: 9: 126: mov $ESTKOVFLO,_perrno 127: error ESTKOVFLO 128: _END: 129: jsr pc,blkexit 130: mov *_dp,sp 131: tst (sp)+ 132: mov (sp)+,_file 133: mov (sp)+,buf 134: tst (sp)+ 135: mov (sp)+,*_dp 136: cmp _dp,$_display+2 137: bhi 3f 138: mov $_unit1,r0 139: mov FBUF(r0),-(sp) 140: jsr pc,_fflush 141: jsr pc,_pmflush 142: clr r0 143: / mov $0644,-(sp) 144: / mov $cntdata,-(sp) 145: / jsr pc,_creat 146: / cmp (sp)+,(sp)+ 147: / mov $1024.,-(sp) 148: / mov $cntab,-(sp) 149: / mov r0,-(sp) 150: / jsr pc,_write 151: /.data 152: /cntdata: <counts\0> 153: /.even 154: /.text 155: jsr pc,_psexit 156: .globl _psexit 157: 3: 158: mov (sp)+,_dp 159: mov (sp)+,lc 160: mov (sp)+,_lino 161: return 162: _CALL: 163: mov lc,r0 164: add (lc)+,r0 165: mov _lino,-(sp) 166: mov lc,-(sp) 167: mov _dp,-(sp) 168: add $_display,r3 169: mov r3,_dp 170: mov r0,lc 171: return 172: _PUSH: 173: bne 1f 174: mov (lc)+,r3 175: 1: 176: mov sp,r0 177: add r3,r0 178: 1: 179: cmp sp,r0 180: blos 1f 181: clr -(sp) 182: br 1b 183: 1: 184: return 185: _POP: 186: bne 1f 187: mov (lc)+,r3 188: 1: 189: add r3,sp 190: return 191: _SDUP: 192: mov (sp),-(sp) 193: return 194: _IF: 195: tstb (sp)+ 196: beq _TRA 197: tst (lc)+ 198: return 199: _ASRT: 200: tstb (sp)+ 201: beq 9f 202: return 203: 9: 204: mov $EASRT,_perrno 205: error EASRT 206: _TRA: 207: add (lc),lc 208: return 209: _LINO: 210: bne 1f 211: mov (lc)+,r3 212: 1: 213: mov r3,_lino 214: mov *_dp,r1 215: cmp (r1),sp 216: bne 2f 217: add $1,_stcnt+2 218: adc _stcnt 219: sub $1,_stlim+2 220: sbc _stlim 221: bne 1f 222: tst _stlim+2 223: bne 1f 224: mov $ESTLIM,_perrno 225: error ESTLIM 226: 1: 227: return 228: 2: 229: mov $ESTKNEMP,_perrno 230: error ESTKNEMP 231: .data 232: .globl _stcnt, _stlim 233: _stcnt: 0 234: 0 235: _stlim: 7 236: 120440 237: .text 238: _GOTO: 239: add (lc),lc 240: add $_display,r3 241: 1: 242: mov *_dp,r2 243: cmp r3,_dp 244: beq 1f 245: cmp _dp,$_display 246: beq 9f 247: jsr pc,blkexit 248: tst (r2)+ 249: mov (r2)+,_file 250: mov (r2)+,buf 251: tst (r2)+ 252: mov (r2)+,*_dp 253: mov (r2)+,_dp 254: br 1b 255: 1: 256: mov (r2),sp 257: return 258: 9: 259: mov $EGOTO,_perrno 260: error EGOTO 261: blkexit: 262: mov r2,-(sp) 263: mov fchain,r2 264: 1: 265: tst r2 266: beq 2f 267: cmp FLEV(r2),*_dp 268: bhi 2f 269: bit $FWRITE,FUNIT(r2) 270: beq 4f 271: mov FBUF(r2),-(sp) 272: jsr pc,_fflush 273: tst (sp)+ 274: 4: 275: mov FUNIT(r2),r0 276: bmi 3f 277: bic $!17,r0 278: mov r0,-(sp) 279: jsr pc,_close 280: tst (sp)+ 281: tst r0 282: bpl 3f 283: mov PFNAME(r2),_file 284: mov $ECLOSE,_perrno 285: error ECLOSE 286: 3: 287: bit $TEMP,FUNIT(r2) 288: beq 4f 289: mov PFNAME(r2),-(sp) 290: jsr pc,_unlink 291: tst (sp)+ 292: tst r0 293: bpl 4f 294: mov PFNAME(r2),_file 295: mov $EREMOVE,_perrno 296: error EREMOVE 297: 4: 298: mov FNAME(r2),-(sp) 299: jsr pc,_free 300: mov r2,(sp) 301: mov FCHAIN(r2),r2 302: sub $518.+14.,(sp) 303: jsr pc,_free 304: tst (sp)+ 305: br 1b 306: 2: 307: mov r2,fchain 308: mov (sp)+,r2 309: rts pc 310: _pmflush: 311: tst _pxpbuf 312: beq 1f 313: mov $0644,-(sp) 314: mov $pmonout,-(sp) 315: jsr pc,_creat 316: cmp (sp)+,(sp)+ 317: tst r0 318: bmi 9f 319: mov _pxpsize,-(sp) 320: mov _pxpbuf,-(sp) 321: mov r0,-(sp) 322: jsr pc,_write 323: add $6,sp 324: tst r0 325: .data 326: _pxpbuf: 0 327: _pxpsize: 0 328: pmonout: <pmon.out\0> 329: .even 330: .text 331: bmi 9f 332: 1: 333: rts pc 334: 9: 335: mov $pmonout,-(sp) 336: .globl _perror 337: jsr pc,_perror 338: mov $1,-(sp) 339: jsr pc,__exit