1: / putw/putc -- write words/characters on output file 2: 3: .globl _putc, _putw, _fflush, _fcreat 4: .globl _werflg 5: .comm _errno,2 6: 7: _fcreat: 8: mov r5,-(sp) 9: mov sp,r5 10: mov 6(r5),r1 11: mov pc,(r1) / a putatively illegal file desc. 12: mov $0644,-(sp) 13: mov 4(r5),-(sp) 14: jsr pc,_creat 15: cmp (sp)+,(sp)+ 16: tst r0 17: bmi badret 18: mov r0,(r1)+ 19: clr (r1)+ 20: clr (r1)+ 21: br goodret 22: 23: _putw: 24: mov r5,-(sp) 25: mov sp,r5 26: mov 6(r5),r1 27: dec 2(r1) 28: bge 1f 29: jsr pc,fl 30: dec 2(r1) 31: 1: 32: movb 4(r5),*4(r1) 33: inc 4(r1) 34: dec 2(r1) 35: bge 1f 36: jsr pc,fl 37: dec 2(r1) 38: 1: 39: movb 5(r5),*4(r1) 40: inc 4(r1) 41: mov 4(r5),r0 42: br goodret 43: 44: _putc: 45: mov r5,-(sp) 46: mov sp,r5 47: mov 6(r5),r1 48: dec 2(r1) 49: bge 1f 50: jsr pc,fl 51: dec 2(r1) 52: 1: 53: mov 4(r5),r0 54: movb r0,*4(r1) 55: inc 4(r1) 56: br goodret 57: 58: _fflush: 59: mov r5,-(sp) 60: mov sp,r5 61: mov 4(r5),r1 62: jsr pc,fl 63: br goodret 64: 65: fl: 66: mov r1,r0 67: add $6,r0 68: mov r0,-(sp) 69: tst 4(r1) 70: beq 1f 71: mov 4(r1),-(sp) 72: sub r0,(sp) 73: mov r0,-(sp) 74: mov (r1),-(sp) 75: jsr pc,_write 76: add $6,sp 77: tst r0 78: bpl 1f 79: mov r0,_werflg 80: 1: 81: mov (sp)+,4(r1) 82: mov $512.,2(r1) 83: rts pc 84: 85: badret: 86: mov r5,sp 87: mov (sp)+,r5 88: rts pc 89: 90: goodret: 91: clr _errno 92: mov (sp)+,r5 93: rts pc 94: .bss 95: _werflg:.=.+2