home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / comm / term23_2.lha / Source_Code / termSource / Format.asm < prev    next >
Assembly Source File  |  1992-08-18  |  3KB  |  113 lines

  1. *--------------------------------------------------------------------------
  2. *
  3. * $Id: Format.asm,v 1.3 92/08/15 20:12:44 olsen Sta Locker: olsen $
  4. * $Revision: 1.3 $
  5. * $Date: 92/08/15 20:12:44 $
  6. *
  7. * ANSI-`C' style string routines not necessarily to be found in amiga.lib
  8. *
  9. * Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
  10. *    All Rights Reserved
  11. *--------------------------------------------------------------------------
  12.  
  13. CALL    macro
  14.     xref    _LVO\1
  15.     jsr    _LVO\1(a6)
  16.     endm
  17.  
  18.     csect    text,0,0,1,2
  19.  
  20. *--------------------------------------------------------------------------
  21.  
  22.     xdef    _SPrintf
  23.     xdef    _VSPrintf
  24.  
  25.     xdef    _atol
  26.  
  27. *--------------------------------------------------------------------------
  28.  
  29. _SPrintf:
  30.     movem.l    a2/a3/a6,-(sp)        ; Save registers
  31.  
  32.     move.l     4+12(sp),a3        ; Get destination buffer
  33.     move.l     8+12(sp),a0        ; Get format string
  34.     lea    12+12(sp),a1        ; Get arguments
  35.     lea    stuffchar(pc),a2    ; Get formatting routine
  36.  
  37.     move.l    4,a6            ; Get ExecBase
  38.     CALL    RawDoFmt        ; Format the string
  39.  
  40.     movem.l    (sp)+,a2/a3/a6        ; Restore registers
  41.  
  42.     rts
  43.  
  44. *--------------------------------------------------------------------------
  45.  
  46. _VSPrintf:
  47.     movem.l    a2/a3/a6,-(sp)
  48.  
  49.     move.l     4+12(sp),a3
  50.     move.l     8+12(sp),a0
  51.     move.l    12+12(sp),a1
  52.     lea    stuffchar(pc),a2
  53.  
  54.     move.l    4,a6
  55.     CALL    RawDoFmt
  56.  
  57.     movem.l    (sp)+,a2/a3/a6
  58.  
  59.     rts
  60.  
  61. stuffchar:
  62.     move.b    d0,(a3)+
  63.     rts
  64.  
  65. *--------------------------------------------------------------------------
  66. *
  67. *    A tiny replacement for atol(), implemented through StrToLong.
  68. *
  69. *--------------------------------------------------------------------------
  70.  
  71. _atol:    move.l    4(sp),d1    ; Save argument
  72.  
  73.     movem.l    d2/a6,-(sp)    ; Save registers
  74.  
  75.     pea.l    0        ; Push a zero on the stack
  76.  
  77.     lea.l    (sp),a0        ; Get a pointer to the value
  78.     move.l    a0,d2        ; Get it into a convenient register
  79.  
  80.     move.l    _DOSBase(a4),a6    ; Get DOSBase
  81.  
  82.     CALL    StrToLong    ; Convert the string
  83.  
  84.     move.l    (sp)+,d0    ; Get the conversion result
  85.  
  86.     movem.l    (sp)+,d2/a6    ; Restore registers
  87.  
  88.     rts
  89.  
  90. *--------------------------------------------------------------------------
  91. *
  92. *    These two lines are actually to make BLINK believe that some kind
  93. *    of startup code will clear the Data/BSS segment before running the
  94. *    main program. Since this is no longer necessary with Kickstart 2.x
  95. *    these two lines save about 34 KBytes of disk space.
  96. *
  97. *--------------------------------------------------------------------------
  98.  
  99.     lea    __BSSBAS,a0
  100.     move.l    #__BSSLEN,d0
  101.  
  102. *--------------------------------------------------------------------------
  103.  
  104.     csect    __MERGED
  105.  
  106.     xref    _DOSBase
  107.  
  108.     xref    __BSSBAS
  109.     xref    __BSSLEN
  110.  
  111.     end
  112.