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