Index: trunk/src/NTDLL/arith64.asm
===================================================================
--- trunk/src/NTDLL/arith64.asm	(revision 6366)
+++ 	(revision )
@@ -1,678 +1,0 @@
-; $Id: arith64.asm,v 1.3 1999-12-20 11:47:00 sandervl Exp $
-
-;/*
-; * 64-bit integer apis
-; *
-; * Copyright 1999 Patrick Haller
-; *
-; *
-; * Project Odin Software License can be found in LICENSE.TXT
-; *
-; */
-.586P
-               NAME    arith64
-
-CODE32         SEGMENT DWORD PUBLIC USE32 'CODE'
-               align 4
-
-; ----------------------------------------------------------------------------
-
-       public  _RtlLargeIntegerDivide@20
-       public  _RtlLargeIntegerAdd@16
-       public  _RtlEnlargedIntegerMultiply@8
-       public  _RtlEnlargedUnsignedMultiply@8
-       public  _RtlEnlargedUnsignedDivide@16
-       public  _RtlExtendedLargeIntegerDivide@16
-       public  _RtlExtendedMagicDivide@20
-       public  _RtlExtendedIntegerMultiply@12
-       public  _RtlLargeIntegerShiftLeft@12
-       public  _RtlLargeIntegerShiftRight@12
-       public  _RtlLargeIntegerArithmeticShift@12
-       public  _RtlLargeIntegerNegate@8
-       public  _RtlLargeIntegerSubtract@16
-       public  _RtlConvertLongToLargeInteger@4
-       public  _RtlConvertUlongToLargeInteger@4
-
-; ----------------------------------------------------------------------------
-
-
-  extrn         RtlRaiseStatus : near
-
-; ----------------------------------------------------------------------------
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlLargeIntegerDivide
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.462
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlLargeIntegerDivide@20 proc near
-
-var_10         = dword ptr -10h
-var_C          = dword ptr -0Ch
-var_8          = dword ptr -8
-var_4          = dword ptr -4
-arg_0          = dword ptr  8
-arg_4          = dword ptr  0Ch
-arg_8          = dword ptr  10h
-arg_C          = dword ptr  14h
-arg_10         = dword ptr  18h
-
-               push    ebp
-               xor     eax, eax
-               mov     ebp, esp
-               sub     esp, 10h
-               push    esi
-               mov     [ebp+var_8], eax
-               push    edi
-               mov     esi, 40h
-               mov     edi, [ebp+arg_C]
-               mov     [ebp+var_4], eax
-               mov     eax, [ebp+arg_8]
-               or      eax, edi
-               jnz     short _rtl_lrgintdiv_1
-               push    0C0000094h
-               call    RtlRaiseStatus
-
-_rtl_lrgintdiv_1:
-               mov     eax, [ebp+arg_0]
-               mov     ecx, [ebp+arg_4]
-               mov     [ebp+var_10], eax
-               mov     [ebp+var_C], ecx
-
-_rtl_lrgintdiv_2:
-               mov     eax, [ebp+var_8]
-               mov     ecx, [ebp+var_4]
-               shr     eax, 1Fh
-               add     ecx, ecx
-               or      eax, ecx
-               mov     ecx, [ebp+var_8]
-               add     ecx, ecx
-               mov     [ebp+var_4], eax
-               mov     eax, [ebp+var_C]
-               shr     eax, 1Fh
-               or      eax, ecx
-               mov     ecx, [ebp+var_C]
-               add     ecx, ecx
-               mov     [ebp+var_8], eax
-               mov     eax, [ebp+var_10]
-               shl     [ebp+var_10], 1
-               shr     eax, 1Fh
-               or      eax, ecx
-               cmp     [ebp+var_4], edi
-               mov     [ebp+var_C], eax
-               ja      short _rtl_lrgintdiv_3
-               mov     eax, [ebp+arg_C]
-               cmp     [ebp+var_4], eax
-               jnz     short _rtl_lrgintdiv_5
-               mov     eax, [ebp+arg_8]
-               cmp     [ebp+var_8], eax
-               jb      short _rtl_lrgintdiv_5
-
-_rtl_lrgintdiv_3:
-               mov     eax, [ebp+arg_C]
-               mov     ecx, [ebp+arg_8]
-               or      byte ptr [ebp+var_10], 1
-               sub     [ebp+var_4], eax
-               cmp     [ebp+var_8], ecx
-               jnb     short _rtl_lrgintdiv_4
-               dec     [ebp+var_4]
-
-_rtl_lrgintdiv_4:
-               mov     eax, [ebp+arg_8]
-               sub     [ebp+var_8], eax
-
-_rtl_lrgintdiv_5:
-               dec     esi
-               jnz     short _rtl_lrgintdiv_2
-               mov     eax, [ebp+arg_10]
-               test    eax, eax
-               jz      short _rtl_lrgintdiv_6
-               mov     ecx, [ebp+var_8]
-               mov     edx, [ebp+var_4]
-               mov     [eax], ecx
-               mov     [eax+4], edx
-
-_rtl_lrgintdiv_6:
-               mov     eax, [ebp+var_10]
-               mov     edx, [ebp+var_C]
-               pop     edi
-               pop     esi
-               mov     esp, ebp
-               pop     ebp
-               retn    14h
-_RtlLargeIntegerDivide@20 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlLargeIntegerAdd
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.460
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlLargeIntegerAdd@16 proc        near
-
-arg_0          = dword ptr  4
-arg_4          = dword ptr  8
-arg_8          = dword ptr  0Ch
-arg_C          = dword ptr  10h
-
-               mov     eax, [esp+arg_0]
-               add     eax, [esp+arg_8]
-               mov     edx, [esp+arg_4]
-               adc     edx, [esp+arg_C]
-               retn    10h
-_RtlLargeIntegerAdd@16 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlEnlargedIntegerMultiply
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.371
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlEnlargedIntegerMultiply@8 proc near
-
-arg_0           = dword ptr  4
-arg_4           = dword ptr  8
-
-                mov     eax, [esp+arg_0]
-                imul    [esp+arg_4]
-                retn    8
-_RtlEnlargedIntegerMultiply@8 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlEnlargedUnsignedMultiply
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.373
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlEnlargedUnsignedMultiply@8 proc near
-
-arg_0           = dword ptr  4
-arg_4           = dword ptr  8
-                mov     eax, [esp+arg_0]
-                mul     [esp+arg_4]
-                retn    8
-_RtlEnlargedUnsignedMultiply@8 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlEnlargedUnsignedDivide
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.372
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlEnlargedUnsignedDivide@16 proc near
-
-arg_0           = dword ptr  4
-arg_4           = dword ptr  8
-arg_8           = dword ptr  0Ch
-arg_C           = dword ptr  10h
-
-                mov     eax, [esp+arg_0]
-                mov     edx, [esp+arg_4]
-                mov     ecx, [esp+arg_C]
-                div     [esp+arg_8]
-                or      ecx, ecx
-                jnz     short _rtl_enlunsdiv_1
-                retn    10h
-
-_rtl_enlunsdiv_1:
-                mov     [ecx], edx
-                retn    10h
-_RtlEnlargedUnsignedDivide@16 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlExtendedLargeIntegerDivide
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.390
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlExtendedLargeIntegerDivide@16 proc near
-
-arg_0           = dword ptr  10h
-arg_4           = dword ptr  14h
-arg_8           = dword ptr  18h
-arg_C           = dword ptr  1Ch
-
-                push    esi
-                push    edi
-                push    ebx
-                mov     eax, [esp+arg_0]
-                mov     edx, [esp+arg_4]
-                mov     ebx, [esp+arg_8]
-                or      ebx, ebx
-                jz      short _rtl_extlrgintdiv_2
-                push    ebp
-                mov     ecx, 40h
-                xor     esi, esi
-                nop
-
-_rtl_extlrgintdiv_1:
-                shl     eax, 1
-                rcl     edx, 1
-                rcl     esi, 1
-                sbb     edi, edi
-                cmp     esi, ebx
-                cmc
-                sbb     ebp, ebp
-                or      edi, ebp
-                sub     eax, edi
-                and     edi, ebx
-                sub     esi, edi
-                dec     ecx
-                jnz     short _rtl_extlrgintdiv_1
-                pop     ebp
-                pop     ebx
-                pop     edi
-                mov     ecx, [esp+0FFFFFFF8h+arg_C]
-                or      ecx, ecx
-                jnz     short _rtl_extlrgintdiv_3
-                pop     esi
-                retn    10h
-
-_rtl_extlrgintdiv_3:
-                mov     [ecx], esi
-                pop     esi
-                retn    10h
-
-_rtl_extlrgintdiv_2:
-                push    0C0000094h
-                call    RtlRaiseStatus
-                pop     ebx
-                pop     edi
-                pop     esi
-                retn    10h
-_RtlExtendedLargeIntegerDivide@16 endp
-
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlExtendedMagicDivide
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.391
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlExtendedMagicDivide@20 proc near
-
-var_C          = dword ptr -0Ch
-var_8          = dword ptr -8
-var_4          = dword ptr -4
-arg_0          = dword ptr  8
-arg_4          = dword ptr  0Ch
-arg_8          = dword ptr  10h
-arg_C          = dword ptr  14h
-arg_10         = byte ptr  18h
-
-               push    ebp
-               mov     ebp, esp
-               sub     esp, 0Ch
-               push    esi
-               mov     esi, [ebp+arg_4]
-               test    esi, 80000000h
-               jz      short _rtl_extmagicdiv_1
-               neg     [ebp+arg_4]
-               neg     [ebp+arg_0]
-               sbb     [ebp+arg_4], 0
-
-_rtl_extmagicdiv_1:
-               mov     eax, [ebp+arg_8]
-               mul     [ebp+arg_0]
-               mov     [ebp+var_4], edx
-               mov     eax, [ebp+arg_8]
-               mul     [ebp+arg_4]
-               mov     [ebp+var_8], eax
-               mov     [ebp+var_C], edx
-               mov     eax, [ebp+arg_C]
-               mul     [ebp+arg_0]
-               xor     ecx, ecx
-               add     eax, [ebp+var_4]
-               adc     ecx, 0
-               add     eax, [ebp+var_8]
-               adc     ecx, 0
-               mov     [ebp+var_4], edx
-               mov     eax, [ebp+arg_C]
-               mul     [ebp+arg_4]
-               add     eax, [ebp+var_4]
-               adc     edx, 0
-               add     eax, [ebp+var_C]
-               adc     edx, 0
-               add     eax, ecx
-               adc     edx, 0
-               mov     cl, [ebp+arg_10]
-
-_rtl_extmagicdiv_3:
-               cmp     cl, 1Fh
-               jbe     short _rtl_extmagicdiv_2
-               sub     cl, 1Fh
-               shrd    eax, edx, 1Fh
-               shr     edx, 1Fh
-               jmp     short _rtl_extmagicdiv_3
-
-_rtl_extmagicdiv_2:
-               shrd    eax, edx, cl
-               shr     edx, cl
-               test    esi, 80000000h
-               jz      short _rtl_extmagicdiv_4
-               neg     edx
-               neg     eax
-               sbb     edx, 0
-
-_rtl_extmagicdiv_4:
-               pop     esi
-               mov     esp, ebp
-               pop     ebp
-               retn    14h
-_RtlExtendedMagicDivide@20 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlExtendedIntegerMultiply
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.389
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlExtendedIntegerMultiply@12 proc        near
-
-var_8          = dword ptr -8
-arg_0          = dword ptr  8
-arg_4          = dword ptr  0Ch
-arg_8          = dword ptr  10h
-
-               push    ebp
-               mov     ebp, esp
-               push    esi
-               mov     esi, [ebp+arg_8]
-               xor     esi, [ebp+arg_4]
-               test    [ebp+arg_4], 80000000h
-               jz      short _rtl_extintmply_1
-               neg     [ebp+arg_4]
-               neg     [ebp+arg_0]
-               sbb     [ebp+arg_4], 0
-
-_rtl_extintmply_1:
-               test    [ebp+arg_8], 80000000h
-               jz      short _rtl_extintmply_2
-               neg     [ebp+arg_8]
-
-_rtl_extintmply_2:
-               mov     eax, [ebp+arg_8]
-               mul     [ebp+arg_0]
-               push    edx
-               mov     ecx, eax
-               mov     eax, [ebp+arg_8]
-               mul     [ebp+arg_4]
-               add     eax, [esp+8+var_8]
-               test    esi, 80000000h
-               jz      short _rtl_extintmply_3
-               neg     eax
-               neg     ecx
-               sbb     eax, 0
-
-_rtl_extintmply_3:
-               add     esp, 4
-               pop     esi
-               mov     edx, eax
-               mov     eax, ecx
-               pop     ebp
-               retn    0Ch
-_RtlExtendedIntegerMultiply@12 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlLargeIntegerShiftLeft
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.464
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlLargeIntegerShiftLeft@12 proc near
-
-arg_0          = dword ptr  4
-arg_4          = dword ptr  8
-arg_8          = dword ptr  0Ch
-
-               mov     ecx, [esp+arg_8]
-               and     ecx, 3Fh
-               cmp     ecx, 20h
-               jnb     short _rtl_lrgintshl_1
-               mov     eax, [esp+arg_0]
-               mov     edx, [esp+arg_4]
-               shld    edx, eax, cl
-               shl     eax, cl
-               retn    0Ch
-
-_rtl_lrgintshl_1:
-               mov     edx, [esp+arg_0]
-               xor     eax, eax
-               shl     edx, cl
-               retn    0Ch
-_RtlLargeIntegerShiftLeft@12 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlLargeIntegerShiftRight
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.465
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlLargeIntegerShiftRight@12 proc near
-
-arg_0          = dword ptr  4
-arg_4          = dword ptr  8
-arg_8          = dword ptr  0Ch
-
-               mov     ecx, [esp+arg_8]
-               and     ecx, 3Fh
-               cmp     ecx, 20h
-               jnb     short _rtl_lrgintshr_1
-               mov     eax, [esp+arg_0]
-               mov     edx, [esp+arg_4]
-               shrd    eax, edx, cl
-               shr     edx, cl
-               retn    0Ch
-
-_rtl_lrgintshr_1:
-               mov     eax, [esp+arg_4]
-               xor     edx, edx
-               shr     eax, cl
-               retn    0Ch
-_RtlLargeIntegerShiftRight@12 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlLargeIntegerArithmeticShift
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.461
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-
-_RtlLargeIntegerArithmeticShift@12 proc near
-
-arg_0          = dword ptr  4
-arg_4          = dword ptr  8
-arg_8          = dword ptr  0Ch
-
-               mov     ecx, [esp+arg_8]
-               and     ecx, 3Fh
-               cmp     ecx, 20h
-               jb      short _rtl_lrgintarithshft_1
-               mov     eax, [esp+arg_4]
-               sar     eax, cl
-               bt      eax, 1Fh
-               sbb     edx, edx
-               retn    0Ch
-
-_rtl_lrgintarithshft_1:
-               mov     eax, [esp+arg_0]
-               mov     edx, [esp+arg_4]
-               shrd    eax, edx, cl
-               sar     edx, cl
-               retn    0Ch
-_RtlLargeIntegerArithmeticShift@12 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlLargeIntegerNegate
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.463
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlLargeIntegerNegate@8 proc near
-
-arg_0          = dword ptr  4
-arg_4          = dword ptr  8
-
-               mov     eax, [esp+arg_0]
-               mov     edx, [esp+arg_4]
-               neg     edx
-               neg     eax
-               sbb     edx, 0
-               retn    8
-_RtlLargeIntegerNegate@8 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlLargeIntegerSubtract
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.466
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlLargeIntegerSubtract@16        proc near
-
-arg_0          = dword ptr  4
-arg_4          = dword ptr  8
-arg_8          = dword ptr  0Ch
-arg_C          = dword ptr  10h
-
-               mov     eax, [esp+arg_0]
-               sub     eax, [esp+arg_8]
-               mov     edx, [esp+arg_4]
-               sbb     edx, [esp+arg_C]
-               retn    10h
-_RtlLargeIntegerSubtract@16        endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlConvertLongToLargeInteger
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.316
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlConvertLongToLargeInteger@4 proc near
-
-arg_0          = dword ptr  4
-
-               mov     eax, [esp+arg_0]
-               cdq
-               retn    4
-_RtlConvertLongToLargeInteger@4 endp
-
-
-; ----------------------------------------------------------------------------
-; Name      : RtlConvertUlongToLargeInteger
-; Purpose   :
-; Parameters:
-; Variables :
-; Result    :
-; Remark    : NTDLL.320
-; Status    : VERIFIED
-;
-; Author    : Patrick Haller [Mon, 1999/11/08 23:44]
-; ----------------------------------------------------------------------------
-_RtlConvertUlongToLargeInteger@4 proc near
-
-arg_0          = dword ptr  4
-
-               mov     eax, [esp+arg_0]
-               xor     edx, edx
-               retn    4
-_RtlConvertUlongToLargeInteger@4 endp
-
-
-
-; ----------------------------------------------------------------------------
-
-PUBLIC 		_POP_FPU
-_POP_FPU proc near
-	mov	eax, [esp+4]
-	fstp	qword ptr [eax]
-	ret
-_POP_FPU endp
-
-CODE32          ENDS
-
-                END
Index: trunk/src/NTDLL/large_int.asm
===================================================================
--- trunk/src/NTDLL/large_int.asm	(revision 6372)
+++ trunk/src/NTDLL/large_int.asm	(revision 6372)
@@ -0,0 +1,456 @@
+	extrn	_dllentry:dword
+	title	large_int.c
+	.386
+	.387
+CODE32	segment para use32 public 'CODE'
+CODE32	ends
+DATA32	segment para use32 public 'DATA'
+DATA32	ends
+CONST32_RO	segment para use32 public 'CONST'
+CONST32_RO	ends
+BSS32	segment para use32 public 'BSS'
+BSS32	ends
+DGROUP	group BSS32, DATA32
+	assume	cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT
+CODE32	segment
+	extrn	__modu64:proc
+
+; 224 ULONGLONG WINAPI _aullrem( ULONGLONG a, ULONGLONG b )
+	align 4
+
+	public __aullrem@16
+__aullrem@16	proc
+
+; 226     return a % b;
+	mov	ecx,[esp+010h];	b
+	push	ecx
+	mov	eax,[esp+08h];	a
+	mov	edx,[esp+0ch];	a
+	mov	ecx,[esp+010h];	b
+	call	__modu64
+	pop	ecx
+	ret	010h
+__aullrem@16	endp
+	extrn	__divu64:proc
+
+; 215 ULONGLONG WINAPI _aulldiv( ULONGLONG a, ULONGLONG b )
+	align 4h
+
+	public __aulldiv@16
+__aulldiv@16	proc
+
+; 217     return a / b;
+	mov	ecx,[esp+010h];	b
+	push	ecx
+	mov	ecx,[esp+010h];	b
+	mov	edx,[esp+0ch];	a
+	mov	eax,[esp+08h];	a
+	call	__divu64
+	pop	ecx
+	ret	010h
+__aulldiv@16	endp
+	extrn	__modi64:proc
+
+; 206 LONGLONG WINAPI _allrem( LONGLONG a, LONGLONG b )
+	align 4h
+
+	public __allrem@16
+__allrem@16	proc
+
+; 208     return a % b;
+	mov	ecx,[esp+010h];	b
+	push	ecx
+	mov	eax,[esp+08h];	a
+	mov	edx,[esp+0ch];	a
+	mov	ecx,[esp+010h];	b
+	call	__modi64
+	pop	ecx
+	ret	010h
+__allrem@16	endp
+	extrn	__multi64:proc
+
+; 197 LONGLONG WINAPI _allmul( LONGLONG a, LONGLONG b )
+	align 4h
+
+	public __allmul@16
+__allmul@16	proc
+
+; 199     return a * b;
+	mov	ecx,[esp+010h];	b
+	push	ecx
+	mov	ecx,[esp+010h];	b
+	mov	edx,[esp+0ch];	a
+	mov	eax,[esp+08h];	a
+	call	__multi64
+	pop	ecx
+	ret	010h
+__allmul@16	endp
+	extrn	__divi64:proc
+
+; 188 LONGLONG WINAPI _alldiv( LONGLONG a, LONGLONG b )
+	align 4h
+
+	public __alldiv@16
+__alldiv@16	proc
+
+; 190     return a / b;
+	mov	ecx,[esp+010h];	b
+	push	ecx
+	sub	esp,0ch
+	mov	ecx,[esp+01ch];	b
+	mov	edx,[esp+018h];	a
+	mov	eax,[esp+014h];	a
+	call	__divi64
+	add	esp,010h
+	ret	010h
+__alldiv@16	endp
+
+; 158 LONGLONG WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b )
+	align 4h
+
+	public _RtlExtendedIntegerMultiply@12
+_RtlExtendedIntegerMultiply@12	proc
+
+; 160     return a * b;
+	mov	ecx,[esp+08h];	a
+	push	ecx
+	mov	eax,[esp+010h];	b
+	mov	ecx,[esp+08h];	a
+	mov	edx,eax
+	sar	edx,01fh
+	call	__multi64
+	pop	ecx
+	ret	0ch
+_RtlExtendedIntegerMultiply@12	endp
+
+; 147 LONGLONG WINAPI RtlExtendedLargeIntegerDivide( LONGLONG a, INT b, INT *rem )
+	align 4h
+
+	public _RtlExtendedLargeIntegerDivide@16
+_RtlExtendedLargeIntegerDivide@16	proc
+	sub	esp,08h
+	push	ebx
+	push	edi
+
+; 149     LONGLONG ret = a / b;
+	mov	ebx,[esp+01ch];	b
+	mov	ecx,ebx
+	sar	ecx,01fh
+	push	ecx
+	mov	ecx,ebx
+	sub	esp,0ch
+	mov	edi,[esp+024h];	a
+	mov	edx,[esp+028h];	a
+	mov	eax,edi
+	call	__divi64
+	add	esp,010h
+
+; 150     if (rem) *rem = a - b * ret;
+	mov	ecx,[esp+020h];	rem
+
+; 149     LONGLONG ret = a / b;
+	mov	[esp+08h],eax;	ret
+	mov	[esp+0ch],edx;	ret
+
+; 150     if (rem) *rem = a - b * ret;
+	test	ecx,ecx
+	je	@BLBL15
+	imul	ebx,eax
+	sub	edi,ebx
+	mov	[ecx],edi
+@BLBL15:
+
+; 151     return ret;
+	pop	edi
+	pop	ebx
+	add	esp,08h
+	ret	010h
+_RtlExtendedLargeIntegerDivide@16	endp
+
+; 127 UINT WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr )
+	align 4h
+
+	public _RtlEnlargedUnsignedDivide@16
+_RtlEnlargedUnsignedDivide@16	proc
+	push	ebp
+	push	ebx
+
+; 137     UINT ret = a / b;
+	xor	ebx,ebx
+
+; 127 UINT WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr )
+	push	edi
+	push	esi
+	push	ebp
+
+; 137     UINT ret = a / b;
+	mov	esi,[esp+020h];	b
+	push	ebx
+	mov	ebp,[esp+020h];	a
+	mov	edi,[esp+01ch];	a
+	mov	ecx,esi
+	mov	edx,ebp
+	mov	eax,edi
+	call	__divu64
+	xchg	edi,eax
+	mov	ecx,esi
+	mov	edx,ebp
+	pop	esi
+	mov	[esp],edi;	ret
+
+; 138     if (remptr) *remptr = a % b;
+	mov	edi,[esp+024h];	remptr
+	test	edi,edi
+	je	@BLBL13
+	push	ebx
+	call	__modu64
+	mov	[edi],eax
+	pop	ecx
+@BLBL13:
+
+; 139     return ret;
+	mov	eax,[esp];	ret
+	pop	ecx
+	pop	esi
+	pop	edi
+	pop	ebx
+	pop	ebp
+	ret	010h
+_RtlEnlargedUnsignedDivide@16	endp
+
+; 118 ULONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b )
+	align 4h
+
+	public _RtlEnlargedUnsignedMultiply@8
+_RtlEnlargedUnsignedMultiply@8	proc
+
+; 120     return (ULONGLONG)a * b;
+	mov	ecx,[esp+04h];	a
+	xor	eax,eax
+	push	eax
+	xor	edx,edx
+	mov	eax,[esp+0ch];	b
+	call	__multi64
+	pop	ecx
+	ret	08h
+_RtlEnlargedUnsignedMultiply@8	endp
+
+; 109 LONGLONG WINAPI RtlEnlargedIntegerMultiply( INT a, INT b )
+	align 4h
+
+	public _RtlEnlargedIntegerMultiply@8
+_RtlEnlargedIntegerMultiply@8	proc
+
+; 111     return (LONGLONG)a * b;
+	mov	ecx,[esp+04h];	a
+	mov	eax,ecx
+	sar	eax,01fh
+	push	eax
+	mov	eax,[esp+0ch];	b
+	mov	edx,eax
+	sar	edx,01fh
+	call	__multi64
+	pop	ecx
+	ret	08h
+_RtlEnlargedIntegerMultiply@8	endp
+
+; 100 ULONGLONG WINAPI RtlConvertUlongToLargeInteger( ULONG a )
+	align 4h
+
+	public _RtlConvertUlongToLargeInteger@4
+_RtlConvertUlongToLargeInteger@4	proc
+
+; 102     return a;
+	mov	eax,[esp+04h];	a
+	xor	edx,edx
+	ret	04h
+_RtlConvertUlongToLargeInteger@4	endp
+
+; 91 LONGLONG WINAPI RtlConvertLongToLargeInteger( LONG a )
+	align 4h
+
+	public _RtlConvertLongToLargeInteger@4
+_RtlConvertLongToLargeInteger@4	proc
+
+; 93     return a;
+	mov	eax,[esp+04h];	a
+	mov	edx,eax
+	sar	edx,01fh
+	ret	04h
+_RtlConvertLongToLargeInteger@4	endp
+
+; 80 ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG a, ULONGLONG b, ULONGLONG *rem )
+	align 4h
+
+	public _RtlLargeIntegerDivide@20
+_RtlLargeIntegerDivide@20	proc
+	push	ebp
+	push	ebx
+	push	edi
+	push	esi
+	sub	esp,08h
+
+; 82     ULONGLONG ret = a / b;
+	mov	ebp,[esp+028h];	b
+	push	ebp
+	mov	ebx,[esp+028h];	b
+	mov	esi,[esp+024h];	a
+	mov	edi,[esp+020h];	a
+	mov	ecx,ebx
+	mov	edx,esi
+	mov	eax,edi
+	call	__divu64
+	mov	ecx,ebx
+	pop	ebx
+
+; 83     if (rem) *rem = a - ret * b;
+	mov	ebx,[esp+02ch];	rem
+
+; 82     ULONGLONG ret = a / b;
+	mov	[esp],eax;	ret
+	mov	[esp+04h],edx;	ret
+
+; 83     if (rem) *rem = a - ret * b;
+	test	ebx,ebx
+	je	@BLBL7
+	push	ebp
+	call	__multi64
+	mov	ecx,edi
+	pop	edi
+	sub	ecx,eax
+	sbb	esi,edx
+	mov	[ebx],ecx
+	mov	[ebx+04h],esi
+@BLBL7:
+
+; 84     return ret;
+	mov	eax,[esp];	ret
+	mov	edx,[esp+04h];	ret
+	add	esp,08h
+	pop	esi
+	pop	edi
+	pop	ebx
+	pop	ebp
+	ret	014h
+_RtlLargeIntegerDivide@20	endp
+
+; 68 LONGLONG WINAPI RtlLargeIntegerArithmeticShift( LONGLONG a, INT count )
+	align 4h
+
+	public _RtlLargeIntegerArithmeticShift@12
+_RtlLargeIntegerArithmeticShift@12	proc
+
+; 71     return a >> count;
+	mov	ecx,[esp+0ch];	count
+	mov	edx,[esp+08h];	a
+	and	ecx,03fh
+	mov	eax,[esp+04h];	a
+	cmp	ecx,01fh
+	jg	@BLBL23
+	shrd	eax,edx,cl
+	sar	edx,cl
+	jmp	@BLBL24
+@BLBL23:
+	mov	eax,edx
+	sub	cl,020h
+	sar	edx,01fh
+	sar	eax,cl
+@BLBL24:
+	ret	0ch
+_RtlLargeIntegerArithmeticShift@12	endp
+
+; 59 LONGLONG WINAPI RtlLargeIntegerShiftRight( LONGLONG a, INT count )
+	align 4h
+
+	public _RtlLargeIntegerShiftRight@12
+_RtlLargeIntegerShiftRight@12	proc
+
+; 61     return (ULONGLONG)a >> count;
+	mov	ecx,[esp+0ch];	count
+	mov	eax,[esp+04h];	a
+	and	ecx,03fh
+	mov	edx,[esp+08h];	a
+	cmp	ecx,01fh
+	jg	@BLBL25
+	shrd	eax,edx,cl
+	shr	edx,cl
+	jmp	@BLBL26
+@BLBL25:
+	mov	eax,edx
+	sub	cl,020h
+	shr	eax,cl
+	xor	edx,edx
+@BLBL26:
+	ret	0ch
+_RtlLargeIntegerShiftRight@12	endp
+
+; 50 LONGLONG WINAPI RtlLargeIntegerShiftLeft( LONGLONG a, INT count )
+	align 4h
+
+	public _RtlLargeIntegerShiftLeft@12
+_RtlLargeIntegerShiftLeft@12	proc
+
+; 52     return a << count;
+	mov	ecx,[esp+0ch];	count
+	mov	eax,[esp+04h];	a
+	and	ecx,03fh
+	mov	edx,[esp+08h];	a
+	cmp	ecx,01fh
+	jg	@BLBL27
+	shld	edx,eax,cl
+	shl	eax,cl
+	jmp	@BLBL28
+@BLBL27:
+	mov	edx,eax
+	sub	cl,020h
+	shl	edx,cl
+	xor	eax,eax
+@BLBL28:
+	ret	0ch
+_RtlLargeIntegerShiftLeft@12	endp
+
+; 41 LONGLONG WINAPI RtlLargeIntegerNegate( LONGLONG a )
+	align 4h
+
+	public _RtlLargeIntegerNegate@8
+_RtlLargeIntegerNegate@8	proc
+
+; 43     return -a;
+	mov	eax,[esp+04h];	a
+	mov	edx,[esp+08h];	a
+	not	eax
+	not	edx
+	add	eax,01h
+	adc	edx,0h
+	ret	08h
+_RtlLargeIntegerNegate@8	endp
+
+; 32 LONGLONG WINAPI RtlLargeIntegerSubtract( LONGLONG a, LONGLONG b )
+	align 4h
+
+	public _RtlLargeIntegerSubtract@16
+_RtlLargeIntegerSubtract@16	proc
+
+; 34     return a - b;
+	mov	eax,[esp+04h];	a
+	mov	edx,[esp+08h];	a
+	sub	eax,[esp+0ch];	b
+	sbb	edx,[esp+010h];	b
+	ret	010h
+_RtlLargeIntegerSubtract@16	endp
+
+; 23 LONGLONG WINAPI RtlLargeIntegerAdd( LONGLONG a, LONGLONG b )
+	align 4h
+
+	public _RtlLargeIntegerAdd@16
+_RtlLargeIntegerAdd@16	proc
+
+; 25     return a + b;
+	mov	eax,[esp+04h];	a
+	mov	edx,[esp+08h];	a
+	add	eax,[esp+0ch];	b
+	adc	edx,[esp+010h];	b
+	ret	010h
+_RtlLargeIntegerAdd@16	endp
+CODE32	ends
+end
Index: trunk/src/NTDLL/large_int.cxx
===================================================================
--- trunk/src/NTDLL/large_int.cxx	(revision 6372)
+++ trunk/src/NTDLL/large_int.cxx	(revision 6372)
@@ -0,0 +1,227 @@
+/*
+ * Large integer functions
+ *
+ * Copyright 2000 Alexandre Julliard
+ */
+
+#include "winnt.h"
+#include "ntddk.h"
+
+/*
+ * Note: we use LONGLONG instead of LARGE_INTEGER, because
+ * the latter is a structure and the calling convention for
+ * returning a structure would not be binary-compatible.
+ *
+ * FIXME: for platforms that don't have a native LONGLONG type,
+ * we should define LONGLONG as a structure similar to LARGE_INTEGER
+ * and do everything by hand. You are welcome to do it...
+ */
+
+/******************************************************************************
+ *        RtlLargeIntegerAdd   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlLargeIntegerAdd( LONGLONG a, LONGLONG b )
+{
+    return a + b;
+}
+
+
+/******************************************************************************
+ *        RtlLargeIntegerSubtract   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlLargeIntegerSubtract( LONGLONG a, LONGLONG b )
+{
+    return a - b;
+}
+
+
+/******************************************************************************
+ *        RtlLargeIntegerNegate   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlLargeIntegerNegate( LONGLONG a )
+{
+    return -a;
+}
+
+
+/******************************************************************************
+ *        RtlLargeIntegerShiftLeft   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlLargeIntegerShiftLeft( LONGLONG a, INT count )
+{
+    return a << count;
+}
+
+
+/******************************************************************************
+ *        RtlLargeIntegerShiftRight   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlLargeIntegerShiftRight( LONGLONG a, INT count )
+{
+    return (ULONGLONG)a >> count;
+}
+
+
+/******************************************************************************
+ *        RtlLargeIntegerArithmeticShift   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlLargeIntegerArithmeticShift( LONGLONG a, INT count )
+{
+    /* FIXME: gcc does arithmetic shift here, but it may not be true on all platforms */
+    return a >> count;
+}
+
+
+/******************************************************************************
+ *        RtlLargeIntegerDivide   (NTDLL.@)
+ *
+ * FIXME: should it be signed division instead?
+ */
+ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG a, ULONGLONG b, ULONGLONG *rem )
+{
+    ULONGLONG ret = a / b;
+    if (rem) *rem = a - ret * b;
+    return ret;
+}
+
+
+/******************************************************************************
+ *        RtlConvertLongToLargeInteger   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlConvertLongToLargeInteger( LONG a )
+{
+    return a;
+}
+
+
+/******************************************************************************
+ *        RtlConvertUlongToLargeInteger   (NTDLL.@)
+ */
+ULONGLONG WINAPI RtlConvertUlongToLargeInteger( ULONG a )
+{
+    return a;
+}
+
+
+/******************************************************************************
+ *        RtlEnlargedIntegerMultiply   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlEnlargedIntegerMultiply( INT a, INT b )
+{
+    return (LONGLONG)a * b;
+}
+
+
+/******************************************************************************
+ *        RtlEnlargedUnsignedMultiply   (NTDLL.@)
+ */
+ULONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b )
+{
+    return (ULONGLONG)a * b;
+}
+
+
+/******************************************************************************
+ *        RtlEnlargedUnsignedDivide   (NTDLL.@)
+ */
+UINT WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr )
+{
+#if defined(__i386__) && defined(__GNUC__)
+    UINT ret, rem;
+    __asm__("div %4,%%eax"
+            : "=a" (ret), "=d" (rem)
+            : "0" (*(UINT*)&a), "1" (*((UINT*)&a+1)), "g" (b) );
+    if (remptr) *remptr = rem;
+    return ret;
+#else
+    UINT ret = a / b;
+    if (remptr) *remptr = a % b;
+    return ret;
+#endif
+}
+
+
+/******************************************************************************
+ *        RtlExtendedLargeIntegerDivide   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlExtendedLargeIntegerDivide( LONGLONG a, INT b, INT *rem )
+{
+    LONGLONG ret = a / b;
+    if (rem) *rem = a - b * ret;
+    return ret;
+}
+
+
+/******************************************************************************
+ *        RtlExtendedIntegerMultiply   (NTDLL.@)
+ */
+LONGLONG WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b )
+{
+    return a * b;
+}
+
+
+/******************************************************************************
+ *        RtlExtendedMagicDivide   (NTDLL.@)
+ *
+ * This function computes (a * b) >> (64 + shift)
+ *
+ * This allows replacing a division by a longlong constant
+ * by a multiplication by the inverse constant.
+ *
+ * If 'c' is the constant divisor, the constants 'b' and 'shift'
+ * must be chosen such that b = 2^(64+shift) / c.
+ * Then we have RtlExtendedMagicDivide(a,b,shift) == a * b / 2^(64+shift) == a / c.
+ *
+ * I'm too lazy to implement it right now...
+ */
+/* LONGLONG WINAPI RtlExtendedMagicDivide( LONGLONG a, LONGLONG b, INT shift )
+ * {
+ *     return 0;
+ * }
+ */
+
+
+/******************************************************************************
+ *        _alldiv   (NTDLL.@)
+ */
+LONGLONG WINAPI _alldiv( LONGLONG a, LONGLONG b )
+{
+    return a / b;
+}
+
+
+/******************************************************************************
+ *        _allmul   (NTDLL.@)
+ */
+LONGLONG WINAPI _allmul( LONGLONG a, LONGLONG b )
+{
+    return a * b;
+}
+
+
+/******************************************************************************
+ *        _allrem   (NTDLL.@)
+ */
+LONGLONG WINAPI _allrem( LONGLONG a, LONGLONG b )
+{
+    return a % b;
+}
+
+
+/******************************************************************************
+ *        _aulldiv   (NTDLL.@)
+ */
+ULONGLONG WINAPI _aulldiv( ULONGLONG a, ULONGLONG b )
+{
+    return a / b;
+}
+
+
+/******************************************************************************
+ *        _aullrem   (NTDLL.@)
+ */
+ULONGLONG WINAPI _aullrem( ULONGLONG a, ULONGLONG b )
+{
+    return a % b;
+}
Index: trunk/src/NTDLL/makefile
===================================================================
--- trunk/src/NTDLL/makefile	(revision 6366)
+++ trunk/src/NTDLL/makefile	(revision 6372)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.28 2001-07-09 08:07:59 bird Exp $
+# $Id: makefile,v 1.29 2001-07-20 15:39:46 sandervl Exp $
 
 #
@@ -31,5 +31,5 @@
 $(OBJDIR)\time.obj \
 $(OBJDIR)\unknown.obj \
-$(OBJDIR)\arith64.obj \
+$(OBJDIR)\large_int.obj \
 $(OBJDIR)\regfunc.obj \
 $(OBJDIR)\ntdllrsrc.obj
Index: trunk/src/NTDLL/ntdll.def
===================================================================
--- trunk/src/NTDLL/ntdll.def	(revision 6366)
+++ trunk/src/NTDLL/ntdll.def	(revision 6372)
@@ -1,3 +1,3 @@
-; $Id: ntdll.def,v 1.38 2001-06-13 14:45:15 bird Exp $
+; $Id: ntdll.def,v 1.39 2001-07-20 15:39:47 sandervl Exp $
 
 ;
@@ -404,5 +404,5 @@
     RtlExtendedIntegerMultiply     = _RtlExtendedIntegerMultiply@12     @389
     RtlExtendedLargeIntegerDivide  = _RtlExtendedLargeIntegerDivide@16  @390
-    RtlExtendedMagicDivide         = _RtlExtendedMagicDivide@20         @391
+;;    RtlExtendedMagicDivide         = _RtlExtendedMagicDivide@20         @391
     RtlFillMemory                  = _RtlFillMemory@12              @392
 ;   RtlFillMemoryUlong                          @393
Index: trunk/src/NTDLL/rtl.cpp
===================================================================
--- trunk/src/NTDLL/rtl.cpp	(revision 6366)
+++ trunk/src/NTDLL/rtl.cpp	(revision 6372)
@@ -1,3 +1,3 @@
-/* $Id: rtl.cpp,v 1.12 2001-04-22 10:38:59 sandervl Exp $ */
+/* $Id: rtl.cpp,v 1.13 2001-07-20 15:39:47 sandervl Exp $ */
 
 /*
@@ -517,21 +517,4 @@
                                              INT factor2);
 
-
-/******************************************************************************
- * RtlExtendedLargeIntegerDivide [NTDLL.359]
- */
-extern INT WINAPI RtlExtendedLargeIntegerDivide(LARGE_INTEGER dividend,
-                                                DWORD         divisor,
-                                                LPDWORD       rest);
-
-/******************************************************************************
- * RtlExtendedLargeIntegerMultiply [NTDLL.358]
- * Note: This even works, since gcc returns 64bit values in eax/edx just like
- * the caller expects. However... The relay code won't grok this I think.
- */
-/* longlong in VAC++ ? */
-
-extern LARGE_INTEGER WINAPI RtlExtendedIntegerMultiply(LARGE_INTEGER factor1,
-                                                       INT           factor2);
 
 /******************************************************************************
