include	clib.inc
include stdio.inc
include limits.inc

CPROC	sprintf, string:DPTR, format:DPTR, argptr:DPTR
local	o:S_FILE
	mov	o.iob_flag,_IOWRT or _IOSTRG
	mov	o.iob_cnt,INT_MAX
	MMOV	dx,word ptr string+2
	MMOV	word ptr o.iob_bp+2,dx
	MMOV	word ptr o.iob_base+2,dx
	mov	ax,word ptr string
	mov	word ptr o.iob_bp,ax
	mov	word ptr o.iob_base,ax
	lea	ax,o
	MPUSH	ss
	push	ax
	MPUSH	word ptr format+2
	push	word ptr format
	lea	ax,argptr
	MPUSH	ss
	push	ax
	call	_output
	les	bx,o.iob_bp
	mov	byte ptr es:[bx],0
	ret
PEND	sprintf

	END
