include	clib.inc
include	stdio.inc

PPROC	fputc, char:BYTE, fp:DPTR
	push	si
	MLES	bx,fp
	dec	es:[bx.iob_cnt]
	jl	fputc_00
	mov	ax,word ptr es:[bx.iob_bp+2]
	mov	si,word ptr es:[bx.iob_bp]
	inc	word ptr es:[bx.iob_bp]
	mov	dl,char
	mov	es,ax
	mov	es:[si],dl
	mov	al,dl
	mov	ah,0
	jmp	fputc_01
    fputc_00:
	push	word ptr char
	MPUSH	word ptr fp+2
	push	word ptr fp
	call	_flsbuf
    fputc_01:
	pop	si
	ret
PEND	fputc

	END
