home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / RAND / UNSPLIT / BM214SRC.ZIP / 68030 / INCLUDE / MACROS.S < prev    next >
Encoding:
Text File  |  1996-06-22  |  4.5 KB  |  290 lines

  1. *=======================================================*
  2. *    Macros: [update 11/02/96]            *
  3. *=======================================================*
  4.  
  5. alignment        =    2
  6.  
  7. *-------------------------------------------------------*
  8. *    Stack management                *
  9. *-------------------------------------------------------*
  10.  
  11. push    macro
  12.     move.\0        \1,-(sp)
  13.     endm
  14.  
  15. pop    macro
  16.     move.\0        (sp)+,\1
  17.     endm
  18.  
  19. pushall    macro
  20.     movem.l        d0-a6,-(sp)
  21.     endm
  22.  
  23. popall    macro
  24.     movem.l        (sp)+,d0-a6
  25.     endm
  26.  
  27. align    macro
  28. .o\@    =        *
  29.     ds.b        (alignment-((.o\@)&(alignment-1)))&(alignment-1)
  30.     endm
  31.  
  32. txtlong    macro
  33.     text
  34.     align        text_start
  35.     endm
  36.  
  37. bsslong    macro
  38.     bss
  39.     align        bss_start
  40.     endm
  41.  
  42. datlong    macro
  43.     data
  44.     align        data_start
  45.     endm
  46.  
  47. fixcase    macro
  48.     cmp.b        #'A',\1
  49.     blo.s        .no\@
  50.     cmp.b        #'Z',\1
  51.     bhi.s        .no\@
  52.     and.w        #$FF,\1
  53.     add.w        #'a'-'A',\1
  54. .no\@:    
  55.     endm    
  56.  
  57. *-------------------------------------------------------*
  58. *    DSP communications                *
  59. *-------------------------------------------------------*
  60.  
  61. dspexec    macro
  62.     moveq        #1,d1
  63.     move.l        #(\1_e-\1)/3,d0
  64.     lea        \1,a0
  65.     jsr        DspExecProg
  66.     endm
  67.  
  68. dspwaitwrite        macro
  69.     ifge        (compat_level-\0)
  70.     ifeq        NARG
  71. .ww\@:    btst        #1,$FFFFA202.w
  72.     beq.s        .ww\@
  73.     elseif    
  74. .ww\@:    btst        #1,\1
  75.     beq.s        .ww\@
  76.     endc
  77.     endc
  78.     endm
  79.  
  80. dspwaitread        macro
  81.     ifge        (compat_level-\0)
  82.     ifeq        NARG
  83. .wr\@:    btst        #0,$FFFFA202.w
  84.     beq.s        .wr\@
  85.     elseif    
  86. .ww\@:    btst        #0,\1
  87.     beq.s        .ww\@
  88.     endc
  89.     endc
  90.     endm
  91.  
  92. dspwrite        macro
  93.     ifeq        '\0'-'r'
  94.     move.l        \1,d0
  95.     dspwaitwrite.0    \2
  96.     move.w        d0,$FFFFA206.w
  97.     swap        d0
  98.     dspwaitwrite.0    \2
  99.     move.w        d0,$FFFFA206.w
  100.     elseif
  101.     dspwaitwrite.0
  102.     ifeq        '\0'-'w'
  103.     move.w        \1,$FFFFA206.w
  104.     elseif
  105.     ifeq        '\0'-'l'
  106.     move.l        \1,$FFFFA204.w
  107.     elseif
  108.     ifeq        '\0'-'b'
  109.     move.b        \1,$FFFFA207.w
  110.     endc
  111.     endc
  112.     endc
  113.     endc
  114.     endm
  115.  
  116. dspread            macro
  117.     ifeq        '\0'-'r'
  118.     elseif
  119.     dspwaitread.0
  120.     ifeq        '\0'-'w'
  121.     move.w        $FFFFA206.w,\1
  122.     elseif
  123.     ifeq        '\0'-'l'
  124.     move.l        $FFFFA204.w,\1
  125.     elseif
  126.     ifeq        '\0'-'b'
  127.     move.b        $FFFFA207.w,\1
  128.     endc
  129.     endc
  130.     endc
  131.     endc
  132.     endm
  133.  
  134. *-------------------------------------------------------*
  135. *    Display management                 *
  136. *-------------------------------------------------------*
  137.  
  138. vsync    macro
  139. .wv\@:    tst.w        timer
  140.     bne.s        .wv\@
  141.     move.w        #vbilock,timer
  142.     endm
  143.  
  144. doublebuffer        macro
  145.     lea        screen_ptrs,a0
  146.     move.l        (a0),d0
  147.     move.l        4(a0),(a0)
  148.     move.l        8(a0),4(a0)
  149.     move.l        d0,8(a0)
  150.     lsr.w        #8,d0
  151.     move.l        d0,$ffff8200.w
  152.     move.b        #0,$ffff820d.w
  153.     endm
  154.  
  155. *-------------------------------------------------------*
  156. *    Memory management                *
  157. *-------------------------------------------------------*
  158.  
  159. Malloc    macro
  160.  
  161.     move.l        \1,d0
  162.     bsr        allocate_chunk
  163.     tst.l        d0
  164.  
  165. ;    move.l        \1,d0
  166. ;    addq.l        #4-1,d0
  167. ;    and.l        #-4,d0
  168. ;    move.l        d0,-(sp)
  169. ;    move.w        #$48,-(sp)
  170. ;    trap        #1
  171. ;    addq.l        #6,sp
  172. ;    tst.l        d0
  173. ;    beq.s        .err\@
  174. ;    addq.l        #4-1,d0
  175. ;    and.l        #-4,d0
  176. ;.err\@:
  177.  
  178.     endm
  179.  
  180. Mxalloc    macro
  181.     move.l        \1,d0
  182.     addq.l        #4-1,d0
  183.     and.l        #-4,d0
  184.     move.w        #\2,-(sp)
  185.     move.l        d0,-(sp)
  186.     move.w        #68,-(sp)
  187.     trap        #1
  188.     addq.l        #8,sp
  189.     tst.l        d0
  190.     beq.s        .err\@
  191.     addq.l        #4-1,d0
  192.     and.l        #-4,d0
  193. .err\@:
  194.     endm
  195.  
  196.  
  197. Mfree    macro        address
  198.  
  199.     move.l        \1,d0
  200.     bsr        deallocate_chunk
  201.  
  202. ;    move.l        \1,-(sp)
  203. ;    move.w        #73,-(sp)
  204. ;    trap        #1
  205. ;    addq.l        #6,sp
  206.  
  207.     endm
  208.  
  209. *-------------------------------------------------------*
  210. *    Processor format operations            *
  211. *-------------------------------------------------------*
  212.  
  213. imov    macro
  214.     ifeq        '\0'-'l'
  215.     move.l        \1,d0
  216.     ror.w        #8,d0
  217.     swap        d0
  218.     ror.w        #8,d0
  219.     move.l        d0,\2
  220.     elseif
  221.     ifeq        '\0'-'w'
  222.     move.w        \1,d0
  223.     ror.w        #8,d0
  224.     move.w        d0,\2
  225.     elseif
  226.     move.b        \1,\2
  227.     endc
  228.     endc
  229.     endm
  230.  
  231. *-------------------------------------------------------*
  232. *    I/O macros                    *
  233. *-------------------------------------------------------*
  234.  
  235. Cconout    macro        char
  236.     move.w        \1,-(sp)
  237.     move.w        #2,-(sp)
  238.     trap        #1
  239.     addq.l        #4,sp
  240.     endm
  241.  
  242. Crawcin    macro
  243.     move.w        #7,-(sp)
  244.     trap        #1
  245.     addq.l        #2,sp
  246.     endm
  247.         
  248. Cconws    macro        string
  249.     move.l        \1,-(sp)
  250.     move.w        #9,-(sp)
  251.     trap        #1
  252.     addq.l        #6,sp
  253.     endm
  254.  
  255. Fopen    macro        fname,mode
  256.     move.w        \2,-(sp)
  257.     move.l        \1,-(sp)
  258.     move.w        #61,-(sp)
  259.     trap        #1
  260.     addq.l        #8,sp
  261.     tst.w        d0
  262.     endm
  263.  
  264. Fclose    macro        handle
  265.     move.w        \1,-(sp)
  266.     move.w        #62,-(sp)
  267.     trap        #1
  268.     addq.l        #4,sp
  269.     endm
  270.  
  271. Fread    macro        handle,count,buffer
  272.     move.l        \3,-(sp)
  273.     move.l        \2,-(sp)
  274.     move.w        \1,-(sp)
  275.     move.w        #63,-(sp)
  276.     trap        #1
  277.     lea        12(sp),sp
  278.     endm
  279.  
  280. Fseek    macro        offset,handle,seekmode
  281.     move.w        \3,-(sp)
  282.     move.w        \2,-(sp)
  283.     move.l        \1,-(sp)
  284.     move.w        #66,-(sp)
  285.     trap        #1
  286.     lea        10(sp),sp
  287.     endm
  288.  
  289. *-------------------------------------------------------*
  290.