Fixed math support routines.

svn path=/trunk/; revision=4881
This commit is contained in:
Eric Kohl 2003-06-11 12:29:49 +00:00
parent 649a9d362a
commit 6fb78880ce
13 changed files with 318 additions and 352 deletions

View file

@ -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 \

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
/* 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 */