include	clib.inc
include	stdio.inc
include	malloc.inc

PPROC	_getbuf, fp:DWORD
	push	ds
	push	_INTIOBUF
	call	malloc
	lds	bx,fp
	jz	_getbuf_00
	or	[bx.iob_flag],_IOMYBUF
	mov	[bx.iob_bufsize],_INTIOBUF
	jmp	_getbuf_01
    _getbuf_00:
	or	[bx.iob_flag],_IONBF
	mov	[bx.iob_bufsize],2
	mov	ax,bx
	add	ax,iob_charbuf
	mov	dx,ds
    _getbuf_01:
	mov	WORD PTR [bx.iob_base],ax
	mov	WORD PTR [bx.iob_base+2],dx
	mov	WORD PTR [bx.iob_bp],ax
	mov	WORD PTR [bx.iob_bp+2],dx
	mov	[bx.iob_cnt],0
	pop	ds
	ret
PEND	_getbuf

	END
