1: / getw/getc -- get words/characters from input file 2: / fopen -- open a file for use by get(c|w) 3: / 4: / calling sequences -- 5: / 6: / mov $filename,r0 7: / jsr r5,fopen; ioptr 8: / 9: / on return ioptr buffer is set up or error bit is set if 10: / file could not be opened. 11: / 12: / jsr r5,get(c|w)1; ioptr 13: / 14: / on return char/word is in r0; error bit is 15: / set on error or end of file. 16: / 17: / ioptr is the address of a 518-byte buffer 18: / whose layout is as follows: 19: / 20: / ioptr: .=.+2 / file descriptor 21: / .=.+2 / charact+2 / pointer to next character (reset if no. chars=0) 22: / .=.+512. / the buffer 23: 24: .globl getc,getw,fopen 25: 26: fopen: 27: mov r1,-(sp) 28: mov (r5)+,r1 29: mov r0,0f 30: sys 0; 9f 31: .data 32: 9: 33: sys open; 0:..; 0 34: .text 35: bes 1f 36: mov r0,(r1)+ 37: clr (r1)+ 38: mov (sp)+,r1 39: rts r5 40: 1: 41: mov $-1,(r1) 42: mov (sp)+,r1 43: sec 44: rts r5 45: 46: .data 47: getw: 48: mov (r5),9f 49: mov (r5)+,8f 50: jsr r5,getc; 8:.. 51: bec 1f 52: rts r5 53: 1: 54: mov r0,-(sp) 55: jsr r5,getc; 9:.. 56: swab r0 57: bis (sp)+,r0 58: rts r5 59: .text 60: 61: getc: 62: mov r1,-(sp) 63: mov (r5)+,r1 64: dec 2(r1) 65: bge 1f 66: mov r1,r0 67: add $6,r0 68: mov r0,0f 69: mov r0,4(r1) 70: mov (r1),r0 71: sys 0; 9f 72: .data 73: 9: 74: sys read; 0:..; 512. 75: .text 76: bes 2f 77: tst r0 78: bne 3f 79: 2: 80: mov (sp)+,r1 81: sec 82: rts r5 83: 3: 84: dec r0 85: mov r0,2(r1) 86: 1: 87: clr r0 88: bisb *4(r1),r0 89: inc 4(r1) 90: mov (sp)+,r1 91: rts r5