home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d528 / keymenu.lha / KeyMenu / src.lzh / macros.i < prev    next >
Text File  |  1991-08-03  |  3KB  |  93 lines

  1. *-----------------------------------------------------------------------*
  2. *   INTUITIONNAME - defines intuition library name                      *
  3. *-----------------------------------------------------------------------*
  4.  
  5. INTUITIONNAME macro
  6.             dc.b    'intuition.library',0
  7.             endm
  8.  
  9. *-----------------------------------------------------------------------*
  10. *   LIBCALL - adds the _LVO prefix to the routine name                  *
  11. *-----------------------------------------------------------------------*
  12.  
  13. libcall     macro   * functionoffset
  14.             jsr     _LVO\1(a6)
  15.             endm
  16.  
  17. *-----------------------------------------------------------------------*
  18. *   LIBLINK - saves a6, sets a6 up with libbase, restores a6 after call *
  19. *-----------------------------------------------------------------------*
  20.  
  21. liblink     macro   * functionoffset,librarybase
  22.             ifgt    narg-2
  23.             fail                            ; too many arguments
  24.             endc
  25.             move.l  a6,-(sp)
  26.             move.l  %2,a6
  27.             libcall %1
  28.             move.l  (sp)+,a6
  29.             endm
  30.  
  31. *-----------------------------------------------------------------------*
  32. *   CALL - calls LIBCALL or LIBLINK and generates xref if necessary     *
  33. *-----------------------------------------------------------------------*
  34. Call        macro   * functionname,libraryname
  35.             ifnd    EXTERN_%1
  36. EXTERN_%1   set     1
  37.             extern_lib  %1
  38.             endc
  39.             ifc     '%2',''
  40.             libcall %1
  41.             endc
  42.             ifnc    '%2',''
  43.             liblink %1,%2
  44.             endc
  45.             endm
  46.             
  47. *-----------------------------------------------------------------------*
  48. *   BITNUM - converts a binary value to its bitnumber                   *
  49. *            value must be a power of 2                                 *
  50. *-----------------------------------------------------------------------*
  51. BITNUM      macro   * name,value
  52. bitpos      set     0
  53. value       set     %2    
  54.             ifgt    value-128
  55. bitpos      set     8
  56. value       set     value>>8
  57.             endc
  58.             ifgt    value-128
  59. bitpos      set     bitpos+8
  60. value       set     value>>8
  61.             endc
  62.             ifgt    value-128
  63. bitpos      set     bitpos+8
  64. value       set     value>>8
  65.             endc
  66.             ifeq    value-128
  67. bitpos      set     bitpos+8
  68.             endc
  69.             ifeq    value-64
  70. bitpos      set     bitpos+7
  71.             endc
  72.             ifeq    value-32
  73. bitpos      set     bitpos+6
  74.             endc
  75.             ifeq    value-16
  76. bitpos      set     bitpos+5
  77.             endc
  78.             ifeq    value-8
  79. bitpos      set     bitpos+4
  80.             endc
  81.             ifeq    value-4
  82. bitpos      set     bitpos+3
  83.             endc
  84.             ifeq    value-2
  85. bitpos      set     bitpos+2
  86.             endc
  87.             ifeq    value-1
  88. bitpos      set     bitpos+1
  89.             endc
  90. %1_B        equ     bitpos-1        ; for bxxx.l instructions
  91. %1_R        equ     (bitpos-1)//8   ; for bxxx.b instructions
  92.             endm
  93.