[comp.sys.amiga.programmer] HELP with RawDoFmt!

231b3678@fergvax.unl.edu (CS 231 section 2) (01/24/91)

Could someone please show an example of how to correctly use
RawDoFmt, specifically something similar to 
 
sprintf(string,"%-22s",fi->fib_FileName);
 
or
 
sprintf(string,"%6ld",t);
 
Thanx a trillion pesos (about $37.00)
Phil Dietz

---                    
   FACT:  the Nebraska Cornhuskers                           Phil Dietz 
          signed a contract to lose the        231b3678@fergvax.unl.edu       
          big games!  Yes, it's true!                 Univ. of Nebraska

peter@cbmvax.commodore.com (Peter Cherna) (01/26/91)

In article <1991Jan24.084316.12804@hoss.unl.edu> 231b3678@fergvax.unl.edu (CS 231 section 2) writes:
>Could someone please show an example of how to correctly use
>RawDoFmt, specifically something similar to 
> 
>sprintf(string,"%-22s",fi->fib_FileName);

RawDoFmt()'s autodoc contains assembler code for a simple sprintf()
that you could then use from C.  You can use that as is, if that's
what you need, or study it to learn about RawDoFmt().  Here is that
code:

	;
	; Simple version of the C "sprintf" function.  Assumes C-style
	; stack-based function conventions.
	;
	;   long eyecount;
	;   eyecount=2;
	;   sprintf(string,"%s have %ld eyes.","Fish",eyecount);
	;
	; would produce "Fish have 2 eyes." in the string buffer.
	;
		XDEF _sprintf
		XREF _AbsExecBase
		XREF _LVORawDoFmt
	_sprintf:	; ( ostring, format, {values} )
		movem.l a2/a3/a6,-(sp)

		move.l	4*4(sp),a3       ;Get the output string pointer
		move.l	5*4(sp),a0       ;Get the FormatString pointer
		lea.l	6*4(sp),a1       ;Get the pointer to the DataStream
		lea.l	stuffChar(pc),a2
		move.l	_AbsExecBase,a6
		jsr	_LVORawDoFmt(a6)

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

	;------ PutChProc function used by RawDoFmt -----------
	stuffChar:
		move.b	d0,(a3)+        ;Put data to output string
		rts


>Phil Dietz

     Peter
--
     Peter Cherna, Software Engineer, Commodore-Amiga, Inc.
     {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"Oh, PIN-compatible!  I thought you wanted me to make it IN-compatible!"

SteveX@omx.UUCP (Steve Tibbett) (01/27/91)

In article <1991Jan24.084316.12804@hoss.unl.edu> 231b3678@fergvax.unl.edu (CS 231 section 2) writes:
>Could someone please show an example of how to correctly use
>RawDoFmt, specifically something similar to 
> 
>sprintf(string,"%-22s",fi->fib_FileName);
>or
>sprintf(string,"%6ld",t);

Far as I know, exactly like that - but link with amiga.lib first.

--
   ...Steve Tibbett...bix=s.tibbett...Plink=STEVEX...BBS=613-731-3419...
              ...VirusX=4.01...Insert Disclaimer Here...