Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
730 B

  1. title pow2 - Danny's cheapo pow function
  2. ;***
  3. ;pow2.asm - compute 2 to the power of something
  4. ;
  5. ; Copyright (c) 1985-88, Microsoft Corporation
  6. ;
  7. ;Purpose:
  8. ;
  9. ;*******************************************************************************
  10. .xlist
  11. include cruntime.inc
  12. .list
  13. CODESEG
  14. pow2 proto stdcall, orig:qword
  15. public pow2
  16. pow2 proc stdcall, orig:qword
  17. fld orig
  18. fst st(1) ; duplicate orig
  19. frndint ; I don't care how it rounds
  20. fstp st(2) ; st=orig st(1)=round
  21. fsub st, st(1) ; st=orig-round
  22. f2xm1 ; st=2^(orig-round)-1
  23. fld1
  24. faddp st(1), st ; st=2^(orig-round)
  25. fscale ; st=2^(orig-round)*2^round=2^orig
  26. fstp st(1) ; clean stack of st(1)
  27. ret
  28. pow2 endp
  29. end