- Combine some assembly files together and move them to rtl
- Convert rtl memory functions written by Greatlord to GAS and properly
add them into build system (not used yet since they haven't been tested)
- Misc cleanups
Deleted: trunk/reactos/lib/ntdll/dbg/brkpoint.c
Deleted: trunk/reactos/lib/ntdll/nasm/
Modified: trunk/reactos/lib/ntdll/ntdll.xml
Deleted: trunk/reactos/lib/ntdll/rtl/i386/
Modified: trunk/reactos/lib/ntdll/rtl/math.c
Deleted: trunk/reactos/lib/rtl/i386/alldiv.s
Deleted: trunk/reactos/lib/rtl/i386/allmul.s
Deleted: trunk/reactos/lib/rtl/i386/allrem.s
Deleted: trunk/reactos/lib/rtl/i386/allshl.s
Deleted: trunk/reactos/lib/rtl/i386/allshr.s
Deleted: trunk/reactos/lib/rtl/i386/aulldiv.s
Deleted: trunk/reactos/lib/rtl/i386/aullrem.s
Deleted: trunk/reactos/lib/rtl/i386/aullshr.s
Added: trunk/reactos/lib/rtl/i386/debug.S
Added: trunk/reactos/lib/rtl/i386/math.S
Added: trunk/reactos/lib/rtl/i386/mem.S
Added: trunk/reactos/lib/rtl/i386/random.S
Modified: trunk/reactos/lib/rtl/rtl.xml
Modified: trunk/reactos/ntoskrnl/ke/i386/brkpoint.S
_____
Deleted: trunk/reactos/lib/ntdll/dbg/brkpoint.c
--- trunk/reactos/lib/ntdll/dbg/brkpoint.c 2005-07-27 14:57:33 UTC
(rev 16800)
+++ trunk/reactos/lib/ntdll/dbg/brkpoint.c 2005-07-27 16:11:29 UTC
(rev 16801)
@@ -1,50 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: lib/ntdll/dbg/brkpoint.c
- * PURPOSE: Handles breakpoints
- * PROGRAMMER: Eric Kohl
- * UPDATE HISTORY:
- * Created 28/12/1999
- */
-
-/* INCLUDES
*****************************************************************/
-
-#include <ntdll.h>
-#define NDEBUG
-#include <debug.h>
-
-/* FUNCTIONS
*****************************************************************/
-
-#if 0
-/*
- * FIXME: DbgBreakPoint must not have a stack frame, but GCC doesn't
support
- * __declspec(naked) yet
- *
- * @implemented
- */
-__declspec(naked) VOID STDCALL DbgBreakPoint(VOID)
-{ __asm__(ASM_BREAKPOINT_STR); }
-
-/*
- * @implemented
- */
-VOID STDCALL DbgUserBreakPoint(VOID)
-{ __asm__(ASM_BREAKPOINT_STR); }
-#else
-#define DBG_BP_FUNC(__NAME__) \
-__asm__ \
-( \
- "\n" \
- ".global _" #__NAME__ "@0\n" \
- "_" #__NAME__ "@0:\n" \
- ASM_BREAKPOINT \
- "ret $0\n" \
-)
-
-DBG_BP_FUNC(DbgBreakPoint);
-DBG_BP_FUNC(DbgUserBreakPoint);
-#endif
-
-/* EOF */
_____
Modified: trunk/reactos/lib/ntdll/ntdll.xml
--- trunk/reactos/lib/ntdll/ntdll.xml 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/ntdll/ntdll.xml 2005-07-27 16:11:29 UTC (rev
16801)
@@ -18,7 +18,6 @@
<file>thread.c</file>
</directory>
<directory name="dbg">
- <file>brkpoint.c</file>
<file>debug.c</file>
<file>print.c</file>
</directory>
@@ -32,9 +31,6 @@
<file>dllmain.c</file>
</directory>
<directory name="rtl">
- <directory name="i386">
- <file>ftol.c</file>
- </directory>
<file>apc.c</file>
<file>callback.c</file>
<file>crc32.c</file>
_____
Modified: trunk/reactos/lib/ntdll/rtl/math.c
--- trunk/reactos/lib/ntdll/rtl/math.c 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/ntdll/rtl/math.c 2005-07-27 16:11:29 UTC (rev
16801)
@@ -33,6 +33,7 @@
double sqrt (double __x);
double tan (double __x);
+int _fltused = 0x9875;
double atan (double __x)
{
_____
Deleted: trunk/reactos/lib/rtl/i386/alldiv.s
--- trunk/reactos/lib/rtl/i386/alldiv.s 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/alldiv.s 2005-07-27 16:11:29 UTC (rev
16801)
@@ -1,50 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Deleted: trunk/reactos/lib/rtl/i386/allmul.s
--- trunk/reactos/lib/rtl/i386/allmul.s 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/allmul.s 2005-07-27 16:11:29 UTC (rev
16801)
@@ -1,54 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Deleted: trunk/reactos/lib/rtl/i386/allrem.s
--- trunk/reactos/lib/rtl/i386/allrem.s 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/allrem.s 2005-07-27 16:11:29 UTC (rev
16801)
@@ -1,31 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Deleted: trunk/reactos/lib/rtl/i386/allshl.s
--- trunk/reactos/lib/rtl/i386/allshl.s 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/allshl.s 2005-07-27 16:11:29 UTC (rev
16801)
@@ -1,33 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Deleted: trunk/reactos/lib/rtl/i386/allshr.s
--- trunk/reactos/lib/rtl/i386/allshr.s 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/allshr.s 2005-07-27 16:11:29 UTC (rev
16801)
@@ -1,33 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Deleted: trunk/reactos/lib/rtl/i386/aulldiv.s
--- trunk/reactos/lib/rtl/i386/aulldiv.s 2005-07-27 14:57:33 UTC
(rev 16800)
+++ trunk/reactos/lib/rtl/i386/aulldiv.s 2005-07-27 16:11:29 UTC
(rev 16801)
@@ -1,29 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Deleted: trunk/reactos/lib/rtl/i386/aullrem.s
--- trunk/reactos/lib/rtl/i386/aullrem.s 2005-07-27 14:57:33 UTC
(rev 16800)
+++ trunk/reactos/lib/rtl/i386/aullrem.s 2005-07-27 16:11:29 UTC
(rev 16801)
@@ -1,29 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Deleted: trunk/reactos/lib/rtl/i386/aullshr.s
--- trunk/reactos/lib/rtl/i386/aullshr.s 2005-07-27 14:57:33 UTC
(rev 16800)
+++ trunk/reactos/lib/rtl/i386/aullshr.s 2005-07-27 16:11:29 UTC
(rev 16801)
@@ -1,32 +0,0 @@
-/* $Id$
- *
- * 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(a)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 */
_____
Added: trunk/reactos/lib/rtl/i386/debug.S
--- trunk/reactos/lib/rtl/i386/debug.S 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/debug.S 2005-07-27 16:11:29 UTC (rev
16801)
@@ -0,0 +1,28 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * PURPOSE: Run-Time Library
+ * FILE: lib/rtl/i386/debug.S
+ * PROGRAMER: Alex Ionescu (alex(a)relsoft.net)
+ * REVISION HISTORY: 27/07/2005 Created
+ */
+
+.intel_syntax noprefix
+
+/* GLOBALS
****************************************************************/
+
+.globl _DbgBreakPoint@0
+.globl _DbgBreakPointWithStatus@4
+.globl _DbgUserBreakPoint@0
+
+/* FUNCTIONS
***************************************************************/
+
+_DbgBreakPoint@0:
+_DbgUserBreakPoint@0:
+ int 3
+ ret
+
+_DbgBreakPointWithStatus@4:
+ mov eax, [esp+4]
+ int 3
+ ret 4
_____
Added: trunk/reactos/lib/rtl/i386/math.S
--- trunk/reactos/lib/rtl/i386/math.S 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/math.S 2005-07-27 16:11:29 UTC (rev
16801)
@@ -0,0 +1,231 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * PURPOSE: Run-Time Library
+ * FILE: lib/rtl/i386/math.S
+ * PROGRAMER: Alex Ionescu (alex(a)relsoft.net)
+ * Eric Kohl (ekohl(a)rz-online.de)
+ * REVISION HISTORY: 27/07/2005 Created
+ */
+
+/* GLOBALS
****************************************************************/
+
+.globl __ftol
+.globl __aullshr
+.globl __allrem
+.globl __aulldiv
+.globl __allshr
+.globl __allshl
+.globl __aullrem
+.globl __allmul
+.globl __alldiv
+
+/* FUNCTIONS
***************************************************************/
+
+/*
+ * 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.
+ */
+__alldiv:
+ call ___divdi3
+ ret $0x10
+
+/*
+ * 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.
+ */
+__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
+
+/*
+ * 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.
+ */
+__aullrem:
+ call ___umoddi3
+ ret $16
+
+/*
+ * 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
+ */
+__allshl:
+ shldl %cl, %eax, %edx
+ sall %cl, %eax
+ andl $32, %ecx
+ je 1f
+ movl %eax, %edx
+ xorl %eax, %eax
+1:
+ ret
+
+/*
+ * 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
+ */
+__allshr:
+ shrdl %cl, %edx, %eax
+ sarl %cl, %edx
+ andl $32, %ecx
+ je 1f
+ movl %edx, %eax
+ sarl $31, %edx
+1:
+ ret
+
+/*
+ * 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.
+ */
+__aulldiv:
+ call ___udivdi3
+ ret $16
+
+/*
+ * 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
+ */
+__aullshr:
+ shrdl %cl, %edx, %eax
+ shrl %cl, %edx
+ andl $32, %ecx
+ je 1f
+ movl %edx, %eax
+1:
+ ret
+
+/*
+ * 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.
+ */
+__allrem:
+ call ___moddi3
+ ret $16
+
+.intel_syntax noprefix
+
+__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
+ fldcw [ebp-4]
+
+ /* Do the conversion */
+ fistp qword ptr [ebp-8]
+
+ /* Restore rounding mode */
+ fldcw [ebp-2]
+
+ /* Return value */
+ mov eax, [ebp-12]
+ mov edx, [ebp-8]
+
+ /* Remove stack frame and return*/
+ leave
+ ret
_____
Added: trunk/reactos/lib/rtl/i386/mem.S
--- trunk/reactos/lib/rtl/i386/mem.S 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/mem.S 2005-07-27 16:11:29 UTC (rev
16801)
@@ -0,0 +1,147 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: mem.asm
+ * PURPOSE: Memory functions
+ * PROGRAMMER: Magnus Olsen (magnusolsen(a)greatlord.com)
+ * UPDATE HISTORY:
+ * Created 27/07/2005
+ */
+
+.intel_syntax noprefix
+
+/* GLOBALS
****************************************************************/
+
+.globl _RtlZeroMemory@8 // (no bug) (max optimze code)
+.globl _RtlFillMemoryUlong@12 // (no bug) (max optimze code)
+.globl _RtlFillMemory@12 // [4] (no bug)
+.globl _RtlCompareMemoryUlong@12 // [5] (no bug)
+.globl _RtlCompareMemory@12 // [4] (no bug)
+
+/* 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
+
+_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
+
+_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
+
+_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
+
+_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
_____
Added: trunk/reactos/lib/rtl/i386/random.S
--- trunk/reactos/lib/rtl/i386/random.S 2005-07-27 14:57:33 UTC (rev
16800)
+++ trunk/reactos/lib/rtl/i386/random.S 2005-07-27 16:11:29 UTC (rev
16801)
@@ -0,0 +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(a)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, dword [_SavedValue + ecx*4]
+ mov dword [_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, dword [_SavedValue + ecx*4]
+ mov dword [_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, dword [_SavedValue + ecx*4]
+ mov dword [_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, dword [_SavedValue + ecx*4]
[truncated at 1000 lines; 157 more skipped]