home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / glquake_src / macrosppc.i < prev    next >
Text File  |  2000-01-07  |  4KB  |  238 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. .endm
  137.  
  138. .macro    lab    # label definition
  139. \1:
  140. .endm
  141.  
  142. .macro    init    # init stack frame: nParams,localSize,nGPR,nFPR
  143. .set    param,    8
  144. .set    local,    8+(\1*4)
  145. .set    save14,    (local+\2+3)&~3
  146. .set    gb,    save14+4
  147. .set    fb,    (gb+\3*4+7)&~7
  148. .set    sfsize,    (fb+\4*8+15)&~15
  149. .ifndef    NOLR
  150.     mflr    r0
  151.     stw    r0,4(r1)
  152. .endif
  153.     stwu    r1,-sfsize(r1)
  154.     stw    r14,save14(r1)
  155. .endm
  156.  
  157. .macro    exit    # free stack frame and return
  158.     lwz    r14,save14(r1)
  159.     addi    r1,r1,sfsize
  160. .ifndef    NOLR
  161.     lwz    r0,4(r1)
  162.     mtlr    r0
  163. .endif
  164.     blr
  165. .endm
  166.  
  167. .macro    funcend    # set function type and size
  168.         .type   \1,@function
  169.         .size   \1,$-\1
  170. .endm
  171.  
  172. .ifndef    NOLR
  173. .macro    call    # call sub routine
  174.     bl    \1
  175. .endm
  176.  
  177. .macro    mcall    # call math subroutine
  178.     bl    \1
  179. .endm
  180. .endif
  181.  
  182. .macro    lxa    # load external object's address
  183.     lis    \1,\2@ha
  184.     addi    \1,\1,\2@l
  185. .endm
  186.  
  187. .macro    lla    # load local object's address
  188.     lis    \1,\2@ha
  189.     addi    \1,\1,\2@l
  190. .endm
  191.  
  192. .macro    lw    # load word
  193.     lis    r14,\2@ha
  194.     lwz    \1,\2@l(r14)
  195. .endm
  196.  
  197. .macro    sw    # store word
  198.     lis    r14,\2@ha
  199.     stw    \1,\2@l(r14)
  200. .endm
  201.  
  202. .macro    lf    # load double float
  203.     lis    r14,\2@ha
  204.     lfd    \1,\2@l(r14)
  205. .endm
  206.  
  207. .macro    ls    # load single float
  208.     lis    r14,\2@ha
  209.     lfs    \1,\2@l(r14)
  210. .endm
  211.  
  212. .macro    ss    # store single float
  213.     lis    r14,\2@ha
  214.     stfs    \1,\2@l(r14)
  215. .endm
  216.  
  217. .endif
  218.  
  219.  
  220. #
  221. # ABI-independant macros
  222. #
  223.  
  224. # int2dbl: Convert Signed Integer to Double Precision Floating Point
  225. .macro    int2dbl    # destFPR,srcGPR,trash,
  226.         # StkFrameOffs=0x4330000000000000,FPR=0x4330000080000000
  227.     xoris    \3,\2,0x8000
  228.     stw    \3,\4+4(r1)
  229.     lfd    \1,\4(r1)
  230.     fsub    \1,\1,\5
  231. .endm
  232.