home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / inc&ad2.0 / includes / exec / macros.i < prev    next >
Text File  |  1992-09-01  |  3KB  |  157 lines

  1.     IFND    EXEC_MACROS_I
  2. EXEC_MACROS_I     SET     1
  3. **
  4. **    $Filename: exec/macros.i $
  5. **    $Release: 2.04 Includes, V37.4 $
  6. **    $Revision: 36.8 $
  7. **    $Date: 90/11/01 $
  8. **
  9. **    Handy macros for assembly language programmers.
  10. **
  11. **    (C) Copyright 1985-1991 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. **
  14.  
  15.         IFND    DEBUG_DETAIL
  16. DEBUG_DETAIL    SET    0    ;Detail level of debugging.  Zero for none.
  17.         ENDC
  18.  
  19.  
  20. JSRLIB        MACRO    ;FunctionName
  21.         XREF    _LVO\1
  22.         jsr    _LVO\1(a6)
  23.         ENDM
  24.  
  25. JMPLIB        MACRO    ;FunctionName
  26.         XREF    _LVO\1
  27.         jmp    _LVO\1(a6)
  28.         ENDM
  29.  
  30. BSRSELF    MACRO
  31.         XREF    \1
  32.         bsr    \1
  33.         ENDM
  34.  
  35. BRASELF    MACRO
  36.         XREF    \1
  37.         bra    \1
  38.         ENDM
  39.  
  40. BLINK        MACRO
  41.         IFNE    DEBUG_DETAIL
  42.           bchg.b #1,$bfe001  ;Toggle the power LED
  43.         ENDC
  44.         ENDM
  45.  
  46. TRIGGER        MACRO    ;<level> Trigger a hardware state analyzer
  47.         IFGE    DEBUG_DETAIL-\1
  48.           move.w #$5555,$2fe
  49.         ENDC
  50.         ENDM
  51.  
  52. CLEAR        MACRO
  53.         moveq.l #0,\1
  54.         ENDM
  55.  
  56. CLEARA        MACRO
  57.         suba.l    \1,\1    ;Quick way to put zero in an address register
  58.         ENDM
  59.  
  60. *************************************************************************
  61.         IFND    PRINTF
  62. PRINTF        MACRO    ; level,<string>,...
  63.         IFGE    DEBUG_DETAIL-\1
  64.         XREF    kprint_macro
  65. PUSHCOUNT    SET    0
  66.  
  67.         IFNC    '\9',''
  68.         move.l    \9,-(sp)
  69. PUSHCOUNT    SET    PUSHCOUNT+4
  70.         ENDC
  71.  
  72.         IFNC    '\8',''
  73.         move.l    \8,-(sp)
  74. PUSHCOUNT    SET    PUSHCOUNT+4
  75.         ENDC
  76.  
  77.         IFNC    '\7',''
  78.         move.l    \7,-(sp)
  79. PUSHCOUNT    SET    PUSHCOUNT+4
  80.         ENDC
  81.  
  82.         IFNC    '\6',''
  83.         move.l    \6,-(sp)
  84. PUSHCOUNT    SET    PUSHCOUNT+4
  85.         ENDC
  86.  
  87.         IFNC    '\5',''
  88.         move.l    \5,-(sp)
  89. PUSHCOUNT    SET    PUSHCOUNT+4
  90.         ENDC
  91.  
  92.         IFNC    '\4',''
  93.         move.l    \4,-(sp)
  94. PUSHCOUNT    SET    PUSHCOUNT+4
  95.         ENDC
  96.  
  97.         IFNC    '\3',''
  98.         move.l    \3,-(sp)
  99. PUSHCOUNT    SET    PUSHCOUNT+4
  100.         ENDC
  101.  
  102.         movem.l a0/a1,-(sp)
  103.         lea.l    PSS\@(pc),A0
  104.         lea.l    4*2(SP),A1
  105.         BSR    kprint_macro
  106.         movem.l (sp)+,a0/a1
  107.         bra.s    PSE\@
  108.  
  109. PSS\@        dc.b    \2
  110.         IFEQ    (\1&1)    ;If even, add CR/LF par...
  111.            dc.b 13,10
  112.         ENDC
  113.         dc.b    0
  114.         ds.w    0
  115. PSE\@
  116.         lea.l    PUSHCOUNT(sp),sp
  117.         ENDC    ;IFGE    DEBUG_DETAIL-\1
  118.         ENDM    ;PRINTF    MACRO
  119.         ENDC    ;IFND    PRINTF
  120.  
  121.  
  122. ;----------------------------------------------------------------------------
  123. ;Push a set of registers onto the stack - undo with POPM.  This prevents
  124. ;the need to update or synchronize two MOVEM instructions.  These macros
  125. ;assume an optimizing assembler that will convert single register  MOVEM
  126. ;to MOVE.  Because the REG assignment can't be reset, these macros do
  127. ;not nest.
  128. ;
  129. ;        PUSHM   d2/a2/a5
  130. ;        ...code...
  131. ;        POPM
  132. ;        RTS
  133. ;
  134. PUSHM_COUNT            SET    0
  135. PUSHM                MACRO
  136.                 IFGT    NARG-1
  137.                 FAIL    !!!! TOO MANY ARGUMENTS TO PUSHM !!!!
  138.                 ENDC
  139. PUSHM_COUNT            SET    PUSHM_COUNT+1
  140. PUSHM_\*VALOF(PUSHM_COUNT)      REG     \1
  141.                 movem.l PUSHM_\*VALOF(PUSHM_COUNT),-(sp)
  142.                 ENDM
  143.  
  144. ;
  145. ;Undo most recent PUSHM.  'POPM NOBUMP' allows multiple exit points.
  146. ;
  147. POPM                MACRO
  148.                 movem.l (sp)+,PUSHM_\*VALOF(PUSHM_COUNT)
  149.                 IFNC    '\1','NOBUMP'
  150. PUSHM_COUNT            SET    PUSHM_COUNT+1    ;error if re-used
  151.                 ENDC
  152.                 ENDM
  153. ;----------------------------------------------------------------------------
  154.  
  155.  
  156.     ENDC    ; EXEC_MACROS_I
  157.