home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quake_src / macrosppc.i < prev    next >
Text File  |  2000-06-17  |  4KB  |  241 lines

  1. # Copyright (C) 1996-1997 Id Software, Inc. 
  2. # This program is free software; you can redistribute it and/or 
  3. # modify it under the terms of the GNU General Public License 
  4. # as published by the Free Software Foundation; either version 2 
  5. # of the License, or (at your option) any later version. 
  6. # This program is distributed in the hope that it will be useful, 
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of 
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   
  9. # See the GNU General Public License for more details. 
  10. # You should have received a copy of the GNU General Public License 
  11. # along with this program; if not, write to the Free Software 
  12. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
  13.  
  14. ##
  15. ## Quake for AMIGA
  16. ##
  17. ## macrosPPC.i
  18. ##
  19. ## Macros used in all PPC assembler sources of Quake.
  20. ## Define WOS for WarpOS/PowerOpen ABI, otherwise code for
  21. ## PowerUp/SVR4 will be generated.
  22. ##
  23. ## Define NOLR, if the init/exit macros must not save/restore the LR.
  24. ##
  25.  
  26. # ABI-specific macros
  27.  
  28. .ifdef    WOS
  29. # WarpOS/PowerOpen
  30.  
  31. .macro    xrefv    # cross reference to an elementary data type
  32.     .extern    _\1
  33. .endm
  34.  
  35. .macro    xrefa    # cross reference to an object's address
  36.     .extern    @__\1
  37. .endm
  38.  
  39. .macro    funcdef    # global function definition
  40.     .text
  41.     .globl    _\1
  42.     .globl    _\1__r
  43. _\1:
  44. _\1__r:
  45. .endm
  46.  
  47. .macro    lab    # label definition
  48. _\1:
  49. .endm
  50.  
  51. .macro    init    # init stack frame: nParams,localSize,nGPR,nFPR
  52. .set    param,    24
  53. .set    local,    24+(\1*4)
  54. .set    gb,    (local+\2+3)&~3
  55. .set    fb,    (gb+\3*4+7)&~7
  56. .set    sfsize,    (fb+\4*8+15)&~15
  57. .ifndef    NOLR
  58.     mflr    r0
  59.     stw    r0,8(r1)
  60. .endif
  61.     stwu    r1,-sfsize(r1)
  62. .endm
  63.  
  64. .macro    exit    # free stack frame and return
  65.     addi    r1,r1,sfsize
  66. .ifndef    NOLR
  67.     lwz    r0,8(r1)
  68.     mtlr    r0
  69. .endif
  70.     blr
  71. .endm
  72.  
  73. .macro    funcend    # set function type and size
  74.         .type   _\1,@function
  75.         .size   _\1,$-_\1
  76. .endm
  77.  
  78. .ifndef    NOLR
  79. .macro    call    # call sub routine
  80.     bl    _\1
  81. .endm
  82.  
  83. .macro    mcall    # call math subroutine
  84. .ifdef    __STORM__
  85.     bl    _\1__r
  86. .else
  87.     bl    _\1
  88. .endif
  89. .endm
  90. .endif
  91.  
  92. .macro    lxa    # load external object's address
  93.     lwz    \1,@__\2(r2)
  94. .endm
  95.  
  96. .macro    lla    # load local object's address
  97.     la    \1,_\2(r2)
  98. .endm
  99.  
  100. .macro    lw    # load word
  101.     lwz    \1,_\2(r2)
  102. .endm
  103.  
  104. .macro    sw    # store word
  105.     stw    \1,_\2(r2)
  106. .endm
  107.  
  108. .macro    lf    # load double float
  109.     lfd    \1,_\2(r2)
  110. .endm
  111.  
  112. .macro    ls    # load single float
  113.     lfs    \1,_\2(r2)
  114. .endm
  115.  
  116. .macro    ss    # store single float
  117.     stfs    \1,_\2(r2)
  118. .endm
  119.  
  120.  
  121. .else
  122. # SVR4/ELF (PowerUp)
  123.  
  124. .macro    xrefv    # cross reference to an elementary data type
  125.     .extern    \1
  126. .endm
  127.  
  128. .macro    xrefa    # cross reference to an object's address
  129.     .extern    \1
  130. .endm
  131.  
  132. .macro    funcdef    # global function definition
  133.     .text
  134.     .globl    \1
  135. \1:
  136. .set    rtmp,    12    # r12 is default reg. for loading/storing data
  137. .endm
  138.  
  139. .macro    lab    # label definition
  140. \1:
  141. .endm
  142.  
  143. .macro    init    # init stack frame: nParams,localSize,nGPR,nFPR
  144. .set    param,    8
  145. .set    local,    8+(\1*4)
  146. .set    save14,    (local+\2+3)&~3
  147. .set    gb,    save14+4
  148. .set    fb,    (gb+\3*4+7)&~7
  149. .set    sfsize,    (fb+\4*8+15)&~15
  150. .ifndef    NOLR
  151.     mflr    r0
  152.     stw    r0,4(r1)
  153. .endif
  154.     stwu    r1,-sfsize(r1)
  155.     stw    r14,save14(r1)
  156. .set    rtmp,    14    # now we may use r14 for loading/storing data
  157. .endm
  158.  
  159. .macro    exit    # free stack frame and return
  160.     lwz    r14,save14(r1)
  161.     addi    r1,r1,sfsize
  162. .ifndef    NOLR
  163.     lwz    r0,4(r1)
  164.     mtlr    r0
  165. .endif
  166.     blr
  167. .set    rtmp,    12
  168. .endm
  169.  
  170. .macro    funcend    # set function type and size
  171.         .type   \1,@function
  172.         .size   \1,$-\1
  173. .endm
  174.  
  175. .ifndef    NOLR
  176. .macro    call    # call sub routine
  177.     bl    \1
  178. .endm
  179.  
  180. .macro    mcall    # call math subroutine
  181.     bl    \1
  182. .endm
  183. .endif
  184.  
  185. .macro    lxa    # load external object's address
  186.     lis    \1,\2@ha
  187.     addi    \1,\1,\2@l
  188. .endm
  189.  
  190. .macro    lla    # load local object's address
  191.     lis    \1,\2@ha
  192.     addi    \1,\1,\2@l
  193. .endm
  194.  
  195. .macro    lw    # load word
  196.     lis    rtmp,\2@ha
  197.     lwz    \1,\2@l(rtmp)
  198. .endm
  199.  
  200. .macro    sw    # store word
  201.     lis    rtmp,\2@ha
  202.     stw    \1,\2@l(rtmp)
  203. .endm
  204.  
  205. .macro    lf    # load double float
  206.     lis    rtmp,\2@ha
  207.     lfd    \1,\2@l(rtmp)
  208. .endm
  209.  
  210. .macro    ls    # load single float
  211.     lis    rtmp,\2@ha
  212.     lfs    \1,\2@l(rtmp)
  213. .endm
  214.  
  215. .macro    ss    # store single float
  216.     lis    rtmp,\2@ha
  217.     stfs    \1,\2@l(rtmp)
  218. .endm
  219.  
  220. .endif
  221.  
  222.  
  223. #
  224. # ABI-independant macros
  225. #
  226.  
  227. # int2dbl: Convert Signed Integer to Double Precision Floating Point
  228. .macro    int2dbl    # destFPR,srcGPR,trash,
  229.         # StkFrameOffs=0x4330000000000000,FPR=0x4330000080000000
  230.     xoris    \3,\2,0x8000
  231.     stw    \3,\4+4(r1)
  232.     lfd    \1,\4(r1)
  233.     fsub    \1,\1,\5
  234. .endm
  235.