From 6fb78880ce5a09a2205b9586fe968ea8fba4dc9d Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 11 Jun 2003 12:29:49 +0000 Subject: [PATCH] Fixed math support routines. svn path=/trunk/; revision=4881 --- reactos/ntoskrnl/Makefile | 3 +- reactos/ntoskrnl/Makefile.i386 | 8 + reactos/ntoskrnl/ntoskrnl.def | 18 +- reactos/ntoskrnl/ntoskrnl.edf | 18 +- reactos/ntoskrnl/rtl/i386/alldiv.s | 50 +++++ reactos/ntoskrnl/rtl/i386/allmul.s | 54 +++++ reactos/ntoskrnl/rtl/i386/allrem.s | 31 +++ reactos/ntoskrnl/rtl/i386/allshl.s | 33 +++ reactos/ntoskrnl/rtl/i386/allshr.s | 33 +++ reactos/ntoskrnl/rtl/i386/aulldiv.s | 29 +++ reactos/ntoskrnl/rtl/i386/aullrem.s | 29 +++ reactos/ntoskrnl/rtl/i386/aullshr.s | 32 +++ reactos/ntoskrnl/rtl/math.c | 332 ---------------------------- 13 files changed, 318 insertions(+), 352 deletions(-) create mode 100644 reactos/ntoskrnl/rtl/i386/alldiv.s create mode 100644 reactos/ntoskrnl/rtl/i386/allmul.s create mode 100644 reactos/ntoskrnl/rtl/i386/allrem.s create mode 100644 reactos/ntoskrnl/rtl/i386/allshl.s create mode 100644 reactos/ntoskrnl/rtl/i386/allshr.s create mode 100644 reactos/ntoskrnl/rtl/i386/aulldiv.s create mode 100644 reactos/ntoskrnl/rtl/i386/aullrem.s create mode 100644 reactos/ntoskrnl/rtl/i386/aullshr.s delete mode 100644 reactos/ntoskrnl/rtl/math.c diff --git a/reactos/ntoskrnl/Makefile b/reactos/ntoskrnl/Makefile index 7f84c50b0b6..6ba3c50c881 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.98 2003/06/07 11:31:06 ekohl Exp $ +# $Id: Makefile,v 1.99 2003/06/11 12:29:49 ekohl Exp $ # # ReactOS Operating System # @@ -89,7 +89,6 @@ OBJECTS_RTL = \ rtl/error.o \ rtl/handle.o \ rtl/largeint.o \ - rtl/math.o \ rtl/mem.o \ rtl/message.o \ rtl/nls.o \ diff --git a/reactos/ntoskrnl/Makefile.i386 b/reactos/ntoskrnl/Makefile.i386 index 4a84e5d972c..39000eeff6b 100644 --- a/reactos/ntoskrnl/Makefile.i386 +++ b/reactos/ntoskrnl/Makefile.i386 @@ -40,6 +40,14 @@ OBJECTS_MM_I386 := \ mm/i386/pfault.o OBJECTS_RTL_I386 := \ + rtl/i386/alldiv.o \ + rtl/i386/allmul.o \ + rtl/i386/allrem.o \ + rtl/i386/allshl.o \ + rtl/i386/allshr.o \ + rtl/i386/aulldiv.o \ + rtl/i386/aullrem.o \ + rtl/i386/aullshr.o \ rtl/i386/except.o \ rtl/i386/exception.o \ rtl/i386/seh.o diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index ed6affb13f3..9903a30dbc8 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.def,v 1.155 2003/06/07 12:17:19 chorns Exp $ +; $Id: ntoskrnl.def,v 1.156 2003/06/11 12:29:49 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -975,14 +975,14 @@ ZwWaitForSingleObject@12 ZwWriteFile@36 ZwYieldExecution@0 _abnormal_termination -_alldiv@4 -_allmul@4 -_allrem@4 -_allshl@4 -_allshr@4 -_aulldiv@4 -_aullrem@4 -_aullshr@4 +_alldiv +_allmul +_allrem +_allshl +_allshr +_aulldiv +_aullrem +_aullshr _except_handler2 _except_handler3 _global_unwind2 diff --git a/reactos/ntoskrnl/ntoskrnl.edf b/reactos/ntoskrnl/ntoskrnl.edf index b3643c5a156..697d31c9405 100644 --- a/reactos/ntoskrnl/ntoskrnl.edf +++ b/reactos/ntoskrnl/ntoskrnl.edf @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.edf,v 1.141 2003/06/07 12:17:19 chorns Exp $ +; $Id: ntoskrnl.edf,v 1.142 2003/06/11 12:29:49 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -973,14 +973,14 @@ ZwWaitForSingleObject=ZwWaitForSingleObject@12 ZwWriteFile=ZwWriteFile@36 ZwYieldExecution=ZwYieldExecution@0 _abnormal_termination -_alldiv=_alldiv@4 -_allmul=_allmul@4 -_allrem=_allrem@4 -_allshl=_allshl@4 -_allshr=_allshr@4 -_aulldiv=_aulldiv@4 -_aullrem=_aullrem@4 -_aullshr=_aullshr@4 +_alldiv +_allmul +_allrem +_allshl +_allshr +_aulldiv +_aullrem +_aullshr _except_handler2 _except_handler3 _global_unwind2 diff --git a/reactos/ntoskrnl/rtl/i386/alldiv.s b/reactos/ntoskrnl/rtl/i386/alldiv.s new file mode 100644 index 00000000000..966794785a9 --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/alldiv.s @@ -0,0 +1,50 @@ +/* $Id: alldiv.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/alldiv.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* + * long long + * __alldiv(long long Dividend, long long Divisor); + * + * Parameters: + * [ESP+04h] - long long Dividend + * [ESP+0Ch] - long long Divisor + * Registers: + * Unknown + * Returns: + * EDX:EAX - long long quotient (Dividend/Divisor) + * Notes: + * Routine removes the arguments from the stack. + */ +.globl __alldiv +__alldiv: + call ___divdi3 + ret $0x10 + +/* +__alldiv: + pushl %ebp + movl %esp, %ebp + pushl %eax + pushl %eax + movl 20(%ebp), %eax + pushl %eax + movl 16(%ebp), %eax + pushl %eax + movl 12(%ebp), %eax + pushl %eax + movl 8(%ebp), %eax + pushl %eax + call ___divdi3 + addl $16, %esp + movl %ebp, %esp + popl %ebp + ret +*/ + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/i386/allmul.s b/reactos/ntoskrnl/rtl/i386/allmul.s new file mode 100644 index 00000000000..1dc58a9b5f8 --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/allmul.s @@ -0,0 +1,54 @@ +/* $Id: allmul.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/allmul.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* + * long long + * __allmul(long long Multiplier, long long Multiplicand); + * + * Parameters: + * [ESP+04h] - long long Multiplier + * [ESP+0Ch] - long long Multiplicand + * Registers: + * Unknown + * Returns: + * EDX:EAX - long long product (Multiplier*Multiplicand) + * Notes: + * Routine removes the arguments from the stack. + */ +.globl __allmul +__allmul: + pushl %ebp + movl %esp, %ebp + pushl %edi + pushl %esi + pushl %ebx + subl $12, %esp + movl 16(%ebp), %ebx + movl 8(%ebp), %eax + mull %ebx + movl 20(%ebp), %ecx + movl %eax, -24(%ebp) + movl 8(%ebp), %eax + movl %edx, %esi + imull %ecx, %eax + addl %eax, %esi + movl 12(%ebp), %eax + imull %eax, %ebx + leal (%ebx,%esi), %eax + movl %eax, -20(%ebp) + movl -24(%ebp), %eax + movl -20(%ebp), %edx + addl $12, %esp + popl %ebx + popl %esi + popl %edi + popl %ebp + ret $0x10 + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/i386/allrem.s b/reactos/ntoskrnl/rtl/i386/allrem.s new file mode 100644 index 00000000000..59a0520d1a4 --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/allrem.s @@ -0,0 +1,31 @@ +/* $Id: allrem.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/math.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + * NOTES: This file is shared with ntoskrnl/rtl/i386/math.s. + * Please keep the files synchronized! + */ + +/* + * long long + * __allrem(long long Dividend, long long Divisor); + * + * Parameters: + * [ESP+04h] - long long Dividend + * [ESP+0Ch] - long long Divisor + * Registers: + * Unknown + * Returns: + * EDX:EAX - long long remainder (Dividend/Divisor) + * Notes: + * Routine removes the arguments from the stack. + */ +.globl __allrem +__allrem: + call ___moddi3 + ret $16 + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/i386/allshl.s b/reactos/ntoskrnl/rtl/i386/allshl.s new file mode 100644 index 00000000000..5f2163d3499 --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/allshl.s @@ -0,0 +1,33 @@ +/* $Id: allshl.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/allshl.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* + * long long + * __allshl(long long Value, unsigned char Shift); + * + * Parameters: + * EDX:EAX - signed long long value to be shifted left + * CL - number of bits to shift by + * Registers: + * Destroys CL + * Returns: + * EDX:EAX - shifted value + */ +.globl __allshl +__allshl: + shldl %cl, %eax, %edx + sall %cl, %eax + andl $32, %ecx + je L1 + movl %eax, %edx + xorl %eax, %eax +L1: + ret + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/i386/allshr.s b/reactos/ntoskrnl/rtl/i386/allshr.s new file mode 100644 index 00000000000..4f67348cc98 --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/allshr.s @@ -0,0 +1,33 @@ +/* $Id: allshr.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/allshr.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* + * long long + * __allshr(long long Value, unsigned char Shift); + * + * Parameters: + * EDX:EAX - signed long long value to be shifted right + * CL - number of bits to shift by + * Registers: + * Destroys CL + * Returns: + * EDX:EAX - shifted value + */ +.globl __allshr +__allshr: + shrdl %cl, %edx, %eax + sarl %cl, %edx + andl $32, %ecx + je L1 + movl %edx, %eax + sarl $31, %edx +L1: + ret + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/i386/aulldiv.s b/reactos/ntoskrnl/rtl/i386/aulldiv.s new file mode 100644 index 00000000000..84f2a90dafb --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/aulldiv.s @@ -0,0 +1,29 @@ +/* $Id: aulldiv.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/aulldiv.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* + * unsigned long long + * __aulldiv(unsigned long long Dividend, unsigned long long Divisor); + * + * Parameters: + * [ESP+04h] - unsigned long long Dividend + * [ESP+0Ch] - unsigned long long Divisor + * Registers: + * Unknown + * Returns: + * EDX:EAX - unsigned long long quotient (Dividend/Divisor) + * Notes: + * Routine removes the arguments from the stack. + */ +.globl __aulldiv +__aulldiv: + call ___udivdi3 + ret $16 + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/i386/aullrem.s b/reactos/ntoskrnl/rtl/i386/aullrem.s new file mode 100644 index 00000000000..208b5a54b6a --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/aullrem.s @@ -0,0 +1,29 @@ +/* $Id: aullrem.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/aullrem.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* + * unsigned long long + * __aullrem(unsigned long long Dividend, unsigned long long Divisor); + * + * Parameters: + * [ESP+04h] - unsigned long long Dividend + * [ESP+0Ch] - unsigned long long Divisor + * Registers: + * Unknown + * Returns: + * EDX:EAX - unsigned long long remainder (Dividend%Divisor) + * Notes: + * Routine removes the arguments from the stack. + */ +.globl __aullrem +__aullrem: + call ___umoddi3 + ret $16 + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/i386/aullshr.s b/reactos/ntoskrnl/rtl/i386/aullshr.s new file mode 100644 index 00000000000..ef8396c1e0d --- /dev/null +++ b/reactos/ntoskrnl/rtl/i386/aullshr.s @@ -0,0 +1,32 @@ +/* $Id: aullshr.s,v 1.1 2003/06/11 12:28:21 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Math support for IA-32 + * FILE: ntoskrnl/rtl/i386/aullshr.s + * PROGRAMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* + * unsigned long long + * __aullshr(unsigned long long Value, unsigned char Shift); + * + * Parameters: + * EDX:EAX - unsigned long long value to be shifted right + * CL - number of bits to shift by + * Registers: + * Destroys CL + * Returns: + * EDX:EAX - shifted value + */ +.globl __aullshr +__aullshr: + shrdl %cl, %edx, %eax + shrl %cl, %edx + andl $32, %ecx + je L1 + movl %edx, %eax +L1: + ret + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/math.c b/reactos/ntoskrnl/rtl/math.c deleted file mode 100644 index 02d1da6030c..00000000000 --- a/reactos/ntoskrnl/rtl/math.c +++ /dev/null @@ -1,332 +0,0 @@ -/* $Id: math.c,v 1.1 2003/01/07 17:48:12 robd Exp $ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: kernel/rtl/math.c - * PURPOSE: - * UPDATE HISTORY: - * Created 20/12/2002 - */ - -/* INCLUDES *****************************************************************/ - -#include - -#define NDEBUG -#include - - -/* FUNCTIONS *****************************************************************/ - -LARGE_INTEGER -STDCALL -_alldiv(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - -LARGE_INTEGER -STDCALL -_allmul(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - -LARGE_INTEGER -STDCALL -_allrem(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - -LARGE_INTEGER -STDCALL -_allshl(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - -LARGE_INTEGER -STDCALL -_allshr(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - -LARGE_INTEGER -STDCALL -_aulldiv(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - -LARGE_INTEGER -STDCALL -_aullrem(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - -LARGE_INTEGER -STDCALL -_aullshr(ULONG UnsignedInteger) -{ - LARGE_INTEGER RC; - - RC.QuadPart = 0; - return RC; -} - - -/* -LARGE_INTEGER -STDCALL -RtlConvertLongToLargeInteger ( - LONG SignedInteger - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = SignedInteger; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlConvertUlongToLargeInteger ( - ULONG UnsignedInteger - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = UnsignedInteger; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlEnlargedIntegerMultiply ( - LONG Multiplicand, - LONG Multiplier - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = (LONGLONG) Multiplicand * Multiplier; - - return RC; -} - -ULONG -STDCALL -RtlEnlargedUnsignedDivide ( - ULARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder - ) -{ - if (Remainder) - *Remainder = Dividend.QuadPart % Divisor; - - return (ULONG)(Dividend.QuadPart / Divisor); -} - -LARGE_INTEGER -STDCALL -RtlEnlargedUnsignedMultiply ( - ULONG Multiplicand, - ULONG Multiplier - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = (ULONGLONG) Multiplicand * Multiplier; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlExtendedIntegerMultiply ( - LARGE_INTEGER Multiplicand, - LONG Multiplier - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = Multiplicand.QuadPart * Multiplier; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlExtendedLargeIntegerDivide ( - LARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder - ) -{ - LARGE_INTEGER RC; - - if (Remainder) - *Remainder = Dividend.QuadPart % Divisor; - - RC.QuadPart = Dividend.QuadPart / Divisor; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlExtendedMagicDivide (LARGE_INTEGER Dividend, - LARGE_INTEGER MagicDivisor, - CCHAR ShiftCount) -{ - LARGE_INTEGER Result; - - Result.QuadPart = (Dividend.QuadPart * MagicDivisor.QuadPart) >> ShiftCount; - return(Result); -} - -LARGE_INTEGER -STDCALL -RtlLargeIntegerAdd ( - LARGE_INTEGER Addend1, - LARGE_INTEGER Addend2 - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = Addend1.QuadPart + Addend2.QuadPart; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlLargeIntegerArithmeticShift ( - LARGE_INTEGER LargeInteger, - CCHAR ShiftCount - ) -{ - LARGE_INTEGER RC; - CHAR Shift; - - Shift = ShiftCount % 64; - - if (Shift < 32) - { - RC.QuadPart = LargeInteger.QuadPart >> Shift; - } - else - { - // copy the sign bit - RC.u.HighPart |= (LargeInteger.u.HighPart & 0x80000000); - RC.u.LowPart = LargeInteger.u.HighPart >> Shift; - } - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlLargeIntegerDivide ( - LARGE_INTEGER Dividend, - LARGE_INTEGER Divisor, - PLARGE_INTEGER Remainder - ) -{ - LARGE_INTEGER RC; - - if (Remainder) - Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; - - RC.QuadPart = Dividend.QuadPart / Divisor.QuadPart; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlLargeIntegerNegate ( - LARGE_INTEGER Subtrahend - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = - Subtrahend.QuadPart; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlLargeIntegerShiftLeft ( - LARGE_INTEGER LargeInteger, - CCHAR ShiftCount - ) -{ - LARGE_INTEGER RC; - CHAR Shift; - - Shift = ShiftCount % 64; - RC.QuadPart = LargeInteger.QuadPart << Shift; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlLargeIntegerShiftRight ( - LARGE_INTEGER LargeInteger, - CCHAR ShiftCount - ) -{ - LARGE_INTEGER RC; - CHAR Shift; - - Shift = ShiftCount % 64; - RC.QuadPart = LargeInteger.QuadPart >> ShiftCount; - - return RC; -} - -LARGE_INTEGER -STDCALL -RtlLargeIntegerSubtract ( - LARGE_INTEGER Minuend, - LARGE_INTEGER Subtrahend - ) -{ - LARGE_INTEGER RC; - - RC.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; - - return RC; -} - */ -/* EOF */