]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.S
1. Add Assert in SetJump.S
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / DivU64x64Remainder.S
CommitLineData
878ddf1f 1#------------------------------------------------------------------------------\r
2#\r
3# Copyright (c) 2006, Intel Corporation\r
4# All rights reserved. This program and the accompanying materials\r
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
23\r
24\r
25 \r
26\r
27.extern _InternalMathDivRemU64x32\r
28\r
29.global _InternalMathDivRemU64x64\r
30_InternalMathDivRemU64x64: \r
31 movl 16(%esp),%ecx\r
32 testl %ecx,%ecx\r
33 jnz _DivRemU64x64\r
34 movl 20(%esp),%ecx\r
35 jecxz L1\r
36 and $0,4(%ecx)\r
37 movl %ecx,16(%esp)\r
38L1: \r
39 jmp _InternalMathDivRemU64x32\r
40\r
41\r
bd0cd44b 42.global _DivRemU64x64\r
43_DivRemU64x64:\r
878ddf1f 44 push %ebx \r
45 push %esi \r
46 push %edi \r
47 mov 20(%esp), %edx\r
48 mov 16(%esp), %eax\r
49 movl %edx,%edi\r
50 movl %eax,%esi\r
51 mov 24(%esp), %ebx\r
52L2: \r
53 shrl %edx\r
54 rcrl $1,%eax\r
55 shrdl $1,%ecx,%ebx\r
56 shrl %ecx\r
57 jnz L2\r
58 divl %ebx\r
59 movl %eax,%ebx\r
60 movl 28(%esp),%ecx\r
61 mull 24(%esp)\r
62 imull %ebx,%ecx\r
63 addl %ecx,%edx\r
64 mov 32(%esp), %ecx\r
65 jc TooLarge\r
66 cmpl %edx,%edi\r
67 ja Correct\r
68 jb TooLarge\r
69 cmpl %eax,%esi\r
70 jae Correct\r
71TooLarge: \r
72 decl %ebx\r
73 jecxz Return\r
74 sub 24(%esp), %eax\r
75 sbb 28(%esp), %edx\r
76Correct: \r
77 jecxz Return\r
78 subl %eax,%esi\r
79 sbbl %edx,%edi\r
80 movl %esi,(%ecx)\r
81 movl %edi,4(%ecx)\r
82Return: \r
83 movl %ebx,%eax\r
84 xorl %edx,%edx\r
85 push %edi \r
86 push %esi \r
87 push %ebx \r
88 ret\r