[comp.sys.amiga.tech] _sprintf

deven@rpi.edu (Deven T. Corzine) (11/09/90)

[ ... didn't understand RawDoFmt() or C calling conventions ... ]

(The C calling conventions mention just means that each argument of a
C function call is pushed on the stack, in reverse order, before the
jsr.  So, the arguments are above the return address on the stack.
4(a7) is the first argument, 8(a7) is the second, etc.  (assuming
longword arguments.))

Here's some assembly source for _sprintf using RawDoFmt:

[This is either similar or identical to code in the V1.3 I&A RKM, back
around where the sample library and device code is, I believe.]

--------
		SECTION _sprintf
		XDEF _sprintf

_sprintf:	movem.l	a2-a3/a6,-(a7)
		move.l	$14(a7),a0
		lea	$18(a7),a1
		lea	PutChProc(pc),a2
		move.l	$10(a7),a3
		move.l	$4,a6
		jsr	$fffffdf6(a6)		;Call RawDoFmt
		movem.l	(a7)+,a2-a3/a6
		rts

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

		END
--------

Deven
-- 
Deven T. Corzine        Internet:  deven@rpi.edu, shadow@pawl.rpi.edu
Snail:  2214 12th St. Apt. 2, Troy, NY 12180   Phone:  (518) 271-0750
Bitnet:  deven@rpitsmts, userfxb6@rpitsmts     UUCP:  uunet!rpi!deven
Simple things should be simple and complex things should be possible.