*--------------------------------------------------------------------------
*
* $Id: format.asm,v 1.1 92/08/29 12:48:14 rwm Exp Locker: rwm $
* $Revision: 1.1 $
* $Date: 92/08/29 12:48:14 $
*
* ANSI-`C' style string routines not necessarily to be found in amiga.lib
*
* Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
*    All Rights Reserved
* 
*--------------------------------------------------------------------------

CALL	macro
	xref	_LVO\1
	jsr	_LVO\1(a6)
	endm

*	csect	text,0,0,1,2

*--------------------------------------------------------------------------

	xref	_DOSBase

*	xref	__BSSBAS
*	xref	__BSSLEN

*	xdef	_PrintF
*	xdef	_FPrintF

	xdef	_SPrintF
*	xdef	_VSPrintF

	xdef	_atol

*--------------------------------------------------------------------------

*_PrintF:
*	movem.l	d2/a6,-(sp)
*
*	move.l	12(sp),d1
*	lea	16(sp),a0
*	move.l	a0,d2
*
*	move.l	_DOSBase(a4),a6
*
*	CALL	VPrintf
*
*	movem.l	(sp)+,d2/a6
*	rts

*--------------------------------------------------------------------------

*_FPrintF:
*	movem.l	d2/d3/a6,-(sp)
*
*	move.l	16(sp),d1
*	move.l	20(sp),d2
*	lea	24(sp),a0
*	move.l	a0,d3
*
*	move.l	_DOSBase(a4),a6
*
*	CALL	VFPrintf
*
*	movem.l	(sp)+,d2/d3/a6
*	rts

*--------------------------------------------------------------------------

_SPrintF:
	movem.l	a2/a3/a6,-(sp)

	move.l	 4+12(sp),a3
	move.l	 8+12(sp),a0
	lea	12+12(sp),a1
	lea	stuffchar(pc),a2

	move.l	4,a6
	CALL	RawDoFmt

	movem.l	(sp)+,a2/a3/a6

	rts

*--------------------------------------------------------------------------

*_VSPrintF:
*	movem.l	a2/a3/a6,-(sp)
*
*	move.l	 4+12(sp),a3
*	move.l	 8+12(sp),a0
*	move.l	12+12(sp),a1
*	lea	stuffchar(pc),a2
*
*	move.l	4,a6
*	CALL	RawDoFmt
*
*	movem.l	(sp)+,a2/a3/a6
*
*	rts

stuffchar:
	move.b	d0,(a3)+
	rts

*--------------------------------------------------------------------------
*
*	A tiny replacement for atol(), implemented through StrToLong.
*
*--------------------------------------------------------------------------

_atol:	move.l	4(sp),d1

	move.l	d2,-(sp)
	move.l	a6,-(sp)

	pea.l	0

	lea.l	(sp),a0
	move.l	a0,d2

	move.l	_DOSBase(a4),a6

	CALL	StrToLong

	move.l	(sp),d0

	add.w	#4,sp
	move.l	(sp)+,a6
	move.l	(sp)+,d2

	rts

*--------------------------------------------------------------------------
*
*	These two lines are actually to make BLINK believe that some kind
*	of startup code will clear the Data/BSS segment before running the
*	main program. Since this is no longer necessary with Kickstart 2.x
*	these two lines save about 34 KBytes of disk space.
*
*--------------------------------------------------------------------------

*	lea	__BSSBAS,a0
*	move.l	#__BSSLEN,d0

*--------------------------------------------------------------------------

*	csect	__MERGED

	end
