home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!gatech!concert!sas!mozart.unx.sas.com!walker
- From: walker@twix.unx.sas.com (Doug Walker)
- Subject: Re: Rewrite of PRINTF function, How do you do multi Args an
- Originator: walker@twix.unx.sas.com
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Message-ID: <Bz40sn.3Dt@unx.sas.com>
- Date: Fri, 11 Dec 1992 19:29:10 GMT
- References: <jvasher.04cn@cquest.mi.org> <paulk.2f1s@terapin.com> <70868@cup.portal.com>
- Nntp-Posting-Host: twix.unx.sas.com
- Organization: SAS Institute Inc.
- Lines: 60
-
-
- In article <70868@cup.portal.com>, jimdawson@cup.portal.com (Jim R Dawson) writes:
- |> Could someone give me an example of how to use RawDoFmt() in C? I haven't
- |> been able to figure out how to call this function and I cannot find an
- |> example anywhere (except in asm).
-
- |> |Jim Dawson - Author of AmiQWK .QWK mail reader | jimdawson@cup.portal.com|
-
- Sure, here's a sprintf() implementation. You can easily modify it
- to work as a printf() instead. Keep in mind that you MUST use %ld
- to print a "long" or "int" value even if you are not using short
- integers.
-
- This should work on any ANSI-compliant compiler.
-
- Note that the callback function below is really a string constant
- which contains the code, written in hex, to implement the RawDoFmt
- callback routine. Using SAS/C, you can use the STRINGMERGE option
- and this string constant will even be placed into the code section!
-
- /*---------cut here---------------*/
-
- #include <stdarg.h>
- #include <clib/exec_protos.h>
- #include <pragmas/exec_pragmas.h>
-
- int rawsprintf(char *buffer, char *ctl, ...)
- {
- va_list args;
-
- va_start(args, ctl);
-
- /*********************************************************/
- /* NOTE: The string below is actually CODE that copies a */
- /* value from D0 to A3 and increments A3: */
- /* */
- /* move.b d0,(a3)+ */
- /* rts */
- /* */
- /* It is essentially the callback routine needed */
- /* by RawDoFmt. */
- /*********************************************************/
-
- RawDoFmt(ctl, args, (void (*))"\x16\xc0\x4e\x75", buffer);
-
- va_end(args);
-
- return((int)strlen(buffer));
- }
-
- /*---------cut here---------------*/
- --
- *****
- =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
- *|. o.| || 1200/2400/9600 Dual
- | o |// For all you do, this bug's for you!
- ======
- usenet: walker@unx.sas.com bix: djwalker
- Any opinions expressed are mine, not those of SAS Institute, Inc.
-
-