]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.S
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / Ia32 / DivU64x64Remainder.S
CommitLineData
3f8f7fa5 1#------------------------------------------------------------------------------\r
2#\r
2c7e5c2f
HT
3# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4# This program and the accompanying materials\r
3f8f7fa5 5# are licensed and made available under the terms and conditions of the BSD License\r
6# which accompanies this distribution. The full text of the license may be found at\r
7# http://opensource.org/licenses/bsd-license.php\r
8#\r
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11#\r
12# Module Name:\r
13#\r
14# DivU64x64Remainder.asm\r
15#\r
16# Abstract:\r
17#\r
18# Calculate the quotient of a 64-bit integer by a 64-bit integer and returns\r
19# both the quotient and the remainder\r
20#\r
21#------------------------------------------------------------------------------\r
22\r
8ad319e5 23#include <EdkIIGlueBase.h>\r
24\r
3f8f7fa5 25.globl ASM_PFX(InternalMathDivRemU64x32), ASM_PFX(InternalMathDivRemU64x64)\r
26\r
27#------------------------------------------------------------------------------\r
28# UINT64\r
29# EFIAPI\r
30# InternalMathDivRemU64x64 (\r
31# IN UINT64 Dividend,\r
32# IN UINT64 Divisor,\r
33# OUT UINT64 *Remainder OPTIONAL\r
34# );\r
35#------------------------------------------------------------------------------\r
36ASM_PFX(InternalMathDivRemU64x64):\r
37 movl 16(%esp), %ecx\r
38 testl %ecx, %ecx\r
39 jnz Hard\r
40 movl 20(%esp), %ecx\r
41 jecxz L1\r
42 and $0, 4(%ecx)\r
43 movl %ecx, 16(%esp)\r
44L1:\r
45 jmp ASM_PFX(InternalMathDivRemU64x32)\r
46Hard:\r
47 push %ebx\r
48 push %esi\r
49 push %edi\r
50 mov 20(%esp), %edx\r
51 mov 16(%esp), %eax\r
52 movl %edx, %edi\r
53 movl %eax, %esi\r
54 mov 24(%esp), %ebx\r
55L2:\r
56 shrl %edx\r
57 rcrl $1, %eax\r
58 shrdl $1, %ecx, %ebx\r
59 shrl %ecx\r
60 jnz L2\r
61 divl %ebx\r
62 movl %eax, %ebx\r
63 movl 28(%esp), %ecx\r
64 mull 24(%esp)\r
65 imull %ebx, %ecx\r
66 addl %ecx, %edx\r
67 mov 32(%esp), %ecx\r
68 jc TooLarge\r
69 cmpl %edx, %edi\r
70 ja Correct\r
71 jb TooLarge\r
72 cmpl %eax, %esi\r
73 jae Correct\r
74TooLarge:\r
75 decl %ebx\r
76 jecxz Return\r
77 sub 24(%esp), %eax\r
78 sbb 28(%esp), %edx\r
79Correct:\r
80 jecxz Return\r
81 subl %eax, %esi\r
82 sbbl %edx, %edi\r
83 movl %esi, (%ecx)\r
84 movl %edi, 4(%ecx)\r
85Return:\r
86 movl %ebx, %eax\r
87 xorl %edx, %edx\r
88 pop %edi\r
89 pop %esi\r
90 pop %ebx\r
91 ret\r