1#------------------------------------------------------------------------------
2#
3# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
4# This program and the accompanying materials are licensed and made available
5# under the terms and conditions of the BSD License which accompanies this
6# distribution.  The full text of the license may be found at
7# http://opensource.org/licenses/bsd-license.php.
8#
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11#
12# Module Name:
13#
14#   MathRShiftU64.S
15#
16# Abstract:
17#
18#   64-bit Math Worker Function.
19#   Shifts a 64-bit unsigned value right by a certain number of bits.
20#
21#------------------------------------------------------------------------------
22
23
24    .686:
25    .code:
26
27ASM_GLOBAL ASM_PFX(__ashrdi3)
28
29#------------------------------------------------------------------------------
30#
31# void __cdecl __ashrdi3 (void)
32#
33#------------------------------------------------------------------------------
34ASM_PFX(__ashrdi3):
35    #
36    # Checking: Only handle 64bit shifting or more
37    #
38    cmpb    $64, %cl
39    jae     _Exit
40
41    #
42    # Handle shifting between 0 and 31 bits
43    #
44    cmpb    $32, %cl
45    jae     More32
46    shrd    %cl, %edx, %eax
47    shr     %cl, %edx
48    ret
49
50    #
51    # Handle shifting of 32-63 bits
52    #
53More32:
54    movl    %edx, %eax
55    xor     %edx, %edx
56    and     $32, %cl
57    shr     %cl, %eax
58    ret
59
60    #
61    # Invalid number (less then 32bits), return 0
62    #
63_Exit:
64    xor     %eax, %eax
65    xor     %edx, %edx
66    ret
67