home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.1 / Assembler / debug / printf.mac < prev    next >
Encoding:
Text File  |  1992-08-27  |  2.6 KB  |  98 lines

  1.  
  2. ;
  3. ; Copyright (c) 1988 Commodore-Amiga, Inc.
  4. ;
  5. ; Executables based on this information may be used in software
  6. ; for Commodore Amiga computers.  All other rights reserved.
  7. ;
  8. ; This information is provided "as is"; no warranties are made.
  9. ; All use is at your own risk, and no liability or responsibility is assumed.
  10. ;
  11.  
  12. ;===========================================================================
  13. ; MACRO to provide a printf debugging call, use it like the 'C' version. ie.
  14. ;
  15. ;    printf    <'value=%ld pointer=%lx count=%d\n'>,d0,a0,d1
  16. ;    printf    <'program name = %s\n'>,#ProgName
  17. ;    printf    <'port name = %s\n'>,a0
  18. ;    printf    <'character received = \t%c\n'>,d0
  19. ;    printf    <'Program length = %d\n'>,#(ProgEnd-ProgStart)
  20. ;    printf    <'%c'>,#7
  21. ;    printf    <'ffp value = %f\n'>,d0
  22. ;
  23. ; No initialisation or cleanup is nescessary because this is done every
  24. ; time the printf code is called.  The only initialisation needed to use
  25. ; the printf call is to invoke the DEBUGENABLE macro at the beginning of
  26. ; the module in which you want to use it.  This just equates a constant
  27. ; (called DEBUG_CODE) to 1 so that the printf macro expands the call.
  28. ;==========================================================================
  29. printf    MACRO
  30.     IFD DEBUG_CODE                ; only if DEBUGENABLE called
  31.     NOLIST
  32. ; first stack up to eight arguments for the printf routine
  33.     IFGE    NARG-9
  34.         LIST
  35.         move.l    \9,-(sp)        ; stack arg8
  36.         NOLIST
  37.     ENDC
  38.     IFGE    NARG-8
  39.         LIST
  40.         move.l    \8,-(sp)        ; stack arg7
  41.         NOLIST
  42.     ENDC
  43.     IFGE    NARG-7
  44.         LIST
  45.         move.l    \7,-(sp)        ; stack arg6
  46.         NOLIST
  47.     ENDC
  48.     IFGE    NARG-6
  49.         LIST
  50.         move.l    \6,-(sp)        ; stack arg5
  51.         NOLIST
  52.     ENDC
  53.     IFGE    NARG-5
  54.         LIST
  55.         move.l    \5,-(sp)        ; stack arg4
  56.         NOLIST
  57.     ENDC
  58.     IFGE    NARG-4
  59.         LIST
  60.         move.l    \4,-(sp)        ; stack arg3
  61.         NOLIST
  62.     ENDC
  63.     IFGE    NARG-3
  64.         LIST
  65.         move.l    \3,-(sp)        ; stack arg2
  66.         NOLIST
  67.     ENDC
  68.     IFGE    NARG-2
  69.         LIST
  70.         move.l    \2,-(sp)        ; stack arg1
  71.         NOLIST
  72.     ENDC
  73. ; Now the actual printf call itself, only if there is an argument string
  74.     IFGE    NARG-1
  75. STKOFF    SET    NARG<<2                ; actual stack space used
  76.     XREF    _printf                ; in case not used before
  77.         LIST
  78.         pea.l    str\@            ; push string address
  79.         jsr    _printf            ; call printf function
  80.         lea.l    STKOFF(sp),sp        ; scrap stuff on stack
  81.         NOLIST
  82.         DATA                ; put in data section
  83. str\@        dc.b    \1,0            ; the actual string
  84.         CNOP    0,2
  85.         CODE                ; change this for other sects
  86.     ENDC
  87.     LIST
  88.     ENDC                    ; end DEBUG_CODE conditional
  89.     ENDM
  90.  
  91. ;===========================================================================
  92. ; MACRO to enable all of the debug routines.  If not called, no extra code.
  93. ;===========================================================================
  94.  
  95. DEBUGENABLE    MACRO
  96. DEBUG_CODE    SET    1
  97.         ENDM
  98.