1: / getw/getc -- get words/characters from input file 2: / fopen -- open a file for use by get(c|w) 3: 4: indir = 0 5: 6: .globl _getc, _getw, _fopen 7: .comm _errno,2 8: 9: _fopen: 10: mov r5,-(sp) 11: mov sp,r5 12: clr -(sp) 13: mov 4(r5),-(sp) 14: jsr pc,_open 15: cmp (sp)+,(sp)+ 16: tst r0 17: bmi badret 18: mov 6(r5),r1 19: mov r0,(r1)+ 20: clr (r1)+ 21: clr r0 22: mov (sp)+,r5 23: rts pc 24: 25: _getw: 26: clr _errno 27: mov r5,-(sp) 28: mov sp,r5 29: mov 4(r5),r1 30: sub $2,2(r1) 31: bge 1f 32: cmp 2(r1),$-1 33: blt 2f 34: movb *4(r1),-(sp) 35: jsr pc,fill 36: mov 4(r1),r0 37: br 3f 38: 2: 39: jsr pc,fill 40: dec 2(r1) 41: 1: 42: mov 4(r1),r0 43: movb (r0)+,-(sp) 44: 3: 45: movb (r0)+,1(sp) 46: mov r0,4(r1) 47: mov (sp)+,r0 48: mov (sp)+,r5 49: rts pc 50: 51: _getc: 52: mov r5,-(sp) 53: mov sp,r5 54: mov 4(r5),r1 55: dec 2(r1) 56: bge 1f 57: jsr pc,fill 58: 1: 59: clr r0 60: bisb *4(r1),r0 61: inc 4(r1) 62: mov (sp)+,r5 63: rts pc 64: 65: fill: 66: mov r1,r0 67: add $6,r0 68: mov r0,4(r1) 69: mov $512.,-(sp) 70: mov r0,-(sp) 71: mov (r1),-(sp) 72: jsr pc,_read 73: add $6,sp 74: tst r0 75: bmi badret 76: dec r0 77: bmi badret 78: mov r0,2(r1) 79: rts pc 80: 81: badret: 82: mov r5,sp 83: mov (sp)+,r5 84: rts pc