NEW
  AUTO 3,1
*--------------------------------------
WRITE
       JSR GET.REFNUM.OF.OPEN.FILE
       BCS .1       ...NOT OPEN
       STA WRITE.REFNUM
       LDA CSWL
       STA VDOSIO
       LDA CSWH
       STA VDOSIO+1
       LDA #WRITE.TEXT.FILE
       STA CSWL
       LDA /WRITE.TEXT.FILE
       STA CSWH
       LDA #$FF
       STA F.WRITE
.1     RTS
*--------------------------------
*   OUTPUT HOOK DURING A WRITE OPERATION
*--------------------------------
WRITE.TEXT.FILE
       AND #$7F     PRODOS STANDARD IS BIT7=0
       STA WRITE.OUTPUT.CHAR
       JSR SAVE.REGS
       LDX WRITE.REFNUM
       STX READ.WRITE.PARMS+1
       ASL          IGNORE BIT 7
       BEQ .2       END OF FILE
       LDA #WRITE.OUTPUT.CHAR
       STA READ.WRITE.PARMS+2
       LDA /WRITE.OUTPUT.CHAR
       STA READ.WRITE.PARMS+3
       LDA #1
       STA READ.WRITE.PARMS+4
       LDA #0
       STA READ.WRITE.PARMS+5
       JSR MLI.CB   WRITE
       BCC RESTORE.REGS
*--------------------------------
.1     JMP ERROR.HANDLER
*--------------------------------
.2     STX MISC.PARMS+1
       JSR MLI.CF   READ MARK
       BCS .1
       JSR MLI.D0   SET EOF
       BCS .1       ...ERROR
*---fall into RESTORE.REGS-------
*--------------------------------
RESTORE.REGS
       LDY PREGY
       LDX PREGX
       LDA PREGA
       RTS
*--------------------------------
SAVE.REGS
       STA PREGA
       STX PREGX
       STY PREGY
       RTS
*--------------------------------------
MAN
SAVE usr/src/scmasm.30/sci.s.rwpa
LOAD usr/src/scmasm.30/scmasm.s
ASM
