home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d952 / machv.lha / MachV / programmer.lha / PrintMacros / sprintf.a < prev   
Text File  |  1992-10-06  |  928b  |  34 lines

  1. ;
  2. ; Simple version of the C "sprintf" function.  Assumes C-style
  3. ; stack-based function conventions.
  4. ;
  5. ;   long eyecount;
  6. ;   eyecount=2;
  7. ;   sprintf(string,"%s have %ld eyes.","Fish",eyecount);
  8. ;
  9. ; would produce "Fish have 2 eyes." in the string buffer.
  10. ;
  11.         xdef _sprintf
  12.         xref _AbsExecBase
  13.         xref _LVORawDoFmt
  14.         section "text",code
  15. _sprintf:       ; ( ostring, format, {values} )
  16.         movem.l a2/a3/a6,-(sp)
  17.  
  18.         move.l  4*4(sp),a3       ;Get the output string pointer
  19.         move.l  5*4(sp),a0       ;Get the FormatString pointer
  20.         lea.l   6*4(sp),a1       ;Get the pointer to the DataStream
  21.         lea.l   stuffChar(pc),a2
  22.         move.l  _AbsExecBase,a6
  23.         jsr     _LVORawDoFmt(a6)
  24.  
  25.         movem.l (sp)+,a2/a3/a6
  26.         rts
  27.  
  28. ;------ PutChProc function used by RawDoFmt -----------
  29. stuffChar:
  30.         move.b  d0,(a3)+        ;Put data to output string
  31.         rts
  32.  
  33.         END
  34.