1: / 2: / IO operations 3: / 4: _GET: 5: jsr pc,get 6: jsr pc,iosync 7: return 8: _PUT: 9: jsr pc,put 10: return 11: _MESSAGE: 12: mov $_unit2,r0 13: jsr pc,unit 14: mov fchain,r2 / flush all files 15: 1: 16: beq 2f 17: bit $FWRITE,FUNIT(r2) 18: beq 3f 19: mov FBUF(r2),-(sp) 20: jsr pc,_fflush 21: tst (sp)+ 22: 3: 23: mov FCHAIN(r2),r2 24: br 1b 25: 2: 26: mov $_unit1,r2 27: mov FBUF(r2),-(sp) 28: jsr pc,_fflush 29: tst (sp)+ 30: return 31: _FNIL: 32: mov (sp),r0 33: mov _file,-(sp) 34: mov buf,-(sp) 35: jsr pc,unit 36: jsr pc,iosync 37: mov (sp)+,buf 38: mov (sp)+,_file 39: return 40: _BUFF: 41: mov r3,bufopt 42: return 43: _EOF: 44: mov (sp)+,r0 45: mov _file,-(sp) 46: mov buf,-(sp) 47: mov $EOF,-(sp) 48: br 1f 49: _EOLN: 50: mov (sp)+,r0 51: mov _file,-(sp) 52: mov buf,-(sp) 53: mov $EOF+EOLN,-(sp) 54: 1: 55: jsr pc,unit 56: cmp buf,$_unit0 57: bne 1f 58: cmp bufopt,$1 59: bne 1f 60: mov $u1buf,-(sp) 61: jsr pc,_fflush 62: tst (sp)+ 63: 1: 64: mov (sp)+,r1 65: clr -(sp) 66: mov buf,r2 67: bit $EOF,FUNIT(r2) 68: bne 2f 69: jsr pc,iosync 70: bit r1,FUNIT(r2) 71: beq 1f 72: 2: 73: mov $1,(sp) 74: 1: 75: mov (sp)+,r0 76: mov (sp)+,buf 77: mov (sp)+,_file 78: mov r0,-(sp) 79: return 80: _RESET: 81: bne 1f / branch if name given 82: cmp *(sp),$_unit0 83: bne 1f 84: tst _unit0+FNAME 85: bne 1f 86: clr r0 87: sys lseek; 0; 0; 0 88: bes 9f 89: tst (sp)+ 90: tst (lc)+ 91: bic $EOF+EOLN,_unit0+FUNIT 92: bis $SYNC,_unit0+FUNIT 93: return 94: 9: 95: mov $stdin,_file 96: mov r0,_errno 97: mov $ESEEK,_perrno 98: error ESEEK 99: 1: 100: jsr pc,getname 101: mov r0,r1 102: mov PFNAME(r1),_file 103: mov FNAME(r1),openrnm 104: sys indir; openr 105: bes eopen 106: mov r0,*FBUF(r1) 107: bis $SYNC|FREAD,r0 108: bis r0,FUNIT(r1) 109: return 110: ecreat: 111: mov r0,_errno 112: mov $ECREATE,_perrno 113: error ECREATE 114: eopen: 115: mov r0,_errno 116: mov $EOPEN,_perrno 117: error EOPEN 118: .data 119: openr: sys open; openrnm: .. ; 0 120: creit: sys creat; crenm: ..; 0644 121: openw: sys open; openwnm: .. ; 1 122: .text 123: _REWRITE: 124: jsr pc,getname 125: mov r0,r1 126: mov PFNAME(r1),_file 127: mov FNAME(r1),crenm 128: sys indir; creit 129: bes ecreat 130: sys close 131: mov FNAME(r1),openwnm 132: sys indir; openw 133: bes eopen 134: mov r0,*FBUF(r1) 135: bis $EOF|FWRITE,r0 136: bis r0,FUNIT(r1) 137: return 138: _REMOVE: 139: bne 1f 140: mov (lc)+,r3 141: 1: 142: mov sp,r1 143: mov r3,r2 144: inc r2 145: bic $1,r2 146: add r2,sp 147: add r3,r1 148: mov r1,r0 149: movb (r1),r2 150: clrb (r1) 151: 1: 152: cmpb -1(r1),$' 153: bne 1f 154: clrb -(r1) 155: dec r3 156: bne 1b 157: 1: 158: sub r3,r1 159: mov r1,1f 160: mov r1,_file 161: sys indir; 0f 162: bes 9f 163: movb r2,(r0) 164: return 165: .data 166: 0: sys unlink; 1: .. 167: .text 168: 9: 169: mov _file,sp 170: mov r0,_errno 171: mov $EREMOVE,_perrno 172: error EREMOVE 173: _UNITINP: 174: cmp bufopt,$2 175: bge 1f / bufopt >= 2, don't flush on read 176: cmp $512.,u1cnt 177: beq 1f 178: mov $u1buf,-(sp) 179: jsr pc,_fflush 180: tst (sp)+ 181: 1: 182: mov $_unit0,buf 183: mov $stdin,_file 184: return 185: _UNITOUT: 186: mov $_unit1,buf 187: mov $stdout,_file 188: return 189: _UNIT: 190: mov (sp)+,r0 191: cmp r0,$_unit0 192: beq _UNITINP 193: jsr pc,unit 194: return 195: _READ8: 196: sub $32.,sp 197: / mov sp,-(sp) This doen't work on all 11's 198: mov sp,r0 199: mov r0,-(sp) 200: mov $32.,-(sp) 201: mov $1,-(sp) 202: jsr pc,_preadn 203: bcs 1f 204: add $6,sp 205: / mov sp,-(sp) This doen't work on all 11's 206: mov sp,r0 207: mov r0,-(sp) 208: jsr pc,_atof 209: add $34.,sp 210: movf fr0,-(sp) 211: return 212: 1: 213: add $38.,sp 214: clrf -(sp) 215: return 216: _READ4: 217: sub $20.,sp 218: / mov sp,-(sp) This doen't work on all 11's 219: mov sp,r0 220: mov r0,-(sp) 221: mov $20.,-(sp) 222: clr -(sp) 223: jsr pc,_preadn 224: bcs 1f 225: add $6.,sp 226: / mov sp,-(sp) This doen't work on all 11's 227: mov sp,r0 228: mov r0,-(sp) 229: jsr pc,_atol 230: add $22.,sp 231: mov r1,-(sp) 232: mov r0,-(sp) 233: return 234: 1: 235: add $26.,sp 236: clr -(sp) 237: sxt -(sp) 238: return 239: _READC: 240: jsr pc,iosync 241: clr -(sp) 242: movb *buf,(sp) 243: jsr pc,get 244: return 245: _READLN: 246: jsr pc,iosync 247: mov buf,r0 248: bit $EOLN+EOF,FUNIT(r0) 249: bne 1f 250: jsr pc,get 251: br _READLN 252: 1: 253: jsr pc,get 254: return 255: _PAGE: 256: mov $14,-(sp) 257: br 1f 258: _WRITC: 259: beq 1f 260: mov $323,r0 261: br pwriteit 262: 1: 263: movb (sp)+,*buf 264: jsr pc,put 265: tst bufopt 266: beq 2f 267: return 268: _WRITLN: 269: mov $327,r0 270: mov $'\n,-(sp) 271: mov $1,r2 272: cmp buf,$_unit1 273: bne 1f 274: cmp bufopt,$1 275: bgt 1f 276: clr r2 277: br 1f 278: _WRITG: 279: mov $325,r0 280: mov (lc)+,-(sp) 281: br pwriteit 282: _WRHEX2: 283: mov $267,r0 284: br 3f 285: _WRHEX4: 286: mov $277,r0 287: br 3f 288: _WROCT2: 289: mov $330,r0 290: br 3f 291: _WROCT4: 292: mov $331,r0 293: br 3f 294: _WRIT2: 295: mov $320,r0 296: br 3f 297: _WRIT4: 298: mov $321,r0 299: br 3f 300: .globl _WRIT8 301: _WRIT8: 302: mov $324,r0 303: br 3f 304: _WRITB: 305: mov $322,r0 306: br 3f 307: _WRIT82: 308: mov $326,r0 309: 3: 310: pwriteit: 311: mov bufopt,r2 312: 1: 313: mov r3,-(sp) 314: mov r0,-(sp) 315: seti 316: jsr pc,_pwrite 317: setl 318: mov r0,sp 319: tst r2 320: bne 1f 321: 2: 322: cmp buf,$_unit1 323: bne 1f 324: mov buf,r0 325: mov FBUF(r0),-(sp) 326: jsr pc,_fflush 327: tst (sp)+ 328: 1: 329: return 330: _DEFNAME: 331: jsr pc,getname 332: bis $100000,FUNIT(r0) 333: return 334: _FLUSH: 335: mov (sp)+,r0 336: jsr pc,unit 337: mov buf,r0 338: bit $FWRITE,FUNIT(r0) 339: beq 1f 340: mov FBUF(r0),-(sp) 341: jsr pc,_fflush 342: tst (sp)+ 343: 1: 344: return