3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 64-bit division function for IA-32
28 OUT UINTN
*Remainder OPTIONAL
34 This routine allows a 64 bit value to be divided with a 32 bit value returns
35 64bit result and the Remainder.
41 Remainder - buffer for remainder
46 Remainder = Dividend mod Divisor
48 N.B. only works for 31bit divisors!!
53 xor edx
, edx
; Clear EDX
55 mov eax
, dword ptr Dividend
[4] ; Put high
32 bits of
64-bit dividend in EAX
56 mov ecx
, Divisor
; Put
32 bits divisor in ECX
57 div ecx
; Dividend Divisor Quoitent
...Remainder
58 ; 0:EAX
/ ECX
= EAX EDX
60 push eax
; Push quoitent in stack
62 mov eax
, dword ptr Dividend
[0] ; Put low
32 bits of
64-bit dividend in EAX
63 div ecx
; Leave the REMAINDER in EDX as High
32-bit of
new dividend
64 ; Dividend Divisor Quoitent
...Remainder
65 ; EDX
:EAX
/ ECX
= EAX EDX
67 mov ecx
, Remainder
; Put
&REMAINDER to ecx
69 jecxz Label1
; If ecx
== 0, no remainder exist
, return with quoitent in EDX directly
70 mov dword ptr
[ecx
], edx
; Put EDX through REMAINDER pointer in ECX
73 pop edx
; Pop High
32-bit QUOITENT to EDX