include	clib.inc
include stdio.inc

GLOBAL	_iob:byte
stdout	equ offset _iob + (size S_FILE)

CPROC	printf, format:DPTR, argptr:DPTR
	push	si
	push	di
	lea	si,argptr
	mov	di,stdout
	MMOV	ax,ds
	MPUSH	ax
	MPUSH	ax
	push	di
	call	_stbuf
	MPOP	dx
	push	ax
	MPUSH	dx
	push	di
	MPUSH	dx
	push	di
	MPUSH	word ptr format+2
	push	word ptr format
	MPUSH	ss
	push	si
	call	_output
	mov	si,ax
	call	_ftbuf
	mov	ax,si
	pop	di
	pop	si
	ret
PEND	printf

	END
