summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
diff options
context:
space:
mode:
authorbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-10 06:57:04 +0000
committerbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-10 06:57:04 +0000
commita9a812a0ed4ab3d83941fdc6da281aebdb9bb296 (patch)
tree869ad144d2c1dcd96d859a9ac4c40617dfc96588 /MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
parent741fb364170375f89aa9c29488cc402db07a3776 (diff)
downloadedk2-platforms-a9a812a0ed4ab3d83941fdc6da281aebdb9bb296.tar.xz
1. Added comments to ASM files
2. Fixed a bug in 64-bit AsmDisablePaging64(), which may cause a #GP exception. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2206 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm')
-rw-r--r--MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm20
1 files changed, 10 insertions, 10 deletions
diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
index 61a53d1e3a..95e57efac1 100644
--- a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
+++ b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm
@@ -36,13 +36,13 @@ EXTERN InternalMathDivRemU64x32:PROC
; );
;------------------------------------------------------------------------------
InternalMathDivRemU64x64 PROC
- mov ecx, [esp + 16]
+ mov ecx, [esp + 16] ; ecx <- divisor[32..63]
test ecx, ecx
jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32
mov ecx, [esp + 20]
jecxz @F
- and dword ptr [ecx + 4], 0
- mov [esp + 16], ecx
+ and dword ptr [ecx + 4], 0 ; zero high dword of remainder
+ mov [esp + 16], ecx ; set up stack frame to match DivRemU64x32
@@:
jmp InternalMathDivRemU64x32
InternalMathDivRemU64x64 ENDP
@@ -61,11 +61,11 @@ _@DivRemU64x64 PROC USES ebx esi edi
jnz @B
div ebx
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]
+ mov ecx, [esp + 28] ; ecx <- high dword of divisor
+ mul dword ptr [esp + 24] ; edx:eax <- quotient * divisor[0..31]
+ imul ecx, ebx ; ecx <- quotient * divisor[32..63]
+ add edx, ecx ; edx <- (quotient * divisor)[32..63]
+ mov ecx, dword ptr [esp + 32] ; ecx <- addr for Remainder
jc @TooLarge ; product > 2^64
cmp edi, edx ; compare high 32 bits
ja @Correct
@@ -76,7 +76,7 @@ _@DivRemU64x64 PROC USES ebx esi edi
dec ebx ; adjust quotient by -1
jecxz @Return ; return if Remainder == NULL
sub eax, dword ptr [esp + 24]
- sbb edx, dword ptr [esp + 28]
+ sbb edx, dword ptr [esp + 28] ; edx:eax <- (quotient - 1) * divisor
@Correct:
jecxz @Return
sub esi, eax
@@ -85,7 +85,7 @@ _@DivRemU64x64 PROC USES ebx esi edi
mov [ecx + 4], edi
@Return:
mov eax, ebx ; eax <- quotient
- xor edx, edx
+ xor edx, edx ; quotient is 32 bits long
ret
_@DivRemU64x64 ENDP