- 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

svn path=/trunk/; revision=16801
This commit is contained in:
Alex Ionescu 2005-07-27 16:11:29 +00:00
parent 6cc3428516
commit c91952309a
28 changed files with 664 additions and 1150 deletions

View file

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

View file

@ -1,26 +0,0 @@
@echo off
echo fix temp slov for to make ntdll use this asm code insted of the c code
echo 1. copy makefile-asm ../makefile
cd rtl
del *.o
del *.d
del i386_RtlCompareMemory
del i386_RtlCompareMemoryUlong
del i386_RtlFillMemory
del i386_RtlFillMemoryUlong
del i386_RtlMoveMemory
del i386_RtlRandom
del i386_RtlZeroMemory
cd ..
rem nasmw -f coff i386_RtlCompareMemory.asm
rem nasmw -f coff i386_RtlCompareMemoryUlong.asm
rem nasmw -f coff i386_RtlFillMemory.asm
rem nasmw -f coff i386_RtlFillMemoryUlong.asm
rem nasmw -f coff i386_RtlMoveMemory.asm
rem nasmw -f coff i386_RtlRandom.asm
rem nasmw -f coff i386_RtlZeroMemory.asm

View file

@ -1,113 +0,0 @@
# $Id$
PATH_TO_TOP = ../..
TARGET_BOOTSTRAP = yes
TARGET_TYPE = dynlink
TARGET_NAME = ntdll
TARGET_CFLAGS = -g -D__NTDLL__
TARGET_ASFLAGS = -I $(PATH_TO_TOP)/include
TARGET_LFLAGS = -Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-nostartfiles -nostdlib
TARGET_SDKLIBS = string.a rosrtl.a
TARGET_GCCLIBS = gcc
TARGET_BASE = 0x77f60000
TARGET_PATH = def
TARGET_ENTRY = 0x0
CSR_OBJECTS = csr/lpc.o csr/capture.o csr/probe.o csr/thread.o
DBG_OBJECTS = dbg/brkpoint.o dbg/debug.o dbg/print.o #dbg/winedbg.o
LDR_OBJECTS = \
ldr/entry.o \
ldr/res.o \
ldr/startup.o \
ldr/utils.o
RTL_I386_OBJECTS = \
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/chkstk.o \
rtl/i386/exception.o \
rtl/i386/except.o \
rtl/i386/float.o \
rtl/i386/ftol.o
RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
rtl/math.o \
nasm/i386_RtlCompareMemory.o nasm/i386_RtlCompareMemoryUlong.o \
nasm/i386_RtlFillMemory.o \
nasm/i386_RtlFillMemoryUlong.o nasm/i386_RtlMoveMemory.o \
nasm/i386_RtlRandom.o nasm/i386_RtlZeroMemory.o \
rtl/nls.o rtl/process.o rtl/sd.o \
rtl/thread.o rtl/unicode.o rtl/env.o rtl/path.o rtl/ppb.o \
rtl/bitmap.o rtl/time.o rtl/acl.o rtl/sid.o rtl/image.o \
rtl/access.o rtl/apc.o rtl/callback.o rtl/luid.o rtl/misc.o \
rtl/registry.o rtl/exception.o rtl/intrlck.o rtl/resource.o \
rtl/handle.o rtl/atom.o rtl/message.o rtl/timezone.o \
rtl/propvar.o rtl/security.o rtl/dos8dot3.o rtl/compress.o \
rtl/encode.o rtl/teb.o
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o
STDLIB_OBJECTS = stdlib/abs.o stdlib/atoi.o stdlib/atoi64.o stdlib/atol.o \
stdlib/itoa.o stdlib/itow.o stdlib/labs.o stdlib/splitp.o \
stdlib/strtol.o stdlib/strtoul.o stdlib/wcstol.o \
stdlib/wcstoul.o stdlib/wtoi.o stdlib/wtoi64.o stdlib/wtol.o \
stdlib/mbstowcs.o stdlib/wcstombs.o
STRING_OBJECTS = string/ctype.o \
string/memicmp.o\
string/stricmp.o \
string/strlwr.o \
string/strnicmp.o \
string/strpbrk.o \
string/strstr.o string/strupr.o string/wstring.o
ARCH_OBJECTS = \
$(RTL_I386_OBJECTS)
TARGET_OBJECTS = \
napi.o \
$(ARCH_OBJECTS) \
$(CSR_OBJECTS) \
$(DBG_OBJECTS) \
$(LDR_OBJECTS) \
$(RTL_OBJECTS) \
$(STDIO_OBJECTS) \
$(STDLIB_OBJECTS) \
$(STRING_OBJECTS) \
stubs/stubs.o
DEP_OBJECTS = $(TARGET_OBJECTS)
DEP_EXCLUDE_FILTER = napi.%
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
%/TAGS:
etags -o $(@D)/TAGS $(@D)/\*.c
etags: csr/TAGS dbg/TAGS ldr/TAGS main/TAGS rtl/TAGS stdio/TAGS stdlib/TAGS string/TAGS stubs/TAGS
etags -i csr/TAGS -i dbg/TAGS -i ldr/TAGS -i main/TAGS -i rtl/TAGS -i stdio/TAGS -i stdlib/TAGS -i string/TAGS -i stubs/TAGS

View file

@ -1,52 +0,0 @@
This is Intel i386 or higher asm code version of ntdll.dll
The minium cpu req by reactos are : 486.
The asm src in this folder need nasm to be compile with.
1. Rename reactos/lib/ntdll/makefile to reactos/lib/ntdll/makefile.c
or make a backup up of it.
(it contain the C code version of ntdll makefile)
2. Copy reactos/lib/ntdll/nasm/makefile-asm to reactos/lib/ntdll/makefile
(it contain the asm verison of ntdll makefile, I need to change some
part to get the asm version be in use insted of the c version)
3. Now run reactos/make so u get the asm version of ntdll
Hope everyone like this asm optimze version.
but for momment are only thing optimze are
ntdll/rtl/mem.c
-----------------------------------------
RtlCompareMemory
RtlCompareMemoryUlong
RtlFillMemoryUlong
RtlMoveMemory
RtlZeroMemory
RtlFillMemory
(can make it lite faster not maxium optimze yet)
ntdll/rtl/RtlRandom.c
-----------------------------------------
RtlRandom
RtlUniform
SavedValue
info about ntdll/nasm/fixasm.bat
-----------------------------------------
delete all file that are not src or bat file
in the folder ntdll/nasm/

View file

@ -1,49 +0,0 @@
; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23
; *
; * COPYRIGHT: See COPYING in the top level directory
; * PROJECT: ReactOS kernel
; * FILE: i386_RtlCompareMemory.asm
; * PURPOSE: Memory functions
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
; * UPDATE HISTORY:
; * Created 20/07-2003
; *
BITS 32
GLOBAL _RtlCompareMemory@12 ; [4] (no bug)
SECTION .text
; *
; * [4] ULONG STDCALL RtlCompareMemory(PVOID Source1, PVOID Source2, ULONG Length)
; *
_RtlCompareMemory@12:
xor eax,eax ; count = 0
mov ecx, dword [esp + 12 ] ; ecx = Length
cmp ecx,0 ; if (Length==0) goto .zero
je .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)] ; edi = Destination
mov edx, dword [esp + (8 + 8)] ; edx = Source
.loop_1byte:
mov bl,byte [edi + eax ] ; if (src[count]!=des[count]) goto .pop_zero
cmp byte [edx + eax ],bl
jne .pop_zero
inc eax ; count = count + 1
dec ecx ; Length = Length - 1
jnz .loop_1byte ; if (Length!=0) goto .loop_1byte
.pop_zero:
pop ebx ; restore regiester
pop edi
.zero:
ret 12 ; return count

View file

@ -1,50 +0,0 @@
; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23
; *
; * COPYRIGHT: See COPYING in the top level directory
; * PROJECT: ReactOS kernel
; * FILE: i386_RtlCompareMemoryUlong.asm
; * PURPOSE: Memory functions
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
; * UPDATE HISTORY:
; * Created 20/07-2003
; *
BITS 32
GLOBAL _RtlCompareMemoryUlong@12 ; [5] (no bug)
SECTION .text
;*
;* [5] ULONG STDCALL RtlCompareMemoryUlong (PVOID Source, ULONG Length, ULONG Value)
;*
_RtlCompareMemoryUlong@12:
xor eax,eax
mov ecx, dword [esp + 8 ] ; ecx = Length
shr ecx,2 ; Length / sizeof(ULONG)
jz .zero ; 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
.zero
ret 12

View file

@ -1,36 +0,0 @@
; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23
; *
; * COPYRIGHT: See COPYING in the top level directory
; * PROJECT: ReactOS kernel
; * FILE: i386_RtlCompareMemory.asm
; * PURPOSE: Memory functions
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
; * UPDATE HISTORY:
; * Created 20/07-2003
; *
BITS 32
GLOBAL _RtlFillMemory@12 ; [4] (no bug)
SECTION .text
; *
; * [6] VOID STDCALL RtlFillMemory (PVOID Destination, ULONG Length, UCHAR Fill)
; *
_RtlFillMemory@12:
mov ecx,dword [esp + 8 ] ; ecx = Length
cmp ecx,0 ; if (Length==0) goto .zero
je .zero
mov edx, dword [esp + 4] ; edx = Destination
mov eax, dword [esp + 12] ; eax = fill
.loop:
mov byte [edx + ecx -1],al ; src[Length - 1] = fill
dec ecx ; Length = Length - 1
jnz .loop ; if (Length!=0) goto .loop
.zero:
ret 12 ; return

View file

@ -1,38 +0,0 @@
; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23
; *
; * COPYRIGHT: See COPYING in the top level directory
; * PROJECT: ReactOS kernel
; * FILE: i386_RtlMemoryUlong.asm
; * PURPOSE: Memory functions
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
; * UPDATE HISTORY:
; * Created 20/07-2003
; *
BITS 32
GLOBAL _RtlFillMemoryUlong@12 ; (no bug) (max optimze code)
SECTION .text
; *
; * VOID STDCALL RtlFillMemoryUlong (PVOID Destination, ULONG Length, ULONG Fill)
; *
_RtlFillMemoryUlong@12:
mov ecx, dword [esp + 8 ] ; Length
shr ecx,2 ; Length = Length / sizeof(ULONG)
jz .zero ; 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
.zero:
ret 12

View file

@ -1,69 +0,0 @@
; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23
; *
; * COPYRIGHT: See COPYING in the top level directory
; * PROJECT: ReactOS kernel
; * FILE: i386_RtlMemory.asm
; * PURPOSE: Memory functions
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
; * UPDATE HISTORY:
; * Created 20/07-2003
; *
BITS 32
GLOBAL _RtlMoveMemory@12 ; (no bug) (max optimze code)
SECTION .text
; *
; * [1] VOID STDCALL RtlMoveMemory (PVOID Destination, CONST VOID *Source,ULONG Length);
; *
_RtlMoveMemory@12:
mov ecx,dword [esp + 12 ] ; ecx = Length
cmp ecx,0 ; if (Length==0) goto .zero
je .zero
pushad
mov edi, dword [esp + (4 + 32)] ; eax = Destination
mov esi, dword [esp + (8 + 32)] ; edx = Source
; calc how many bytes it should handle same time
mov ebx,ecx ; temp_Length = Length
shr ecx,2 ; Length = Length / sizeof(ULONG)
jz .1byte ; if (Length==0) goto .1byte
shl ecx,2 ; Length = Length * sizeof(ULONG)
sub ebx,ecx ; temp_Length = temp_Length - Length
jz .4bytes ; if (temp_Length==0) goto .4byte
; move 4byte and 1byte
shr ecx,2 ; Length = Length / sizeof(ULONG)
cld ; clear d flag
rep movsd ; while (Length!=0) { (ULONG *) Destination[Length-1] = (ULONG *) Source[Length-1]; Legnth = Legnth - 1 }
mov ecx,ebx ; Length = temp_Length
rep movsb ; while (Length!=0) { (UCHAR *) Destination[Length-1] = (UCHAR *) Source[Length-1]; Legnth = Legnth - 1 }
popad ; restore regiester
ret 12 ; return
; move 1byte
.1byte:
mov ecx,dword [esp + (12 +32) ] ; ecx = Length
cld ; clear d flag
rep movsb ; while (Length!=0) { (UCHAR *) Destination[Length-1] = (UCHAR *) Source[Length-1]; Legnth = Legnth - 1 }
popad ; restore regiester
ret 12 ; return
; move 4bytes
.4bytes:
shr ecx,2 ; Length = Length / sizeof(ULONG)
cld ; clear d flag
rep movsd ; while (Length!=0) { (ULONG *) Destination[Length-1] = (ULONG *) Source[Length-1]; Legnth = Legnth - 1 }
popad ; restore regiester
.zero:
ret 12 ; return

View file

@ -1,249 +0,0 @@
; * base on ntdll/rtl/random.c v 1.1 2003/06/07 11:32:03
; *
; * COPYRIGHT: See COPYING in the top level directory
; * PROJECT: ReactOS kernel
; * FILE: i386_RtlRandom.asm
; * PURPOSE: Random number generator functions
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
; * UPDATE HISTORY:
; * Created 20/07-2003
; *
BITS 32
GLOBAL _RtlRandom@4 ; [1] (no bug) (max optimze code)
GLOBAL _RtlUniform@4 ; [2] (no bug) (max optimze code)
GLOBAL _SavedValue ; [3] (no bug) (max optimze code)
SECTION .text
_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)]
mov dword [_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
SECTION .data
; SavedValue[128]
_SavedValue:
dd 0x4c8bc0aa, 0x4c022957, 0x2232827a, 0x2f1e7626
dd 0x7f8bdafb, 0x5c37d02a, 0x0ab48f72, 0x2f0c4ffa
dd 0x290e1954, 0x6b635f23, 0x5d3885c0, 0x74b49ff8
dd 0x5155fa54, 0x6214ad3f, 0x111e9c29, 0x242a3a09
dd 0x75932ae1, 0x40ac432e, 0x54f7ba7a, 0x585ccbd5
dd 0x6df5c727, 0x0374dad1, 0x7112b3f1, 0x735fc311
dd 0x404331a9, 0x74d97781, 0x64495118, 0x323e04be
dd 0x5974b425, 0x4862e393, 0x62389c1d, 0x28a68b82
dd 0x0f95da37, 0x7a50bbc6, 0x09b0091c, 0x22cdb7b4
dd 0x4faaed26, 0x66417ccd, 0x189e4bfa, 0x1ce4e8dd
dd 0x5274c742, 0x3bdcf4dc, 0x2d94e907, 0x32eac016
dd 0x26d33ca3, 0x60415a8a, 0x31f57880, 0x68c8aa52
dd 0x23eb16da, 0x6204f4a1, 0x373927c1, 0x0d24eb7c
dd 0x06dd7379, 0x2b3be507, 0x0f9c55b1, 0x2c7925eb
dd 0x36d67c9a, 0x42f831d9, 0x5e3961cb, 0x65d637a8
dd 0x24bb3820, 0x4d08e33d, 0x2188754f, 0x147e409e
dd 0x6a9620a0, 0x62e26657, 0x7bd8ce81, 0x11da0abb
dd 0x5f9e7b50, 0x23e444b6, 0x25920c78, 0x5fc894f0
dd 0x5e338cbb, 0x404237fd, 0x1d60f80f, 0x320a1743
dd 0x76013d2b, 0x070294ee, 0x695e243b, 0x56b177fd
dd 0x752492e1, 0x6decd52f, 0x125f5219, 0x139d2e78
dd 0x1898d11e, 0x2f7ee785, 0x4db405d8, 0x1a028a35
dd 0x63f6f323, 0x1f6d0078, 0x307cfd67, 0x3f32a78a
dd 0x6980796c, 0x462b3d83, 0x34b639f2, 0x53fce379
dd 0x74ba50f4, 0x1abc2c4b, 0x5eeaeb8d, 0x335a7a0d
dd 0x3973dd20, 0x0462d66b, 0x159813ff, 0x1e4643fd
dd 0x06bc5c62, 0x3115e3fc, 0x09101613, 0x47af2515
dd 0x4f11ec54, 0x78b99911, 0x3db8dd44, 0x1ec10b9b
dd 0x5b5506ca, 0x773ce092, 0x567be81a, 0x5475b975
dd 0x7a2cde1a, 0x494536f5, 0x34737bb4, 0x76d9750b
dd 0x2a1f6232, 0x2e49644d, 0x7dddcbe7, 0x500cebdb
dd 0x619dab9e, 0x48c626fe, 0x1cda3193, 0x52dabe9d

View file

@ -1,65 +0,0 @@
; *
; * COPYRIGHT: See COPYING in the top level directory
; * PROJECT: ReactOS kernel
; * FILE: i386_RtlZeroMemory.asm
; * PURPOSE: Memory functions
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
; * UPDATE HISTORY:
; * Created 20/07-2003
; *
BITS 32
GLOBAL _RtlZeroMemory@8 ; (no bug) (max optimze code)
SECTION .text
; *
; * [1] VOID STDCALL RtlZeroMemory (PVOID Destination, ULONG Length);
; *
_RtlZeroMemory@8:
mov ecx,dword [esp + 8 ] ; Length
cmp ecx,0 ; if (Length==0) goto .zero
je .zero
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 .1byte ; if (Length==0) goto .1byte
shl ecx,2 ; Length = Length * sizeof(ULONG)
sub ebx,ecx ; temp_Length = temp_Length - Length;
jz .4bytes ; 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
.1byte:
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
.4bytes:
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
.zero:
ret 8 ; return

View file

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

View file

@ -1,36 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Security manager
* FILE: lib/ntdll/rtl/i386/ftol.c
* PROGRAMER: Ge van Geldorp (ge@gse.nl)
* REVISION HISTORY: 2003/04/24 Created
*/
int _fltused = 0x9875;
/*
* 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.
*/
long long __cdecl _ftol(void)
{
unsigned short cw_orig;
unsigned short cw_round_chop;
long long ll;
/* Set "round towards zero" mode */
__asm__("fstcw %0\n\t" : "=m" (cw_orig));
__asm__("fwait\n\t");
cw_round_chop = cw_orig | 0x0c00;
__asm__("fldcw %0\n\t" : : "m" (cw_round_chop));
/* Do the actual conversion */
__asm__("fistpq %0\n\t" : "=m" (ll) );
/* And restore the rounding mode */
__asm__("fldcw %0\n\t" : : "m" (cw_orig));
return ll;
}

View file

@ -33,6 +33,7 @@ double sin (double __x);
double sqrt (double __x);
double tan (double __x);
int _fltused = 0x9875;
double atan (double __x)
{

View file

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

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

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

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

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

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

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

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

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

231
reactos/lib/rtl/i386/math.S Normal file
View file

@ -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@relsoft.net)
* Eric Kohl (ekohl@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

147
reactos/lib/rtl/i386/mem.S Normal file
View file

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

View file

@ -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@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]
mov dword [_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

View file

@ -2,19 +2,17 @@
<define name="__USE_W32API" />
<define name="_NTOSKRNL_" />
<include base="rtl">.</include>
<directory name="i386">
<file>allshl.s</file>
<file>aulldiv.s</file>
<file>aullrem.s</file>
<file>allshr.s</file>
<file>allmul.s</file>
<file>aullshr.s</file>
<file>alldiv.s</file>
<file>allrem.s</file>
<file>chkstk.s</file>
<file>except.s</file>
<file>exception.c</file>
</directory>
<if property="ARCH" value="i386">
<directory name="i386">
<file>debug.S</file>
<file>chkstk.s</file>
<file>except.s</file>
<file>exception.c</file>
<file>math.S</file>
<file>mem.S</file>
<file>random.S</file>
</directory>
</if>
<file>access.c</file>
<file>acl.c</file>
<file>atom.c</file>
@ -30,9 +28,9 @@
<file>generictable.c</file>
<file>heap.c</file>
<file>image.c</file>
<file>mem.c</file>
<file>largeint.c</file>
<file>luid.c</file>
<file>mem.c</file>
<file>network.c</file>
<file>nls.c</file>
<file>ppb.c</file>

View file

@ -8,15 +8,7 @@
* PROGRAMMERS: No programmer listed.
*/
.global _DbgBreakPoint@0
_DbgBreakPoint@0:
.global _DbgBreakPointNoBugCheck@0
_DbgBreakPointNoBugCheck@0:
int $3
ret
.global _DbgBreakPointWithStatus@4
_DbgBreakPointWithStatus@4:
mov 0x4(%esp), %eax
int $3
ret $4