mirror of
https://github.com/reactos/reactos.git
synced 2024-08-03 18:10:54 +00:00
set eol-style to native
svn path=/trunk/; revision=19988
This commit is contained in:
parent
84649db0e9
commit
ca9005ad4e
|
@ -1,225 +1,225 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/alldiv_asm.S
|
* FILE: lib/rtl/i386/alldiv_asm.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __alldiv
|
.globl __alldiv
|
||||||
.globl __fltused
|
.globl __fltused
|
||||||
|
|
||||||
/* DATA ********************************************************************/
|
/* DATA ********************************************************************/
|
||||||
|
|
||||||
__fltused:
|
__fltused:
|
||||||
.long 0x9875
|
.long 0x9875
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// lldiv - signed long divide
|
// lldiv - signed long divide
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a signed long divide of the arguments. Arguments are
|
// Does a signed long divide of the arguments. Arguments are
|
||||||
// not changed.
|
// not changed.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// Arguments are passed on the stack:
|
// Arguments are passed on the stack:
|
||||||
// 1st pushed: divisor (QWORD)
|
// 1st pushed: divisor (QWORD)
|
||||||
// 2nd pushed: dividend (QWORD)
|
// 2nd pushed: dividend (QWORD)
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX contains the quotient (dividend/divisor)
|
// EDX:EAX contains the quotient (dividend/divisor)
|
||||||
// NOTE: this routine removes the parameters from the stack.
|
// NOTE: this routine removes the parameters from the stack.
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// ECX
|
// ECX
|
||||||
//
|
//
|
||||||
|
|
||||||
__alldiv:
|
__alldiv:
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
push esi
|
push esi
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
// Set up the local stack and save the index registers. When this is done
|
// Set up the local stack and save the index registers. When this is done
|
||||||
// the stack frame will look as follows (assuming that the expression a/b will
|
// the stack frame will look as follows (assuming that the expression a/b will
|
||||||
// generate a call to lldiv(a, b)):
|
// generate a call to lldiv(a, b)):
|
||||||
//
|
//
|
||||||
// -----------------
|
// -----------------
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--divisor (b)--|
|
// |--divisor (b)--|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--dividend (a)-|
|
// |--dividend (a)-|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | return addr** |
|
// | return addr** |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | EDI |
|
// | EDI |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | ESI |
|
// | ESI |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// ESP---->| EBX |
|
// ESP---->| EBX |
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#define DVNDLO [esp + 16] // stack address of dividend (a)
|
#define DVNDLO [esp + 16] // stack address of dividend (a)
|
||||||
#define DVNDHI [esp + 20] // stack address of dividend (a)
|
#define DVNDHI [esp + 20] // stack address of dividend (a)
|
||||||
#define DVSRLO [esp + 24] // stack address of divisor (b)
|
#define DVSRLO [esp + 24] // stack address of divisor (b)
|
||||||
#define DVSRHI [esp + 28] // stack address of divisor (b)
|
#define DVSRHI [esp + 28] // stack address of divisor (b)
|
||||||
|
|
||||||
// Determine sign of the result (edi = 0 if result is positive, non-zero
|
// Determine sign of the result (edi = 0 if result is positive, non-zero
|
||||||
// otherwise) and make operands positive.
|
// otherwise) and make operands positive.
|
||||||
|
|
||||||
xor edi,edi // result sign assumed positive
|
xor edi,edi // result sign assumed positive
|
||||||
|
|
||||||
mov eax,DVNDHI // hi word of a
|
mov eax,DVNDHI // hi word of a
|
||||||
or eax,eax // test to see if signed
|
or eax,eax // test to see if signed
|
||||||
jge short L1 // skip rest if a is already positive
|
jge short L1 // skip rest if a is already positive
|
||||||
inc edi // complement result sign flag
|
inc edi // complement result sign flag
|
||||||
mov edx,DVNDLO // lo word of a
|
mov edx,DVNDLO // lo word of a
|
||||||
neg eax // make a positive
|
neg eax // make a positive
|
||||||
neg edx
|
neg edx
|
||||||
sbb eax,0
|
sbb eax,0
|
||||||
mov DVNDHI,eax // save positive value
|
mov DVNDHI,eax // save positive value
|
||||||
mov DVNDLO,edx
|
mov DVNDLO,edx
|
||||||
L1:
|
L1:
|
||||||
mov eax,DVSRHI // hi word of b
|
mov eax,DVSRHI // hi word of b
|
||||||
or eax,eax // test to see if signed
|
or eax,eax // test to see if signed
|
||||||
jge short L2 // skip rest if b is already positive
|
jge short L2 // skip rest if b is already positive
|
||||||
inc edi // complement the result sign flag
|
inc edi // complement the result sign flag
|
||||||
mov edx,DVSRLO // lo word of a
|
mov edx,DVSRLO // lo word of a
|
||||||
neg eax // make b positive
|
neg eax // make b positive
|
||||||
neg edx
|
neg edx
|
||||||
sbb eax,0
|
sbb eax,0
|
||||||
mov DVSRHI,eax // save positive value
|
mov DVSRHI,eax // save positive value
|
||||||
mov DVSRLO,edx
|
mov DVSRLO,edx
|
||||||
L2:
|
L2:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
||||||
// If so, then we can use a simple algorithm with word divides, otherwise
|
// If so, then we can use a simple algorithm with word divides, otherwise
|
||||||
// things get a little more complex.
|
// things get a little more complex.
|
||||||
//
|
//
|
||||||
// NOTE - eax currently contains the high order word of DVSR
|
// NOTE - eax currently contains the high order word of DVSR
|
||||||
//
|
//
|
||||||
|
|
||||||
or eax,eax // check to see if divisor < 4194304K
|
or eax,eax // check to see if divisor < 4194304K
|
||||||
jnz short L3 // nope, gotta do this the hard way
|
jnz short L3 // nope, gotta do this the hard way
|
||||||
mov ecx,DVSRLO // load divisor
|
mov ecx,DVSRLO // load divisor
|
||||||
mov eax,DVNDHI // load high word of dividend
|
mov eax,DVNDHI // load high word of dividend
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
div ecx // eax <- high order bits of quotient
|
div ecx // eax <- high order bits of quotient
|
||||||
mov ebx,eax // save high bits of quotient
|
mov ebx,eax // save high bits of quotient
|
||||||
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
||||||
div ecx // eax <- low order bits of quotient
|
div ecx // eax <- low order bits of quotient
|
||||||
mov edx,ebx // edx:eax <- quotient
|
mov edx,ebx // edx:eax <- quotient
|
||||||
jmp short L4 // set sign, restore stack and return
|
jmp short L4 // set sign, restore stack and return
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we do it the hard way. Remember, eax contains the high word of DVSR
|
// Here we do it the hard way. Remember, eax contains the high word of DVSR
|
||||||
//
|
//
|
||||||
|
|
||||||
L3:
|
L3:
|
||||||
mov ebx,eax // ebx:ecx <- divisor
|
mov ebx,eax // ebx:ecx <- divisor
|
||||||
mov ecx,DVSRLO
|
mov ecx,DVSRLO
|
||||||
mov edx,DVNDHI // edx:eax <- dividend
|
mov edx,DVNDHI // edx:eax <- dividend
|
||||||
mov eax,DVNDLO
|
mov eax,DVNDLO
|
||||||
L5:
|
L5:
|
||||||
shr ebx,1 // shift divisor right one bit
|
shr ebx,1 // shift divisor right one bit
|
||||||
rcr ecx,1
|
rcr ecx,1
|
||||||
shr edx,1 // shift dividend right one bit
|
shr edx,1 // shift dividend right one bit
|
||||||
rcr eax,1
|
rcr eax,1
|
||||||
or ebx,ebx
|
or ebx,ebx
|
||||||
jnz short L5 // loop until divisor < 4194304K
|
jnz short L5 // loop until divisor < 4194304K
|
||||||
div ecx // now divide, ignore remainder
|
div ecx // now divide, ignore remainder
|
||||||
mov esi,eax // save quotient
|
mov esi,eax // save quotient
|
||||||
|
|
||||||
//
|
//
|
||||||
// We may be off by one, so to check, we will multiply the quotient
|
// We may be off by one, so to check, we will multiply the quotient
|
||||||
// by the divisor and check the result against the orignal dividend
|
// by the divisor and check the result against the orignal dividend
|
||||||
// Note that we must also check for overflow, which can occur if the
|
// Note that we must also check for overflow, which can occur if the
|
||||||
// dividend is close to 2**64 and the quotient is off by 1.
|
// dividend is close to 2**64 and the quotient is off by 1.
|
||||||
//
|
//
|
||||||
|
|
||||||
mul dword ptr DVSRHI // QUOT * DVSRHI
|
mul dword ptr DVSRHI // QUOT * DVSRHI
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
mov eax,DVSRLO
|
mov eax,DVSRLO
|
||||||
mul esi // QUOT * DVSRLO
|
mul esi // QUOT * DVSRLO
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jc short L6 // carry means Quotient is off by 1
|
jc short L6 // carry means Quotient is off by 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// do long compare here between original dividend and the result of the
|
// do long compare here between original dividend and the result of the
|
||||||
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
||||||
// subtract one (1) from the quotient.
|
// subtract one (1) from the quotient.
|
||||||
//
|
//
|
||||||
|
|
||||||
cmp edx,DVNDHI // compare hi words of result and original
|
cmp edx,DVNDHI // compare hi words of result and original
|
||||||
ja short L6 // if result > original, do subtract
|
ja short L6 // if result > original, do subtract
|
||||||
jb short L7 // if result < original, we are ok
|
jb short L7 // if result < original, we are ok
|
||||||
cmp eax,DVNDLO // hi words are equal, compare lo words
|
cmp eax,DVNDLO // hi words are equal, compare lo words
|
||||||
jbe short L7 // if less or equal we are ok, else subtract
|
jbe short L7 // if less or equal we are ok, else subtract
|
||||||
L6:
|
L6:
|
||||||
dec esi // subtract 1 from quotient
|
dec esi // subtract 1 from quotient
|
||||||
L7:
|
L7:
|
||||||
xor edx,edx // edx:eax <- quotient
|
xor edx,edx // edx:eax <- quotient
|
||||||
mov eax,esi
|
mov eax,esi
|
||||||
|
|
||||||
//
|
//
|
||||||
// Just the cleanup left to do. edx:eax contains the quotient. Set the sign
|
// Just the cleanup left to do. edx:eax contains the quotient. Set the sign
|
||||||
// according to the save value, cleanup the stack, and return.
|
// according to the save value, cleanup the stack, and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
L4:
|
L4:
|
||||||
dec edi // check to see if result is negative
|
dec edi // check to see if result is negative
|
||||||
jnz short L8 // if EDI == 0, result should be negative
|
jnz short L8 // if EDI == 0, result should be negative
|
||||||
neg edx // otherwise, negate the result
|
neg edx // otherwise, negate the result
|
||||||
neg eax
|
neg eax
|
||||||
sbb edx,0
|
sbb edx,0
|
||||||
|
|
||||||
//
|
//
|
||||||
// Restore the saved registers and return.
|
// Restore the saved registers and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
L8:
|
L8:
|
||||||
pop ebx
|
pop ebx
|
||||||
pop esi
|
pop esi
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
ret 16
|
ret 16
|
||||||
|
|
|
@ -1,247 +1,247 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/alldvrm.S
|
* FILE: lib/rtl/i386/alldvrm.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __alldvrm
|
.globl __alldvrm
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
__alldvrm:
|
__alldvrm:
|
||||||
push edi
|
push edi
|
||||||
push esi
|
push esi
|
||||||
push ebp
|
push ebp
|
||||||
|
|
||||||
// Set up the local stack and save the index registers. When this is done
|
// Set up the local stack and save the index registers. When this is done
|
||||||
// the stack frame will look as follows (assuming that the expression a/b will
|
// the stack frame will look as follows (assuming that the expression a/b will
|
||||||
// generate a call to alldvrm(a, b)):
|
// generate a call to alldvrm(a, b)):
|
||||||
//
|
//
|
||||||
// -----------------
|
// -----------------
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--divisor (b)--|
|
// |--divisor (b)--|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--dividend (a)-|
|
// |--dividend (a)-|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | return addr** |
|
// | return addr** |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | EDI |
|
// | EDI |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | ESI |
|
// | ESI |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// ESP---->| EBP |
|
// ESP---->| EBP |
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#undef DVNDLO
|
#undef DVNDLO
|
||||||
#undef DVNDHI
|
#undef DVNDHI
|
||||||
#undef DVSRLO
|
#undef DVSRLO
|
||||||
#undef DVSRHI
|
#undef DVSRHI
|
||||||
#define DVNDLO [esp + 16] // stack address of dividend (a)
|
#define DVNDLO [esp + 16] // stack address of dividend (a)
|
||||||
#define DVNDHI [esp + 20] // stack address of dividend (a)
|
#define DVNDHI [esp + 20] // stack address of dividend (a)
|
||||||
#define DVSRLO [esp + 24] // stack address of divisor (b)
|
#define DVSRLO [esp + 24] // stack address of divisor (b)
|
||||||
#define DVSRHI [esp + 28] // stack address of divisor (b)
|
#define DVSRHI [esp + 28] // stack address of divisor (b)
|
||||||
|
|
||||||
// Determine sign of the quotient (edi = 0 if result is positive, non-zero
|
// Determine sign of the quotient (edi = 0 if result is positive, non-zero
|
||||||
// otherwise) and make operands positive.
|
// otherwise) and make operands positive.
|
||||||
// Sign of the remainder is kept in ebp.
|
// Sign of the remainder is kept in ebp.
|
||||||
|
|
||||||
xor edi,edi // result sign assumed positive
|
xor edi,edi // result sign assumed positive
|
||||||
xor ebp,ebp // result sign assumed positive
|
xor ebp,ebp // result sign assumed positive
|
||||||
|
|
||||||
mov eax,DVNDHI // hi word of a
|
mov eax,DVNDHI // hi word of a
|
||||||
or eax,eax // test to see if signed
|
or eax,eax // test to see if signed
|
||||||
jge short ....L1 // skip rest if a is already positive
|
jge short ....L1 // skip rest if a is already positive
|
||||||
inc edi // complement result sign flag
|
inc edi // complement result sign flag
|
||||||
inc ebp // complement result sign flag
|
inc ebp // complement result sign flag
|
||||||
mov edx,DVNDLO // lo word of a
|
mov edx,DVNDLO // lo word of a
|
||||||
neg eax // make a positive
|
neg eax // make a positive
|
||||||
neg edx
|
neg edx
|
||||||
sbb eax,0
|
sbb eax,0
|
||||||
mov DVNDHI,eax // save positive value
|
mov DVNDHI,eax // save positive value
|
||||||
mov DVNDLO,edx
|
mov DVNDLO,edx
|
||||||
....L1:
|
....L1:
|
||||||
mov eax,DVSRHI // hi word of b
|
mov eax,DVSRHI // hi word of b
|
||||||
or eax,eax // test to see if signed
|
or eax,eax // test to see if signed
|
||||||
jge short ....L2 // skip rest if b is already positive
|
jge short ....L2 // skip rest if b is already positive
|
||||||
inc edi // complement the result sign flag
|
inc edi // complement the result sign flag
|
||||||
mov edx,DVSRLO // lo word of a
|
mov edx,DVSRLO // lo word of a
|
||||||
neg eax // make b positive
|
neg eax // make b positive
|
||||||
neg edx
|
neg edx
|
||||||
sbb eax,0
|
sbb eax,0
|
||||||
mov DVSRHI,eax // save positive value
|
mov DVSRHI,eax // save positive value
|
||||||
mov DVSRLO,edx
|
mov DVSRLO,edx
|
||||||
....L2:
|
....L2:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
||||||
// If so, then we can use a simple algorithm with word divides, otherwise
|
// If so, then we can use a simple algorithm with word divides, otherwise
|
||||||
// things get a little more complex.
|
// things get a little more complex.
|
||||||
//
|
//
|
||||||
// NOTE - eax currently contains the high order word of DVSR
|
// NOTE - eax currently contains the high order word of DVSR
|
||||||
//
|
//
|
||||||
|
|
||||||
or eax,eax // check to see if divisor < 4194304K
|
or eax,eax // check to see if divisor < 4194304K
|
||||||
jnz short ....L3 // nope, gotta do this the hard way
|
jnz short ....L3 // nope, gotta do this the hard way
|
||||||
mov ecx,DVSRLO // load divisor
|
mov ecx,DVSRLO // load divisor
|
||||||
mov eax,DVNDHI // load high word of dividend
|
mov eax,DVNDHI // load high word of dividend
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
div ecx // eax <- high order bits of quotient
|
div ecx // eax <- high order bits of quotient
|
||||||
mov ebx,eax // save high bits of quotient
|
mov ebx,eax // save high bits of quotient
|
||||||
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
||||||
div ecx // eax <- low order bits of quotient
|
div ecx // eax <- low order bits of quotient
|
||||||
mov esi,eax // ebx:esi <- quotient
|
mov esi,eax // ebx:esi <- quotient
|
||||||
//
|
//
|
||||||
// Now we need to do a multiply so that we can compute the remainder.
|
// Now we need to do a multiply so that we can compute the remainder.
|
||||||
//
|
//
|
||||||
mov eax,ebx // set up high word of quotient
|
mov eax,ebx // set up high word of quotient
|
||||||
mul dword ptr DVSRLO // HIWORD(QUOT) * DVSR
|
mul dword ptr DVSRLO // HIWORD(QUOT) * DVSR
|
||||||
mov ecx,eax // save the result in ecx
|
mov ecx,eax // save the result in ecx
|
||||||
mov eax,esi // set up low word of quotient
|
mov eax,esi // set up low word of quotient
|
||||||
mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR
|
mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jmp short ....L4 // complete remainder calculation
|
jmp short ....L4 // complete remainder calculation
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we do it the hard way. Remember, eax contains the high word of DVSR
|
// Here we do it the hard way. Remember, eax contains the high word of DVSR
|
||||||
//
|
//
|
||||||
|
|
||||||
....L3:
|
....L3:
|
||||||
mov ebx,eax // ebx:ecx <- divisor
|
mov ebx,eax // ebx:ecx <- divisor
|
||||||
mov ecx,DVSRLO
|
mov ecx,DVSRLO
|
||||||
mov edx,DVNDHI // edx:eax <- dividend
|
mov edx,DVNDHI // edx:eax <- dividend
|
||||||
mov eax,DVNDLO
|
mov eax,DVNDLO
|
||||||
....L5:
|
....L5:
|
||||||
shr ebx,1 // shift divisor right one bit
|
shr ebx,1 // shift divisor right one bit
|
||||||
rcr ecx,1
|
rcr ecx,1
|
||||||
shr edx,1 // shift dividend right one bit
|
shr edx,1 // shift dividend right one bit
|
||||||
rcr eax,1
|
rcr eax,1
|
||||||
or ebx,ebx
|
or ebx,ebx
|
||||||
jnz short ....L5 // loop until divisor < 4194304K
|
jnz short ....L5 // loop until divisor < 4194304K
|
||||||
div ecx // now divide, ignore remainder
|
div ecx // now divide, ignore remainder
|
||||||
mov esi,eax // save quotient
|
mov esi,eax // save quotient
|
||||||
|
|
||||||
//
|
//
|
||||||
// We may be off by one, so to check, we will multiply the quotient
|
// We may be off by one, so to check, we will multiply the quotient
|
||||||
// by the divisor and check the result against the orignal dividend
|
// by the divisor and check the result against the orignal dividend
|
||||||
// Note that we must also check for overflow, which can occur if the
|
// Note that we must also check for overflow, which can occur if the
|
||||||
// dividend is close to 2**64 and the quotient is off by 1.
|
// dividend is close to 2**64 and the quotient is off by 1.
|
||||||
//
|
//
|
||||||
|
|
||||||
mul dword ptr DVSRHI // QUOT * DVSRHI
|
mul dword ptr DVSRHI // QUOT * DVSRHI
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
mov eax,DVSRLO
|
mov eax,DVSRLO
|
||||||
mul esi // QUOT * DVSRLO
|
mul esi // QUOT * DVSRLO
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jc short ....L6 // carry means Quotient is off by 1
|
jc short ....L6 // carry means Quotient is off by 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// do long compare here between original dividend and the result of the
|
// do long compare here between original dividend and the result of the
|
||||||
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
||||||
// subtract one (1) from the quotient.
|
// subtract one (1) from the quotient.
|
||||||
//
|
//
|
||||||
|
|
||||||
cmp edx,DVNDHI // compare hi words of result and original
|
cmp edx,DVNDHI // compare hi words of result and original
|
||||||
ja short ....L6 // if result > original, do subtract
|
ja short ....L6 // if result > original, do subtract
|
||||||
jb short ....L7 // if result < original, we are ok
|
jb short ....L7 // if result < original, we are ok
|
||||||
cmp eax,DVNDLO // hi words are equal, compare lo words
|
cmp eax,DVNDLO // hi words are equal, compare lo words
|
||||||
jbe short ....L7 // if less or equal we are ok, else subtract
|
jbe short ....L7 // if less or equal we are ok, else subtract
|
||||||
....L6:
|
....L6:
|
||||||
dec esi // subtract 1 from quotient
|
dec esi // subtract 1 from quotient
|
||||||
sub eax,DVSRLO // subtract divisor from result
|
sub eax,DVSRLO // subtract divisor from result
|
||||||
sbb edx,DVSRHI
|
sbb edx,DVSRHI
|
||||||
....L7:
|
....L7:
|
||||||
xor ebx,ebx // ebx:esi <- quotient
|
xor ebx,ebx // ebx:esi <- quotient
|
||||||
|
|
||||||
....L4:
|
....L4:
|
||||||
//
|
//
|
||||||
// Calculate remainder by subtracting the result from the original dividend.
|
// Calculate remainder by subtracting the result from the original dividend.
|
||||||
// Since the result is already in a register, we will do the subtract in the
|
// Since the result is already in a register, we will do the subtract in the
|
||||||
// opposite direction and negate the result if necessary.
|
// opposite direction and negate the result if necessary.
|
||||||
//
|
//
|
||||||
|
|
||||||
sub eax,DVNDLO // subtract dividend from result
|
sub eax,DVNDLO // subtract dividend from result
|
||||||
sbb edx,DVNDHI
|
sbb edx,DVNDHI
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now check the result sign flag to see if the result is supposed to be positive
|
// Now check the result sign flag to see if the result is supposed to be positive
|
||||||
// or negative. It is currently negated (because we subtracted in the 'wrong'
|
// or negative. It is currently negated (because we subtracted in the 'wrong'
|
||||||
// direction), so if the sign flag is set we are done, otherwise we must negate
|
// direction), so if the sign flag is set we are done, otherwise we must negate
|
||||||
// the result to make it positive again.
|
// the result to make it positive again.
|
||||||
//
|
//
|
||||||
|
|
||||||
dec ebp // check result sign flag
|
dec ebp // check result sign flag
|
||||||
jns short ....L9 // result is ok, set up the quotient
|
jns short ....L9 // result is ok, set up the quotient
|
||||||
neg edx // otherwise, negate the result
|
neg edx // otherwise, negate the result
|
||||||
neg eax
|
neg eax
|
||||||
sbb edx,0
|
sbb edx,0
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now we need to get the quotient into edx:eax and the remainder into ebx:ecx.
|
// Now we need to get the quotient into edx:eax and the remainder into ebx:ecx.
|
||||||
//
|
//
|
||||||
....L9:
|
....L9:
|
||||||
mov ecx,edx
|
mov ecx,edx
|
||||||
mov edx,ebx
|
mov edx,ebx
|
||||||
mov ebx,ecx
|
mov ebx,ecx
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
mov eax,esi
|
mov eax,esi
|
||||||
|
|
||||||
//
|
//
|
||||||
// Just the cleanup left to do. edx:eax contains the quotient. Set the sign
|
// Just the cleanup left to do. edx:eax contains the quotient. Set the sign
|
||||||
// according to the save value, cleanup the stack, and return.
|
// according to the save value, cleanup the stack, and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
dec edi // check to see if result is negative
|
dec edi // check to see if result is negative
|
||||||
jnz short ....L8 // if EDI == 0, result should be negative
|
jnz short ....L8 // if EDI == 0, result should be negative
|
||||||
neg edx // otherwise, negate the result
|
neg edx // otherwise, negate the result
|
||||||
neg eax
|
neg eax
|
||||||
sbb edx,0
|
sbb edx,0
|
||||||
|
|
||||||
//
|
//
|
||||||
// Restore the saved registers and return.
|
// Restore the saved registers and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
....L8:
|
....L8:
|
||||||
pop ebp
|
pop ebp
|
||||||
pop esi
|
pop esi
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
ret 16
|
ret 16
|
||||||
|
|
|
@ -1,116 +1,116 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/allmul.S
|
* FILE: lib/rtl/i386/allmul.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __allmul
|
.globl __allmul
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// llmul - long multiply routine
|
// llmul - long multiply routine
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a long multiply (same for signed/unsigned)
|
// Does a long multiply (same for signed/unsigned)
|
||||||
// Parameters are not changed.
|
// Parameters are not changed.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// Parameters are passed on the stack:
|
// Parameters are passed on the stack:
|
||||||
// 1st pushed: multiplier (QWORD)
|
// 1st pushed: multiplier (QWORD)
|
||||||
// 2nd pushed: multiplicand (QWORD)
|
// 2nd pushed: multiplicand (QWORD)
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX - product of multiplier and multiplicand
|
// EDX:EAX - product of multiplier and multiplicand
|
||||||
// NOTE: parameters are removed from the stack
|
// NOTE: parameters are removed from the stack
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// ECX
|
// ECX
|
||||||
//
|
//
|
||||||
|
|
||||||
__allmul:
|
__allmul:
|
||||||
|
|
||||||
#define ALO [esp + 4] // stack address of a
|
#define ALO [esp + 4] // stack address of a
|
||||||
#define AHI [esp + 8] // stack address of a
|
#define AHI [esp + 8] // stack address of a
|
||||||
#define BLO [esp + 12] // stack address of b
|
#define BLO [esp + 12] // stack address of b
|
||||||
#define BHI [esp + 16] // stack address of b
|
#define BHI [esp + 16] // stack address of b
|
||||||
|
|
||||||
//
|
//
|
||||||
// AHI, BHI : upper 32 bits of A and B
|
// AHI, BHI : upper 32 bits of A and B
|
||||||
// ALO, BLO : lower 32 bits of A and B
|
// ALO, BLO : lower 32 bits of A and B
|
||||||
//
|
//
|
||||||
// ALO * BLO
|
// ALO * BLO
|
||||||
// ALO * BHI
|
// ALO * BHI
|
||||||
// + BLO * AHI
|
// + BLO * AHI
|
||||||
// ---------------------
|
// ---------------------
|
||||||
//
|
//
|
||||||
|
|
||||||
mov eax,AHI
|
mov eax,AHI
|
||||||
mov ecx,BHI
|
mov ecx,BHI
|
||||||
or ecx,eax //test for both hiwords zero.
|
or ecx,eax //test for both hiwords zero.
|
||||||
mov ecx,BLO
|
mov ecx,BLO
|
||||||
jnz short hard //both are zero, just mult ALO and BLO
|
jnz short hard //both are zero, just mult ALO and BLO
|
||||||
|
|
||||||
mov eax,AHI
|
mov eax,AHI
|
||||||
mul ecx
|
mul ecx
|
||||||
|
|
||||||
ret 16 // callee restores the stack
|
ret 16 // callee restores the stack
|
||||||
|
|
||||||
hard:
|
hard:
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
// must redefine A and B since esp has been altered
|
// must redefine A and B since esp has been altered
|
||||||
|
|
||||||
#define A2LO [esp + 4] // stack address of a
|
#define A2LO [esp + 4] // stack address of a
|
||||||
#define A2HI [esp + 8] // stack address of a
|
#define A2HI [esp + 8] // stack address of a
|
||||||
#define B2LO [esp + 12] // stack address of b
|
#define B2LO [esp + 12] // stack address of b
|
||||||
#define B2HI [esp + 16] // stack address of b
|
#define B2HI [esp + 16] // stack address of b
|
||||||
|
|
||||||
mul ecx //eax has AHI, ecx has BLO, so AHI * BLO
|
mul ecx //eax has AHI, ecx has BLO, so AHI * BLO
|
||||||
mov ebx,eax //save result
|
mov ebx,eax //save result
|
||||||
|
|
||||||
mov eax,A2LO
|
mov eax,A2LO
|
||||||
mul dword ptr B2HI //ALO * BHI
|
mul dword ptr B2HI //ALO * BHI
|
||||||
add ebx,eax //ebx = ((ALO * BHI) + (AHI * BLO))
|
add ebx,eax //ebx = ((ALO * BHI) + (AHI * BLO))
|
||||||
|
|
||||||
mov eax,A2LO //ecx = BLO
|
mov eax,A2LO //ecx = BLO
|
||||||
mul ecx //so edx:eax = ALO*BLO
|
mul ecx //so edx:eax = ALO*BLO
|
||||||
add edx,ebx //now edx has all the LO*HI stuff
|
add edx,ebx //now edx has all the LO*HI stuff
|
||||||
|
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
ret 16 // callee restores the stack
|
ret 16 // callee restores the stack
|
||||||
|
|
||||||
|
|
|
@ -1,230 +1,230 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/allrem.S
|
* FILE: lib/rtl/i386/allrem.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __allrem
|
.globl __allrem
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// llrem - signed long remainder
|
// llrem - signed long remainder
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a signed long remainder of the arguments. Arguments are
|
// Does a signed long remainder of the arguments. Arguments are
|
||||||
// not changed.
|
// not changed.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// Arguments are passed on the stack:
|
// Arguments are passed on the stack:
|
||||||
// 1st pushed: divisor (QWORD)
|
// 1st pushed: divisor (QWORD)
|
||||||
// 2nd pushed: dividend (QWORD)
|
// 2nd pushed: dividend (QWORD)
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX contains the remainder (dividend%divisor)
|
// EDX:EAX contains the remainder (dividend%divisor)
|
||||||
// NOTE: this routine removes the parameters from the stack.
|
// NOTE: this routine removes the parameters from the stack.
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// ECX
|
// ECX
|
||||||
//
|
//
|
||||||
|
|
||||||
__allrem :
|
__allrem :
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
push edi
|
push edi
|
||||||
|
|
||||||
// Set up the local stack and save the index registers. When this is done
|
// Set up the local stack and save the index registers. When this is done
|
||||||
// the stack frame will look as follows (assuming that the expression a%b will
|
// the stack frame will look as follows (assuming that the expression a%b will
|
||||||
// generate a call to lrem(a, b)):
|
// generate a call to lrem(a, b)):
|
||||||
//
|
//
|
||||||
// -----------------
|
// -----------------
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--divisor (b)--|
|
// |--divisor (b)--|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--dividend (a)-|
|
// |--dividend (a)-|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | return addr** |
|
// | return addr** |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | EBX |
|
// | EBX |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// ESP---->| EDI |
|
// ESP---->| EDI |
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#undef DVNDLO
|
#undef DVNDLO
|
||||||
#undef DVNDHI
|
#undef DVNDHI
|
||||||
#undef DVSRLO
|
#undef DVSRLO
|
||||||
#undef DVSRHI
|
#undef DVSRHI
|
||||||
#define DVNDLO [esp + 12] // stack address of dividend (a)
|
#define DVNDLO [esp + 12] // stack address of dividend (a)
|
||||||
#define DVNDHI [esp + 16] // stack address of dividend (a)
|
#define DVNDHI [esp + 16] // stack address of dividend (a)
|
||||||
#define DVSRLO [esp + 20] // stack address of divisor (b)
|
#define DVSRLO [esp + 20] // stack address of divisor (b)
|
||||||
#define DVSRHI [esp + 24] // stack address of divisor (b)
|
#define DVSRHI [esp + 24] // stack address of divisor (b)
|
||||||
|
|
||||||
// Determine sign of the result (edi = 0 if result is positive, non-zero
|
// Determine sign of the result (edi = 0 if result is positive, non-zero
|
||||||
// otherwise) and make operands positive.
|
// otherwise) and make operands positive.
|
||||||
|
|
||||||
xor edi,edi // result sign assumed positive
|
xor edi,edi // result sign assumed positive
|
||||||
|
|
||||||
mov eax,DVNDHI // hi word of a
|
mov eax,DVNDHI // hi word of a
|
||||||
or eax,eax // test to see if signed
|
or eax,eax // test to see if signed
|
||||||
jge short .L1 // skip rest if a is already positive
|
jge short .L1 // skip rest if a is already positive
|
||||||
inc edi // complement result sign flag bit
|
inc edi // complement result sign flag bit
|
||||||
mov edx,DVNDLO // lo word of a
|
mov edx,DVNDLO // lo word of a
|
||||||
neg eax // make a positive
|
neg eax // make a positive
|
||||||
neg edx
|
neg edx
|
||||||
sbb eax,0
|
sbb eax,0
|
||||||
mov DVNDHI,eax // save positive value
|
mov DVNDHI,eax // save positive value
|
||||||
mov DVNDLO,edx
|
mov DVNDLO,edx
|
||||||
.L1:
|
.L1:
|
||||||
mov eax,DVSRHI // hi word of b
|
mov eax,DVSRHI // hi word of b
|
||||||
or eax,eax // test to see if signed
|
or eax,eax // test to see if signed
|
||||||
jge short .L2 // skip rest if b is already positive
|
jge short .L2 // skip rest if b is already positive
|
||||||
mov edx,DVSRLO // lo word of b
|
mov edx,DVSRLO // lo word of b
|
||||||
neg eax // make b positive
|
neg eax // make b positive
|
||||||
neg edx
|
neg edx
|
||||||
sbb eax,0
|
sbb eax,0
|
||||||
mov DVSRHI,eax // save positive value
|
mov DVSRHI,eax // save positive value
|
||||||
mov DVSRLO,edx
|
mov DVSRLO,edx
|
||||||
.L2:
|
.L2:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
||||||
// If so, then we can use a simple algorithm with word divides, otherwise
|
// If so, then we can use a simple algorithm with word divides, otherwise
|
||||||
// things get a little more complex.
|
// things get a little more complex.
|
||||||
//
|
//
|
||||||
// NOTE - eax currently contains the high order word of DVSR
|
// NOTE - eax currently contains the high order word of DVSR
|
||||||
//
|
//
|
||||||
|
|
||||||
or eax,eax // check to see if divisor < 4194304K
|
or eax,eax // check to see if divisor < 4194304K
|
||||||
jnz short .L3 // nope, gotta do this the hard way
|
jnz short .L3 // nope, gotta do this the hard way
|
||||||
mov ecx,DVSRLO // load divisor
|
mov ecx,DVSRLO // load divisor
|
||||||
mov eax,DVNDHI // load high word of dividend
|
mov eax,DVNDHI // load high word of dividend
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
div ecx // edx <- remainder
|
div ecx // edx <- remainder
|
||||||
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
||||||
div ecx // edx <- final remainder
|
div ecx // edx <- final remainder
|
||||||
mov eax,edx // edx:eax <- remainder
|
mov eax,edx // edx:eax <- remainder
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
dec edi // check result sign flag
|
dec edi // check result sign flag
|
||||||
jns short .L4 // negate result, restore stack and return
|
jns short .L4 // negate result, restore stack and return
|
||||||
jmp short .L8 // result sign ok, restore stack and return
|
jmp short .L8 // result sign ok, restore stack and return
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we do it the hard way. Remember, eax contains the high word of DVSR
|
// Here we do it the hard way. Remember, eax contains the high word of DVSR
|
||||||
//
|
//
|
||||||
|
|
||||||
.L3:
|
.L3:
|
||||||
mov ebx,eax // ebx:ecx <- divisor
|
mov ebx,eax // ebx:ecx <- divisor
|
||||||
mov ecx,DVSRLO
|
mov ecx,DVSRLO
|
||||||
mov edx,DVNDHI // edx:eax <- dividend
|
mov edx,DVNDHI // edx:eax <- dividend
|
||||||
mov eax,DVNDLO
|
mov eax,DVNDLO
|
||||||
.L5:
|
.L5:
|
||||||
shr ebx,1 // shift divisor right one bit
|
shr ebx,1 // shift divisor right one bit
|
||||||
rcr ecx,1
|
rcr ecx,1
|
||||||
shr edx,1 // shift dividend right one bit
|
shr edx,1 // shift dividend right one bit
|
||||||
rcr eax,1
|
rcr eax,1
|
||||||
or ebx,ebx
|
or ebx,ebx
|
||||||
jnz short .L5 // loop until divisor < 4194304K
|
jnz short .L5 // loop until divisor < 4194304K
|
||||||
div ecx // now divide, ignore remainder
|
div ecx // now divide, ignore remainder
|
||||||
|
|
||||||
//
|
//
|
||||||
// We may be off by one, so to check, we will multiply the quotient
|
// We may be off by one, so to check, we will multiply the quotient
|
||||||
// by the divisor and check the result against the orignal dividend
|
// by the divisor and check the result against the orignal dividend
|
||||||
// Note that we must also check for overflow, which can occur if the
|
// Note that we must also check for overflow, which can occur if the
|
||||||
// dividend is close to 2**64 and the quotient is off by 1.
|
// dividend is close to 2**64 and the quotient is off by 1.
|
||||||
//
|
//
|
||||||
|
|
||||||
mov ecx,eax // save a copy of quotient in ECX
|
mov ecx,eax // save a copy of quotient in ECX
|
||||||
mul dword ptr DVSRHI
|
mul dword ptr DVSRHI
|
||||||
xchg ecx,eax // save product, get quotient in EAX
|
xchg ecx,eax // save product, get quotient in EAX
|
||||||
mul dword ptr DVSRLO
|
mul dword ptr DVSRLO
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jc short .L6 // carry means Quotient is off by 1
|
jc short .L6 // carry means Quotient is off by 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// do long compare here between original dividend and the result of the
|
// do long compare here between original dividend and the result of the
|
||||||
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
||||||
// subtract the original divisor from the result.
|
// subtract the original divisor from the result.
|
||||||
//
|
//
|
||||||
|
|
||||||
cmp edx,DVNDHI // compare hi words of result and original
|
cmp edx,DVNDHI // compare hi words of result and original
|
||||||
ja short .L6 // if result > original, do subtract
|
ja short .L6 // if result > original, do subtract
|
||||||
jb short .L7 // if result < original, we are ok
|
jb short .L7 // if result < original, we are ok
|
||||||
cmp eax,DVNDLO // hi words are equal, compare lo words
|
cmp eax,DVNDLO // hi words are equal, compare lo words
|
||||||
jbe short .L7 // if less or equal we are ok, else subtract
|
jbe short .L7 // if less or equal we are ok, else subtract
|
||||||
.L6:
|
.L6:
|
||||||
sub eax,DVSRLO // subtract divisor from result
|
sub eax,DVSRLO // subtract divisor from result
|
||||||
sbb edx,DVSRHI
|
sbb edx,DVSRHI
|
||||||
.L7:
|
.L7:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate remainder by subtracting the result from the original dividend.
|
// Calculate remainder by subtracting the result from the original dividend.
|
||||||
// Since the result is already in a register, we will do the subtract in the
|
// Since the result is already in a register, we will do the subtract in the
|
||||||
// opposite direction and negate the result if necessary.
|
// opposite direction and negate the result if necessary.
|
||||||
//
|
//
|
||||||
|
|
||||||
sub eax,DVNDLO // subtract dividend from result
|
sub eax,DVNDLO // subtract dividend from result
|
||||||
sbb edx,DVNDHI
|
sbb edx,DVNDHI
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now check the result sign flag to see if the result is supposed to be positive
|
// Now check the result sign flag to see if the result is supposed to be positive
|
||||||
// or negative. It is currently negated (because we subtracted in the 'wrong'
|
// or negative. It is currently negated (because we subtracted in the 'wrong'
|
||||||
// direction), so if the sign flag is set we are done, otherwise we must negate
|
// direction), so if the sign flag is set we are done, otherwise we must negate
|
||||||
// the result to make it positive again.
|
// the result to make it positive again.
|
||||||
//
|
//
|
||||||
|
|
||||||
dec edi // check result sign flag
|
dec edi // check result sign flag
|
||||||
jns short .L8 // result is ok, restore stack and return
|
jns short .L8 // result is ok, restore stack and return
|
||||||
.L4:
|
.L4:
|
||||||
neg edx // otherwise, negate the result
|
neg edx // otherwise, negate the result
|
||||||
neg eax
|
neg eax
|
||||||
sbb edx,0
|
sbb edx,0
|
||||||
|
|
||||||
//
|
//
|
||||||
// Just the cleanup left to do. edx:eax contains the quotient.
|
// Just the cleanup left to do. edx:eax contains the quotient.
|
||||||
// Restore the saved registers and return.
|
// Restore the saved registers and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
.L8:
|
.L8:
|
||||||
pop edi
|
pop edi
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
ret 16
|
ret 16
|
||||||
|
|
|
@ -1,95 +1,95 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/allshl.S
|
* FILE: lib/rtl/i386/allshl.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __allshl
|
.globl __allshl
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// llshl - long shift left
|
// llshl - long shift left
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a Long Shift Left (signed and unsigned are identical)
|
// Does a Long Shift Left (signed and unsigned are identical)
|
||||||
// Shifts a long left any number of bits.
|
// Shifts a long left any number of bits.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// EDX:EAX - long value to be shifted
|
// EDX:EAX - long value to be shifted
|
||||||
// CL - number of bits to shift by
|
// CL - number of bits to shift by
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX - shifted value
|
// EDX:EAX - shifted value
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// CL is destroyed.
|
// CL is destroyed.
|
||||||
//
|
//
|
||||||
|
|
||||||
__allshl:
|
__allshl:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of 64 or more bits (all get 0)
|
// Handle shifts of 64 or more bits (all get 0)
|
||||||
//
|
//
|
||||||
cmp cl, 64
|
cmp cl, 64
|
||||||
jae short RETZERO
|
jae short RETZERO
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of between 0 and 31 bits
|
// Handle shifts of between 0 and 31 bits
|
||||||
//
|
//
|
||||||
cmp cl, 32
|
cmp cl, 32
|
||||||
jae short MORE32
|
jae short MORE32
|
||||||
shld edx,eax,cl
|
shld edx,eax,cl
|
||||||
shl eax,cl
|
shl eax,cl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of between 32 and 63 bits
|
// Handle shifts of between 32 and 63 bits
|
||||||
//
|
//
|
||||||
MORE32:
|
MORE32:
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
and cl,31
|
and cl,31
|
||||||
shl edx,cl
|
shl edx,cl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
//
|
//
|
||||||
// return 0 in edx:eax
|
// return 0 in edx:eax
|
||||||
//
|
//
|
||||||
RETZERO:
|
RETZERO:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,96 +1,96 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/allshr.S
|
* FILE: lib/rtl/i386/allshr.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __allshr
|
.globl __allshr
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// llshr - long shift right
|
// llshr - long shift right
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a signed Long Shift Right
|
// Does a signed Long Shift Right
|
||||||
// Shifts a long right any number of bits.
|
// Shifts a long right any number of bits.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// EDX:EAX - long value to be shifted
|
// EDX:EAX - long value to be shifted
|
||||||
// CL - number of bits to shift by
|
// CL - number of bits to shift by
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX - shifted value
|
// EDX:EAX - shifted value
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// CL is destroyed.
|
// CL is destroyed.
|
||||||
//
|
//
|
||||||
|
|
||||||
__allshr:
|
__allshr:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
|
// Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
|
||||||
// depends only on the high order bit of edx).
|
// depends only on the high order bit of edx).
|
||||||
//
|
//
|
||||||
cmp cl,64
|
cmp cl,64
|
||||||
jae short .RETSIGN
|
jae short .RETSIGN
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of between 0 and 31 bits
|
// Handle shifts of between 0 and 31 bits
|
||||||
//
|
//
|
||||||
cmp cl, 32
|
cmp cl, 32
|
||||||
jae short .MORE32
|
jae short .MORE32
|
||||||
shrd eax,edx,cl
|
shrd eax,edx,cl
|
||||||
sar edx,cl
|
sar edx,cl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of between 32 and 63 bits
|
// Handle shifts of between 32 and 63 bits
|
||||||
//
|
//
|
||||||
.MORE32:
|
.MORE32:
|
||||||
mov eax,edx
|
mov eax,edx
|
||||||
sar edx,31
|
sar edx,31
|
||||||
and cl,31
|
and cl,31
|
||||||
sar eax,cl
|
sar eax,cl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return double precision 0 or -1, depending on the sign of edx
|
// Return double precision 0 or -1, depending on the sign of edx
|
||||||
//
|
//
|
||||||
.RETSIGN:
|
.RETSIGN:
|
||||||
sar edx,31
|
sar edx,31
|
||||||
mov eax,edx
|
mov eax,edx
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/atan.S
|
* FILE: lib/rtl/i386/atan.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _atan
|
.globl _atan
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_atan:
|
_atan:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fld1 // Load constant 1
|
fld1 // Load constant 1
|
||||||
fpatan // Take the arctangent
|
fpatan // Take the arctangent
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,180 +1,180 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/aulldiv_asm.S
|
* FILE: lib/rtl/i386/aulldiv_asm.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __aulldiv
|
.globl __aulldiv
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// ulldiv - unsigned long divide
|
// ulldiv - unsigned long divide
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a unsigned long divide of the arguments. Arguments are
|
// Does a unsigned long divide of the arguments. Arguments are
|
||||||
// not changed.
|
// not changed.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// Arguments are passed on the stack:
|
// Arguments are passed on the stack:
|
||||||
// 1st pushed: divisor (QWORD)
|
// 1st pushed: divisor (QWORD)
|
||||||
// 2nd pushed: dividend (QWORD)
|
// 2nd pushed: dividend (QWORD)
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX contains the quotient (dividend/divisor)
|
// EDX:EAX contains the quotient (dividend/divisor)
|
||||||
// NOTE: this routine removes the parameters from the stack.
|
// NOTE: this routine removes the parameters from the stack.
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// ECX
|
// ECX
|
||||||
//
|
//
|
||||||
|
|
||||||
__aulldiv:
|
__aulldiv:
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
push esi
|
push esi
|
||||||
|
|
||||||
// Set up the local stack and save the index registers. When this is done
|
// Set up the local stack and save the index registers. When this is done
|
||||||
// the stack frame will look as follows (assuming that the expression a/b will
|
// the stack frame will look as follows (assuming that the expression a/b will
|
||||||
// generate a call to uldiv(a, b)):
|
// generate a call to uldiv(a, b)):
|
||||||
//
|
//
|
||||||
// -----------------
|
// -----------------
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--divisor (b)--|
|
// |--divisor (b)--|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--dividend (a)-|
|
// |--dividend (a)-|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | return addr** |
|
// | return addr** |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | EBX |
|
// | EBX |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// ESP---->| ESI |
|
// ESP---->| ESI |
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#undef DVNDLO
|
#undef DVNDLO
|
||||||
#undef DVNDHI
|
#undef DVNDHI
|
||||||
#undef DVSRLO
|
#undef DVSRLO
|
||||||
#undef DVSRHI
|
#undef DVSRHI
|
||||||
#define DVNDLO [esp + 12] // stack address of dividend (a)
|
#define DVNDLO [esp + 12] // stack address of dividend (a)
|
||||||
#define DVNDHI [esp + 16] // stack address of dividend (a)
|
#define DVNDHI [esp + 16] // stack address of dividend (a)
|
||||||
#define DVSRLO [esp + 20] // stack address of divisor (b)
|
#define DVSRLO [esp + 20] // stack address of divisor (b)
|
||||||
#define DVSRHI [esp + 24] // stack address of divisor (b)
|
#define DVSRHI [esp + 24] // stack address of divisor (b)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
||||||
// If so, then we can use a simple algorithm with word divides, otherwise
|
// If so, then we can use a simple algorithm with word divides, otherwise
|
||||||
// things get a little more complex.
|
// things get a little more complex.
|
||||||
//
|
//
|
||||||
|
|
||||||
mov eax,DVSRHI // check to see if divisor < 4194304K
|
mov eax,DVSRHI // check to see if divisor < 4194304K
|
||||||
or eax,eax
|
or eax,eax
|
||||||
jnz short ..L1 // nope, gotta do this the hard way
|
jnz short ..L1 // nope, gotta do this the hard way
|
||||||
mov ecx,DVSRLO // load divisor
|
mov ecx,DVSRLO // load divisor
|
||||||
mov eax,DVNDHI // load high word of dividend
|
mov eax,DVNDHI // load high word of dividend
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
div ecx // get high order bits of quotient
|
div ecx // get high order bits of quotient
|
||||||
mov ebx,eax // save high bits of quotient
|
mov ebx,eax // save high bits of quotient
|
||||||
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
||||||
div ecx // get low order bits of quotient
|
div ecx // get low order bits of quotient
|
||||||
mov edx,ebx // edx:eax <- quotient hi:quotient lo
|
mov edx,ebx // edx:eax <- quotient hi:quotient lo
|
||||||
jmp short ..L2 // restore stack and return
|
jmp short ..L2 // restore stack and return
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we do it the hard way. Remember, eax contains DVSRHI
|
// Here we do it the hard way. Remember, eax contains DVSRHI
|
||||||
//
|
//
|
||||||
|
|
||||||
..L1:
|
..L1:
|
||||||
mov ecx,eax // ecx:ebx <- divisor
|
mov ecx,eax // ecx:ebx <- divisor
|
||||||
mov ebx,DVSRLO
|
mov ebx,DVSRLO
|
||||||
mov edx,DVNDHI // edx:eax <- dividend
|
mov edx,DVNDHI // edx:eax <- dividend
|
||||||
mov eax,DVNDLO
|
mov eax,DVNDLO
|
||||||
..L3:
|
..L3:
|
||||||
shr ecx,1 // shift divisor right one bit// hi bit <- 0
|
shr ecx,1 // shift divisor right one bit// hi bit <- 0
|
||||||
rcr ebx,1
|
rcr ebx,1
|
||||||
shr edx,1 // shift dividend right one bit// hi bit <- 0
|
shr edx,1 // shift dividend right one bit// hi bit <- 0
|
||||||
rcr eax,1
|
rcr eax,1
|
||||||
or ecx,ecx
|
or ecx,ecx
|
||||||
jnz short ..L3 // loop until divisor < 4194304K
|
jnz short ..L3 // loop until divisor < 4194304K
|
||||||
div ebx // now divide, ignore remainder
|
div ebx // now divide, ignore remainder
|
||||||
mov esi,eax // save quotient
|
mov esi,eax // save quotient
|
||||||
|
|
||||||
//
|
//
|
||||||
// We may be off by one, so to check, we will multiply the quotient
|
// We may be off by one, so to check, we will multiply the quotient
|
||||||
// by the divisor and check the result against the orignal dividend
|
// by the divisor and check the result against the orignal dividend
|
||||||
// Note that we must also check for overflow, which can occur if the
|
// Note that we must also check for overflow, which can occur if the
|
||||||
// dividend is close to 2**64 and the quotient is off by 1.
|
// dividend is close to 2**64 and the quotient is off by 1.
|
||||||
//
|
//
|
||||||
|
|
||||||
mul dword ptr DVSRHI // QUOT * DVSRHI
|
mul dword ptr DVSRHI // QUOT * DVSRHI
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
mov eax,DVSRLO
|
mov eax,DVSRLO
|
||||||
mul esi // QUOT * DVSRLO
|
mul esi // QUOT * DVSRLO
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jc short ..L4 // carry means Quotient is off by 1
|
jc short ..L4 // carry means Quotient is off by 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// do long compare here between original dividend and the result of the
|
// do long compare here between original dividend and the result of the
|
||||||
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
||||||
// subtract one (1) from the quotient.
|
// subtract one (1) from the quotient.
|
||||||
//
|
//
|
||||||
|
|
||||||
cmp edx,DVNDHI // compare hi words of result and original
|
cmp edx,DVNDHI // compare hi words of result and original
|
||||||
ja short ..L4 // if result > original, do subtract
|
ja short ..L4 // if result > original, do subtract
|
||||||
jb short ..L5 // if result < original, we are ok
|
jb short ..L5 // if result < original, we are ok
|
||||||
cmp eax,DVNDLO // hi words are equal, compare lo words
|
cmp eax,DVNDLO // hi words are equal, compare lo words
|
||||||
jbe short ..L5 // if less or equal we are ok, else subtract
|
jbe short ..L5 // if less or equal we are ok, else subtract
|
||||||
..L4:
|
..L4:
|
||||||
dec esi // subtract 1 from quotient
|
dec esi // subtract 1 from quotient
|
||||||
..L5:
|
..L5:
|
||||||
xor edx,edx // edx:eax <- quotient
|
xor edx,edx // edx:eax <- quotient
|
||||||
mov eax,esi
|
mov eax,esi
|
||||||
|
|
||||||
//
|
//
|
||||||
// Just the cleanup left to do. edx:eax contains the quotient.
|
// Just the cleanup left to do. edx:eax contains the quotient.
|
||||||
// Restore the saved registers and return.
|
// Restore the saved registers and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
..L2:
|
..L2:
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
ret 16
|
ret 16
|
||||||
|
|
|
@ -1,205 +1,205 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/aulldvrm.S
|
* FILE: lib/rtl/i386/aulldvrm.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __aulldvrm
|
.globl __aulldvrm
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
__aulldvrm:
|
__aulldvrm:
|
||||||
|
|
||||||
// ulldvrm - unsigned long divide and remainder
|
// ulldvrm - unsigned long divide and remainder
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a unsigned long divide and remainder of the arguments. Arguments
|
// Does a unsigned long divide and remainder of the arguments. Arguments
|
||||||
// are not changed.
|
// are not changed.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// Arguments are passed on the stack:
|
// Arguments are passed on the stack:
|
||||||
// 1st pushed: divisor (QWORD)
|
// 1st pushed: divisor (QWORD)
|
||||||
// 2nd pushed: dividend (QWORD)
|
// 2nd pushed: dividend (QWORD)
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX contains the quotient (dividend/divisor)
|
// EDX:EAX contains the quotient (dividend/divisor)
|
||||||
// EBX:ECX contains the remainder (divided % divisor)
|
// EBX:ECX contains the remainder (divided % divisor)
|
||||||
// NOTE: this routine removes the parameters from the stack.
|
// NOTE: this routine removes the parameters from the stack.
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// ECX
|
// ECX
|
||||||
//
|
//
|
||||||
push esi
|
push esi
|
||||||
|
|
||||||
// Set up the local stack and save the index registers. When this is done
|
// Set up the local stack and save the index registers. When this is done
|
||||||
// the stack frame will look as follows (assuming that the expression a/b will
|
// the stack frame will look as follows (assuming that the expression a/b will
|
||||||
// generate a call to aulldvrm(a, b)):
|
// generate a call to aulldvrm(a, b)):
|
||||||
//
|
//
|
||||||
// -----------------
|
// -----------------
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--divisor (b)--|
|
// |--divisor (b)--|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--dividend (a)-|
|
// |--dividend (a)-|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | return addr** |
|
// | return addr** |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// ESP---->| ESI |
|
// ESP---->| ESI |
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#undef DVNDLO
|
#undef DVNDLO
|
||||||
#undef DVNDHI
|
#undef DVNDHI
|
||||||
#undef DVSRLO
|
#undef DVSRLO
|
||||||
#undef DVSRHI
|
#undef DVSRHI
|
||||||
#define DVNDLO [esp + 8] // stack address of dividend (a)
|
#define DVNDLO [esp + 8] // stack address of dividend (a)
|
||||||
#define DVNDHI [esp + 8] // stack address of dividend (a)
|
#define DVNDHI [esp + 8] // stack address of dividend (a)
|
||||||
#define DVSRLO [esp + 16] // stack address of divisor (b)
|
#define DVSRLO [esp + 16] // stack address of divisor (b)
|
||||||
#define DVSRHI [esp + 20] // stack address of divisor (b)
|
#define DVSRHI [esp + 20] // stack address of divisor (b)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
||||||
// If so, then we can use a simple algorithm with word divides, otherwise
|
// If so, then we can use a simple algorithm with word divides, otherwise
|
||||||
// things get a little more complex.
|
// things get a little more complex.
|
||||||
//
|
//
|
||||||
|
|
||||||
mov eax,DVSRHI // check to see if divisor < 4194304K
|
mov eax,DVSRHI // check to see if divisor < 4194304K
|
||||||
or eax,eax
|
or eax,eax
|
||||||
jnz short .....L1 // nope, gotta do this the hard way
|
jnz short .....L1 // nope, gotta do this the hard way
|
||||||
mov ecx,DVSRLO // load divisor
|
mov ecx,DVSRLO // load divisor
|
||||||
mov eax,DVNDHI // load high word of dividend
|
mov eax,DVNDHI // load high word of dividend
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
div ecx // get high order bits of quotient
|
div ecx // get high order bits of quotient
|
||||||
mov ebx,eax // save high bits of quotient
|
mov ebx,eax // save high bits of quotient
|
||||||
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
||||||
div ecx // get low order bits of quotient
|
div ecx // get low order bits of quotient
|
||||||
mov esi,eax // ebx:esi <- quotient
|
mov esi,eax // ebx:esi <- quotient
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now we need to do a multiply so that we can compute the remainder.
|
// Now we need to do a multiply so that we can compute the remainder.
|
||||||
//
|
//
|
||||||
mov eax,ebx // set up high word of quotient
|
mov eax,ebx // set up high word of quotient
|
||||||
mul dword ptr DVSRLO // HIWORD(QUOT) * DVSR
|
mul dword ptr DVSRLO // HIWORD(QUOT) * DVSR
|
||||||
mov ecx,eax // save the result in ecx
|
mov ecx,eax // save the result in ecx
|
||||||
mov eax,esi // set up low word of quotient
|
mov eax,esi // set up low word of quotient
|
||||||
mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR
|
mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jmp short .....L2 // complete remainder calculation
|
jmp short .....L2 // complete remainder calculation
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we do it the hard way. Remember, eax contains DVSRHI
|
// Here we do it the hard way. Remember, eax contains DVSRHI
|
||||||
//
|
//
|
||||||
|
|
||||||
.....L1:
|
.....L1:
|
||||||
mov ecx,eax // ecx:ebx <- divisor
|
mov ecx,eax // ecx:ebx <- divisor
|
||||||
mov ebx,DVSRLO
|
mov ebx,DVSRLO
|
||||||
mov edx,DVNDHI // edx:eax <- dividend
|
mov edx,DVNDHI // edx:eax <- dividend
|
||||||
mov eax,DVNDLO
|
mov eax,DVNDLO
|
||||||
.....L3:
|
.....L3:
|
||||||
shr ecx,1 // shift divisor right one bit// hi bit <- 0
|
shr ecx,1 // shift divisor right one bit// hi bit <- 0
|
||||||
rcr ebx,1
|
rcr ebx,1
|
||||||
shr edx,1 // shift dividend right one bit// hi bit <- 0
|
shr edx,1 // shift dividend right one bit// hi bit <- 0
|
||||||
rcr eax,1
|
rcr eax,1
|
||||||
or ecx,ecx
|
or ecx,ecx
|
||||||
jnz short .....L3 // loop until divisor < 4194304K
|
jnz short .....L3 // loop until divisor < 4194304K
|
||||||
div ebx // now divide, ignore remainder
|
div ebx // now divide, ignore remainder
|
||||||
mov esi,eax // save quotient
|
mov esi,eax // save quotient
|
||||||
|
|
||||||
//
|
//
|
||||||
// We may be off by one, so to check, we will multiply the quotient
|
// We may be off by one, so to check, we will multiply the quotient
|
||||||
// by the divisor and check the result against the orignal dividend
|
// by the divisor and check the result against the orignal dividend
|
||||||
// Note that we must also check for overflow, which can occur if the
|
// Note that we must also check for overflow, which can occur if the
|
||||||
// dividend is close to 2**64 and the quotient is off by 1.
|
// dividend is close to 2**64 and the quotient is off by 1.
|
||||||
//
|
//
|
||||||
|
|
||||||
mul dword ptr DVSRHI // QUOT * DVSRHI
|
mul dword ptr DVSRHI // QUOT * DVSRHI
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
mov eax,DVSRLO
|
mov eax,DVSRLO
|
||||||
mul esi // QUOT * DVSRLO
|
mul esi // QUOT * DVSRLO
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jc short .....L4 // carry means Quotient is off by 1
|
jc short .....L4 // carry means Quotient is off by 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// do long compare here between original dividend and the result of the
|
// do long compare here between original dividend and the result of the
|
||||||
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
|
||||||
// subtract one (1) from the quotient.
|
// subtract one (1) from the quotient.
|
||||||
//
|
//
|
||||||
|
|
||||||
cmp edx,DVNDHI // compare hi words of result and original
|
cmp edx,DVNDHI // compare hi words of result and original
|
||||||
ja short .....L4 // if result > original, do subtract
|
ja short .....L4 // if result > original, do subtract
|
||||||
jb short .....L5 // if result < original, we are ok
|
jb short .....L5 // if result < original, we are ok
|
||||||
cmp eax,DVNDLO // hi words are equal, compare lo words
|
cmp eax,DVNDLO // hi words are equal, compare lo words
|
||||||
jbe short .....L5 // if less or equal we are ok, else subtract
|
jbe short .....L5 // if less or equal we are ok, else subtract
|
||||||
.....L4:
|
.....L4:
|
||||||
dec esi // subtract 1 from quotient
|
dec esi // subtract 1 from quotient
|
||||||
sub eax,DVSRLO // subtract divisor from result
|
sub eax,DVSRLO // subtract divisor from result
|
||||||
sbb edx,DVSRHI
|
sbb edx,DVSRHI
|
||||||
.....L5:
|
.....L5:
|
||||||
xor ebx,ebx // ebx:esi <- quotient
|
xor ebx,ebx // ebx:esi <- quotient
|
||||||
|
|
||||||
.....L2:
|
.....L2:
|
||||||
//
|
//
|
||||||
// Calculate remainder by subtracting the result from the original dividend.
|
// Calculate remainder by subtracting the result from the original dividend.
|
||||||
// Since the result is already in a register, we will do the subtract in the
|
// Since the result is already in a register, we will do the subtract in the
|
||||||
// opposite direction and negate the result.
|
// opposite direction and negate the result.
|
||||||
//
|
//
|
||||||
|
|
||||||
sub eax,DVNDLO // subtract dividend from result
|
sub eax,DVNDLO // subtract dividend from result
|
||||||
sbb edx,DVNDHI
|
sbb edx,DVNDHI
|
||||||
neg edx // otherwise, negate the result
|
neg edx // otherwise, negate the result
|
||||||
neg eax
|
neg eax
|
||||||
sbb edx,0
|
sbb edx,0
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now we need to get the quotient into edx:eax and the remainder into ebx:ecx.
|
// Now we need to get the quotient into edx:eax and the remainder into ebx:ecx.
|
||||||
//
|
//
|
||||||
mov ecx,edx
|
mov ecx,edx
|
||||||
mov edx,ebx
|
mov edx,ebx
|
||||||
mov ebx,ecx
|
mov ebx,ecx
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
mov eax,esi
|
mov eax,esi
|
||||||
//
|
//
|
||||||
// Just the cleanup left to do. edx:eax contains the quotient.
|
// Just the cleanup left to do. edx:eax contains the quotient.
|
||||||
// Restore the saved registers and return.
|
// Restore the saved registers and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
|
|
||||||
ret 16
|
ret 16
|
||||||
|
|
|
@ -1,185 +1,185 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/aullrem.S
|
* FILE: lib/rtl/i386/aullrem.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __aullrem
|
.globl __aullrem
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// ullrem - unsigned long remainder
|
// ullrem - unsigned long remainder
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a unsigned long remainder of the arguments. Arguments are
|
// Does a unsigned long remainder of the arguments. Arguments are
|
||||||
// not changed.
|
// not changed.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// Arguments are passed on the stack:
|
// Arguments are passed on the stack:
|
||||||
// 1st pushed: divisor (QWORD)
|
// 1st pushed: divisor (QWORD)
|
||||||
// 2nd pushed: dividend (QWORD)
|
// 2nd pushed: dividend (QWORD)
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX contains the remainder (dividend%divisor)
|
// EDX:EAX contains the remainder (dividend%divisor)
|
||||||
// NOTE: this routine removes the parameters from the stack.
|
// NOTE: this routine removes the parameters from the stack.
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// ECX
|
// ECX
|
||||||
//
|
//
|
||||||
|
|
||||||
__aullrem:
|
__aullrem:
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
// Set up the local stack and save the index registers. When this is done
|
// Set up the local stack and save the index registers. When this is done
|
||||||
// the stack frame will look as follows (assuming that the expression a%b will
|
// the stack frame will look as follows (assuming that the expression a%b will
|
||||||
// generate a call to ullrem(a, b)):
|
// generate a call to ullrem(a, b)):
|
||||||
//
|
//
|
||||||
// -----------------
|
// -----------------
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--divisor (b)--|
|
// |--divisor (b)--|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | |
|
// | |
|
||||||
// |--dividend (a)-|
|
// |--dividend (a)-|
|
||||||
// | |
|
// | |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// | return addr** |
|
// | return addr** |
|
||||||
// |---------------|
|
// |---------------|
|
||||||
// ESP---->| EBX |
|
// ESP---->| EBX |
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#undef DVNDLO
|
#undef DVNDLO
|
||||||
#undef DVNDHI
|
#undef DVNDHI
|
||||||
#undef DVSRLO
|
#undef DVSRLO
|
||||||
#undef DVSRHI
|
#undef DVSRHI
|
||||||
#define DVNDLO [esp + 8] // stack address of dividend (a)
|
#define DVNDLO [esp + 8] // stack address of dividend (a)
|
||||||
#define DVNDHI [esp + 8] // stack address of dividend (a)
|
#define DVNDHI [esp + 8] // stack address of dividend (a)
|
||||||
#define DVSRLO [esp + 16] // stack address of divisor (b)
|
#define DVSRLO [esp + 16] // stack address of divisor (b)
|
||||||
#define DVSRHI [esp + 20] // stack address of divisor (b)
|
#define DVSRHI [esp + 20] // stack address of divisor (b)
|
||||||
|
|
||||||
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
||||||
// If so, then we can use a simple algorithm with word divides, otherwise
|
// If so, then we can use a simple algorithm with word divides, otherwise
|
||||||
// things get a little more complex.
|
// things get a little more complex.
|
||||||
//
|
//
|
||||||
|
|
||||||
mov eax,DVSRHI // check to see if divisor < 4194304K
|
mov eax,DVSRHI // check to see if divisor < 4194304K
|
||||||
or eax,eax
|
or eax,eax
|
||||||
jnz short ...L1 // nope, gotta do this the hard way
|
jnz short ...L1 // nope, gotta do this the hard way
|
||||||
mov ecx,DVSRLO // load divisor
|
mov ecx,DVSRLO // load divisor
|
||||||
mov eax,DVNDHI // load high word of dividend
|
mov eax,DVNDHI // load high word of dividend
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
div ecx // edx <- remainder, eax <- quotient
|
div ecx // edx <- remainder, eax <- quotient
|
||||||
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
|
||||||
div ecx // edx <- final remainder
|
div ecx // edx <- final remainder
|
||||||
mov eax,edx // edx:eax <- remainder
|
mov eax,edx // edx:eax <- remainder
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
jmp short ...L2 // restore stack and return
|
jmp short ...L2 // restore stack and return
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we do it the hard way. Remember, eax contains DVSRHI
|
// Here we do it the hard way. Remember, eax contains DVSRHI
|
||||||
//
|
//
|
||||||
|
|
||||||
...L1:
|
...L1:
|
||||||
mov ecx,eax // ecx:ebx <- divisor
|
mov ecx,eax // ecx:ebx <- divisor
|
||||||
mov ebx,DVSRLO
|
mov ebx,DVSRLO
|
||||||
mov edx,DVNDHI // edx:eax <- dividend
|
mov edx,DVNDHI // edx:eax <- dividend
|
||||||
mov eax,DVNDLO
|
mov eax,DVNDLO
|
||||||
...L3:
|
...L3:
|
||||||
shr ecx,1 // shift divisor right one bit// hi bit <- 0
|
shr ecx,1 // shift divisor right one bit// hi bit <- 0
|
||||||
rcr ebx,1
|
rcr ebx,1
|
||||||
shr edx,1 // shift dividend right one bit// hi bit <- 0
|
shr edx,1 // shift dividend right one bit// hi bit <- 0
|
||||||
rcr eax,1
|
rcr eax,1
|
||||||
or ecx,ecx
|
or ecx,ecx
|
||||||
jnz short ...L3 // loop until divisor < 4194304K
|
jnz short ...L3 // loop until divisor < 4194304K
|
||||||
div ebx // now divide, ignore remainder
|
div ebx // now divide, ignore remainder
|
||||||
|
|
||||||
//
|
//
|
||||||
// We may be off by one, so to check, we will multiply the quotient
|
// We may be off by one, so to check, we will multiply the quotient
|
||||||
// by the divisor and check the result against the orignal dividend
|
// by the divisor and check the result against the orignal dividend
|
||||||
// Note that we must also check for overflow, which can occur if the
|
// Note that we must also check for overflow, which can occur if the
|
||||||
// dividend is close to 2**64 and the quotient is off by 1.
|
// dividend is close to 2**64 and the quotient is off by 1.
|
||||||
//
|
//
|
||||||
|
|
||||||
mov ecx,eax // save a copy of quotient in ECX
|
mov ecx,eax // save a copy of quotient in ECX
|
||||||
mul dword ptr DVSRHI
|
mul dword ptr DVSRHI
|
||||||
xchg ecx,eax // put partial product in ECX, get quotient in EAX
|
xchg ecx,eax // put partial product in ECX, get quotient in EAX
|
||||||
mul dword ptr DVSRLO
|
mul dword ptr DVSRLO
|
||||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||||
jc short ...L4 // carry means Quotient is off by 1
|
jc short ...L4 // carry means Quotient is off by 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// do long compare here between original dividend and the result of the
|
// do long compare here between original dividend and the result of the
|
||||||
// multiply in edx:eax. If original is larger or equal, we're ok, otherwise
|
// multiply in edx:eax. If original is larger or equal, we're ok, otherwise
|
||||||
// subtract the original divisor from the result.
|
// subtract the original divisor from the result.
|
||||||
//
|
//
|
||||||
|
|
||||||
cmp edx,DVNDHI // compare hi words of result and original
|
cmp edx,DVNDHI // compare hi words of result and original
|
||||||
ja short ...L4 // if result > original, do subtract
|
ja short ...L4 // if result > original, do subtract
|
||||||
jb short ...L5 // if result < original, we're ok
|
jb short ...L5 // if result < original, we're ok
|
||||||
cmp eax,DVNDLO // hi words are equal, compare lo words
|
cmp eax,DVNDLO // hi words are equal, compare lo words
|
||||||
jbe short ...L5 // if less or equal we're ok, else subtract
|
jbe short ...L5 // if less or equal we're ok, else subtract
|
||||||
...L4:
|
...L4:
|
||||||
sub eax,DVSRLO // subtract divisor from result
|
sub eax,DVSRLO // subtract divisor from result
|
||||||
sbb edx,DVSRHI
|
sbb edx,DVSRHI
|
||||||
...L5:
|
...L5:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate remainder by subtracting the result from the original dividend.
|
// Calculate remainder by subtracting the result from the original dividend.
|
||||||
// Since the result is already in a register, we will perform the subtract in
|
// Since the result is already in a register, we will perform the subtract in
|
||||||
// the opposite direction and negate the result to make it positive.
|
// the opposite direction and negate the result to make it positive.
|
||||||
//
|
//
|
||||||
|
|
||||||
sub eax,DVNDLO // subtract original dividend from result
|
sub eax,DVNDLO // subtract original dividend from result
|
||||||
sbb edx,DVNDHI
|
sbb edx,DVNDHI
|
||||||
neg edx // and negate it
|
neg edx // and negate it
|
||||||
neg eax
|
neg eax
|
||||||
sbb edx,0
|
sbb edx,0
|
||||||
|
|
||||||
//
|
//
|
||||||
// Just the cleanup left to do. dx:ax contains the remainder.
|
// Just the cleanup left to do. dx:ax contains the remainder.
|
||||||
// Restore the saved registers and return.
|
// Restore the saved registers and return.
|
||||||
//
|
//
|
||||||
|
|
||||||
...L2:
|
...L2:
|
||||||
|
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
ret 16
|
ret 16
|
||||||
|
|
|
@ -1,96 +1,96 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/uallshr.S
|
* FILE: lib/rtl/i386/uallshr.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __aullshr
|
.globl __aullshr
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// ullshr - long shift right
|
// ullshr - long shift right
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Does a unsigned Long Shift Right
|
// Does a unsigned Long Shift Right
|
||||||
// Shifts a long right any number of bits.
|
// Shifts a long right any number of bits.
|
||||||
//
|
//
|
||||||
// Entry:
|
// Entry:
|
||||||
// EDX:EAX - long value to be shifted
|
// EDX:EAX - long value to be shifted
|
||||||
// CL - number of bits to shift by
|
// CL - number of bits to shift by
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// EDX:EAX - shifted value
|
// EDX:EAX - shifted value
|
||||||
//
|
//
|
||||||
// Uses:
|
// Uses:
|
||||||
// CL is destroyed.
|
// CL is destroyed.
|
||||||
//
|
//
|
||||||
|
|
||||||
__aullshr:
|
__aullshr:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
|
// Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
|
||||||
// depends only on the high order bit of edx).
|
// depends only on the high order bit of edx).
|
||||||
//
|
//
|
||||||
cmp cl,64
|
cmp cl,64
|
||||||
jae short ..RETZERO
|
jae short ..RETZERO
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of between 0 and 31 bits
|
// Handle shifts of between 0 and 31 bits
|
||||||
//
|
//
|
||||||
cmp cl, 32
|
cmp cl, 32
|
||||||
jae short ..MORE32
|
jae short ..MORE32
|
||||||
shrd eax,edx,cl
|
shrd eax,edx,cl
|
||||||
shr edx,cl
|
shr edx,cl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle shifts of between 32 and 63 bits
|
// Handle shifts of between 32 and 63 bits
|
||||||
//
|
//
|
||||||
..MORE32:
|
..MORE32:
|
||||||
mov eax,edx
|
mov eax,edx
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
and cl,31
|
and cl,31
|
||||||
shr eax,cl
|
shr eax,cl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
//
|
//
|
||||||
// return 0 in edx:eax
|
// return 0 in edx:eax
|
||||||
//
|
//
|
||||||
..RETZERO:
|
..RETZERO:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,58 +1,58 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/ceil.S
|
* FILE: lib/rtl/i386/ceil.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _ceil
|
.globl _ceil
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_ceil:
|
_ceil:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
sub esp,4 // Allocate temporary space
|
sub esp,4 // Allocate temporary space
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fstcw [ebp-2] // Save control word
|
fstcw [ebp-2] // Save control word
|
||||||
fclex // Clear exceptions
|
fclex // Clear exceptions
|
||||||
mov word ptr [ebp-4],0xb63 // Rounding control word
|
mov word ptr [ebp-4],0xb63 // Rounding control word
|
||||||
fldcw [ebp-4] // Set new rounding control
|
fldcw [ebp-4] // Set new rounding control
|
||||||
frndint // Round to integer
|
frndint // Round to integer
|
||||||
fclex // Clear exceptions
|
fclex // Clear exceptions
|
||||||
fldcw [ebp-2] // Restore control word
|
fldcw [ebp-2] // Restore control word
|
||||||
mov esp,ebp // Deallocate temporary space
|
mov esp,ebp // Deallocate temporary space
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: comparememory_asm.S
|
* FILE: comparememory_asm.S
|
||||||
* PURPOSE: Memory functions
|
* PURPOSE: Memory functions
|
||||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||||
* Alex Ionescu (alex@relsoft.net)
|
* Alex Ionescu (alex@relsoft.net)
|
||||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl _RtlCompareMemory@12 // [4] (no bug)
|
.globl _RtlCompareMemory@12 // [4] (no bug)
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_RtlCompareMemory@12:
|
_RtlCompareMemory@12:
|
||||||
xor eax,eax // count = 0
|
xor eax,eax // count = 0
|
||||||
mov ecx, dword [esp + 12 ] // ecx = Length
|
mov ecx, dword [esp + 12 ] // ecx = Length
|
||||||
cmp ecx,0 // if (Length==0) goto .zero
|
cmp ecx,0 // if (Length==0) goto .zero
|
||||||
je 3f
|
je 3f
|
||||||
|
|
||||||
push edi// register that does not to be save eax,ecx,edx to
|
push edi// register that does not to be save eax,ecx,edx to
|
||||||
push ebx// the stack for protetion
|
push ebx// the stack for protetion
|
||||||
|
|
||||||
mov edi, dword [esp + (4 + 8)] // edi = Destination
|
mov edi, dword [esp + (4 + 8)] // edi = Destination
|
||||||
mov edx, dword [esp + (8 + 8)] // edx = Source
|
mov edx, dword [esp + (8 + 8)] // edx = Source
|
||||||
|
|
||||||
1:
|
1:
|
||||||
mov bl,byte [edi + eax ] // if (src[count]!=des[count]) goto .pop_zero
|
mov bl,byte [edi + eax ] // if (src[count]!=des[count]) goto .pop_zero
|
||||||
cmp byte [edx + eax ],bl
|
cmp byte [edx + eax ],bl
|
||||||
jne 2f
|
jne 2f
|
||||||
|
|
||||||
inc eax // count = count + 1
|
inc eax // count = count + 1
|
||||||
dec ecx // Length = Length - 1
|
dec ecx // Length = Length - 1
|
||||||
jnz 1b // if (Length!=0) goto .loop_1byte
|
jnz 1b // if (Length!=0) goto .loop_1byte
|
||||||
|
|
||||||
2:
|
2:
|
||||||
pop ebx // restore regiester
|
pop ebx // restore regiester
|
||||||
pop edi
|
pop edi
|
||||||
3:
|
3:
|
||||||
ret 12 // return count
|
ret 12 // return count
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: comparememory_ulong_asm.S
|
* FILE: comparememory_ulong_asm.S
|
||||||
* PURPOSE: Memory functions
|
* PURPOSE: Memory functions
|
||||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||||
* Alex Ionescu (alex@relsoft.net)
|
* Alex Ionescu (alex@relsoft.net)
|
||||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl _RtlCompareMemoryUlong@12 // [5] (no bug)
|
.globl _RtlCompareMemoryUlong@12 // [5] (no bug)
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_RtlCompareMemoryUlong@12:
|
_RtlCompareMemoryUlong@12:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov ecx, dword [esp + 8 ] // ecx = Length
|
mov ecx, dword [esp + 8 ] // ecx = Length
|
||||||
shr ecx,2 // Length / sizeof(ULONG)
|
shr ecx,2 // Length / sizeof(ULONG)
|
||||||
jz 1f // if (Length==0) goto .zero
|
jz 1f // if (Length==0) goto .zero
|
||||||
|
|
||||||
push edi// register that does not to be save eax,ecx,edx to
|
push edi// register that does not to be save eax,ecx,edx to
|
||||||
push ebx// the stack for protetion
|
push ebx// the stack for protetion
|
||||||
|
|
||||||
mov edi, dword [esp + (4 + 8)] // edx = Destination
|
mov edi, dword [esp + (4 + 8)] // edx = Destination
|
||||||
mov eax, dword [esp + (12 + 8)] // ebx = value
|
mov eax, dword [esp + (12 + 8)] // ebx = value
|
||||||
mov ebx,ecx
|
mov ebx,ecx
|
||||||
cld
|
cld
|
||||||
repe scasd
|
repe scasd
|
||||||
|
|
||||||
inc ecx
|
inc ecx
|
||||||
mov eax,ebx
|
mov eax,ebx
|
||||||
|
|
||||||
sub eax,ecx
|
sub eax,ecx
|
||||||
shl eax,2
|
shl eax,2
|
||||||
|
|
||||||
pop ebx
|
pop ebx
|
||||||
pop edi
|
pop edi
|
||||||
|
|
||||||
1:
|
1:
|
||||||
ret 12
|
ret 12
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/cos.S
|
* FILE: lib/rtl/i386/cos.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _cos
|
.globl _cos
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_cos:
|
_cos:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp // Point to the stack frame
|
mov ebp,esp // Point to the stack frame
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fcos // Take the cosine
|
fcos // Take the cosine
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,61 +1,61 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS Run-Time Library
|
* PROJECT: ReactOS Run-Time Library
|
||||||
* PURPOSE: Debug Routines
|
* PURPOSE: Debug Routines
|
||||||
* FILE: lib/rtl/i386/debug.S
|
* FILE: lib/rtl/i386/debug.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl _DbgBreakPoint@0
|
.globl _DbgBreakPoint@0
|
||||||
.globl _DbgBreakPointWithStatus@4
|
.globl _DbgBreakPointWithStatus@4
|
||||||
.globl _DbgUserBreakPoint@0
|
.globl _DbgUserBreakPoint@0
|
||||||
.globl _DebugService@20
|
.globl _DebugService@20
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_DbgBreakPoint@0:
|
_DbgBreakPoint@0:
|
||||||
_DbgUserBreakPoint@0:
|
_DbgUserBreakPoint@0:
|
||||||
int 3
|
int 3
|
||||||
ret
|
ret
|
||||||
|
|
||||||
_DbgBreakPointWithStatus@4:
|
_DbgBreakPointWithStatus@4:
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
int 3
|
int 3
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
_DebugService@20:
|
_DebugService@20:
|
||||||
|
|
||||||
/* Setup the stack */
|
/* Setup the stack */
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
|
|
||||||
/* Save the registers */
|
/* Save the registers */
|
||||||
push ecx
|
push ecx
|
||||||
push ebx
|
push ebx
|
||||||
push edi
|
push edi
|
||||||
push edi
|
push edi
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
/* Call the Interrupt */
|
/* Call the Interrupt */
|
||||||
mov eax, [ebp+8]
|
mov eax, [ebp+8]
|
||||||
mov ecx, [ebp+12]
|
mov ecx, [ebp+12]
|
||||||
mov edx, [ebp+16]
|
mov edx, [ebp+16]
|
||||||
mov ebx, [ebp+20]
|
mov ebx, [ebp+20]
|
||||||
mov edi, [ebp+24]
|
mov edi, [ebp+24]
|
||||||
int 0x2D
|
int 0x2D
|
||||||
//int 3
|
//int 3
|
||||||
|
|
||||||
/* Restore registers */
|
/* Restore registers */
|
||||||
pop ebx
|
pop ebx
|
||||||
pop edi
|
pop edi
|
||||||
pop edi
|
pop edi
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
/* Return */
|
/* Return */
|
||||||
leave
|
leave
|
||||||
ret 20
|
ret 20
|
||||||
|
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/fabs.S
|
* FILE: lib/rtl/i386/fabs.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _fabs
|
.globl _fabs
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_fabs:
|
_fabs:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fabs // Take the absolute value
|
fabs // Take the absolute value
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: fillmemory_asm.S
|
* FILE: fillmemory_asm.S
|
||||||
* PURPOSE: Memory functions
|
* PURPOSE: Memory functions
|
||||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||||
* Alex Ionescu (alex@relsoft.net)
|
* Alex Ionescu (alex@relsoft.net)
|
||||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl _RtlFillMemory@12 //[4] (no bug)
|
.globl _RtlFillMemory@12 //[4] (no bug)
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_RtlFillMemory@12:
|
_RtlFillMemory@12:
|
||||||
mov ecx,dword [esp + 8 ] // ecx = Length
|
mov ecx,dword [esp + 8 ] // ecx = Length
|
||||||
cmp ecx,0// if (Length==0) goto .zero
|
cmp ecx,0// if (Length==0) goto .zero
|
||||||
je 2f
|
je 2f
|
||||||
|
|
||||||
mov edx, dword [esp + 4] // edx = Destination
|
mov edx, dword [esp + 4] // edx = Destination
|
||||||
mov eax, dword [esp + 12] // eax = fill
|
mov eax, dword [esp + 12] // eax = fill
|
||||||
1:
|
1:
|
||||||
mov byte [edx + ecx -1],al // src[Length - 1] = fill
|
mov byte [edx + ecx -1],al // src[Length - 1] = fill
|
||||||
dec ecx // Length = Length - 1
|
dec ecx // Length = Length - 1
|
||||||
jnz 1b // if (Length!=0) goto .loop
|
jnz 1b // if (Length!=0) goto .loop
|
||||||
2:
|
2:
|
||||||
ret 12 // return
|
ret 12 // return
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: fillmemory_ulong_asm.S
|
* FILE: fillmemory_ulong_asm.S
|
||||||
* PURPOSE: Memory functions
|
* PURPOSE: Memory functions
|
||||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||||
* Alex Ionescu (alex@relsoft.net)
|
* Alex Ionescu (alex@relsoft.net)
|
||||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl _RtlFillMemoryUlong@12 // (no bug) (max optimze code)
|
.globl _RtlFillMemoryUlong@12 // (no bug) (max optimze code)
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_RtlFillMemoryUlong@12:
|
_RtlFillMemoryUlong@12:
|
||||||
mov ecx, dword [esp + 8 ] // Length
|
mov ecx, dword [esp + 8 ] // Length
|
||||||
shr ecx,2// Length = Length / sizeof(ULONG)
|
shr ecx,2// Length = Length / sizeof(ULONG)
|
||||||
jz 1f // if (Length==0) goto .zero
|
jz 1f // if (Length==0) goto .zero
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi, dword [esp + (4 + 4)] // Destination
|
mov edi, dword [esp + (4 + 4)] // Destination
|
||||||
mov eax, dword [esp + (12 + 4)] // Fill
|
mov eax, dword [esp + (12 + 4)] // Fill
|
||||||
cld
|
cld
|
||||||
rep stosd// while (Length>0) {Destination[Length-1]=Fill// Length = Length - 1}
|
rep stosd// while (Length>0) {Destination[Length-1]=Fill// Length = Length - 1}
|
||||||
pop edi
|
pop edi
|
||||||
1:
|
1:
|
||||||
ret 12
|
ret 12
|
||||||
|
|
|
@ -1,58 +1,58 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/floor.S
|
* FILE: lib/rtl/i386/floor.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _floor
|
.globl _floor
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_floor:
|
_floor:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
sub esp,4 // Allocate temporary space
|
sub esp,4 // Allocate temporary space
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fstcw [ebp-2] // Save control word
|
fstcw [ebp-2] // Save control word
|
||||||
fclex // Clear exceptions
|
fclex // Clear exceptions
|
||||||
mov word ptr [ebp-4],0x763 // Rounding control word
|
mov word ptr [ebp-4],0x763 // Rounding control word
|
||||||
fldcw [ebp-4] // Set new rounding control
|
fldcw [ebp-4] // Set new rounding control
|
||||||
frndint // Round to integer
|
frndint // Round to integer
|
||||||
fclex // Clear exceptions
|
fclex // Clear exceptions
|
||||||
fldcw [ebp-2] // Restore control word
|
fldcw [ebp-2] // Restore control word
|
||||||
mov esp,ebp
|
mov esp,ebp
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,74 +1,74 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/ftol.S
|
* FILE: lib/rtl/i386/ftol.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl __ftol
|
.globl __ftol
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine is called by MSVC-generated code to convert from floating point
|
* This routine is called by MSVC-generated code to convert from floating point
|
||||||
* to integer representation. The floating point number to be converted is
|
* to integer representation. The floating point number to be converted is
|
||||||
* on the top of the floating point stack.
|
* on the top of the floating point stack.
|
||||||
*/
|
*/
|
||||||
__ftol:
|
__ftol:
|
||||||
/* Set up stack frame */
|
/* Set up stack frame */
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
|
|
||||||
/* Set "round towards zero" mode */
|
/* Set "round towards zero" mode */
|
||||||
fstcw [ebp-2]
|
fstcw [ebp-2]
|
||||||
wait
|
wait
|
||||||
mov ax, [ebp-2]
|
mov ax, [ebp-2]
|
||||||
or ah, 0xC
|
or ah, 0xC
|
||||||
mov [ebp-4], ax
|
mov [ebp-4], ax
|
||||||
fldcw [ebp-4]
|
fldcw [ebp-4]
|
||||||
|
|
||||||
/* Do the conversion */
|
/* Do the conversion */
|
||||||
fistp qword ptr [ebp-12]
|
fistp qword ptr [ebp-12]
|
||||||
|
|
||||||
/* Restore rounding mode */
|
/* Restore rounding mode */
|
||||||
fldcw [ebp-2]
|
fldcw [ebp-2]
|
||||||
|
|
||||||
/* Return value */
|
/* Return value */
|
||||||
mov eax, [ebp-12]
|
mov eax, [ebp-12]
|
||||||
mov edx, [ebp-8]
|
mov edx, [ebp-8]
|
||||||
|
|
||||||
/* Remove stack frame and return*/
|
/* Remove stack frame and return*/
|
||||||
leave
|
leave
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,52 +1,52 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/log.S
|
* FILE: lib/rtl/i386/log.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _log
|
.globl _log
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_log:
|
_log:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fldln2 // Load log base e of 2
|
fldln2 // Load log base e of 2
|
||||||
fxch st(1) // Exchange st, st(1)
|
fxch st(1) // Exchange st, st(1)
|
||||||
fyl2x // Compute the natural log(x)
|
fyl2x // Compute the natural log(x)
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,140 +1,140 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/pow.S
|
* FILE: lib/rtl/i386/pow.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _pow
|
.globl _pow
|
||||||
|
|
||||||
/* DATA ********************************************************************/
|
/* DATA ********************************************************************/
|
||||||
|
|
||||||
fzero:
|
fzero:
|
||||||
.long 0 // Floating point zero
|
.long 0 // Floating point zero
|
||||||
.long 0 // Floating point zero
|
.long 0 // Floating point zero
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_pow:
|
_pow:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
sub esp,12 // Allocate temporary space
|
sub esp,12 // Allocate temporary space
|
||||||
push edi // Save register edi
|
push edi // Save register edi
|
||||||
push eax // Save register eax
|
push eax // Save register eax
|
||||||
mov dword ptr [ebp-12],0 // Set negation flag to zero
|
mov dword ptr [ebp-12],0 // Set negation flag to zero
|
||||||
fld qword ptr [ebp+16] // Load real from stack
|
fld qword ptr [ebp+16] // Load real from stack
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
mov edi,offset flat:fzero // Point to real zero
|
mov edi,offset flat:fzero // Point to real zero
|
||||||
fcom qword ptr [edi] // Compare x with zero
|
fcom qword ptr [edi] // Compare x with zero
|
||||||
fstsw ax // Get the FPU status word
|
fstsw ax // Get the FPU status word
|
||||||
mov al,ah // Move condition flags to AL
|
mov al,ah // Move condition flags to AL
|
||||||
lahf // Load Flags into AH
|
lahf // Load Flags into AH
|
||||||
and al, 0b01000101 // Isolate C0, C2 and C3
|
and al, 0b01000101 // Isolate C0, C2 and C3
|
||||||
and ah, 0b10111010 // Turn off CF, PF and ZF
|
and ah, 0b10111010 // Turn off CF, PF and ZF
|
||||||
or ah,al // Set new CF, PF and ZF
|
or ah,al // Set new CF, PF and ZF
|
||||||
sahf // Store AH into Flags
|
sahf // Store AH into Flags
|
||||||
jb __fpow1 // Re-direct if x < 0
|
jb __fpow1 // Re-direct if x < 0
|
||||||
ja __fpow3 // Re-direct if x > 0
|
ja __fpow3 // Re-direct if x > 0
|
||||||
fxch // Swap st, st(1)
|
fxch // Swap st, st(1)
|
||||||
fcom qword ptr [edi] // Compare y with zero
|
fcom qword ptr [edi] // Compare y with zero
|
||||||
fxch // Restore x as top of stack
|
fxch // Restore x as top of stack
|
||||||
fstsw ax // Get the FPU status word
|
fstsw ax // Get the FPU status word
|
||||||
mov al,ah // Move condition flags to AL
|
mov al,ah // Move condition flags to AL
|
||||||
lahf // Load Flags into AH
|
lahf // Load Flags into AH
|
||||||
and al, 0b01000101 // Isolate C0, C2 and C3
|
and al, 0b01000101 // Isolate C0, C2 and C3
|
||||||
and ah, 0b10111010 // Turn off CF, PF and ZF
|
and ah, 0b10111010 // Turn off CF, PF and ZF
|
||||||
or ah,al // Set new CF, PF and ZF
|
or ah,al // Set new CF, PF and ZF
|
||||||
sahf // Store AH into Flags
|
sahf // Store AH into Flags
|
||||||
ja __fpow3 // Re-direct if y > 0
|
ja __fpow3 // Re-direct if y > 0
|
||||||
fstp st(1) // Set new stack top and pop
|
fstp st(1) // Set new stack top and pop
|
||||||
mov eax,1 // Set domain error (EDOM)
|
mov eax,1 // Set domain error (EDOM)
|
||||||
jmp __fpow5 // End of case
|
jmp __fpow5 // End of case
|
||||||
__fpow1: fxch // Put y on top of stack
|
__fpow1: fxch // Put y on top of stack
|
||||||
fld st // Duplicate y as st(1)
|
fld st // Duplicate y as st(1)
|
||||||
frndint // Round to integer
|
frndint // Round to integer
|
||||||
fxch // Put y on top of stack
|
fxch // Put y on top of stack
|
||||||
fcomp // y = int(y) ?
|
fcomp // y = int(y) ?
|
||||||
fstsw ax // Get the FPU status word
|
fstsw ax // Get the FPU status word
|
||||||
mov al,ah // Move condition flags to AL
|
mov al,ah // Move condition flags to AL
|
||||||
lahf // Load Flags into AH
|
lahf // Load Flags into AH
|
||||||
and al, 0b01000101 // Isolate C0, C2 and C3
|
and al, 0b01000101 // Isolate C0, C2 and C3
|
||||||
and ah, 0b10111010 // Turn off CF, PF and ZF
|
and ah, 0b10111010 // Turn off CF, PF and ZF
|
||||||
or ah,al // Set new CF, PF and ZF
|
or ah,al // Set new CF, PF and ZF
|
||||||
sahf // Store AH into Flags
|
sahf // Store AH into Flags
|
||||||
je __fpow2 // Proceed if y = int(y)
|
je __fpow2 // Proceed if y = int(y)
|
||||||
fstp st(1) // Set new stack top and pop
|
fstp st(1) // Set new stack top and pop
|
||||||
fldz // Set result to zero
|
fldz // Set result to zero
|
||||||
fstp st(1) // Set new stack top and pop
|
fstp st(1) // Set new stack top and pop
|
||||||
mov eax,1 // Set domain error (EDOM)
|
mov eax,1 // Set domain error (EDOM)
|
||||||
jmp __fpow5 // End of case
|
jmp __fpow5 // End of case
|
||||||
__fpow2: fist dword ptr [ebp-12] // Store y as integer
|
__fpow2: fist dword ptr [ebp-12] // Store y as integer
|
||||||
and dword ptr [ebp-12],1 // Set bit if y is odd
|
and dword ptr [ebp-12],1 // Set bit if y is odd
|
||||||
fxch // Put x on top of stack
|
fxch // Put x on top of stack
|
||||||
fabs // x = |x|
|
fabs // x = |x|
|
||||||
__fpow3: fldln2 // Load log base e of 2
|
__fpow3: fldln2 // Load log base e of 2
|
||||||
fxch st(1) // Exchange st, st(1)
|
fxch st(1) // Exchange st, st(1)
|
||||||
fyl2x // Compute the natural log(x)
|
fyl2x // Compute the natural log(x)
|
||||||
fmulp // Compute y * ln(x)
|
fmulp // Compute y * ln(x)
|
||||||
fldl2e // Load log base 2(e)
|
fldl2e // Load log base 2(e)
|
||||||
fmulp st(1),st // Multiply x * log base 2(e)
|
fmulp st(1),st // Multiply x * log base 2(e)
|
||||||
fst st(1) // Push result
|
fst st(1) // Push result
|
||||||
frndint // Round to integer
|
frndint // Round to integer
|
||||||
fsub st(1),st // Subtract
|
fsub st(1),st // Subtract
|
||||||
fxch // Exchange st, st(1)
|
fxch // Exchange st, st(1)
|
||||||
f2xm1 // Compute 2 to the (x - 1)
|
f2xm1 // Compute 2 to the (x - 1)
|
||||||
fld1 // Load real number 1
|
fld1 // Load real number 1
|
||||||
faddp // 2 to the x
|
faddp // 2 to the x
|
||||||
fscale // Scale by power of 2
|
fscale // Scale by power of 2
|
||||||
fstp st(1) // Set new stack top and pop
|
fstp st(1) // Set new stack top and pop
|
||||||
test dword ptr [ebp-12],1 // Negation required ?
|
test dword ptr [ebp-12],1 // Negation required ?
|
||||||
jz __fpow4 // No, re-direct
|
jz __fpow4 // No, re-direct
|
||||||
fchs // Negate the result
|
fchs // Negate the result
|
||||||
__fpow4: fstp qword ptr [ebp-8] // Save (double)pow(x, y)
|
__fpow4: fstp qword ptr [ebp-8] // Save (double)pow(x, y)
|
||||||
fld qword ptr [ebp-8] // Load (double)pow(x, y)
|
fld qword ptr [ebp-8] // Load (double)pow(x, y)
|
||||||
fxam // Examine st
|
fxam // Examine st
|
||||||
fstsw ax // Get the FPU status word
|
fstsw ax // Get the FPU status word
|
||||||
cmp ah,5 // Infinity ?
|
cmp ah,5 // Infinity ?
|
||||||
jne __fpow6 // No, end of case
|
jne __fpow6 // No, end of case
|
||||||
mov eax,2 // Set range error (ERANGE)
|
mov eax,2 // Set range error (ERANGE)
|
||||||
// Get errno pointer offset
|
// Get errno pointer offset
|
||||||
__fpow5: int 3
|
__fpow5: int 3
|
||||||
mov edi,0 // TODO: offset flat:__crt_errno
|
mov edi,0 // TODO: offset flat:__crt_errno
|
||||||
mov edi,[edi] // Get C errno variable pointer
|
mov edi,[edi] // Get C errno variable pointer
|
||||||
mov dword ptr [edi],eax // Set errno
|
mov dword ptr [edi],eax // Set errno
|
||||||
__fpow6: pop eax // Restore register eax
|
__fpow6: pop eax // Restore register eax
|
||||||
pop edi // Restore register edi
|
pop edi // Restore register edi
|
||||||
mov esp,ebp // Deallocate temporary space
|
mov esp,ebp // Deallocate temporary space
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: prefetchmemory_asm.S
|
* FILE: prefetchmemory_asm.S
|
||||||
* PURPOSE: Memory functions
|
* PURPOSE: Memory functions
|
||||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||||
* Alex Ionescu (alex@relsoft.net)
|
* Alex Ionescu (alex@relsoft.net)
|
||||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl @RtlPrefetchMemoryNonTemporal@8
|
.globl @RtlPrefetchMemoryNonTemporal@8
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
@RtlPrefetchMemoryNonTemporal@8:
|
@RtlPrefetchMemoryNonTemporal@8:
|
||||||
ret /* Overwritten by ntoskrnl/ke/i386/kernel.c if SSE is supported (see Ki386SetProcessorFeatures() ) */
|
ret /* Overwritten by ntoskrnl/ke/i386/kernel.c if SSE is supported (see Ki386SetProcessorFeatures() ) */
|
||||||
|
|
||||||
mov eax, [_Ke386CacheAlignment] // Get cache line size
|
mov eax, [_Ke386CacheAlignment] // Get cache line size
|
||||||
|
|
||||||
// This is fastcall, so ecx = address, edx = size
|
// This is fastcall, so ecx = address, edx = size
|
||||||
fetch_next_line:
|
fetch_next_line:
|
||||||
prefetchnta byte ptr [ecx] // prefechnta(address)
|
prefetchnta byte ptr [ecx] // prefechnta(address)
|
||||||
add ecx, eax // address = address + cache_line_size
|
add ecx, eax // address = address + cache_line_size
|
||||||
sub edx, eax // count = count - cache_line_size
|
sub edx, eax // count = count - cache_line_size
|
||||||
ja fetch_next_line // goto fetch_next_line
|
ja fetch_next_line // goto fetch_next_line
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,245 +1,245 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ranom.asm
|
* FILE: ranom.asm
|
||||||
* PURPOSE: Random number generator functions
|
* PURPOSE: Random number generator functions
|
||||||
* PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
|
* PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 27/07/2005
|
* Created 27/07/2005
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl _RtlRandom@4 // [1] (no bug) (max optimze code)
|
.globl _RtlRandom@4 // [1] (no bug) (max optimze code)
|
||||||
.globl _RtlUniform@4 // [2] (no bug) (max optimze code)
|
.globl _RtlUniform@4 // [2] (no bug) (max optimze code)
|
||||||
.globl _SavedValue // [3] (no bug) (max optimze code)
|
.globl _SavedValue // [3] (no bug) (max optimze code)
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_RtlRandom@4:
|
_RtlRandom@4:
|
||||||
// load pointer
|
// load pointer
|
||||||
mov ecx,[esp+4]
|
mov ecx,[esp+4]
|
||||||
mov eax,[ecx]
|
mov eax,[ecx]
|
||||||
|
|
||||||
// Result = *Seed * 0xffffffed + 0x7fffffc3 // take now 3 cycles
|
// Result = *Seed * 0xffffffed + 0x7fffffc3 // take now 3 cycles
|
||||||
lea edx,[eax + eax * 8]
|
lea edx,[eax + eax * 8]
|
||||||
|
|
||||||
lea eax,[eax + edx * 2 + 2147483709 ] // + 2147483709
|
lea eax,[eax + edx * 2 + 2147483709 ] // + 2147483709
|
||||||
neg eax
|
neg eax
|
||||||
|
|
||||||
cmp eax,-1
|
cmp eax,-1
|
||||||
je .RtlRandom_Rand1
|
je .RtlRandom_Rand1
|
||||||
cmp eax, 2147483646
|
cmp eax, 2147483646
|
||||||
je .RtlRandom_Rand1
|
je .RtlRandom_Rand1
|
||||||
|
|
||||||
cmp eax, 2147483647
|
cmp eax, 2147483647
|
||||||
je .RtlRandom_Rand2
|
je .RtlRandom_Rand2
|
||||||
|
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jns .RtlRandom_Rand3
|
jns .RtlRandom_Rand3
|
||||||
|
|
||||||
// else {
|
// else {
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
and edx,1
|
and edx,1
|
||||||
add eax,edx
|
add eax,edx
|
||||||
and eax,2147483647
|
and eax,2147483647
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
jmp .RtlRandom_Seed
|
jmp .RtlRandom_Seed
|
||||||
|
|
||||||
.RtlRandom_Rand1:
|
.RtlRandom_Rand1:
|
||||||
// if (Result == 0xffffffff || Result == 0x7ffffffe)
|
// if (Result == 0xffffffff || Result == 0x7ffffffe)
|
||||||
add eax, 2
|
add eax, 2
|
||||||
and eax, 2147483647
|
and eax, 2147483647
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
jmp .RtlRandom_Seed
|
jmp .RtlRandom_Seed
|
||||||
|
|
||||||
.RtlRandom_Rand2:
|
.RtlRandom_Rand2:
|
||||||
// else if (Result == 0x7fffffff)
|
// else if (Result == 0x7fffffff)
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
jmp .RtlRandom_Seed
|
jmp .RtlRandom_Seed
|
||||||
|
|
||||||
.RtlRandom_Rand3:
|
.RtlRandom_Rand3:
|
||||||
// else if ((Result & 0x80000000) == 0)
|
// else if ((Result & 0x80000000) == 0)
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
xor edx,-1 // not edx lock all clock until it finsish, but xor does not do that
|
xor edx,-1 // not edx lock all clock until it finsish, but xor does not do that
|
||||||
and edx,1
|
and edx,1
|
||||||
add eax,edx
|
add eax,edx
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
|
|
||||||
.RtlRandom_Seed:
|
.RtlRandom_Seed:
|
||||||
mov eax,[ecx]
|
mov eax,[ecx]
|
||||||
|
|
||||||
// Result = *Seed * 0xffffffed + 0x7fffffc3 // take now 3 cycles
|
// Result = *Seed * 0xffffffed + 0x7fffffc3 // take now 3 cycles
|
||||||
lea edx,[eax + eax * 8]
|
lea edx,[eax + eax * 8]
|
||||||
|
|
||||||
lea eax,[eax + edx * 2 + 2147483709 ] // + 2147483709 09-18
|
lea eax,[eax + edx * 2 + 2147483709 ] // + 2147483709 09-18
|
||||||
neg eax
|
neg eax
|
||||||
|
|
||||||
cmp eax,-1
|
cmp eax,-1
|
||||||
je .RtlRandom_Seed1
|
je .RtlRandom_Seed1
|
||||||
cmp eax, 2147483646
|
cmp eax, 2147483646
|
||||||
je .RtlRandom_Seed1
|
je .RtlRandom_Seed1
|
||||||
|
|
||||||
cmp eax, 2147483647
|
cmp eax, 2147483647
|
||||||
je .RtlRandom_Seed2
|
je .RtlRandom_Seed2
|
||||||
|
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jns .RtlRandom_Seed3
|
jns .RtlRandom_Seed3
|
||||||
|
|
||||||
// else {
|
// else {
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
and edx,1
|
and edx,1
|
||||||
add eax,edx
|
add eax,edx
|
||||||
and eax,2147483647
|
and eax,2147483647
|
||||||
|
|
||||||
// end
|
// end
|
||||||
mov edx,[ecx]
|
mov edx,[ecx]
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
|
|
||||||
mov ecx,eax // pos
|
mov ecx,eax // pos
|
||||||
and ecx, 0x7f // pos = seed & 0x7f
|
and ecx, 0x7f // pos = seed & 0x7f
|
||||||
mov eax,ecx//
|
mov eax,ecx//
|
||||||
mov eax, [_SavedValue + ecx*4]
|
mov eax, [_SavedValue + ecx*4]
|
||||||
mov [_SavedValue + ecx*4], edx
|
mov [_SavedValue + ecx*4], edx
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.RtlRandom_Seed1:
|
.RtlRandom_Seed1:
|
||||||
// if (Result == 0xffffffff || Result == 0x7ffffffe)
|
// if (Result == 0xffffffff || Result == 0x7ffffffe)
|
||||||
add eax, 2
|
add eax, 2
|
||||||
and eax, 2147483647
|
and eax, 2147483647
|
||||||
|
|
||||||
// end
|
// end
|
||||||
mov edx,[ecx]
|
mov edx,[ecx]
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
|
|
||||||
mov ecx,eax // pos
|
mov ecx,eax // pos
|
||||||
and ecx, 0x7f // pos = seed & 0x7f
|
and ecx, 0x7f // pos = seed & 0x7f
|
||||||
mov eax,ecx//
|
mov eax,ecx//
|
||||||
mov eax, [_SavedValue + ecx*4]
|
mov eax, [_SavedValue + ecx*4]
|
||||||
mov [_SavedValue + ecx*4], edx
|
mov [_SavedValue + ecx*4], edx
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.RtlRandom_Seed2:
|
.RtlRandom_Seed2:
|
||||||
// else if (Result == 0x7fffffff)
|
// else if (Result == 0x7fffffff)
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
|
|
||||||
// end
|
// end
|
||||||
mov edx,[ecx]
|
mov edx,[ecx]
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
|
|
||||||
mov ecx,eax // pos
|
mov ecx,eax // pos
|
||||||
and ecx, 0x7f // pos = seed & 0x7f
|
and ecx, 0x7f // pos = seed & 0x7f
|
||||||
mov eax,ecx//
|
mov eax,ecx//
|
||||||
mov eax, [_SavedValue + ecx*4]
|
mov eax, [_SavedValue + ecx*4]
|
||||||
mov [_SavedValue + ecx*4], edx
|
mov [_SavedValue + ecx*4], edx
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.RtlRandom_Seed3:
|
.RtlRandom_Seed3:
|
||||||
// else if ((Result & 0x80000000) == 0)
|
// else if ((Result & 0x80000000) == 0)
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
xor edx,-1 // not edx lock all clock until it finsish, but xor does not do that
|
xor edx,-1 // not edx lock all clock until it finsish, but xor does not do that
|
||||||
and edx,1
|
and edx,1
|
||||||
add eax,edx
|
add eax,edx
|
||||||
|
|
||||||
// end
|
// end
|
||||||
mov edx,[ecx]
|
mov edx,[ecx]
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
|
|
||||||
mov ecx,eax // pos
|
mov ecx,eax // pos
|
||||||
and ecx, 0x7f // pos = seed & 0x7f
|
and ecx, 0x7f // pos = seed & 0x7f
|
||||||
mov eax,ecx//
|
mov eax,ecx//
|
||||||
mov eax, [_SavedValue + ecx*4]
|
mov eax, [_SavedValue + ecx*4]
|
||||||
mov [_SavedValue + ecx*4], edx
|
mov [_SavedValue + ecx*4], edx
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
// prototype: ULONG STDCALL RtlUniform (PULONG Seed)
|
// prototype: ULONG STDCALL RtlUniform (PULONG Seed)
|
||||||
_RtlUniform@4:
|
_RtlUniform@4:
|
||||||
// load pointer
|
// load pointer
|
||||||
mov ecx,[esp+4]
|
mov ecx,[esp+4]
|
||||||
mov eax,[ecx]
|
mov eax,[ecx]
|
||||||
|
|
||||||
// Result = *Seed * 0xffffffed + 0x7fffffc3 // take now 3 cycles
|
// Result = *Seed * 0xffffffed + 0x7fffffc3 // take now 3 cycles
|
||||||
lea edx,[eax + eax * 8]
|
lea edx,[eax + eax * 8]
|
||||||
|
|
||||||
lea eax,[eax + edx * 2 + 2147483709 ] // + 2147483709 09-18
|
lea eax,[eax + edx * 2 + 2147483709 ] // + 2147483709 09-18
|
||||||
neg eax
|
neg eax
|
||||||
|
|
||||||
cmp eax,-1
|
cmp eax,-1
|
||||||
je .RtlUniform_jump1
|
je .RtlUniform_jump1
|
||||||
cmp eax, 2147483646
|
cmp eax, 2147483646
|
||||||
je .RtlUniform_jump1
|
je .RtlUniform_jump1
|
||||||
|
|
||||||
cmp eax, 2147483647
|
cmp eax, 2147483647
|
||||||
je .RtlUniform_jump2
|
je .RtlUniform_jump2
|
||||||
|
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jns .RtlUniform_jump3
|
jns .RtlUniform_jump3
|
||||||
|
|
||||||
// else {
|
// else {
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
and edx,1
|
and edx,1
|
||||||
add eax,edx
|
add eax,edx
|
||||||
and eax,2147483647
|
and eax,2147483647
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.RtlUniform_jump1:
|
.RtlUniform_jump1:
|
||||||
// if (Result == 0xffffffff || Result == 0x7ffffffe)
|
// if (Result == 0xffffffff || Result == 0x7ffffffe)
|
||||||
add eax, 2
|
add eax, 2
|
||||||
and eax, 2147483647
|
and eax, 2147483647
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.RtlUniform_jump2:
|
.RtlUniform_jump2:
|
||||||
// else if (Result == 0x7fffffff)
|
// else if (Result == 0x7fffffff)
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.RtlUniform_jump3:
|
.RtlUniform_jump3:
|
||||||
// else if ((Result & 0x80000000) == 0)
|
// else if ((Result & 0x80000000) == 0)
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
xor edx,-1 // not edx lock all clock until it finsish, but xor does not do that
|
xor edx,-1 // not edx lock all clock until it finsish, but xor does not do that
|
||||||
and edx,1
|
and edx,1
|
||||||
add eax,edx
|
add eax,edx
|
||||||
mov [ecx],eax
|
mov [ecx],eax
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.data
|
.data
|
||||||
// SavedValue[128]
|
// SavedValue[128]
|
||||||
_SavedValue:
|
_SavedValue:
|
||||||
.long 0x4c8bc0aa, 0x4c022957, 0x2232827a, 0x2f1e7626
|
.long 0x4c8bc0aa, 0x4c022957, 0x2232827a, 0x2f1e7626
|
||||||
.long 0x7f8bdafb, 0x5c37d02a, 0x0ab48f72, 0x2f0c4ffa
|
.long 0x7f8bdafb, 0x5c37d02a, 0x0ab48f72, 0x2f0c4ffa
|
||||||
.long 0x290e1954, 0x6b635f23, 0x5d3885c0, 0x74b49ff8
|
.long 0x290e1954, 0x6b635f23, 0x5d3885c0, 0x74b49ff8
|
||||||
.long 0x5155fa54, 0x6214ad3f, 0x111e9c29, 0x242a3a09
|
.long 0x5155fa54, 0x6214ad3f, 0x111e9c29, 0x242a3a09
|
||||||
.long 0x75932ae1, 0x40ac432e, 0x54f7ba7a, 0x585ccbd5
|
.long 0x75932ae1, 0x40ac432e, 0x54f7ba7a, 0x585ccbd5
|
||||||
.long 0x6df5c727, 0x0374dad1, 0x7112b3f1, 0x735fc311
|
.long 0x6df5c727, 0x0374dad1, 0x7112b3f1, 0x735fc311
|
||||||
.long 0x404331a9, 0x74d97781, 0x64495118, 0x323e04be
|
.long 0x404331a9, 0x74d97781, 0x64495118, 0x323e04be
|
||||||
.long 0x5974b425, 0x4862e393, 0x62389c1d, 0x28a68b82
|
.long 0x5974b425, 0x4862e393, 0x62389c1d, 0x28a68b82
|
||||||
.long 0x0f95da37, 0x7a50bbc6, 0x09b0091c, 0x22cdb7b4
|
.long 0x0f95da37, 0x7a50bbc6, 0x09b0091c, 0x22cdb7b4
|
||||||
.long 0x4faaed26, 0x66417ccd, 0x189e4bfa, 0x1ce4e8dd
|
.long 0x4faaed26, 0x66417ccd, 0x189e4bfa, 0x1ce4e8dd
|
||||||
.long 0x5274c742, 0x3bdcf4dc, 0x2d94e907, 0x32eac016
|
.long 0x5274c742, 0x3bdcf4dc, 0x2d94e907, 0x32eac016
|
||||||
.long 0x26d33ca3, 0x60415a8a, 0x31f57880, 0x68c8aa52
|
.long 0x26d33ca3, 0x60415a8a, 0x31f57880, 0x68c8aa52
|
||||||
.long 0x23eb16da, 0x6204f4a1, 0x373927c1, 0x0d24eb7c
|
.long 0x23eb16da, 0x6204f4a1, 0x373927c1, 0x0d24eb7c
|
||||||
.long 0x06dd7379, 0x2b3be507, 0x0f9c55b1, 0x2c7925eb
|
.long 0x06dd7379, 0x2b3be507, 0x0f9c55b1, 0x2c7925eb
|
||||||
.long 0x36d67c9a, 0x42f831d9, 0x5e3961cb, 0x65d637a8
|
.long 0x36d67c9a, 0x42f831d9, 0x5e3961cb, 0x65d637a8
|
||||||
.long 0x24bb3820, 0x4d08e33d, 0x2188754f, 0x147e409e
|
.long 0x24bb3820, 0x4d08e33d, 0x2188754f, 0x147e409e
|
||||||
.long 0x6a9620a0, 0x62e26657, 0x7bd8ce81, 0x11da0abb
|
.long 0x6a9620a0, 0x62e26657, 0x7bd8ce81, 0x11da0abb
|
||||||
.long 0x5f9e7b50, 0x23e444b6, 0x25920c78, 0x5fc894f0
|
.long 0x5f9e7b50, 0x23e444b6, 0x25920c78, 0x5fc894f0
|
||||||
.long 0x5e338cbb, 0x404237fd, 0x1d60f80f, 0x320a1743
|
.long 0x5e338cbb, 0x404237fd, 0x1d60f80f, 0x320a1743
|
||||||
.long 0x76013d2b, 0x070294ee, 0x695e243b, 0x56b177fd
|
.long 0x76013d2b, 0x070294ee, 0x695e243b, 0x56b177fd
|
||||||
.long 0x752492e1, 0x6decd52f, 0x125f5219, 0x139d2e78
|
.long 0x752492e1, 0x6decd52f, 0x125f5219, 0x139d2e78
|
||||||
.long 0x1898d11e, 0x2f7ee785, 0x4db405d8, 0x1a028a35
|
.long 0x1898d11e, 0x2f7ee785, 0x4db405d8, 0x1a028a35
|
||||||
.long 0x63f6f323, 0x1f6d0078, 0x307cfd67, 0x3f32a78a
|
.long 0x63f6f323, 0x1f6d0078, 0x307cfd67, 0x3f32a78a
|
||||||
.long 0x6980796c, 0x462b3d83, 0x34b639f2, 0x53fce379
|
.long 0x6980796c, 0x462b3d83, 0x34b639f2, 0x53fce379
|
||||||
.long 0x74ba50f4, 0x1abc2c4b, 0x5eeaeb8d, 0x335a7a0d
|
.long 0x74ba50f4, 0x1abc2c4b, 0x5eeaeb8d, 0x335a7a0d
|
||||||
.long 0x3973dd20, 0x0462d66b, 0x159813ff, 0x1e4643fd
|
.long 0x3973dd20, 0x0462d66b, 0x159813ff, 0x1e4643fd
|
||||||
.long 0x06bc5c62, 0x3115e3fc, 0x09101613, 0x47af2515
|
.long 0x06bc5c62, 0x3115e3fc, 0x09101613, 0x47af2515
|
||||||
.long 0x4f11ec54, 0x78b99911, 0x3db8dd44, 0x1ec10b9b
|
.long 0x4f11ec54, 0x78b99911, 0x3db8dd44, 0x1ec10b9b
|
||||||
.long 0x5b5506ca, 0x773ce092, 0x567be81a, 0x5475b975
|
.long 0x5b5506ca, 0x773ce092, 0x567be81a, 0x5475b975
|
||||||
.long 0x7a2cde1a, 0x494536f5, 0x34737bb4, 0x76d9750b
|
.long 0x7a2cde1a, 0x494536f5, 0x34737bb4, 0x76d9750b
|
||||||
.long 0x2a1f6232, 0x2e49644d, 0x7dddcbe7, 0x500cebdb
|
.long 0x2a1f6232, 0x2e49644d, 0x7dddcbe7, 0x500cebdb
|
||||||
.long 0x619dab9e, 0x48c626fe, 0x1cda3193, 0x52dabe9d
|
.long 0x619dab9e, 0x48c626fe, 0x1cda3193, 0x52dabe9d
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/sin.S
|
* FILE: lib/rtl/i386/sin.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _sin
|
.globl _sin
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_sin:
|
_sin:
|
||||||
push ebp // Save register bp
|
push ebp // Save register bp
|
||||||
mov ebp,esp // Point to the stack frame
|
mov ebp,esp // Point to the stack frame
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fsin // Take the sine
|
fsin // Take the sine
|
||||||
pop ebp // Restore register bp
|
pop ebp // Restore register bp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/sqrt.S
|
* FILE: lib/rtl/i386/sqrt.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _sqrt
|
.globl _sqrt
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_sqrt:
|
_sqrt:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fsqrt // Take the square root
|
fsqrt // Take the square root
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Run-Time Library
|
* PURPOSE: Run-Time Library
|
||||||
* FILE: lib/rtl/i386/tan.S
|
* FILE: lib/rtl/i386/tan.S
|
||||||
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Eric Kohl (ekohl@rz-online.de)
|
* Eric Kohl (ekohl@rz-online.de)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Michael Ringgaard.
|
* Copyright (C) 2002 Michael Ringgaard.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
* OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _tan
|
.globl _tan
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_tan:
|
_tan:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
sub esp,4 // Allocate temporary space
|
sub esp,4 // Allocate temporary space
|
||||||
fld qword ptr [ebp+8] // Load real from stack
|
fld qword ptr [ebp+8] // Load real from stack
|
||||||
fptan // Take the tangent
|
fptan // Take the tangent
|
||||||
fstp dword ptr [ebp-4] // Throw away the constant 1
|
fstp dword ptr [ebp-4] // Throw away the constant 1
|
||||||
mov esp,ebp // Deallocate temporary space
|
mov esp,ebp // Deallocate temporary space
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,61 +1,61 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: zeromemory_asm.S
|
* FILE: zeromemory_asm.S
|
||||||
* PURPOSE: Memory functions
|
* PURPOSE: Memory functions
|
||||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||||
* Alex Ionescu (alex@relsoft.net)
|
* Alex Ionescu (alex@relsoft.net)
|
||||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
/* GLOBALS ****************************************************************/
|
/* GLOBALS ****************************************************************/
|
||||||
|
|
||||||
.globl _RtlZeroMemory@8 // (no bug) (max optimze code)
|
.globl _RtlZeroMemory@8 // (no bug) (max optimze code)
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
_RtlZeroMemory@8:
|
_RtlZeroMemory@8:
|
||||||
mov ecx,dword [esp + 8 ] // Length
|
mov ecx,dword [esp + 8 ] // Length
|
||||||
cmp ecx,0// if (Length==0) goto .zero
|
cmp ecx,0// if (Length==0) goto .zero
|
||||||
je 3f
|
je 3f
|
||||||
|
|
||||||
pushad // Save all register on the stack
|
pushad // Save all register on the stack
|
||||||
mov edi, dword [esp + (4 + 32)] // Destination
|
mov edi, dword [esp + (4 + 32)] // Destination
|
||||||
xor eax,eax // ZeroFillByte = 0
|
xor eax,eax // ZeroFillByte = 0
|
||||||
|
|
||||||
// code for take four byte each time it loop
|
// code for take four byte each time it loop
|
||||||
mov ebx,ecx // temp_Length = Length
|
mov ebx,ecx // temp_Length = Length
|
||||||
shr ecx,2// Length = Length / sizeof(ULONG)
|
shr ecx,2// Length = Length / sizeof(ULONG)
|
||||||
jz 1f // if (Length==0) goto .1byte
|
jz 1f // if (Length==0) goto .1byte
|
||||||
|
|
||||||
shl ecx,2// Length = Length * sizeof(ULONG)
|
shl ecx,2// Length = Length * sizeof(ULONG)
|
||||||
sub ebx,ecx // temp_Length = temp_Length - Length//
|
sub ebx,ecx // temp_Length = temp_Length - Length//
|
||||||
jz 2f // if (temp_Length==0) goto .4byte
|
jz 2f // if (temp_Length==0) goto .4byte
|
||||||
|
|
||||||
// move 4byte and 1byte
|
// move 4byte and 1byte
|
||||||
shr ecx,2// Length = Length / sizeof(ULONG)
|
shr ecx,2// Length = Length / sizeof(ULONG)
|
||||||
cld // clear d flag
|
cld // clear d flag
|
||||||
rep stosd// while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
rep stosd// while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
||||||
mov ecx,ebx // Length = temp_Length
|
mov ecx,ebx // Length = temp_Length
|
||||||
rep stosb// while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
rep stosb// while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
||||||
popad // restore register
|
popad // restore register
|
||||||
ret 8 // return
|
ret 8 // return
|
||||||
|
|
||||||
// move 1byte
|
// move 1byte
|
||||||
1:
|
1:
|
||||||
mov ecx,dword [esp + (12 +32) ] // Length
|
mov ecx,dword [esp + (12 +32) ] // Length
|
||||||
cld // clear d flag
|
cld // clear d flag
|
||||||
rep stosb// while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
rep stosb// while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
||||||
popad // restore register
|
popad // restore register
|
||||||
ret 8 // return
|
ret 8 // return
|
||||||
|
|
||||||
// move 4bytes
|
// move 4bytes
|
||||||
2:
|
2:
|
||||||
shr ecx,2// Length = Length / sizeof(ULONG)
|
shr ecx,2// Length = Length / sizeof(ULONG)
|
||||||
cld // clear d flag
|
cld // clear d flag
|
||||||
rep stosd// while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
rep stosd// while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
|
||||||
popad // restore register
|
popad // restore register
|
||||||
3:
|
3:
|
||||||
ret 8 // return
|
ret 8 // return
|
||||||
|
|
Loading…
Reference in a new issue