

                                'Sprintf'
                                [32m---------[0m
                             by PowerPeak '90


    Only a very small subroutine this month, didn't have much time to write
something bigger.  As some people might have noticed there was no article last
month, I most humbly apologize. (DID anyone notice ?? :-)

    On the subject of noticing the articles, it would be nice to know if
people appreciate these programming examples.  Sofar I've only had one (1)
reaction regarding this series, so as far as I know only one person reads this
stuff :^) (well, at least he liked it :^D )

    If Ron uses the new Selector I sent him, this Newsflash should be all
new-style, suspiciously resembling Kickstart 2.0 style :-). The nice thing is
that everything works on Kickstart 1.3 as well (though it looks better on
Kick 2.0).
    I programmed this new look because I got my first 'oh-toidy' computer last
week (guess which one :-) and after working with AmigaOS 2.0 for a while I can
tell you you really start wondering how you ever managed to work on 1.3 :^)
All I can say is :  once Kickstart 2.0 becomes available UPGRADE !!  A lot of
stuff no longer works, but who cares ! All my programs seem to work, so at
least all the IMPORTANT programs work ! (Gee, aren't we being modest again
today :^D )

    Anyway, enough of this banter, on with, euh the show ?

    Sprintf is a subroutine that can be called from C, it behaves almost
exactly like sprintf (the library function), but is a lot shorter.
    Sprintf uses exec's RawDoFmt and therefore can't work with floating point
numbers, almost all the other standard C stuff should work. I use it in almost
all my programs and it works just fine.

    Source should assemble with almost everything (except Seka of course :),
don't you just love to hate utter crap ;^D )
    I guess that's all for this month, if I don't stop quickly I'll have hords
of angry Seka-lovers on my back :-)

                                                            Nico


[43m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[43m                                  Sprintf.asm                                
[43m-----------------------------------------------------------------------------

	SECTION "Sprintf",CODE

	XDEF _Sprintf

_LVORawDoFmt	equ	-$20a

*
* Call like this:  Sprintf (buffer, fmt, ...);
*
*           e.g.:  Sprintf (str, "%s : %ld\n", name, number);
*
* NOTE: ALWAYS use %ld and %lx etc. instead of %d and %x !
*
* Put this at the start of your Lattice C code:
*
*   extern void __stdargs Sprintf (char *, char *,...);
*

_Sprintf:
	movem.l  a2/a3,-(a7)
	movea.l  8+8(a7),a0
	lea      8+12(a7),a1
	lea      PutCharInBuff(PC),a2
	move.l   8+4(a7),a3
	move.l   ($4).w,a6
	jsr      _LVORawDoFmt(a6)
	movem.l  (a7)+,a2/a3
	rts

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

	END

[43m-----------------------------------------------------------------------------
[43m                                                              Nico François  
[43m-----------------------------------------------------------------------------
[0m                                                                             
