]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/CRT/Ia32/llshr.c
StdLib: Add a runtime helper function for VC++ 64-bit right shift on Ia32 target...
[mirror_edk2.git] / StdLib / LibC / CRT / Ia32 / llshr.c
1 /** @file
2 64-bit Math Worker Function.
3 The 32-bit versions of C compiler generate calls to library routines
4 to handle 64-bit math. These functions use non-standard calling conventions.
5
6 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17
18 /*
19 * Shifts a 64-bit signed value right by a particular number of bits.
20 */
21 __declspec(naked) void __cdecl _allshr (void)
22 {
23 _asm {
24 ;
25 ; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
26 ; depends only on the high order bit of edx).
27 ;
28 cmp cl,64
29 jae short SIGNRETURN
30
31 ;
32 ; Handle shifts of between 0 and 31 bits
33 ;
34 cmp cl, 32
35 jae short MORE32
36 shrd eax,edx,cl
37 sar edx,cl
38 ret
39
40 ;
41 ; Handle shifts of between 32 and 63 bits
42 ;
43 MORE32:
44 mov eax,edx
45 sar edx,31
46 and cl,31
47 sar eax,cl
48 ret
49
50 ;
51 ; Return double precision 0 or -1, depending on the sign of edx
52 ;
53 SIGNRETURN:
54 sar edx,31
55 mov eax,edx
56 ret
57 }
58 }