;	kdofmt.a - KDoFmt implementation using ROM routines
;	$VER: kdofmt.a 37.1 (10.5.96)
;	Copyright © 1996 Michael Letowski
;
;	37.1 (10.5.96) - initial version

	include	"exec/funcdef.i"
	include	"exec/exec_lib.i"

	xdef	_KDoFmt
	xdef	@KDoFmt

; Some aliases

	xdef	KDoFmt

	section	text,code


******* debug.lib/KDoFmt ****************************************************
*
*   NAME
*       KDoFmt -- format data into a character stream. (V37)
*
*   SYNOPSIS
*       nextData = KDoFmt(formatString, dataStream, putChProc, putChData)
*       D0                A0            A1          A2         A3
*
*       APTR KDoFmt(STRPTR, STRPTR, void (*)(), APTR);
*
*   FUNCTION
*       Interface to ROM RawDoFmt() function.
*
*   INPUTS
*       formatString - "C"-language-like NULL terminated format string.
*       dataStream   - stream of data to be interpreted.
*       putChProc    - the procedure to call with each character to be
*                      output.
*       putChData    - the value that is passed through to the putChProc
*                      procedure.
*
*   RESULT
*       nextData - pointer to end of the data stream (the next argument that
*                  would have been processed).
*
*   NOTES
*       @KDoFmt, KDoFmt are identical assembly interfaces that want pointers
*       in registers. _KDoFmt is a C interface that expects the parameters
*       on the stack.
*
*   SEE ALSO
*       exec.library/RawDoFmt().
*
*****************************************************************************
*
* _KDoFmt(formatString, dataString, putProc, procData)
* @KDoFmt(R_A0 format, R_A1 data, R_A2 putProc, R_A3 procData)
*

_KDoFmt:
	movem.l	a2-a3/a6,-(sp)		; Save registers on stack
	movem.l	4*4(sp),a0-a3		; Load registers with stack parameters
	bra	ParamsLoaded		; Go with register parameters

@KDoFmt:
KDoFmt:
	movem.l	a2-a3/a6,-(sp)		; Save registers on stack

ParamsLoaded:
	move.l	(4).w,a6		; Load a6 with SysBase
	jsr	_LVORawDoFmt(a6)	; Jump to ROM
	movem.l	(sp)+,a2-a3/a6		; Restore registers from stack
	rts				; Done

	end
