home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1997 #3 / amigamamagazinepolishissue03-1 / polski_aminet / michal_letowski / debuglib / src / kprintf.a < prev    next >
Text File  |  1996-05-11  |  3KB  |  107 lines

  1. ;    kprintf.a - KPrintf implementation using ROM routines
  2. ;    $VER: kprintf.a 37.1 (11.5.96)
  3. ;    Copyright © 1996 Michael Letowski
  4. ;
  5. ;    37.1 (11.5.96) - initial version
  6.  
  7.     include    "exec/funcdef.i"
  8.     include    "exec/exec_lib.i"
  9.  
  10.     xdef    _KPrintf
  11.     xdef    _VKPrintf
  12.     xdef    @VKPrintf
  13.  
  14. ; Some aliases
  15.  
  16.     xdef    _KPrintF
  17.     xdef    _kprintf
  18.     xdef    _VKPrintF
  19.     xdef    _vkprintf
  20.     xdef    _KPutFmt
  21.     xdef    @VKPrintF
  22.     xdef    KPutFmt
  23.     xdef    KPrintF
  24.  
  25.     section    text,code
  26.  
  27.  
  28. ******* debug.lib/VKPrintf **************************************************
  29. *
  30. *   NAME
  31. *       VKPrintf -- print formatted data to the debugging console. (V37)
  32. *
  33. *   SYNOPSIS
  34. *       nextData = VKPrintf(format, data)
  35. *       D0                  A0      A1
  36. *
  37. *       APTR VKPrintf(STRPTR, APTR);
  38. *
  39. *       nextData = KPrintf(buffer, format, ...)
  40. *
  41. *       APTR KPrintf(STRPTR, STRPTR, ...);
  42. *
  43. *   FUNCTION
  44. *       Prints data formatted with C-like string to the debugging console
  45. *       (defaults to the serial port at 9600 baud). The data is formatted
  46. *       using ROM RawDoFmt() function.
  47. *
  48. *   INPUTS
  49. *       format - "C"-language-like NULL terminated format string.
  50. *       data   - stream of data to be interpreted.
  51. *
  52. *   RESULT
  53. *       nextData - pointer to end of the data stream (the next argument that
  54. *                  would have been processed).
  55. *
  56. *   NOTES
  57. *       @VKPrintf, @VKPrintF, KPutFmt, KPrintF are identical assembly
  58. *       interfaces that want the two pointers in registers.
  59. *       _VKPrintf, _VKPrintF, _vkprintf, _KPutFmt are C interfaces that want
  60. *       the two string pointers on stack.
  61. *       _KPrintf, _KPrintF, _kprintf are C interfaces that expect the format
  62. *       string pointer on the stack, and the parameters on the stack above
  63. *       that.
  64. *
  65. *   SEE ALSO
  66. *       KDoFmt(), exec.library/RawDoFmt().
  67. *
  68. *****************************************************************************
  69. *
  70. * _KPrintf(format, ...)
  71. * _VKPrintf(format, data)
  72. * @VKPrintf(R_A0 format, R_A1 data)
  73. *
  74.  
  75. _KPrintf:
  76. _KPrintF:
  77. _kprintf:
  78.     move.l    1*4(sp),a0
  79.     lea.l    2*4(sp),a1
  80.     bra.b    KPrintF
  81.  
  82. _VKPrintf:
  83. _VKPrintF:
  84. _vkprintf:
  85. _KPutFmt:
  86.     move.l    1*4(sp),a0
  87.     move.l    2*4(sp),a1
  88.  
  89. @VKPrintf:
  90. @VKPrintF:
  91. KPutFmt:
  92. KPrintF:
  93.     movem.l    a2-a3/a6,-(sp)        ; Save registers
  94.     lea.l    StuffChar(pc),a2    ; a2 = put char proc
  95.     move.l    (4).w,a3        ; Remember SysBase
  96.     move.l    a3,a6            ; Use SysBase
  97.     jsr    _LVORawDoFmt(a6)    ; Jump to ROM
  98.     movem.l    (sp)+,a2-a3/a6        ; Restore registers
  99.     rts                ; Done
  100.  
  101. StuffChar:
  102.     move.l    a3,a6            ; Get SysBase
  103.     jsr    _LVORawPutChar(a6)    ; Use serial I/O to stuff chars
  104.     rts
  105.  
  106.     end
  107.