home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quake_src / commonppc.s < prev    next >
Encoding:
Text File  |  2000-06-17  |  1.7 KB  |  96 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. ## commonPPC.s
  16. ##
  17. ## PPC assembler implementations of several functions in common.c
  18. ##
  19.  
  20. .include    "macrosPPC.i"
  21.  
  22.  
  23. # void Q_memcpy (void *dest, void *src, int count)
  24.  
  25.     funcdef    Q_memcpy
  26.  
  27.     mr.    r5,r5
  28.     or    r0,r3,r4
  29.     or    r0,r0,r5
  30.     beqlr
  31.     andi.   r0,r0,3
  32.     bne     bytecopy
  33.     srawi   r5,r5,2
  34.     subi    r3,r3,4
  35.     subi    r4,r4,4
  36.     mtctr   r5
  37. loop:
  38.     lwzu    r0,4(r4)
  39.     stwu    r0,4(r3)
  40.     bdnz    loop
  41.     blr
  42. bytecopy:
  43.     subi    r3,r3,1
  44.     subi    r4,r4,1
  45.     mtctr   r5
  46. loop2:
  47.     lbzu    r0,1(r4)
  48.     stbu    r0,1(r3)
  49.     bdnz    loop2
  50.     blr
  51.  
  52.  
  53. # short ShortSwap (short l)
  54. #       swap word (LE->BE)
  55.  
  56.     funcdef    ShortSwap
  57.  
  58.     extrwi    r0,r3,8,16
  59.     insrwi    r0,r3,8,16
  60.     extsh    r3,r0
  61.     blr
  62.  
  63.  
  64. # int LongSwap (int l)
  65. #     swap longword (LE->BE)
  66.  
  67.     funcdef    LongSwap
  68.  
  69.     extrwi    r0,r3,8,0
  70.     rlwimi    r0,r3,24,16,23
  71.     rlwimi    r0,r3,8,8,15
  72.     insrwi    r0,r3,8,0
  73.     mr    r3,r0
  74.     blr
  75.  
  76.  
  77. # float FloatSwap (float f)
  78. #       swap float (LE->BE)
  79.  
  80.     funcdef    FloatSwap
  81.  
  82.     stwu    r1,-32(r1)
  83.     stfs    f1,24(r1)
  84.     lwz    r3,24(r1)
  85.     li    r0,24
  86.     stwbrx    r3,r1,r0
  87.     lfs    f1,24(r1)
  88.     addi    r1,r1,32
  89.     blr
  90.