summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
diff options
context:
space:
mode:
authorbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-21 08:47:38 +0000
committerbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-21 08:47:38 +0000
commit3f566587aea64bb986866c7f69a6b82891bf59db (patch)
tree406fa713c2baaa46f9c357f49bcef7d710e7f044 /MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
parent31a9215c3223d3818d1709f39d06774e18df103f (diff)
downloadedk2-platforms-3f566587aea64bb986866c7f69a6b82891bf59db.tar.xz
1. Updated function headers in all assembly files.
2. Split x86LowLevel.c into a bunch of C files to make images linked with BaseLib smaller. 3. Fixed a few minor bugs. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1066 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm')
-rw-r--r--MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm35
1 files changed, 22 insertions, 13 deletions
diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
index 261211b946..61a53d1e3a 100644
--- a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
+++ b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
@@ -26,10 +26,19 @@
EXTERN InternalMathDivRemU64x32:PROC
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathDivRemU64x64 (
+; IN UINT64 Dividend,
+; IN UINT64 Divisor,
+; OUT UINT64 *Remainder OPTIONAL
+; );
+;------------------------------------------------------------------------------
InternalMathDivRemU64x64 PROC
mov ecx, [esp + 16]
test ecx, ecx
- jnz _@DivRemU64x64
+ jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32
mov ecx, [esp + 20]
jecxz @F
and dword ptr [ecx + 4], 0
@@ -40,10 +49,10 @@ InternalMathDivRemU64x64 ENDP
_@DivRemU64x64 PROC USES ebx esi edi
mov edx, dword ptr [esp + 20]
- mov eax, dword ptr [esp + 16]
+ mov eax, dword ptr [esp + 16] ; edx:eax <- dividend
mov edi, edx
- mov esi, eax
- mov ebx, dword ptr [esp + 24]
+ mov esi, eax ; edi:esi <- dividend
+ mov ebx, dword ptr [esp + 24] ; ecx:ebx <- divisor
@@:
shr edx, 1
rcr eax, 1
@@ -51,31 +60,31 @@ _@DivRemU64x64 PROC USES ebx esi edi
shr ecx, 1
jnz @B
div ebx
- mov ebx, eax
+ mov ebx, eax ; ebx <- quotient
mov ecx, [esp + 28]
mul dword ptr [esp + 24]
imul ecx, ebx
add edx, ecx
mov ecx, dword ptr [esp + 32]
- jc @TooLarge
- cmp edi, edx
+ jc @TooLarge ; product > 2^64
+ cmp edi, edx ; compare high 32 bits
ja @Correct
- jb @TooLarge
+ jb @TooLarge ; product > dividend
cmp esi, eax
- jae @Correct
+ jae @Correct ; product <= dividend
@TooLarge:
- dec ebx
- jecxz @Return
+ dec ebx ; adjust quotient by -1
+ jecxz @Return ; return if Remainder == NULL
sub eax, dword ptr [esp + 24]
sbb edx, dword ptr [esp + 28]
@Correct:
jecxz @Return
sub esi, eax
- sbb edi, edx
+ sbb edi, edx ; edi:esi <- remainder
mov [ecx], esi
mov [ecx + 4], edi
@Return:
- mov eax, ebx
+ mov eax, ebx ; eax <- quotient
xor edx, edx
ret
_@DivRemU64x64 ENDP