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.

91 lines
1.7 KiB

  1. title llshr - long shift right
  2. ;***
  3. ;llshr.asm - long shift right
  4. ;
  5. ; Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  6. ;
  7. ;Purpose:
  8. ; define signed long shift right routine
  9. ; __allshr
  10. ;
  11. ;Revision History:
  12. ; 11-??-83 HS initial version
  13. ; 11-30-83 DFW added medium model support
  14. ; 03-12-84 DFW broke apart; added long model support
  15. ; 06-01-84 RN modified to use cmacros
  16. ; 11-28-89 GJF Fixed copyright
  17. ; 11-19-93 SMK Modified to work on 64 bit integers
  18. ; 01-17-94 GJF Minor changes to build with NT's masm386.
  19. ; 07-08-94 GJF Faster, fatter version for NT.
  20. ; 07-13-94 GJF Further improvements from JonM.
  21. ;
  22. ;*******************************************************************************
  23. .xlist
  24. include cruntime.inc
  25. include mm.inc
  26. .list
  27. ;***
  28. ;llshr - long shift right
  29. ;
  30. ;Purpose:
  31. ; Does a signed Long Shift Right
  32. ; Shifts a long right any number of bits.
  33. ;
  34. ;Entry:
  35. ; EDX:EAX - long value to be shifted
  36. ; CL - number of bits to shift by
  37. ;
  38. ;Exit:
  39. ; EDX:EAX - shifted value
  40. ;
  41. ;Uses:
  42. ; CL is destroyed.
  43. ;
  44. ;Exceptions:
  45. ;
  46. ;*******************************************************************************
  47. CODESEG
  48. _allshr PROC NEAR
  49. ;
  50. ; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
  51. ; depends only on the high order bit of edx).
  52. ;
  53. cmp cl,64
  54. jae short RETSIGN
  55. ;
  56. ; Handle shifts of between 0 and 31 bits
  57. ;
  58. cmp cl, 32
  59. jae short MORE32
  60. shrd eax,edx,cl
  61. sar edx,cl
  62. ret
  63. ;
  64. ; Handle shifts of between 32 and 63 bits
  65. ;
  66. MORE32:
  67. mov eax,edx
  68. sar edx,31
  69. and cl,31
  70. sar eax,cl
  71. ret
  72. ;
  73. ; Return double precision 0 or -1, depending on the sign of edx
  74. ;
  75. RETSIGN:
  76. sar edx,31
  77. mov eax,edx
  78. ret
  79. _allshr ENDP
  80. end