home *** CD-ROM | disk | FTP | other *** search
/ Total Destruction / Total_Destruction.iso / addons / Lccwin32.exe / Lccwin32 / lccpub / demo / intrinsic / intrinsic.c next >
Encoding:
C/C++ Source or Header  |  1997-04-27  |  945 b   |  44 lines

  1. #include <stdio.h>
  2. #include <intrinsics.h>
  3. /*
  4.     Examples for using the intrinsics of lcc-win32.
  5. */
  6. int main()
  7. {
  8.     double arg,sin,cos;
  9.     char *p="abcd";
  10.     long l;
  11.     int i1,i2,i3,c;
  12.  
  13.     /* _fsincos returns the sin and stores the cosinus at the
  14.        given address
  15.     */
  16.     arg = 0.5;
  17.     sin = _fsincos(arg,&cos);
  18.     printf("sin(0.5)=%g,cos(0.5)=%g\n",sin,cos);
  19.  
  20.     /* bswap instruction */
  21.     l = _bswap(*(long *)p);
  22.     *(unsigned long *)p = l;
  23.     printf("byte swap of 'abcd'=%s\n",p);
  24.  
  25.     /* rounding a floating point number with _fistp */
  26.     printf("rounding cos(0.5)=%d\n",_fistp(cos));
  27.  
  28.     /* built in constants of the fpu */
  29.     printf("Pi=%4.15f\n",_fldpi());
  30.     printf("e^2=%4.15f\n",_fldl2e());
  31.     printf("log(2)=%4.15f\n",_fldlg2());
  32.     printf("ln(2)=%4.15f\n",_fldln2());
  33.  
  34.     /* carry flag */
  35.     c = _carry();
  36.     printf("carry before=%d\n",c);
  37.     i2 = 48765456L;
  38.     i1 = 83654098L;
  39.     i3 = i2*i1;
  40.     c = _carry();
  41.     printf("carry after=%d\n",c);
  42.     
  43. }
  44.