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