home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / uccs / root.14 / udk / usr / ccs / lib / intrinsics < prev    next >
Encoding:
Text File  |  1998-08-19  |  2.7 KB  |  213 lines

  1. #ident    "@(#)cg:i386/intrinsics    1.17"
  2.  
  3.  
  4. function alloca(x)::x86
  5. {
  6. % mem x
  7. /ALLOCA
  8.     movl    %esp,%ecx
  9.      subl    x,%esp
  10.     andl    $0xfffffffc,%esp
  11.     movl    %esp,%eax
  12.     pushl    8(%ecx)
  13.     pushl    4(%ecx)
  14.     pushl    (%ecx)
  15. }
  16. function memcpy(x,y,z)::x86
  17. {
  18. % con z==4; mem x,y
  19.     movl    x,%eax
  20.     movl    y,%ecx
  21.     movl    (%ecx), %edx
  22.     movl    %edx, (%eax)
  23. }
  24. function memset(x,y,z)::x86
  25. {
  26. % con y(v),z==4; mem x; lab t
  27. # Mask off the low order byte of y and replicate it into all four
  28. # bytes of a full word.
  29.     .set     t,[v&0xff]
  30.     .set    t,t|[t<<8]|[t<<16]|[t<<24]
  31.     movl    x, %eax
  32.     movl    $t,(%eax)
  33. % con y(v),z==8; mem x; lab t
  34.     .set     t,[v&0xff]
  35.     .set    t,t|[t<<8]|[t<<16]|[t<<24]
  36.     movl    x, %eax
  37.     movl    $4, %ecx
  38.     movl    $t, (%eax)
  39.     addl    %eax, %ecx
  40.     movl    $t, (%ecx)
  41. % con y(v),z!%4; mem x; lab t
  42.     .set     t,[v&0xff]
  43.     .set    t,t|[t<<8]|[t<<16]|[t<<24]
  44. /INTRINSIC
  45.     movl    %edi,%edx
  46.     movl    z, %ecx
  47.     movl    $t,%eax
  48.     movl    x, %edi
  49.     shrl    $0x2,%ecx
  50.     rep;    sstol 
  51.     movl    %edx,%edi
  52.     movl    x, %eax
  53. /INTRINSICEND
  54. % con z<16; mem x,y
  55. /INTRINSIC
  56.     movl    %edi,%edx
  57.     movl    z, %ecx
  58.     movl    y,%eax
  59.     movl    x, %edi
  60.     rep;    sstob
  61.     movl    %edx,%edi
  62.     movl    x, %eax
  63. /INTRINSICEND
  64. % con y(v); mem x; ureg z; lab t, l
  65.     .set     t,[v&0xff]
  66.     .set    t,t|[t<<8]|[t<<16]|[t<<24]
  67. /INTRINSIC
  68.     movl    %edi,%edx
  69.     movl    z, %ecx
  70.     movl    $t,%eax
  71.     movl    x, %edi
  72.     shrl    $0x2,%ecx
  73.     rep;    sstol 
  74.     movl    %edi,%ecx
  75.     movl    %edx,%edi
  76.     movl    z,%edi
  77.     xchgl    %edi,%ecx
  78.     andl    $3,%ecx
  79.     je    l
  80.     rep;    sstob
  81. l:
  82.     movl    %edx,%edi
  83.     movl    x, %eax
  84. /INTRINSICEND
  85. % con y(v); mem x,z; lab t, l
  86.     .set     t,[v&0xff]
  87.     .set    t,t|[t<<8]|[t<<16]|[t<<24]
  88. /INTRINSIC
  89.     movl    %edi,%edx
  90.     movl    z, %ecx
  91.     movl    $t,%eax
  92.     movl    x, %edi
  93.     shrl    $0x2,%ecx
  94.     rep;    sstol 
  95.     movl    z,%ecx
  96.     andl    $3,%ecx
  97.     je    l
  98.     rep;    sstob
  99. l:
  100.     movl    %edx,%edi
  101.     movl    x, %eax
  102. /INTRINSICEND
  103. }    
  104. # function abs is valid for all x86 processors in all modes 
  105. #
  106. function abs(x)::x86
  107. {
  108. % con x<0
  109.     movl    x,%eax
  110.     negl    %eax
  111. % con x>=0
  112.     movl    x,%eax
  113. % reg x; lab y
  114.     movl x,%eax
  115.     testl %eax,%eax
  116.     jns  y
  117.     negl %eax
  118. y:
  119. % mem x; lab z
  120.     movl x,%eax
  121.     testl %eax,%eax
  122.     jns  z
  123.     negl %eax
  124. z:
  125. }
  126. function fabs(x):noieee:x86
  127. {
  128. %reg x
  129.     fabs
  130. %mem x
  131.     fldl x
  132.     fabs
  133. }
  134. #
  135. #
  136. function sqrt(x):noieee:x86
  137. {
  138. %reg x
  139.     fsqrt
  140. %mem x
  141.     fldl x
  142.     fsqrt
  143. }
  144. #
  145. #
  146. function exp(x):noieee:x86
  147. {
  148. %reg x
  149.     fldl
  150.     fld1    
  151.     fldl2e    
  152.     fmul    %st(2),%st
  153.     fst    %st(2)
  154.     fprem    
  155.     f2xm1    
  156.     fadd    
  157.     fscale    
  158.     fstp    %st(1)
  159. %mem x
  160.     fldl    x
  161.     fld1    
  162.     fldl2e    
  163.     fmul    %st(2),%st
  164.     fst    %st(2)
  165.     fprem    
  166.     f2xm1    
  167.     fadd    
  168.     fscale    
  169.     fstp    %st(1)
  170. }
  171. function log(x):noieee:x86
  172. {
  173. %reg x
  174.         fldln2
  175.         fldl   
  176.         fyl2x
  177. %mem x
  178.         fldln2
  179.         fldl    x
  180.         fyl2x
  181. }
  182. #
  183. # Following Trignometric functions valid on all x86 processors only in noieee
  184. #
  185. function atan(x):noieee:x86
  186. {
  187. %reg x
  188.         fldl
  189.         fld1
  190.         fpatan
  191. %mem x
  192.         fldl    x
  193.         fld1
  194.         fpatan
  195. }
  196. function cos(x):noieee:x86
  197. {
  198. %reg x
  199.     fcos
  200. %mem x
  201.     fldl x
  202.     fcos
  203. }
  204.  
  205. function sin(x):noieee:x86
  206. {
  207. %reg x
  208.     fsin
  209. %mem x
  210.     fldl x
  211.     fsin
  212. }
  213.