home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d832 / term.lha / Term / term-3.1-Source.lha / termMisc.asm < prev    next >
Assembly Source File  |  1993-01-24  |  3KB  |  147 lines

  1. **
  2. **    termMisc.asm
  3. **
  4. **    Miscellaneous assembly language routines.
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. **
  9.  
  10.     include    "exec/lists.i"
  11.     include    "exec/io.i"
  12.  
  13. *--------------------------------------------------------------------------
  14.  
  15. CALL    macro
  16.     xref    _LVO\1
  17.     jsr    _LVO\1(a6)
  18.     endm
  19.  
  20. *--------------------------------------------------------------------------
  21.  
  22.     csect    text,0,0,1,2
  23.  
  24. *--------------------------------------------------------------------------
  25.  
  26.     xdef    _SPrintf
  27.     xdef    _VSPrintf
  28.  
  29.     xdef    _Atol
  30.  
  31.     xdef    __BeginIO
  32.     xdef    __NewList
  33.  
  34. *--------------------------------------------------------------------------
  35.  
  36. _SPrintf:
  37.  
  38.     movem.l    a2/a3/a6,-(sp)        ; Save registers
  39.  
  40.     move.l     4+12(sp),a3        ; Get destination buffer
  41.     move.l     8+12(sp),a0        ; Get format string
  42.     lea    12+12(sp),a1        ; Get arguments
  43.     lea    stuffchar(pc),a2    ; Get formatting routine
  44.  
  45.     move.l    4,a6            ; Get ExecBase
  46.     CALL    RawDoFmt        ; Format the string
  47.  
  48.     movem.l    (sp)+,a2/a3/a6        ; Restore registers
  49.  
  50.     rts
  51.  
  52. *--------------------------------------------------------------------------
  53.  
  54. _VSPrintf:
  55.  
  56.     movem.l    a2/a3/a6,-(sp)
  57.  
  58.     move.l     4+12(sp),a3
  59.     move.l     8+12(sp),a0
  60.     move.l    12+12(sp),a1
  61.     lea    stuffchar(pc),a2
  62.  
  63.     move.l    4,a6
  64.     CALL    RawDoFmt
  65.  
  66.     movem.l    (sp)+,a2/a3/a6
  67.  
  68.     rts
  69.  
  70. stuffchar:
  71.  
  72.     move.b    d0,(a3)+
  73.     rts
  74.  
  75. *--------------------------------------------------------------------------
  76. *
  77. *    A tiny replacement for Atol(), implemented through StrToLong.
  78. *
  79. *--------------------------------------------------------------------------
  80.  
  81. _Atol:    move.l    a0,d1        ; Save argument
  82.  
  83.     movem.l    d2/a6,-(sp)    ; Save registers
  84.  
  85.     pea.l    0        ; Push a zero on the stack
  86.  
  87.     lea.l    (sp),a0        ; Get a pointer to the value
  88.     move.l    a0,d2        ; Get it into a convenient register
  89.  
  90.     move.l    _DOSBase(a4),a6    ; Get DOSBase
  91.  
  92.     CALL    StrToLong    ; Convert the string
  93.     tst.l    d0
  94.  
  95.     bgt.b    1$        ; Did we get anything sensible?
  96.  
  97.     addq    #4,sp        ; Fix the stack
  98.     moveq    #0,d0        ; Clear the result
  99.  
  100.     movem.l    (sp)+,d2/a6    ; Restore registers
  101.     rts
  102.  
  103. 1$    move.l    (sp)+,d0    ; Get the conversion result
  104.  
  105.     movem.l    (sp)+,d2/a6    ; Restore registers
  106.     rts
  107.  
  108. *--------------------------------------------------------------------------
  109. *
  110. *    Replacements for two amiga.lib provided routines. These are
  111. *    special versions which accept their parameters in registers.
  112. *
  113. *--------------------------------------------------------------------------
  114.  
  115. __BeginIO:
  116.  
  117.     BEGINIO
  118.     rts
  119.  
  120. __NewList:
  121.  
  122.     NEWLIST    a0
  123.     rts
  124.  
  125. *--------------------------------------------------------------------------
  126. *
  127. *    These two lines are actually to make SLINK believe that some kind
  128. *    of startup code will clear the Data/BSS segment before running the
  129. *    main program. Since this is no longer necessary with Kickstart 2.x
  130. *    these two lines will save quite some disk space.
  131. *
  132. *--------------------------------------------------------------------------
  133.  
  134.     lea    __BSSBAS,a0
  135.     move.l    #__BSSLEN,d0
  136.  
  137. *--------------------------------------------------------------------------
  138.  
  139.     csect    __MERGED
  140.  
  141.     xref    _DOSBase
  142.  
  143.     xref    __BSSBAS
  144.     xref    __BSSLEN
  145.  
  146.     end
  147.