From 1d70b8136abd6c1805bffa90cd182ec57e7a0fa2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Nov 2010 22:12:15 +0000 Subject: [PATCH] [ASM] Merge asm related changes from cmake branch. svn path=/trunk/; revision=49826 --- .../boot/freeldr/freeldr/arch/amd64/arch.S | 9 +- .../boot/freeldr/freeldr/arch/amd64/boot.S | 10 +- .../boot/freeldr/freeldr/arch/amd64/i386pnp.S | 4 + .../boot/freeldr/freeldr/arch/amd64/int386.S | 5 + reactos/boot/freeldr/freeldr/arch/amd64/mb.S | 5 + reactos/boot/freeldr/freeldr/arch/i386/arch.S | 366 +++---- reactos/dll/ntdll/dispatch/i386/dispatch.S | 70 +- .../dll/win32/kernel32/thread/amd64/fiber.S | 8 +- .../dll/win32/kernel32/thread/amd64/thread.S | 9 +- .../dll/win32/kernel32/thread/i386/fiber.S | 16 +- .../dll/win32/kernel32/thread/i386/thread.S | 13 +- reactos/hal/halx86/amd64/mps.S | 7 +- reactos/hal/halx86/amd64/systimer.S | 6 +- reactos/hal/halx86/generic/i386/systimer.S | 224 +++-- reactos/hal/halx86/generic/i386/trap.S | 10 +- reactos/include/reactos/asm.inc | 262 +++++ reactos/include/reactos/ks386.inc | 946 ++++++++++++++++++ reactos/lib/rtl/amd64/debug_asm.S | 2 +- reactos/lib/rtl/amd64/except_asm.S | 4 +- reactos/lib/rtl/amd64/rtlmem.S | 3 +- reactos/lib/rtl/amd64/slist.S | 4 +- reactos/lib/rtl/i386/debug_asm.S | 36 +- reactos/lib/rtl/i386/except_asm.s | 90 +- reactos/lib/rtl/i386/interlck.S | 37 +- reactos/lib/rtl/i386/res_asm.s | 19 +- reactos/lib/rtl/i386/rtlmem.s | 47 +- reactos/lib/sdk/crt/except/amd64/chkstk_asm.s | 6 +- reactos/lib/sdk/crt/except/amd64/seh.s | 6 +- reactos/lib/sdk/crt/except/i386/chkstk_asm.s | 99 +- reactos/lib/sdk/crt/except/i386/prolog.s | 27 +- reactos/lib/sdk/crt/except/i386/seh.s | 41 +- reactos/lib/sdk/crt/float/i386/logb.c | 2 +- reactos/lib/sdk/crt/math/amd64/alldiv.S | 3 +- reactos/lib/sdk/crt/math/amd64/atan.S | 4 +- reactos/lib/sdk/crt/math/amd64/atan2.S | 4 +- reactos/lib/sdk/crt/math/amd64/ceil.S | 4 +- reactos/lib/sdk/crt/math/amd64/ceilf.S | 32 +- reactos/lib/sdk/crt/math/amd64/exp.S | 5 +- reactos/lib/sdk/crt/math/amd64/fabs.S | 3 +- reactos/lib/sdk/crt/math/amd64/floor.S | 6 +- reactos/lib/sdk/crt/math/amd64/floorf.S | 25 +- reactos/lib/sdk/crt/math/amd64/fmod.S | 5 +- reactos/lib/sdk/crt/math/amd64/fmodf.S | 5 +- reactos/lib/sdk/crt/math/amd64/ldexp.S | 5 +- reactos/lib/sdk/crt/math/amd64/log.S | 3 +- reactos/lib/sdk/crt/math/amd64/log10.S | 3 +- reactos/lib/sdk/crt/math/amd64/pow.S | 4 +- reactos/lib/sdk/crt/math/amd64/sqrt.S | 6 +- reactos/lib/sdk/crt/math/amd64/sqrtf.S | 6 +- reactos/lib/sdk/crt/math/amd64/tan.S | 6 +- reactos/lib/sdk/crt/math/i386/alldiv_asm.s | 18 +- reactos/lib/sdk/crt/math/i386/alldvrm_asm.s | 51 +- reactos/lib/sdk/crt/math/i386/allmul_asm.s | 8 +- reactos/lib/sdk/crt/math/i386/allrem_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/allshl_asm.s | 9 +- reactos/lib/sdk/crt/math/i386/allshr_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/atan2_asm.s | 18 + reactos/lib/sdk/crt/math/i386/atan_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/aulldiv_asm.s | 33 +- reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s | 35 +- reactos/lib/sdk/crt/math/i386/aullrem_asm.s | 35 +- reactos/lib/sdk/crt/math/i386/aullshr_asm.s | 19 +- reactos/lib/sdk/crt/math/i386/ceil_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/ceilf.S | 57 +- reactos/lib/sdk/crt/math/i386/cos_asm.s | 9 +- reactos/lib/sdk/crt/math/i386/exp_asm.s | 29 + reactos/lib/sdk/crt/math/i386/fabs_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/floor_asm.s | 13 +- reactos/lib/sdk/crt/math/i386/floorf.S | 59 +- reactos/lib/sdk/crt/math/i386/fmod_asm.s | 26 + reactos/lib/sdk/crt/math/i386/fmodf_asm.s | 26 + reactos/lib/sdk/crt/math/i386/ftol2_asm.s | 28 + reactos/lib/sdk/crt/math/i386/ftol_asm.s | 13 +- reactos/lib/sdk/crt/math/i386/log10_asm.s | 8 +- reactos/lib/sdk/crt/math/i386/log_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/pow_asm.s | 379 +++---- reactos/lib/sdk/crt/math/i386/sin_asm.s | 9 +- reactos/lib/sdk/crt/math/i386/sqrt_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/tan_asm.s | 11 +- reactos/lib/sdk/crt/mem/i386/memchr_asm.s | 34 +- reactos/lib/sdk/crt/mem/i386/memcpy_asm.s | 114 --- reactos/lib/sdk/crt/mem/i386/memmove_asm.s | 156 +-- reactos/lib/sdk/crt/mem/i386/memset_asm.s | 65 +- reactos/lib/sdk/crt/setjmp/amd64/setjmp.s | 6 +- reactos/lib/sdk/crt/setjmp/i386/setjmp.s | 71 +- reactos/lib/sdk/crt/string/i386/strcat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strchr_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strcmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strcpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strlen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strncat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strncmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strncpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strnlen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strrchr_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/tchar.h | 8 +- reactos/lib/sdk/crt/string/i386/tcscat.h | 32 - reactos/lib/sdk/crt/string/i386/tcscat.inc | 35 + reactos/lib/sdk/crt/string/i386/tcschr.h | 30 - reactos/lib/sdk/crt/string/i386/tcschr.inc | 32 + reactos/lib/sdk/crt/string/i386/tcscmp.h | 34 - reactos/lib/sdk/crt/string/i386/tcscmp.inc | 37 + reactos/lib/sdk/crt/string/i386/tcscpy.h | 27 - reactos/lib/sdk/crt/string/i386/tcscpy.inc | 30 + reactos/lib/sdk/crt/string/i386/tcslen.h | 29 - reactos/lib/sdk/crt/string/i386/tcslen.inc | 32 + reactos/lib/sdk/crt/string/i386/tcsncat.h | 42 - reactos/lib/sdk/crt/string/i386/tcsncat.inc | 45 + reactos/lib/sdk/crt/string/i386/tcsncmp.h | 40 - reactos/lib/sdk/crt/string/i386/tcsncmp.inc | 43 + reactos/lib/sdk/crt/string/i386/tcsncpy.h | 34 - reactos/lib/sdk/crt/string/i386/tcsncpy.inc | 37 + reactos/lib/sdk/crt/string/i386/tcsnlen.h | 30 - reactos/lib/sdk/crt/string/i386/tcsnlen.inc | 33 + reactos/lib/sdk/crt/string/i386/tcsrchr.h | 31 - reactos/lib/sdk/crt/string/i386/tcsrchr.inc | 34 + reactos/lib/sdk/crt/string/i386/wcscat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcschr_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcscmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcscpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcslen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsncat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s | 2 +- reactos/ntoskrnl/ex/i386/fastinterlck_asm.S | 104 +- reactos/ntoskrnl/ex/i386/interlck_asm.S | 54 +- reactos/ntoskrnl/ex/i386/ioport.S | 66 +- .../ntoskrnl/include/internal/i386/asmmacro.S | 14 +- reactos/ntoskrnl/kdbg/amd64/kdb_help.S | 12 +- reactos/ntoskrnl/kdbg/i386/kdb_help.S | 187 ++-- reactos/ntoskrnl/ke/amd64/boot.S | 8 +- reactos/ntoskrnl/ke/amd64/ctxswitch.S | 5 +- reactos/ntoskrnl/ke/amd64/trap.S | 5 +- reactos/ntoskrnl/ke/i386/ctxswitch.S | 39 +- reactos/ntoskrnl/ke/i386/trap.s | 30 +- reactos/ntoskrnl/ke/i386/usercall_asm.S | 38 +- reactos/ntoskrnl/rtl/i386/stack.S | 11 +- .../win32/win32k/dib/i386/dib24bpp_hline.s | 13 +- .../win32k/dib/i386/dib32bpp_colorfill.s | 17 +- .../win32/win32k/dib/i386/dib32bpp_hline.s | 11 +- .../win32/win32k/eng/i386/floatobj.S | 72 +- .../win32/win32k/misc/i386/atan2_asm.s | 10 +- .../win32/win32k/misc/i386/ceil_asm.s | 10 +- .../win32/win32k/misc/i386/cos_asm.s | 8 +- .../win32/win32k/misc/i386/floor_asm.s | 12 +- .../win32/win32k/misc/i386/sin_asm.s | 8 +- reactos/tools/nci/ncitool.c | 104 +- 149 files changed, 3478 insertions(+), 2033 deletions(-) create mode 100644 reactos/include/reactos/asm.inc create mode 100644 reactos/include/reactos/ks386.inc create mode 100644 reactos/lib/sdk/crt/math/i386/atan2_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/exp_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/fmod_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/fmodf_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/ftol2_asm.s delete mode 100644 reactos/lib/sdk/crt/string/i386/tcscat.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscat.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcschr.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcschr.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcscmp.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscmp.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcscpy.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscpy.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcslen.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcslen.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsncat.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncat.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsncmp.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncmp.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsncpy.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncpy.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsnlen.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsnlen.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsrchr.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsrchr.inc diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/arch.S b/reactos/boot/freeldr/freeldr/arch/amd64/arch.S index 9def109221c..236a0be4b69 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/arch.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/arch.S @@ -1,10 +1,13 @@ -.intel_syntax noprefix -.text -.code16 #define ASM + +#include + #include +.text +.code16 + //.org 0x8000 .global RealEntryPoint diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/boot.S b/reactos/boot/freeldr/freeldr/arch/amd64/boot.S index eb3ba3c3c64..bc2e43e9e8b 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/boot.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/boot.S @@ -17,14 +17,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .text .code16 #define ASM #include - -EXTERN(ChainLoadBiosBootSectorCode) +PUBLIC ChainLoadBiosBootSectorCode +ChainLoadBiosBootSectorCode: .code64 call x86_64_SwitchToReal @@ -46,7 +49,8 @@ EXTERN(ChainLoadBiosBootSectorCode) // ljmpl $0x0000,$0x7C00 jmp 0x7c00:0x0000 -EXTERN(SoftReboot) +PUBLIC SoftReboot +SoftReboot: .code64 call x86_64_SwitchToReal diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S b/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S index 19589275bac..c74fb97d64d 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S @@ -17,6 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .text .code16 @@ -255,4 +258,5 @@ EXTERN(PnpBiosGetDeviceNode) ret +END /* EOF */ diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/int386.S b/reactos/boot/freeldr/freeldr/arch/amd64/int386.S index a22e409c61c..6881173910d 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/int386.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/int386.S @@ -17,6 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .intel_syntax noprefix .text .code16 @@ -168,3 +171,5 @@ Int386_vector_opcode: mov eax, Int386_eax ret + +END diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/mb.S b/reactos/boot/freeldr/freeldr/arch/amd64/mb.S index 2d515e90053..51b06bc1e01 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/mb.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/mb.S @@ -17,6 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .text .code16 @@ -61,3 +64,5 @@ pd_startup: .fill 4096, 1, 0 PageDirectoryEnd: + +END diff --git a/reactos/boot/freeldr/freeldr/arch/i386/arch.S b/reactos/boot/freeldr/freeldr/arch/i386/arch.S index 9e9475eecda..225dc4be3f9 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/arch.S +++ b/reactos/boot/freeldr/freeldr/arch/i386/arch.S @@ -17,27 +17,29 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - .text - .code16 +.intel_syntax noprefix +#define HEX(y) 0x##y #define ASM #include #include + .code16 EXTERN(RealEntryPoint) cli /* Setup segment registers */ - xorw %ax,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + xor ax, ax + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + /* Setup a stack */ - movw stack16,%sp + mov sp, word ptr ds:stack16 sti @@ -47,24 +49,24 @@ EXTERN(RealEntryPoint) .code32 /* Zero BootDrive and BootPartition */ - xorl %eax,%eax - movl %eax,(_BootDrive) - movl %eax,(_BootPartition) + xor eax, eax + mov dword ptr [_BootDrive], eax + mov dword ptr [_BootPartition], eax /* Store the boot drive */ - movb %dl,(_BootDrive) + mov byte ptr [_BootDrive], dl /* Store the boot partition */ - movb %dh,(_BootPartition) + mov byte ptr [_BootPartition], dh /* GO! */ - pushl %eax + push eax call _BootMain call switch_to_real .code16 - int $0x19 + int HEX(19) /* We should never get here */ stop: @@ -78,7 +80,7 @@ stop: */ EXTERN(switch_to_prot) - .code16 +.code16 cli /* None of these */ @@ -88,18 +90,18 @@ EXTERN(switch_to_prot) /* Of course CS has to already be valid. */ /* We are currently in real-mode so we */ /* need real-mode segment values. */ - xorw %ax,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + xor ax, ax + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Get the return address off the stack */ - popw (code32ret) + pop word ptr ds:[code32ret] /* Save 16-bit stack pointer */ - movw %sp,stack16 + mov word ptr ds:[stack16], sp /* Load the GDT */ lgdt gdtptr @@ -107,28 +109,28 @@ EXTERN(switch_to_prot) lidt i386idtptr /* Enable Protected Mode */ - mov %cr0,%eax - orl $CR0_PE_SET,%eax - mov %eax,%cr0 + mov eax, cr0 + or eax, CR0_PE_SET + mov cr0, eax /* Clear prefetch queue & correct CS */ - ljmp $PMODE_CS, $inpmode - + //ljmp PMODE_CS, inpmode + jmp far ptr PMODE_CS:inpmode - .code32 +.code32 inpmode: /* Setup segment selectors */ - movw $PMODE_DS,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss - movl stack32,%esp + mov ax, PMODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + mov esp, dword ptr [stack32] /* Put the return address back onto the stack */ - pushl (code32ret) + push dword ptr [code32ret] /* Now return in p-mode! */ ret @@ -139,7 +141,7 @@ inpmode: */ EXTERN(switch_to_real) - .code32 +.code32 /* We don't know what values are currently */ /* in the segment registers. So we are */ @@ -147,48 +149,49 @@ EXTERN(switch_to_real) /* Of course CS has to already be valid. */ /* We are currently in protected-mode so we */ /* need protected-mode segment values. */ - movw $PMODE_DS,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + mov ax, PMODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Get the return address off the stack */ - popl (code16ret) + pop dword ptr [code16ret] /* Save 32-bit stack pointer */ - movl %esp,stack32 + mov dword ptr [stack32], esp /* jmp to 16-bit segment to set the limit correctly */ - ljmp $RMODE_CS, $switch_to_real16 + ljmp RMODE_CS, switch_to_real16 switch_to_real16: - .code16 +.code16 /* Restore segment registers to correct limit */ - movw $RMODE_DS,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + mov ax, RMODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Disable Protected Mode */ - mov %cr0,%eax - andl $CR0_PE_CLR,%eax - mov %eax,%cr0 + mov eax, cr0 + and eax, CR0_PE_CLR + mov cr0, eax /* Clear prefetch queue & correct CS */ - ljmp $0, $inrmode + //ljmp $0, $inrmode + jmp far ptr 0:inrmode inrmode: - movw %cs,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + mov ax, cs + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Clear out the high 16-bits of ESP */ /* This is needed because I have one */ @@ -196,12 +199,12 @@ inrmode: /* anything other than 0x0000 is in the high */ /* 16-bits of ESP. Even though real-mode */ /* code should only use SP and not ESP. */ - xorl %esp,%esp + xor esp, esp - movw stack16,%sp + mov sp, word ptr ds:[stack16] /* Put the return address back onto the stack */ - pushw (code16ret) + push word ptr ds:[code16ret] /* Load IDTR with real mode value */ lidt rmode_idtptr @@ -215,14 +218,14 @@ inrmode: /* * Needed for enabling the a20 address line */ - .code16 +.code16 empty_8042: .word 0x00eb,0x00eb // jmp $+2, jmp $+2 - inb $0x64,%al - cmp $0xff, %al // legacy-free machine without keyboard - jz empty_8042_ret // controllers on Intel Macs read back 0xFF - testb $0x02,%al - jnz empty_8042 + in al, HEX(64) + cmp al, HEX(ff) // legacy-free machine without keyboard + jz empty_8042_ret // controllers on Intel Macs read back 0xFF + test al, 2 + jnz empty_8042 empty_8042_ret: ret @@ -230,24 +233,24 @@ empty_8042_ret: * Enable the A20 address line (to allow access to over 1mb) */ EXTERN(_EnableA20) - .code32 +.code32 - pushal + pusha - call switch_to_real - .code16 + call switch_to_real +.code16 - call empty_8042 - movb $0xD1,%al // command write - outb %al,$0x64 - call empty_8042 - mov $0xDF,%al // A20 on - out %al,$0x60 - call empty_8042 - call switch_to_prot + call empty_8042 + mov al, HEX(D1) // command write + out HEX(64), al + call empty_8042 + mov al, HEX(DF) // A20 on + out HEX(60), al + call empty_8042 + call switch_to_prot .code32 - popal + popa ret @@ -255,24 +258,24 @@ EXTERN(_EnableA20) * Disable the A20 address line */ EXTERN(_DisableA20) - .code32 +.code32 - pushal + pusha - call switch_to_real + call switch_to_real .code16 call empty_8042 - movb $0xD1,%al // command write - outb %al,$0x64 - call empty_8042 - mov $0xDD,%al // A20 off - out %al,$0x60 + mov al, HEX(D1) // command write + out HEX(64), al + call empty_8042 + mov al, HEX(DD) // A20 off + out HEX(60), al call empty_8042 call switch_to_prot .code32 - popal + popa ret @@ -294,11 +297,11 @@ EXTERN(_DisableA20) * above 1MB. So we let Grub load us there and then relocate * ourself to 0x8000 */ -#define FREELDR_BASE 0x8000 -#define INITIAL_BASE 0x200000 +#define FREELDR_BASE HEX(8000) +#define INITIAL_BASE HEX(200000) /* Align 32 bits boundary */ - .align 4 +.align 4 /* Multiboot header */ MultibootHeader: @@ -330,44 +333,45 @@ MultibootEntry: * our own */ lgdt gdtptrhigh + INITIAL_BASE - FREELDR_BASE /* Reload segment selectors */ - ljmp $PMODE_CS, $(mb1 + INITIAL_BASE - FREELDR_BASE) + //ljmp $PMODE_CS, $(mb1 + INITIAL_BASE - FREELDR_BASE) + jmp far ptr PMODE_CS: (mb1 + INITIAL_BASE - FREELDR_BASE) mb1: - movw $PMODE_DS,%dx - movw %dx,%ds - movw %dx,%es + mov dx, PMODE_DS + mov ds, dx + mov es, dx /* Check for valid multiboot signature */ - cmpl $MULTIBOOT_BOOTLOADER_MAGIC,%eax - jne mbfail + cmp eax, MULTIBOOT_BOOTLOADER_MAGIC + jne mbfail /* Store multiboot info in a safe place */ - movl %ebx,%esi - movl $(mb_info + INITIAL_BASE - FREELDR_BASE),%edi - movl $MB_INFO_SIZE,%ecx + mov esi, ebx + mov edi, offset mb_info + INITIAL_BASE - FREELDR_BASE + mov ecx, MB_INFO_SIZE rep movsb /* Save commandline */ - movl MB_INFO_FLAGS_OFFSET(%ebx),%edx - testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx) - jz mb3 - movl MB_INFO_COMMAND_LINE_OFFSET(%ebx),%esi - movl $(cmdline + INITIAL_BASE - FREELDR_BASE),%edi - movl $CMDLINE_SIZE,%ecx + mov edx, [ebx + MB_INFO_FLAGS_OFFSET] + test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_COMMAND_LINE + jz mb3 + mov esi, [ebx + MB_INFO_COMMAND_LINE_OFFSET] + mov edi, offset cmdline + INITIAL_BASE - FREELDR_BASE + mov ecx, CMDLINE_SIZE mb2: lodsb stosb - testb %al,%al - jz mb3 - dec %ecx - jnz mb2 + test al, al + jz mb3 + dec ecx + jnz mb2 mb3: /* Copy to low mem */ - movl $INITIAL_BASE,%esi - movl $FREELDR_BASE,%edi - movl $(__bss_end__ - FREELDR_BASE),%ecx - addl $3,%ecx - shrl $2,%ecx - rep movsl + mov esi, INITIAL_BASE + mov edi, FREELDR_BASE + mov ecx, (offset __bss_end__ - FREELDR_BASE) + add ecx, 3 + shr ecx, 2 + rep movsd /* Load the GDT and IDT */ lgdt gdtptr @@ -375,47 +379,49 @@ mb3: /* Clear prefetch queue & correct CS, * jump to low mem */ - ljmp $PMODE_CS, $mb4 + //ljmp $PMODE_CS, $mb4 + jmp far ptr PMODE_CS:mb4 mb4: /* Reload segment selectors */ - movw $PMODE_DS,%dx - movw %dx,%ds - movw %dx,%es - movw %dx,%fs - movw %dx,%gs - movw %dx,%ss - movl $STACK32ADDR,%esp - - movl $mb_info,%ebx + mov dx, PMODE_DS + mov ds, dx + mov es, dx + mov fs, dx + mov gs, dx + mov ss, dx + mov esp, STACK32ADDR + + mov ebx, offset mb_info /* See if the boot device was passed in */ - movl MB_INFO_FLAGS_OFFSET(%ebx),%edx - testl $MB_INFO_FLAG_BOOT_DEVICE,%edx - jz mb5 + mov edx, [ebx + MB_INFO_FLAGS_OFFSET] + test edx, MB_INFO_FLAG_BOOT_DEVICE + jz mb5 /* Retrieve boot device info */ - movl MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax - shrl $16,%eax - incb %al - movb %al,_BootPartition - movb %ah,_BootDrive - jmp mb6 + mov eax, [ebx + MB_INFO_BOOT_DEVICE_OFFSET] + shr eax, 16 + inc al + mov byte ptr _BootPartition, al + mov byte ptr _BootDrive, ah + jmp mb6 mb5: /* No boot device known, assume first partition of first harddisk */ - movb $0x80,_BootDrive - movb $1,_BootPartition + mov byte ptr _BootDrive, HEX(80) + mov byte ptr _BootPartition, 1 mb6: /* Check for command line */ - mov $cmdline,%eax - testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx) - jnz mb7 - xorl %eax,%eax + mov eax, offset cmdline + test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_COMMAND_LINE + jnz mb7 + xor eax, eax mb7: /* GO! */ - pushl %eax + push eax call _BootMain -mbfail: call switch_to_real +mbfail: + call switch_to_real .code16 - int $0x19 + int 0x19 mbstop: jmp mbstop /* We should never get here */ .code32 @@ -437,52 +443,52 @@ code32ret: .long 0 - .p2align 2 /* force 4-byte alignment */ + .align 4 /* force 4-byte alignment */ gdt: /* NULL Descriptor */ - .word 0x0000 - .word 0x0000 - .word 0x0000 - .word 0x0000 + .word HEX(0000) + .word HEX(0000) + .word HEX(0000) + .word HEX(0000) /* 32-bit flat CS */ - .word 0xFFFF - .word 0x0000 - .word 0x9A00 - .word 0x00CF + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9A00) + .word HEX(00CF) /* 32-bit flat DS */ - .word 0xFFFF - .word 0x0000 - .word 0x9200 - .word 0x00CF + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9200) + .word HEX(00CF) /* 16-bit real mode CS */ - .word 0xFFFF - .word 0x0000 - .word 0x9E00 - .word 0x0000 + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9E00) + .word HEX(0000) /* 16-bit real mode DS */ - .word 0xFFFF - .word 0x0000 - .word 0x9200 - .word 0x0000 + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9200) + .word HEX(0000) /* GDT table pointer */ gdtptr: - .word 0x27 /* Limit */ - .long gdt /* Base Address */ + .word HEX(27) /* Limit */ + .long gdt /* Base Address */ /* Initial GDT table pointer for multiboot */ gdtptrhigh: - .word 0x27 /* Limit */ - .long gdt + INITIAL_BASE - FREELDR_BASE /* Base Address */ + .word HEX(27) /* Limit */ + .long gdt + INITIAL_BASE - FREELDR_BASE /* Base Address */ /* Real-mode IDT pointer */ rmode_idtptr: - .word 0x3ff /* Limit */ - .long 0 /* Base Address */ + .word HEX(3ff) /* Limit */ + .long 0 /* Base Address */ mb_info: .fill MB_INFO_SIZE, 1, 0 diff --git a/reactos/dll/ntdll/dispatch/i386/dispatch.S b/reactos/dll/ntdll/dispatch/i386/dispatch.S index c17374e9ed1..25f7c34bcee 100644 --- a/reactos/dll/ntdll/dispatch/i386/dispatch.S +++ b/reactos/dll/ntdll/dispatch/i386/dispatch.S @@ -8,13 +8,22 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include + +EXTERN _LdrpInit@12:PROC +EXTERN _NtTestAlert@0:PROC +EXTERN _RtlDispatchException@8:PROC +EXTERN _RtlRaiseException@4:PROC +EXTERN _RtlRaiseStatus@4:PROC +EXTERN _ZwCallbackReturn@12:PROC +EXTERN _ZwContinue@8:PROC +EXTERN _ZwRaiseException@12:PROC /* FUNCTIONS ****************************************************************/ +.code -.func LdrInitializeThunk@16 -.globl _LdrInitializeThunk@16 +PUBLIC _LdrInitializeThunk@16 _LdrInitializeThunk@16: /* Get the APC Context */ @@ -28,9 +37,8 @@ _LdrInitializeThunk@16: /* Jump into the C initialization routine */ jmp _LdrpInit@12 -.endfunc -.func KiUserApcExceptionHandler + _KiUserApcExceptionHandler: /* Put the exception record in ECX and check the Flags */ @@ -45,10 +53,9 @@ _KiUserApcExceptionHandler: /* We'll execute handler */ mov eax, EXCEPTION_EXECUTE_HANDLER ret 16 -.endfunc -.func KiUserApcDispatcher@16 -.globl _KiUserApcDispatcher@16 + +PUBLIC _KiUserApcDispatcher@16 _KiUserApcDispatcher@16: /* Setup SEH stack */ @@ -86,9 +93,8 @@ StatusRaiseApc: call _RtlRaiseStatus@4 jmp StatusRaiseApc ret 16 -.endfunc -.func KiUserCallbackExceptionHandler + _KiUserCallbackExceptionHandler: /* Put the exception record in ECX and check the Flags */ @@ -106,10 +112,9 @@ return: /* We'll execute the handler */ mov eax, EXCEPTION_EXECUTE_HANDLER ret 16 -.endfunc -.func KiUserCallbackDispatcher@12 -.globl _KiUserCallbackDispatcher@12 + +PUBLIC _KiUserCallbackDispatcher@12 _KiUserCallbackDispatcher@12: /* Setup SEH stack */ @@ -131,7 +136,7 @@ _KiUserCallbackDispatcher@12: mov eax, [eax+PEB_KERNEL_CALLBACK_TABLE] /* Call the routine */ - call [eax+edx*4] + call dword ptr [eax+edx*4] /* Return from callback */ push eax @@ -148,10 +153,9 @@ StatusRaise: call _RtlRaiseStatus@4 jmp StatusRaise ret 12 -.endfunc -.func KiRaiseUserExceptionDispatcher@0 -.globl _KiRaiseUserExceptionDispatcher@0 + +PUBLIC _KiRaiseUserExceptionDispatcher@0 _KiRaiseUserExceptionDispatcher@0: /* Setup stack for EXCEPTION_RECORD */ @@ -177,10 +181,9 @@ _KiRaiseUserExceptionDispatcher@0: mov esp, ebp pop ebp ret -.endfunc -.func KiUserExceptionDispatcher@8 -.globl _KiUserExceptionDispatcher@8 + +PUBLIC _KiUserExceptionDispatcher@8 _KiUserExceptionDispatcher@8: /* Clear direction flag */ @@ -236,39 +239,35 @@ Exit: push esp call _RtlRaiseException@4 ret 8 -.endfunc -.func KiIntSystemCall@0 -.globl _KiIntSystemCall@0 + +PUBLIC _KiIntSystemCall@0 _KiIntSystemCall@0: /* Set stack in EDX and do the interrupt */ lea edx, [esp+8] - int 0x2E + int HEX(2E) /* Return to caller */ ret -.endfunc -.func KiFastSystemCall@0 -.globl _KiFastSystemCall@0 + +PUBLIC _KiFastSystemCall@0 _KiFastSystemCall@0: /* Put ESP in EDX and do the SYSENTER */ mov edx, esp sysenter -.endfunc -.func KiFastSystemCallRet@0 -.globl _KiFastSystemCallRet@0 + +PUBLIC _KiFastSystemCallRet@0 _KiFastSystemCallRet@0: /* Just return to caller */ ret -.endfunc -.func RtlpGetStackLimits@8 -.globl _RtlpGetStackLimits@8 + +PUBLIC _RtlpGetStackLimits@8 _RtlpGetStackLimits@8: /* Get the stack limits */ @@ -283,4 +282,5 @@ _RtlpGetStackLimits@8: /* return */ ret 8 -.endfunc + +END diff --git a/reactos/dll/win32/kernel32/thread/amd64/fiber.S b/reactos/dll/win32/kernel32/thread/amd64/fiber.S index 984447abe11..09ea635d23c 100644 --- a/reactos/dll/win32/kernel32/thread/amd64/fiber.S +++ b/reactos/dll/win32/kernel32/thread/amd64/fiber.S @@ -7,11 +7,13 @@ * KJK::Hyperion */ -#include +#include -.globl SwitchToFiber -.intel_syntax noprefix + +PUBLIC SwitchToFiber SwitchToFiber: /* FIXME: TODO */ ret 4 + +END diff --git a/reactos/dll/win32/kernel32/thread/amd64/thread.S b/reactos/dll/win32/kernel32/thread/amd64/thread.S index 2c0c2260cb8..71ed562f816 100644 --- a/reactos/dll/win32/kernel32/thread/amd64/thread.S +++ b/reactos/dll/win32/kernel32/thread/amd64/thread.S @@ -6,9 +6,11 @@ * PROGRAMMER: Alex Ionescu (alex@relsoft.net) */ -.globl BaseThreadStartupThunk -.globl BaseProcessStartThunk -.intel_syntax noprefix +#include + + +PUBLIC BaseThreadStartupThunk +PUBLIC BaseProcessStartThunk BaseThreadStartupThunk: @@ -29,4 +31,5 @@ BaseProcessStartThunk: push 0 /* Return RIP */ jmp BaseProcessStartup +END /* EOF */ diff --git a/reactos/dll/win32/kernel32/thread/i386/fiber.S b/reactos/dll/win32/kernel32/thread/i386/fiber.S index 57358ffeed4..bf88c468487 100644 --- a/reactos/dll/win32/kernel32/thread/i386/fiber.S +++ b/reactos/dll/win32/kernel32/thread/i386/fiber.S @@ -7,11 +7,12 @@ * KJK::Hyperion */ -#include +#include +#include -.globl _SwitchToFiber@4 -.intel_syntax noprefix +.code +PUBLIC _SwitchToFiber@4 _SwitchToFiber@4: /* Get the TEB */ mov edx, fs:[TEB_SELF] @@ -30,7 +31,7 @@ _SwitchToFiber@4: mov [eax+FIBER_CONTEXT_EIP], ebx /* Check if we're to save FPU State */ - cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL | CONTEXT_FLOATING_POINT + cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT jnz NoFpuStateSave /* Save the FPU State (Status and Control)*/ @@ -80,7 +81,7 @@ NoFpuStateSave: mov [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER], esi /* Restore FPU State */ - cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL | CONTEXT_FLOATING_POINT + cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT jnz NoFpuStateRestore /* Check if the Status Word Changed */ @@ -96,7 +97,7 @@ NoFpuStateSave: StatusWordChanged: /* Load the new one */ - mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], 0xFFFF + mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], HEX(0FFFF) fldenv [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] ControlWordEqual: @@ -120,6 +121,7 @@ NoFpuStateRestore: mov [edx+TEB_FLS_DATA], eax /* Jump to new fiber */ - jmp [ecx+FIBER_CONTEXT_EIP] + jmp dword ptr [ecx+FIBER_CONTEXT_EIP] +END /* EOF */ diff --git a/reactos/dll/win32/kernel32/thread/i386/thread.S b/reactos/dll/win32/kernel32/thread/i386/thread.S index 5dea1ee7400..a07bcb2e60e 100644 --- a/reactos/dll/win32/kernel32/thread/i386/thread.S +++ b/reactos/dll/win32/kernel32/thread/i386/thread.S @@ -6,9 +6,15 @@ * PROGRAMMER: Alex Ionescu (alex@relsoft.net) */ -.globl _BaseThreadStartupThunk@0 -.globl _BaseProcessStartThunk@0 -.intel_syntax noprefix +#include + +.code + +EXTERN _BaseThreadStartup@8:PROC +EXTERN _BaseProcessStartup@4:PROC + +PUBLIC _BaseThreadStartupThunk@0 +PUBLIC _BaseProcessStartThunk@0 _BaseThreadStartupThunk@0: @@ -29,4 +35,5 @@ _BaseProcessStartThunk@0: push 0 /* Return EIP */ jmp _BaseProcessStartup@4 +END /* EOF */ diff --git a/reactos/hal/halx86/amd64/mps.S b/reactos/hal/halx86/amd64/mps.S index 35436520ae6..7a3b8c55aa6 100644 --- a/reactos/hal/halx86/amd64/mps.S +++ b/reactos/hal/halx86/amd64/mps.S @@ -8,8 +8,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include /* FUNCTIONS *****************************************************************/ @@ -92,5 +93,5 @@ MpsTimerInterrupt: AFTER iret - +END /* EOF */ diff --git a/reactos/hal/halx86/amd64/systimer.S b/reactos/hal/halx86/amd64/systimer.S index 1cb3b6e02a3..47d2a844b23 100644 --- a/reactos/hal/halx86/amd64/systimer.S +++ b/reactos/hal/halx86/amd64/systimer.S @@ -7,8 +7,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include /* GLOBALS *******************************************************************/ @@ -90,3 +91,4 @@ HalpClockInterrupt: UNIMPLEMENTED _HalpClockInterrupt iret +END diff --git a/reactos/hal/halx86/generic/i386/systimer.S b/reactos/hal/halx86/generic/i386/systimer.S index 1a5bb45a1b8..8534f88a204 100644 --- a/reactos/hal/halx86/generic/i386/systimer.S +++ b/reactos/hal/halx86/generic/i386/systimer.S @@ -7,12 +7,42 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include + +#include + +EXTERN _HalpAcquireSystemHardwareSpinLock@0:PROC +EXTERN _HalpReleaseCmosSpinLock@0:PROC +EXTERN _DbgBreakPoint@0:PROC +EXTERN _HalpCurrentRollOver:DWORD +EXTERN _HalpPerfCounterCutoff:DWORD + +#define PIC1_BASE HEX(20) /* IO base address for master PIC */ +#define PIC2_BASE HEX(A0) /* IO base address for slave PIC */ +#define PIC1_COMMAND PIC1_BASE +#define PIC1_DATA (PIC1_BASE+1) +#define PIC2_COMMAND PIC2_BASE +#define PIC2_DATA (PIC2_BASE+1) +#define PIC_EOI HEX(20) +#define PIC_SPECIFIC_EOI2 HEX(62) + +#define CMOS_ADDR HEX(70) +#define CMOS_DATA HEX(71) +#define CMOS_REGISTER_A HEX(0A) +#define CMOS_REGISTER_B HEX(0B) +#define CMOS_REGISTER_C HEX(0C) +#define CMOS_REGISTER_D HEX(0D) + +#define PIT_CH0 HEX(40) +#define PIT_MODE HEX(43) +#define SYSTEM_CTRL_PORT_A HEX(92) /* GLOBALS *******************************************************************/ -.globl _HalpPerfCounter +.data +ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING + +PUBLIC _HalpPerfCounter _HalpLastPerfCounterLow: .long 0 _HalpLastPerfCounterHigh: .long 0 _HalpPerfCounter: @@ -22,8 +52,8 @@ _HalpSystemHardwareFlags: .long 0 /* FUNCTIONS *****************************************************************/ -.global _HalpCalibrateStallExecution@0 -.func HalpCalibrateStallExecution@0 +.code +PUBLIC _HalpCalibrateStallExecution@0 _HalpCalibrateStallExecution@0: /* Setup the stack frame */ @@ -37,27 +67,27 @@ _HalpCalibrateStallExecution@0: /* Get the current interrupt mask on the PICs */ xor eax, eax - in al, 0xA1 + in al, PIC2_DATA shl eax, 8 - in al, 0x21 + in al, PIC1_DATA /* Save it */ push eax /* Now mask everything except the RTC and PIC 2 chain-interrupt */ - mov eax, ~((1 << 2) | (1 << 8)) + mov eax, NOT (HEX(04) OR HEX(100)) /* Program the PICs */ - out 0x21, al + out PIC1_DATA, al shr eax, 8 - out 0xA1, al + out PIC2_DATA, al /* Now get the IDT */ sidt [ebp-8] mov ecx, [ebp-6] /* Get the IDT entry for the RTC */ - mov eax, 0x38 + mov eax, HEX(38) shl eax, 3 add ecx, eax @@ -70,7 +100,7 @@ _HalpCalibrateStallExecution@0: mov eax, offset OnlyOnePersonCanWriteHalCode mov [ecx], ax mov word ptr [ecx+2], KGDT_R0_CODE - mov word ptr [ecx+4], 0x8E00 + mov word ptr [ecx+4], HEX(08E00) shr eax, 16 mov [ecx+6], ax @@ -81,18 +111,18 @@ _HalpCalibrateStallExecution@0: call _HalpAcquireSystemHardwareSpinLock@0 /* Now initialize register A on the CMOS */ - mov ax, (0x2D << 8) | 0xA - out 0x70, al + mov ax, HEX(2D00) OR CMOS_REGISTER_A + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register B */ - mov ax, 0xB - out 0x70, al + mov ax, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Don't touch the LastKnownGoodConfig hack */ @@ -100,28 +130,28 @@ _HalpCalibrateStallExecution@0: mov ah, al /* Enable the interrupt */ - or ah, 0x42 + or ah, HEX(42) /* Now write the register B */ - mov al, 0xB - out 0x70, al + mov al, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register C */ - mov al, 0xC - out 0x70, al + mov al, CMOS_REGISTER_C + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Read register D */ - mov al, 0xD - out 0x70, al + mov al, CMOS_REGISTER_D + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Release CMOS lock */ @@ -169,18 +199,18 @@ OnlyOnePersonCanWriteHalCode: call _HalpAcquireSystemHardwareSpinLock@0 /* Now initialize register A on the CMOS */ - mov ax, (0x2D << 8) | 0xA - out 0x70, al + mov ax, HEX(2D00) OR CMOS_REGISTER_A + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register B */ - mov ax, 0xB - out 0x70, al + mov ax, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Don't touch the LastKnownGoodConfig hack */ @@ -188,38 +218,38 @@ OnlyOnePersonCanWriteHalCode: mov ah, al /* Enable the interrupt */ - or ah, 0x42 + or ah, HEX(42) /* Now write the register B */ - mov al, 0xB - out 0x70, al + mov al, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register C */ - mov al, 0xC - out 0x70, al + mov al, CMOS_REGISTER_C + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Read register D */ - mov al, 0xD - out 0x70, al + mov al, CMOS_REGISTER_D + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Release CMOS lock */ call _HalpReleaseCmosSpinLock@0 /* Dismiss the interrupt */ - mov al, 0x20 - out 0xA0, al - mov al, 0x62 - out 0x20, al + mov al, PIC_EOI + out PIC2_COMMAND, al + mov al, PIC_SPECIFIC_EOI2 + out PIC1_COMMAND, al /* Reset the counter and return back to the looper */ xor eax, eax @@ -248,24 +278,24 @@ FoundFactor: /* Prepare for interrupt return */ pop eax push offset AndItsNotYou - mov eax, 0x13 + mov eax, HEX(13) /* Acquire CMOS lock */ call _HalpAcquireSystemHardwareSpinLock@0 /* Now initialize register A on the CMOS */ - mov ax, (0x2D << 8) | 0xA - out 0x70, al + mov ax, HEX(2D00) OR CMOS_REGISTER_A + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register B */ - mov ax, 0xB - out 0x70, al + mov ax, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Don't touch the LastKnownGoodConfig hack */ @@ -273,34 +303,34 @@ FoundFactor: mov ah, al /* Disable the interrupt */ - or ah, 0x2 + or ah, 2 /* Now write the register B */ - mov al, 0xB - out 0x70, al + mov al, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register C */ - mov al, 0xC - out 0x70, al + mov al, CMOS_REGISTER_C + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Release CMOS lock */ call _HalpReleaseCmosSpinLock@0 /* Dismiss the interrupt */ - mov al, 0x20 - out 0xA0, al - mov al, 0x62 - out 0x20, al + mov al, PIC_EOI + out PIC2_COMMAND, al + mov al, PIC_SPECIFIC_EOI2 + out PIC1_COMMAND, al /* Disable interrupts on return */ - and word ptr [esp+8], ~EFLAGS_INTERRUPT_MASK + and word ptr [esp+8], NOT EFLAGS_INTERRUPT_MASK iretd /************************* WE ARE BACK FROM RTC ***************************/ @@ -313,9 +343,9 @@ AndItsNotYou: /* Restore the mask */ pop eax - out 0x21, al + out PIC1_DATA, al shr eax, 8 - out 0xA1, al + out PIC2_DATA, al /* Restore EFLAGS */ popf @@ -324,11 +354,10 @@ AndItsNotYou: mov esp, ebp pop ebp ret -.endfunc + #ifndef _MINIHAL_ -.globl _KeStallExecutionProcessor@4 -.func KeStallExecutionProcessor@4 +PUBLIC _KeStallExecutionProcessor@4 _KeStallExecutionProcessor@4: /* Get the number of microseconds required */ @@ -356,11 +385,9 @@ SubtractLoop: Done: /* Return */ ret 4 -.endfunc #endif -.global _KeQueryPerformanceCounter@4 -.func KeQueryPerformanceCounter@4 +PUBLIC _KeQueryPerformanceCounter@4 _KeQueryPerformanceCounter@4: /* Check if we were called too early */ @@ -380,20 +407,20 @@ LoopPreInt: LoopPostInt: /* Get the current value */ - mov ebx, _HalpPerfCounterLow - mov esi, _HalpPerfCounterHigh + mov ebx, dword ptr _HalpPerfCounterLow + mov esi, dword ptr _HalpPerfCounterHigh /* Read 8254 timer */ - mov al, 0 - out 0x43, al - in al, 0x92 - or al, _HalpPerfCounterCutoff - out 0x92, al + mov al, 0 /* Interrupt on terminal count */ + out PIT_MODE, al + in al, SYSTEM_CTRL_PORT_A + or al, byte ptr _HalpPerfCounterCutoff + out SYSTEM_CTRL_PORT_A, al jmp $+2 - in al, 0x40 + in al, PIT_CH0 jmp $+2 movzx ecx, al - in al, 0x40 + in al, PIT_CH0 mov ch, al /* Enable interrupts and do a short wait */ @@ -406,8 +433,8 @@ LoopPostInt: cli /* Get the counter value again */ - mov eax, _HalpPerfCounterLow - mov edx, _HalpPerfCounterHigh + mov eax, dword ptr _HalpPerfCounterLow + mov edx, dword ptr _HalpPerfCounterHigh /* Check if someone updated the counter */ cmp eax, ebx @@ -417,7 +444,7 @@ LoopPostInt: /* Check if the current 8254 value causes rollover */ neg ecx - add ecx, _HalpCurrentRollOver + add ecx, dword ptr _HalpCurrentRollOver jnb DoRollOver SetSum: @@ -427,19 +454,19 @@ SetSum: adc edx, 0 /* Check if we're above or below the last high value */ - cmp edx, _HalpLastPerfCounterHigh + cmp edx, dword ptr _HalpLastPerfCounterHigh jb short BelowHigh jnz short BelowLow /* Check if we're above or below the last low value */ - cmp eax, _HalpLastPerfCounterLow + cmp eax, dword ptr _HalpLastPerfCounterLow jb BelowHigh BelowLow: /* Update the last value and bring back interrupts */ - mov _HalpLastPerfCounterLow, eax - mov _HalpLastPerfCounterHigh, edx + mov dword ptr _HalpLastPerfCounterLow, eax + mov dword ptr _HalpLastPerfCounterHigh, edx popf /* Check if caller wants frequency */ @@ -469,7 +496,7 @@ DoRollOver: /* We might have an incoming interrupt, save EFLAGS and reset rollover */ mov esi, [esp] - mov ecx, _HalpCurrentRollOver + mov ecx, dword ptr _HalpCurrentRollOver popf /* Check if interrupts were enabled and try again */ @@ -483,8 +510,8 @@ DoRollOver: BelowHigh: /* Get the last counter values */ - mov ebx, _HalpLastPerfCounterLow - mov esi, _HalpLastPerfCounterHigh + mov ebx, dword ptr _HalpLastPerfCounterLow + mov esi, dword ptr _HalpLastPerfCounterHigh /* Check if the previous value was 0 and go back if yes */ mov ecx, ebx @@ -495,7 +522,7 @@ BelowHigh: sub ebx, eax sbb esi, edx jnz InvalidCount - cmp ebx, _HalpCurrentRollOver + cmp ebx, dword ptr _HalpCurrentRollOver jg InvalidCount /* Fixup the count with the last known value */ @@ -517,7 +544,8 @@ BelowHigh: InvalidCount: popf xor eax, eax - mov _HalpLastPerfCounterLow, eax - mov _HalpLastPerfCounterHigh, eax + mov dword ptr _HalpLastPerfCounterLow, eax + mov dword ptr _HalpLastPerfCounterHigh, eax jmp LoopPreInt -.endfunc + +END diff --git a/reactos/hal/halx86/generic/i386/trap.S b/reactos/hal/halx86/generic/i386/trap.S index 2ad319bfb6e..8a4f4538144 100644 --- a/reactos/hal/halx86/generic/i386/trap.S +++ b/reactos/hal/halx86/generic/i386/trap.S @@ -8,12 +8,12 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include #include -.code32 -.text +.code TRAP_ENTRY HalpTrap0D, 0 TRAP_ENTRY HalpApcInterrupt, KI_SOFTWARE_TRAP @@ -42,4 +42,6 @@ _HalpRealModeStart: .space 2048 _HalpRealModeEnd: PUBLIC _HalpRealModeEnd +.endcode16 +END diff --git a/reactos/include/reactos/asm.inc b/reactos/include/reactos/asm.inc new file mode 100644 index 00000000000..4274221fc19 --- /dev/null +++ b/reactos/include/reactos/asm.inc @@ -0,0 +1,262 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Kernel + * FILE: ntoskrnl/include/amd64/asmmacro.S + * PURPOSE: ASM macros for for GAS and MASM/ML64 + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#ifdef _USE_ML + +/* Allow ".name" identifiers */ +OPTION DOTNAME + +.686P +.XMM +.MODEL FLAT +ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING + +/* Hex numbers need to be in 01ABh format */ +#define HEX(x) 0##x##h + +/* Macro values need to be marked */ +#define VAL(x) x + +/* MASM/ML doesn't want explicit [rip] addressing */ +rip = 0 + +/* Due to MASM's reverse syntax, we are forced to use a precompiler macro */ +#define MACRO(name, ...) name MACRO __VA_ARGS__ + +/* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */ +.PROC MACRO name + name PROC FRAME + _name: +ENDM + +/* ... and .ENDP, replacing ENDP */ +.ENDP MACRO name + name ENDP +ENDM + +/* MASM doesn't have an ASCII macro */ +.ASCII MACRO text + DB text +ENDM + +/* MASM doesn't have an ASCIZ macro */ +.ASCIZ MACRO text + DB text, 0 +ENDM + +#define lgdt lgdt fword ptr ds: + +#define lidt lidt fword ptr ds: + +ljmp MACRO segment, offset + DB 0 +ENDM + +.code64 MACRO + .code +ENDM + +.code32 MACRO + .code + .586P +ENDM + +.code16 MACRO + ASSUME nothing + .text SEGMENT use16 +ENDM + +.endcode16 MACRO + .text ENDS +ENDM + +.bss MACRO + .DATA? + ASSUME nothing +ENDM + +//.text MACRO +//ENDM + +.align MACRO alignment + ALIGN alignment +ENDM + +.byte MACRO args:VARARG + db args +ENDM + +.short MACRO args:VARARG + dw args +ENDM + +.word MACRO args:VARARG + dw args +ENDM + +.long MACRO args:VARARG + dd args +ENDM + +.double MACRO args:VARARG + dq args +ENDM + +.org MACRO value + ORG value +ENDM + +.fill MACRO repeat, size, value +// FIXME +ENDM + +ljmp MACRO segment, offset +// FIXME +ENDM + +UNIMPLEMENTED MACRO name +ENDM + +/* We need this to distinguish repeat from macros */ +#define ENDR ENDM + +#else /***********************************************************************/ + +/* Force intel syntax */ +.intel_syntax noprefix + +.altmacro + +/* Hex numbers need to be in 0x1AB format */ +#define HEX(y) 0x##y + +/* Macro values need to be marked */ +#define VAL(x) \x + +/* Due to MASM's reverse syntax, we are forced to use a precompiler macro */ +#define MACRO(...) .macro __VA_ARGS__ +#define ENDM .endm + +/* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */ +.macro .PROC name + .func \name + \name: + .cfi_startproc + .equ cfa_current_offset, -8 +.endm + +/* ... and .ENDP, replacing ENDP */ +.macro .ENDP name + .cfi_endproc + .endfunc +.endm + +/* MASM compatible PUBLIC */ +.macro PUBLIC symbol + .global \symbol +.endm + +/* Dummy ASSUME */ +.macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8 +.endm + +/* MASM needs an end tag for segments */ +.macro .endcode16 +.endm + +/* MASM compatible ALIGN */ +#define ALIGN .align + +/* MASM compatible REPEAT, additional ENDR */ +#define REPEAT .rept +#define ENDR .endr + +.macro ljmp segment, offset + jmp far ptr \segment:\offset +.endm + +/* MASM compatible EXTERN */ +.macro EXTERN name +.endm + +/* MASM needs an END tag */ +#define END + +.macro .MODEL model +.endm + +.macro .code + .text +.endm + +/* Macros for x64 stack unwind OPs */ + +.macro .allocstack size + .cfi_adjust_cfa_offset \size + .set cfa_current_offset, cfa_current_offset - \size +.endm + +code = 1 +.macro .pushframe param=0 + .if (\param) + .cfi_adjust_cfa_offset 0x30 + .set cfa_current_offset, cfa_current_offset - 0x30 + .else + .cfi_adjust_cfa_offset 0x28 + .set cfa_current_offset, cfa_current_offset - 0x28 + .endif +.endm + +.macro .pushreg reg + .cfi_adjust_cfa_offset 8 + .equ cfa_current_offset, cfa_current_offset - 8 + .cfi_offset \reg, cfa_current_offset +.endm + +.macro .savereg reg, offset + // checkme!!! + .cfi_offset \reg, \offset +.endm + +.macro .savexmm128 reg, offset + // checkme!!! + .cfi_offset \reg, \offset +.endm + +.macro .setframe reg, offset + .cfi_def_cfa reg, \offset + .equ cfa_current_offset, \offset +.endm + +.macro .endprolog +.endm + +.macro UNIMPLEMENTED2 file, line, func + + jmp 3f +1: .asciz "\func" +2: .asciz \file +3: + sub rsp, 0x20 + lea rcx, MsgUnimplemented[rip] + lea rdx, 1b[rip] + lea r8, 2b[rip] + mov r9, \line + call DbgPrint + add rsp, 0x20 +.endm +#define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__, + +/* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time + conditionals. We therefore use "if", too. .if shouldn't be used at all */ +#define if .if +#define endif .endif +#define else .else +#define elseif .elseif + +#endif diff --git a/reactos/include/reactos/ks386.inc b/reactos/include/reactos/ks386.inc new file mode 100644 index 00000000000..a4272847a9f --- /dev/null +++ b/reactos/include/reactos/ks386.inc @@ -0,0 +1,946 @@ + +/* Pointer size */ +SizeofPointer = 0x4 + +/* Breakpoints */ +BREAKPOINT_BREAK = 0x0 +BREAKPOINT_PRINT = 0x1 +BREAKPOINT_PROMPT = 0x2 +BREAKPOINT_LOAD_SYMBOLS = 0x3 +BREAKPOINT_UNLOAD_SYMBOLS = 0x4 +BREAKPOINT_COMMAND_STRING = 0x5 + +/* Context Frame Flags */ +CONTEXT_FULL = 0x10007 +CONTEXT_CONTROL = 0x10001 +CONTEXT_INTEGER = 0x10002 +CONTEXT_SEGMENTS = 0x10004 +CONTEXT_FLOATING_POINT = 0x10008 +CONTEXT_DEBUG_REGISTERS = 0x10010 + +/* Exception flags */ +EXCEPTION_NONCONTINUABLE = 0x1 +EXCEPTION_UNWINDING = 0x2 +EXCEPTION_EXIT_UNWIND = 0x4 +EXCEPTION_STACK_INVALID = 0x8 +EXCEPTION_NESTED_CALL = 0x10 +EXCEPTION_TARGET_UNWIND = 0x20 +EXCEPTION_COLLIDED_UNWIND = 0x20 +EXCEPTION_UNWIND = 0x6 +EXCEPTION_EXECUTE_HANDLER = 0x1 +EXCEPTION_CONTINUE_SEARCH = 0x0 +EXCEPTION_CONTINUE_EXECUTION = 0xffffffff +EXCEPTION_CHAIN_END = 0xffffffff + +/* Exception types */ +ExceptionContinueExecution = 0x0 +ExceptionContinueSearch = 0x1 +ExceptionNestedException = 0x2 +ExceptionCollidedUnwind = 0x3 + +/* Lock Queue */ +LOCK_QUEUE_WAIT = 0x1 +LOCK_QUEUE_OWNER = 0x2 +LockQueueDispatcherLock = 0x0 + +/* Process states */ +ProcessInMemory = 0x0 +ProcessOutOfMemory = 0x1 +ProcessInTransition = 0x2 + +/* Processor mode */ +KernelMode = 0x0 +UserMode = 0x1 + +/* Status codes */ +STATUS_ACCESS_VIOLATION = 0xc0000005 +STATUS_ASSERTION_FAILURE = 0xc0000420 +STATUS_ARRAY_BOUNDS_EXCEEDED = 0xc000008c +STATUS_BAD_COMPRESSION_BUFFER = 0xc0000242 +STATUS_BREAKPOINT = 0x80000003 +STATUS_CALLBACK_POP_STACK = 0xc0000423 +STATUS_DATATYPE_MISALIGNMENT = 0x80000002 +STATUS_FLOAT_DENORMAL_OPERAND = 0xc000008d +STATUS_FLOAT_DIVIDE_BY_ZERO = 0xc000008e +STATUS_FLOAT_INEXACT_RESULT = 0xc000008f +STATUS_FLOAT_INVALID_OPERATION = 0xc0000090 +STATUS_FLOAT_OVERFLOW = 0xc0000091 +STATUS_FLOAT_STACK_CHECK = 0xc0000092 +STATUS_FLOAT_UNDERFLOW = 0xc0000093 +STATUS_FLOAT_MULTIPLE_FAULTS = 0xc00002b4 +STATUS_FLOAT_MULTIPLE_TRAPS = 0xc00002b5 +STATUS_GUARD_PAGE_VIOLATION = 0x80000001 +STATUS_ILLEGAL_FLOAT_CONTEXT = 0xc000014a +STATUS_ILLEGAL_INSTRUCTION = 0xc000001d +STATUS_INSTRUCTION_MISALIGNMENT = 0xc00000aa +STATUS_INVALID_HANDLE = 0xc0000008 +STATUS_INVALID_LOCK_SEQUENCE = 0xc000001e +STATUS_INVALID_OWNER = 0xc000005a +STATUS_INVALID_PARAMETER = 0xc000000d +STATUS_INVALID_PARAMETER_1 = 0xc00000ef +STATUS_INVALID_SYSTEM_SERVICE = 0xc000001c +STATUS_INTEGER_DIVIDE_BY_ZERO = 0xc0000094 +STATUS_INTEGER_OVERFLOW = 0xc0000095 +STATUS_IN_PAGE_ERROR = 0xc0000006 +STATUS_KERNEL_APC = 0x100 +STATUS_LONGJUMP = 0x80000026 +STATUS_NO_CALLBACK_ACTIVE = 0xc0000258 +STATUS_NO_EVENT_PAIR = 0xc000014e +STATUS_PRIVILEGED_INSTRUCTION = 0xc0000096 +STATUS_SINGLE_STEP = 0x80000004 +STATUS_STACK_BUFFER_OVERRUN = 0xc0000409 +STATUS_STACK_OVERFLOW = 0xc00000fd +STATUS_SUCCESS = 0x0 +STATUS_THREAD_IS_TERMINATING = 0xc000004b +STATUS_TIMEOUT = 0x102 +STATUS_UNWIND = 0xc0000027 +STATUS_UNWIND_CONSOLIDATE = 0x80000029 +STATUS_USER_APC = 0xc0 +STATUS_WAKE_SYSTEM_DEBUGGER = 0x80000007 + +/* TLS defines */ +TLS_MINIMUM_AVAILABLE = 0x40 +TLS_EXPANSION_SLOTS = 0x400 + +/* Thread states */ +Initialized = 0x0 +Ready = 0x1 +Running = 0x2 +Standby = 0x3 +Terminated = 0x4 +Waiting = 0x5 + +/* Wait type / reason */ +WrExecutive = 0x7 +WrMutex = 0x1d +WrDispatchInt = 0x1f +WrQuantumEnd = 0x1e +WrEventPair = 0xe +WaitAny = 0x1 +WaitAll = 0x0 + +/* Interrupt object types */ +InLevelSensitive = 0x0 +InLatched = 0x1 + +/* Bug Check Codes */ +APC_INDEX_MISMATCH = 0x1 +INVALID_AFFINITY_SET = 0x3 +INVALID_DATA_ACCESS_TRAP = 0x4 +IRQL_NOT_GREATER_OR_EQUAL = 0x9 +IRQL_NOT_LESS_OR_EQUAL = 0xa +NO_USER_MODE_CONTEXT = 0xe +SPIN_LOCK_ALREADY_OWNED = 0xf +SPIN_LOCK_NOT_OWNED = 0x10 +THREAD_NOT_MUTEX_OWNER = 0x11 +TRAP_CAUSE_UNKNOWN = 0x12 +KMODE_EXCEPTION_NOT_HANDLED = 0x1e +KERNEL_APC_PENDING_DURING_EXIT = 0x20 +PANIC_STACK_SWITCH = 0x2b +DATA_BUS_ERROR = 0x2e +INSTRUCTION_BUS_ERROR = 0x2f +SYSTEM_EXIT_OWNED_MUTEX = 0x39 +PAGE_FAULT_WITH_INTERRUPTS_OFF = 0x49 +IRQL_GT_ZERO_AT_SYSTEM_SERVICE = 0x4a +DATA_COHERENCY_EXCEPTION = 0x55 +INSTRUCTION_COHERENCY_EXCEPTION = 0x56 +HAL1_INITIALIZATION_FAILED = 0x61 +UNEXPECTED_KERNEL_MODE_TRAP = 0x7f +NMI_HARDWARE_FAILURE = 0x80 +SPIN_LOCK_INIT_FAILURE = 0x81 +ATTEMPTED_SWITCH_FROM_DPC = 0xb8 + +/* IRQL */ +PASSIVE_LEVEL = 0x0 +APC_LEVEL = 0x1 +DISPATCH_LEVEL = 0x2 +CLOCK1_LEVEL = 0x1c +CLOCK2_LEVEL = 0x1c +IPI_LEVEL = 0x1d +POWER_LEVEL = 0x1e +PROFILE_LEVEL = 0x1b +HIGH_LEVEL = 0x1f +#ifdef NT_UP +SYNCH_LEVEL = 0x2 +#else +SYNCH_LEVEL = 0x1b +#endif + +/* Stack sizes */ +KERNEL_STACK_SIZE = 0x3000 +KERNEL_LARGE_STACK_SIZE = 0xf000 +KERNEL_LARGE_STACK_COMMIT = 0x3000 + +/* Miscellaneous Definitions */ +LOW_REALTIME_PRIORITY = 0x10 +CLOCK_QUANTUM_DECREMENT = 0x3 +WAIT_QUANTUM_DECREMENT = 0x1 +MAXIMUM_PROCESSORS = 0x20 +INITIAL_STALL_COUNT = 0x64 +KI_EXCEPTION_ACCESS_VIOLATION = 0x10000004 +Executive = 0x0 +FALSE = 0x0 +TRUE = 0x1 +DBG_STATUS_CONTROL_C = 0x1 +USER_SHARED_DATA = 0x7ffe0000 +PAGE_SIZE = 0x1000 +MAXIMUM_IDTVECTOR = 0xff +PRIMARY_VECTOR_BASE = 0x30 +RPL_MASK = 0x3 +MODE_MASK = 0x1 +NUMBER_SERVICE_TABLES = 0x2 +SERVICE_NUMBER_MASK = 0xfff +SERVICE_TABLE_SHIFT = 0x8 +SERVICE_TABLE_MASK = 0x10 +SERVICE_TABLE_TEST = 0x10 + +/* KAPC */ +ApType = 0x0 +ApSize = 0x2 +ApThread = 0x8 +ApApcListEntry = 0xc +ApKernelRoutine = 0x14 +ApRundownRoutine = 0x18 +ApNormalRoutine = 0x1c +ApNormalContext = 0x20 +ApSystemArgument1 = 0x24 +ApSystemArgument2 = 0x28 +ApApcStateIndex = 0x2c +ApApcMode = 0x2d +ApInserted = 0x2e +ApcObjectLength = 0x30 + +/* KAPC_STATE */ +AsApcListHead = 0x0 +AsProcess = 0x10 +AsKernelApcInProgress = 0x14 +AsKernelApcPending = 0x15 +AsUserApcPending = 0x16 + +/* CLIENT_ID */ +CidUniqueProcess = 0x0 +CidUniqueThread = 0x4 + +/* RTL_CRITICAL_SECTION */ +CsDebugInfo = 0x0 +CsLockCount = 0x4 +CsRecursionCount = 0x8 +CsOwningThread = 0xc +CsLockSemaphore = 0x10 +CsSpinCount = 0x14 + +/* RTL_CRITICAL_SECTION_DEBUG */ +CsType = 0x0 +CsCreatorBackTraceIndex = 0x2 +CsCriticalSection = 0x4 +CsProcessLocksList = 0x8 +CsEntryCount = 0x10 +CsContentionCount = 0x14 + +/* KDEVICE_QUEUE_ENTRY */ +DeDeviceListEntry = 0x0 +DeSortKey = 0x8 +DeInserted = 0xc +DeviceQueueEntryLength = 0x10 + +/* KDPC */ +DpType = 0x0 +DpImportance = 0x1 +DpNumber = 0x2 +DpDpcListEntry = 0x4 +DpDeferredRoutine = 0xc +DpDeferredContext = 0x10 +DpSystemArgument1 = 0x14 +DpSystemArgument2 = 0x18 +DpDpcData = 0x1c +DpcObjectLength = 0x20 + +/* KDEVICE_QUEUE */ +DvType = 0x0 +DvSize = 0x2 +DvDeviceListHead = 0x4 +DvSpinLock = 0xc +DvBusy = 0x10 +DeviceQueueObjectLength = 0x14 + +/* EXCEPTION_RECORD */ +ErExceptionCode = 0x0 +ErExceptionFlags = 0x4 +ErExceptionRecord = 0x8 +ErExceptionAddress = 0xc +ErNumberParameters = 0x10 +ErExceptionInformation = 0x14 +ExceptionRecordLength = 0x50 +EXCEPTION_RECORD_LENGTH = 0x50 + +/* EPROCESS */ +EpDebugPort = 0xcc +EpVdmObjects = 0x144 +ExecutiveProcessObjectLength = 0x278 + +/* KEVENT */ +EvType = 0x0 +EvSize = 0x2 +EvSignalState = 0x4 +EvWaitListHead = 0x8 +EventObjectLength = 0x10 + +/* FAST_MUTEX */ +FmCount = 0x0 +FmOwner = 0x4 +FmContention = 0x8 +FmOldIrql = 0x1c + +/* KINTERRUPT */ +InType = 0x0 +InSize = 0x2 +InInterruptListEntry = 0x4 +InServiceRoutine = 0xc +InServiceContext = 0x10 +InSpinLock = 0x14 +InTickCount = 0x18 +InActualLock = 0x1c +InDispatchAddress = 0x20 +InVector = 0x24 +InIrql = 0x28 +InSynchronizeIrql = 0x29 +InFloatingSave = 0x2a +InConnected = 0x2b +InNumber = 0x2c +InShareVector = 0x2d +InMode = 0x30 +InServiceCount = 0x34 +InDispatchCount = 0x38 +InDispatchCode = 0x3c +InterruptObjectLength = 0x1e4 + +/* IO_STATUS_BLOCK */ +IoStatus = 0x0 +IoPointer = 0x0 +IoInformation = 0x4 + +/* KNODE */ +KnPfnDereferenceSListHead = 0x8 +KnProcessorMask = 0x10 +KnColor = 0x14 +KnSeed = 0x18 +KnNodeNumber = 0x19 +KnFlags = 0x1a +knMmShiftedColor = 0x1e +KnFreeCount = 0x22 +KnPfnDeferredList = 0x2a +KNODE_SIZE = 0x2e + +/* KSPIN_LOCK_QUEUE */ +LqNext = 0x0 +LqLock = 0x4 + +/* KLOCK_QUEUE_HANDLE */ +LqhNext = 0x0 +LqhLock = 0x4 +LqhOldIrql = 0x8 +LOCK_QUEUE_HEADER_SIZE = 0xc + +/* LARGE_INTEGER */ +LiLowPart = 0x0 +LiHighPart = 0x4 + +/* LIST_ENTRY */ +LsFlink = 0x0 +LsBlink = 0x4 + +/* PEB */ +PeKernelCallbackTable = 0x2c +ProcessEnvironmentBlockLength = 0x230 + +/* KPROFILE */ +PfType = 0x0 +PfSize = 0x2 +PfProfileListEntry = 0x4 +PfProcess = 0xc +PfRangeBase = 0x10 +PfRangeLimit = 0x14 +PfBucketShift = 0x18 +PfBuffer = 0x1c +PfSegment = 0x20 +PfAffinity = 0x24 +PfSource = 0x28 +PfStarted = 0x2c +ProfileObjectLength = 0x30 + +/* PORT_MESSAGE */ +PmLength = 0x0 +PmZeroInit = 0x4 +PmClientId = 0x8 +PmProcess = 0x8 +PmThread = 0xc +PmMessageId = 0x10 +PmClientViewSize = 0x14 +PortMessageLength = 0x18 + +/* KPROCESS */ +PrType = 0x0 +PrSize = 0x2 +PrSignalState = 0x4 +PrProfileListHead = 0x10 +PrDirectoryTableBase = 0x18 +PrLdtDescriptor = 0x20 +PrIopmOffset = 0x30 +PrInt21Descriptor = 0x28 +PrVdmTrapcHandler = 0x4c +PrFlags = 0x6b +PrActiveProcessors = 0x34 +PrKernelTime = 0x38 +PrUserTime = 0x3c +PrReadyListHead = 0x40 +PrSwapListEntry = 0x48 +PrThreadListHead = 0x50 +PrProcessLock = 0x58 +PrAffinity = 0x5c +PrProcessFlags = 0x60 +PrBasePriority = 0x64 +PrQuantumReset = 0x65 +PrState = 0x66 +PrStackCount = 0x6c +KernelProcessObjectLength = 0x78 + +/* KQUEUE */ +QuType = 0x0 +QuSize = 0x2 +QuSignalState = 0x4 +QuEntryListHead = 0x10 +QuCurrentCount = 0x18 +QuMaximumCount = 0x1c +QuThreadListHead = 0x20 +QueueObjectLength = 0x28 + +/* STRING */ +StrLength = 0x0 +StrMaximumLength = 0x2 +StrBuffer = 0x4 + +/* TEB */ +TeCmTeb = 0x0 +TeExceptionList = 0x0 +TeStackBase = 0x4 +TeStackLimit = 0x8 +TeFiberData = 0x10 +TeSelf = 0x18 +TeEnvironmentPointer = 0x1c +TeClientId = 0x20 +TeActiveRpcHandle = 0x28 +TeThreadLocalStoragePointer = 0x2c +TeCountOfOwnedCriticalSections = 0x38 +TePeb = 0x30 +TeCsrClientThread = 0x3c +TeWOW32Reserved = 0xc0 +TeExceptionCode = 0x1a4 +TeActivationContextStackPointer = 0x1a8 +TeGdiClientPID = 0x6c0 +TeGdiClientTID = 0x6c4 +TeGdiThreadLocalInfo = 0x6c8 +TeglDispatchTable = 0x7c4 +TeglReserved1 = 0xb68 +TeglReserved2 = 0xbdc +TeglSectionInfo = 0xbe0 +TeglSection = 0xbe4 +TeglTable = 0xbe8 +TeglCurrentRC = 0xbec +TeglContext = 0xbf0 +TeDeallocationStack = 0xe0c +TeTlsSlots = 0xe10 +TeTlsExpansionSlots = 0xf94 +TeLastErrorValue = 0x34 +TeVdm = 0xf18 +TeInstrumentation = 0xf2c +TeGdiBatchCount = 0xf70 +TeGuaranteedStackBytes = 0xf78 +TeFlsData = 0xfb4 +ThreadEnvironmentBlockLength = 0xfbc + +/* TIME_FIELDS */ +TfSecond = 0xa +TfMinute = 0x8 +TfHour = 0x6 +TfWeekday = 0xe +TfDay = 0x4 +TfMonth = 0x2 +TfYear = 0x0 +TfMilliseconds = 0xc + +/* KTHREAD */ +ThType = 0x0 +ThSize = 0x2 +ThLock = 0x0 +ThDebugActive = 0x3 +ThSignalState = 0x4 +ThInitialStack = 0x18 +ThStackLimit = 0x1c +ThKernelStack = 0x20 +ThThreadLock = 0x24 +ThAlerted = 0x5e +ThApcState = 0x28 +ThPriority = 0x5b +ThSwapBusy = 0x5d +ThNextProcessor = 0x40 +ThDeferredProcessor = 0x41 +ThApcQueueLock = 0x44 +ThContextSwitches = 0x48 +ThState = 0x4c +ThNpxState = 0x4d +ThWaitIrql = 0x4e +ThWaitMode = 0x4f +ThWaitStatus = 0x50 +ThWaitBlockList = 0x54 +ThGateObject = 0x54 +ThWaitListEntry = 0x60 +ThSwapListEntry = 0x60 +ThQueue = 0x68 +ThWaitTime = 0x6c +ThCombinedApcDisable = 0x70 +ThKernelApcDisable = 0x70 +ThSpecialApcDisable = 0x72 +ThTeb = 0x74 +ThTimer = 0x78 +ThThreadFlags = 0xa0 +ThServiceTable = 0x118 +ThWaitBlock = 0xa8 +ThResourceIndex = 0xef +ThQueueListEntry = 0x108 +ThTrapFrame = 0x110 +ThCallbackStack = 0x114 +ThApcStateIndex = 0x11c +ThIdealProcessor = 0x11d +ThBasePriority = 0x121 +ThPriorityDecrement = 0x122 +ThAdjustReason = 0x42 +ThAdjustIncrement = 0x43 +ThPreviousMode = 0xd7 +ThSaturation = 0x123 +ThFreezeCount = 0x14f +ThUserAffinity = 0x124 +ThProcess = 0x128 +ThAffinity = 0x12c +ThUserIdealProcessor = 0x151 +ThApcStatePointer = 0x130 +ThSavedApcState = 0x138 +ThWaitReason = 0x5a +ThSuspendCount = 0x150 +ThWin32Thread = 0x154 +ThStackBase = 0x158 +ThSuspendApc = 0x15c +ThPowerState = 0x18b +ThKernelTime = 0x160 +ThLegoData = 0x184 +ThLargeStack = 0x107 +ThUserTime = 0x18c +ThSuspendSemaphore = 0x190 +ThSListFaultCount = 0x1a4 +ThThreadListEntry = 0x1a8 +ThMutantListHead = 0x10 +ThSListFaultAddress = 0x1b0 +KernelThreadObjectLength = 0x1b8 +ExecutiveThreadObjectLength = 0x250 + +/* KTIMER */ +TiType = 0x0 +TiSize = 0x2 +TiInserted = 0x3 +TiSignalState = 0x4 +TiDueTime = 0x10 +TiTimerListEntry = 0x18 +TiDpc = 0x20 +TiPeriod = 0x24 +TimerObjectLength = 0x28 + +/* TIME */ + +/* KUSER_SHARED_DATA */ +UsTickCountMultiplier = 0x4 +UsInterruptTime = 0x8 +UsSystemTime = 0x14 +UsTimeZoneBias = 0x20 +UsImageNumberLow = 0x2c +UsImageNumberHigh = 0x2e +UsNtSystemRoot = 0x30 +UsMaxStackTraceDepth = 0x238 +UsCryptoExponent = 0x23c +UsTimeZoneId = 0x240 +UsLargePageMinimum = 0x244 +UsReserved2 = 0x248 +UsNtProductType = 0x264 +UsProductTypeIsValid = 0x268 +UsNtMajorVersion = 0x26c +UsNtMinorVersion = 0x270 +UsProcessorFeatures = 0x274 +UsReserved1 = 0x2b4 +UsReserved3 = 0x2b8 +UsTimeSlip = 0x2bc +UsAlternativeArchitecture = 0x2c0 +UsSystemExpirationDate = 0x2c8 +UsSuiteMask = 0x2d0 +UsKdDebuggerEnabled = 0x2d4 +UsActiveConsoleId = 0x2d8 +UsDismountCount = 0x2dc +UsComPlusPackage = 0x2e0 +UsLastSystemRITEventTickCount = 0x2e4 +UsNumberOfPhysicalPages = 0x2e8 +UsSafeBootMode = 0x2ec +UsTestRetInstruction = 0x2f8 +UsSystemCall = 0x300 +UsSystemCallReturn = 0x304 +UsSystemCallPad = 0x308 +UsTickCount = 0x320 +UsTickCountQuad = 0x320 +UsWow64SharedInformation = 0x340 + +/* KWAIT_BLOCK */ +WbWaitListEntry = 0x0 +WbThread = 0x8 +WbObject = 0xc +WbNextWaitBlock = 0x10 +WbWaitKey = 0x14 +WbWaitType = 0x16 + +/* CR0 flags */ +CR0_PE = 0x1 +CR0_MP = 0x2 +CR0_EM = 0x4 +CR0_TS = 0x8 +CR0_ET = 0x10 +CR0_NE = 0x20 +CR0_WP = 0x10000 +CR0_AM = 0x40000 +CR0_NW = 0x20000000 +CR0_CD = 0x40000000 +CR0_PG = 0x80000000 + +/* CR4 flags */ +CR4_VME = 0x1 +CR4_PVI = 0x2 +CR4_TSD = 0x4 +CR4_DE = 0x8 +CR4_PSE = 0x10 +CR4_PAE = 0x20 +CR4_MCE = 0x40 +CR4_PGE = 0x80 +CR4_FXSR = 0x200 +CR4_XMMEXCPT = 0x400 + +/* KeFeatureBits flags */ +KF_RDTSC = 0x2 +KF_CR4 = 0x4 +KF_GLOBAL_PAGE = 0x10 +KF_LARGE_PAGE = 0x20 +KF_CMPXCHG8B = 0x80 +KF_FAST_SYSCALL = 0x1000 +KF_V86_VIS = 0x1 + +/* Machine type definitions */ +MACHINE_TYPE_ISA = 0x0 +MACHINE_TYPE_EISA = 0x1 +MACHINE_TYPE_MCA = 0x2 + +/* EFLAGS */ +EFLAGS_TF = 0x100 +EFLAGS_INTERRUPT_MASK = 0x200 +EFLAGS_V86_MASK = 0x20000 +EFLAGS_ALIGN_CHECK = 0x40000 +EFLAGS_VIF = 0x80000 +EFLAGS_VIP = 0x100000 +EFLAGS_USER_SANITIZE = 0x3f4dd7 + +/* KDGT selectors */ +KGDT_R3_DATA = 0x20 +KGDT_R3_CODE = 0x18 +KGDT_R0_CODE = 0x8 +KGDT_R0_DATA = 0x10 +KGDT_R0_PCR = 0x30 +KGDT_TSS = 0x28 +KGDT_R3_TEB = 0x38 +KGDT_DF_TSS = 0x50 +KGDT_NMI_TSS = 0x58 +KGDT_LDT = 0x48 +NPX_STATE_NOT_LOADED = 0xa +NPX_STATE_LOADED = 0x0 +PF_XMMI_INSTRUCTIONS_AVAILABLE = 0x6 +EFLAG_SELECT = 0xc000 + +/* CONTEXT */ +CsContextFlags = 0x0 +CsDr0 = 0x4 +CsDr1 = 0x8 +CsDr2 = 0xc +CsDr3 = 0x10 +CsDr6 = 0x14 +CsDr7 = 0x18 +CsFloatSave = 0x1c +CsSegGs = 0x8c +CsSegFs = 0x90 +CsSegEs = 0x94 +CsSegDs = 0x98 +CsEdi = 0x9c +CsEsi = 0xa0 +CsEbx = 0xa4 +CsEdx = 0xa8 +CsEcx = 0xac +CsEax = 0xb0 +CsEbp = 0xb4 +CsEip = 0xb8 +CsSegCs = 0xbc +CsEflags = 0xc0 +CsEsp = 0xc4 +CsSegSs = 0xc8 +CsExtendedRegisters = 0xcc +ContextFrameLength = 0x2cc +CONTEXT_LENGTH = 0x2cc + +/* KGDTENTRY */ +KgdtBaseLow = 0x2 +KgdtBaseMid = 0x4 +KgdtBaseHi = 0x7 +KgdtLimitHi = 0x6 +KgdtLimitLow = 0x0 + +/* KTRAP_FRAME */ +TsExceptionList = 0x4c +TsPreviousPreviousMode = 0x48 +TsSegGs = 0x30 +TsSegFs = 0x50 +TsSegEs = 0x34 +TsSegDs = 0x38 +TsEdi = 0x54 +TsEsi = 0x58 +TsEbp = 0x60 +TsEbx = 0x5c +TsEdx = 0x3c +TsEcx = 0x40 +TsEax = 0x44 +TsErrCode = 0x64 +TsEip = 0x68 +TsSegCs = 0x6c +TsEflags = 0x70 +TsHardwareEsp = 0x74 +TsHardwareSegSs = 0x78 +TsTempSegCs = 0x10 +TsTempEsp = 0x14 +TsDbgEbp = 0x0 +TsDbgEip = 0x4 +TsDbgArgMark = 0x8 +TsDbgArgPointer = 0xc +TsDr0 = 0x18 +TsDr1 = 0x1c +TsDr2 = 0x20 +TsDr3 = 0x24 +TsDr6 = 0x28 +TsDr7 = 0x2c +TsV86Es = 0x7c +TsV86Ds = 0x80 +TsV86Fs = 0x84 +TsV86Gs = 0x88 +KTRAP_FRAME_LENGTH = 0x8c +KTRAP_FRAME_ALIGN = 0x4 +FRAME_EDITED = 0xfff8 + +/* KTSS */ +TssEsp0 = 0x4 +TssCR3 = 0x1c +TssEip = 0x20 +TssEFlags = 0x24 +TssEax = 0x28 +TssEbx = 0x34 +TssEcx = 0x2c +TssEdx = 0x30 +TssEsp = 0x38 +TssEbp = 0x3c +TssEsi = 0x40 +TssEdi = 0x44 +TssEs = 0x48 +TssCs = 0x4c +TssSs = 0x50 +TssDs = 0x54 +TssFs = 0x58 +TssGs = 0x5c +TssLDT = 0x60 +TssIoMapBase = 0x66 +TssIoMaps = 0x68 +TssLength = 0x20ac + +/* KPCR */ +KPCR_EXCEPTION_LIST = 0x0 +KPCR_PERF_GLOBAL_GROUP_MASK = 0x8 +KPCR_CONTEXT_SWITCHES = 0x10 +KPCR_TEB = 0x18 +KPCR_SELF = 0x1c +KPCR_PRCB = 0x20 +KPCR_IDT = 0x38 +KPCR_GDT = 0x3c +KPCR_TSS = 0x40 +KPCR_STALL_SCALE_FACTOR = 0x4c +KPCR_PRCB_DATA = 0x120 +KPCR_CURRENT_THREAD = 0x124 +KPCR_PRCB_NEXT_THREAD = 0x128 +KPCR_PRCB_DPC_QUEUE_DEPTH = 0xa4c +KPCR_PRCB_DPC_STACK = 0xa68 +KPCR_PRCB_MAXIMUM_DPC_QUEUE_DEPTH = 0xa6c +KPCR_PRCB_DPC_ROUTINE_ACTIVE = 0xa7a +KPCR_PRCB_TIMER_REQUEST = 0xa88 +KPCR_PRCB_QUANTUM_END = 0xaa1 +KPCR_PRCB_DEFERRED_READY_LIST_HEAD = 0xc10 +KPCR_PRCB_POWER_STATE_IDLE_FUNCTION = 0xec0 + +/* KTRAP_FRAME */ +KTRAP_FRAME_DEBUGEBP = 0x0 +KTRAP_FRAME_DEBUGEIP = 0x4 +KTRAP_FRAME_TEMPESP = 0x14 +KTRAP_FRAME_DR0 = 0x18 +KTRAP_FRAME_DR1 = 0x1c +KTRAP_FRAME_DR2 = 0x20 +KTRAP_FRAME_DR3 = 0x24 +KTRAP_FRAME_DR6 = 0x28 +KTRAP_FRAME_DR7 = 0x2c +KTRAP_FRAME_GS = 0x30 +KTRAP_FRAME_ES = 0x34 +KTRAP_FRAME_DS = 0x38 +KTRAP_FRAME_EDX = 0x3c +KTRAP_FRAME_ECX = 0x40 +KTRAP_FRAME_EAX = 0x44 +KTRAP_FRAME_PREVIOUS_MODE = 0x48 +KTRAP_FRAME_EXCEPTION_LIST = 0x4c +KTRAP_FRAME_FS = 0x50 +KTRAP_FRAME_EDI = 0x54 +KTRAP_FRAME_ESI = 0x58 +KTRAP_FRAME_EBX = 0x5c +KTRAP_FRAME_EBP = 0x60 +KTRAP_FRAME_ERROR_CODE = 0x64 +KTRAP_FRAME_EIP = 0x68 +KTRAP_FRAME_EFLAGS = 0x70 +KTRAP_FRAME_ESP = 0x74 +KTRAP_FRAME_SS = 0x78 +KTRAP_FRAME_V86_ES = 0x7c +KTRAP_FRAME_V86_DS = 0x80 +KTRAP_FRAME_V86_FS = 0x84 +KTRAP_FRAME_V86_GS = 0x88 +KTRAP_FRAME_SIZE = 0x8c +FRAME_EDITED = 0xfff8 + +/* CONTEXT */ +CONTEXT_FLAGS = 0x0 +CONTEXT_SEGGS = 0x8c +CONTEXT_SEGFS = 0x90 +CONTEXT_SEGES = 0x94 +CONTEXT_SEGDS = 0x98 +CONTEXT_EDI = 0x9c +CONTEXT_ESI = 0xa0 +CONTEXT_EBX = 0xa4 +CONTEXT_EDX = 0xa8 +CONTEXT_ECX = 0xac +CONTEXT_EAX = 0xb0 +CONTEXT_EBP = 0xb4 +CONTEXT_EIP = 0xb8 +CONTEXT_SEGCS = 0xbc +CONTEXT_EFLAGS = 0xc0 +CONTEXT_ESP = 0xc4 +CONTEXT_SEGSS = 0xc8 +CONTEXT_FRAME_LENGTH = 0x2cc + +/* FIBER */ +FIBER_PARAMETER = 0x0 +FIBER_EXCEPTION_LIST = 0x4 +FIBER_STACK_BASE = 0x8 +FIBER_STACK_LIMIT = 0xc +FIBER_DEALLOCATION_STACK = 0x10 +FIBER_CONTEXT = 0x14 +FIBER_CONTEXT_FLAGS = 0x14 +FIBER_CONTEXT_EAX = 0xc4 +FIBER_CONTEXT_EBX = 0xb8 +FIBER_CONTEXT_ECX = 0xc0 +FIBER_CONTEXT_EDX = 0xbc +FIBER_CONTEXT_ESI = 0xb4 +FIBER_CONTEXT_EDI = 0xb0 +FIBER_CONTEXT_EBP = 0xc8 +FIBER_CONTEXT_EIP = 0xcc +FIBER_CONTEXT_ESP = 0xd8 +FIBER_CONTEXT_DR6 = 0x28 +FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD = 0x30 +FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD = 0x34 +FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD = 0x38 +FIBER_GUARANTEED_STACK_BYTES = 0x2e0 +FIBER_FLS_DATA = 0x2e4 +FIBER_ACTIVATION_CONTEXT_STACK = 0x2e8 + +/* KTSS */ +KTSS_IOMAPBASE = 0x66 +KTSS_ESP0 = 0x4 + +/* EXCEPTION_RECORD */ +EXCEPTION_RECORD_EXCEPTION_CODE = 0x0 +EXCEPTION_RECORD_EXCEPTION_FLAGS = 0x4 +EXCEPTION_RECORD_EXCEPTION_RECORD = 0x8 +EXCEPTION_RECORD_EXCEPTION_ADDRESS = 0xc +EXCEPTION_RECORD_NUMBER_PARAMETERS = 0x10 +EXCEPTION_RECORD_EXCEPTION_ADDRESS = 0xc +SIZEOF_EXCEPTION_RECORD = 0x50 +EXCEPTION_RECORD_LENGTH = 0x50 + +/* KTHREAD */ +KTHREAD_DEBUG_ACTIVE = 0x3 +KTHREAD_INITIAL_STACK = 0x18 +KTHREAD_STACK_LIMIT = 0x1c +KTHREAD_TEB = 0x74 +KTHREAD_KERNEL_STACK = 0x20 +KTHREAD_APCSTATE_PROCESS = 0x38 +KTHREAD_PENDING_KERNEL_APC = 0x3d +KTHREAD_CONTEXT_SWITCHES = 0x48 +KTHREAD_STATE_ = 0x4c +KTHREAD_NPX_STATE = 0x4d +KTHREAD_WAIT_IRQL = 0x4e +KTHREAD_WAIT_REASON = 0x5a +KTHREAD_COMBINED_APC_DISABLE = 0x70 +KTHREAD_SPECIAL_APC_DISABLE = 0x72 +KTHREAD_LARGE_STACK = 0x107 +KTHREAD_TRAP_FRAME = 0x110 +KTHREAD_CALLBACK_STACK = 0x114 +KTHREAD_APC_STATE_INDEX = 0x11c +KTHREAD_STACK_BASE = 0x158 + +/* KPROCESS */ +KPROCESS_DIRECTORY_TABLE_BASE = 0x18 +KPROCESS_LDT_DESCRIPTOR0 = 0x20 +KPROCESS_LDT_DESCRIPTOR1 = 0x24 +KPROCESS_INT21_DESCRIPTOR0 = 0x28 +KPROCESS_INT21_DESCRIPTOR1 = 0x2c +KPROCESS_IOPM_OFFSET = 0x30 + +/* Teb */ +TEB_EXCEPTION_LIST = 0x0 +TEB_STACK_LIMIT = 0x8 +TEB_STACK_BASE = 0x4 +TEB_SELF = 0x18 +TEB_FIBER_DATA = 0x10 +TEB_PEB = 0x30 +TEB_EXCEPTION_CODE = 0x1a4 +PEB_KERNEL_CALLBACK_TABLE = 0x2c +TEB_FLS_DATA = 0xfb4 +TEB_ACTIVATION_CONTEXT_STACK_POINTER = 0x1a8 +TEB_GUARANTEED_STACK_BYTES = 0xf78 +TEB_DEALLOCATION_STACK = 0xe0c + +/* Misc */ +NPX_FRAME_LENGTH = 0x210 +FN_CR0_NPX_STATE = 0x20c +DR7_RESERVED_MASK = 0xdc00 +FP_CONTROL_WORD = 0x0 +FP_STATUS_WORD = 0x4 +FP_TAG_WORD = 0x8 +FP_DATA_SELECTOR = 0x18 +CBSTACK_RESULT = 0x20 +CBSTACK_RESULT_LENGTH = 0x24 +CBSTACK_TRAP_FRAME = 0x4 +CBSTACK_CALLBACK_STACK = 0x8 +SIZEOF_FX_SAVE_AREA = 0x210 +KUSER_SHARED_SYSCALL = 0x7ffe0300 +EXCEPTION_EXECUTE_HANDLER = 0x1 +STATUS_CALLBACK_POP_STACK = 0xc0000423 +CONTEXT_ALIGNED_SIZE = 0x2cc +PROCESSOR_FEATURE_FXSR = 0x7ffe0278 diff --git a/reactos/lib/rtl/amd64/debug_asm.S b/reactos/lib/rtl/amd64/debug_asm.S index c115feb12fc..ca09236c566 100644 --- a/reactos/lib/rtl/amd64/debug_asm.S +++ b/reactos/lib/rtl/amd64/debug_asm.S @@ -6,7 +6,7 @@ * PROGRAMER: Timo Kreuzer (timo.kreuzer@reactos.org) */ -#include +#include /* GLOBALS ****************************************************************/ diff --git a/reactos/lib/rtl/amd64/except_asm.S b/reactos/lib/rtl/amd64/except_asm.S index a4b35079fcd..54f44ce445a 100644 --- a/reactos/lib/rtl/amd64/except_asm.S +++ b/reactos/lib/rtl/amd64/except_asm.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/lib/rtl/amd64/rtlmem.S b/reactos/lib/rtl/amd64/rtlmem.S index d0a82068251..e75161061ee 100644 --- a/reactos/lib/rtl/amd64/rtlmem.S +++ b/reactos/lib/rtl/amd64/rtlmem.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/lib/rtl/amd64/slist.S b/reactos/lib/rtl/amd64/slist.S index ca1ed3905d5..efdada51999 100644 --- a/reactos/lib/rtl/amd64/slist.S +++ b/reactos/lib/rtl/amd64/slist.S @@ -6,8 +6,8 @@ * PROGRAMMERS: Timo Kreuzer */ -#include -#include +#include +#include #define SLIST8A_DEPTH_MASK HEX(000000000000FFFF) #define SLIST8A_DEPTH_INC HEX(0000000000000001) diff --git a/reactos/lib/rtl/i386/debug_asm.S b/reactos/lib/rtl/i386/debug_asm.S index c79545f53c0..39b6fa84236 100644 --- a/reactos/lib/rtl/i386/debug_asm.S +++ b/reactos/lib/rtl/i386/debug_asm.S @@ -6,43 +6,39 @@ * PROGRAMER: Alex Ionescu (alex@relsoft.net) */ -.intel_syntax noprefix +#include /* GLOBALS ****************************************************************/ -.globl _DbgBreakPoint@0 -.globl _DbgBreakPointWithStatus@4 -.globl _DbgUserBreakPoint@0 -.globl _DebugService@20 -.globl _DebugService2@12 -.globl _DbgBreakPointNoBugCheck@0 -.globl _RtlpBreakWithStatusInstruction@0 +PUBLIC _DbgBreakPoint@0 +PUBLIC _DbgBreakPointWithStatus@4 +PUBLIC _DbgUserBreakPoint@0 +PUBLIC _DebugService@20 +PUBLIC _DebugService2@12 +PUBLIC _DbgBreakPointNoBugCheck@0 +PUBLIC _RtlpBreakWithStatusInstruction@0 /* FUNCTIONS ***************************************************************/ -.func DbgBreakPointNoBugCheck@0 +.code + _DbgBreakPointNoBugCheck@0: int 3 ret -.endfunc -.func DbgBreakPoint@0 _DbgBreakPoint@0: _DbgUserBreakPoint@0: int 3 ret -.endfunc -.func DbgBreakPointWithStatus@4 _DbgBreakPointWithStatus@4: mov eax, [esp+4] _RtlpBreakWithStatusInstruction@0: int 3 ret 4 -.endfunc -.func DebugService2@12 + _DebugService2@12: /* Setup the stack */ @@ -53,15 +49,14 @@ _DebugService2@12: mov eax, [ebp+16] mov ecx, [ebp+8] mov edx, [ebp+12] - int 0x2D + int HEX(2D) int 3 /* Restore stack */ pop ebp ret 12 -.endfunc -.func DebugService@20 + _DebugService@20: /* Setup the stack */ @@ -78,7 +73,7 @@ _DebugService@20: mov edx, [ebp+16] mov ebx, [ebp+20] mov edi, [ebp+24] - int 0x2D + int HEX(2D) int 3 /* Restore registers */ @@ -88,4 +83,5 @@ _DebugService@20: /* Return */ pop ebp ret 20 -.endfunc + +END diff --git a/reactos/lib/rtl/i386/except_asm.s b/reactos/lib/rtl/i386/except_asm.s index 9b2f856c724..53b07c69711 100644 --- a/reactos/lib/rtl/i386/except_asm.s +++ b/reactos/lib/rtl/i386/except_asm.s @@ -9,8 +9,13 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include + +EXTERN _RtlpCheckForActiveDebugger@0:PROC +EXTERN _RtlDispatchException@8:PROC +EXTERN _ZwContinue@8:PROC +EXTERN _ZwRaiseException@12:PROC #define ExceptionContinueSearch 1 #define ExceptionNestedException 2 @@ -18,17 +23,17 @@ /* FUNCTIONS *****************************************************************/ -.func RtlpGetExceptionList@0 -.globl _RtlpGetExceptionList@0 +.code + +PUBLIC _RtlpGetExceptionList@0 _RtlpGetExceptionList@0: /* Return the exception list */ mov eax, fs:[TEB_EXCEPTION_LIST] ret -.endfunc -.func RtlpSetExceptionList@4 -.globl _RtlpSetExceptionList@4 + +PUBLIC _RtlpSetExceptionList@4 _RtlpSetExceptionList@4: /* Get the new list */ @@ -40,10 +45,9 @@ _RtlpSetExceptionList@4: /* Return */ ret 4 -.endfunc -.func RtlCaptureContext@4 -.globl _RtlCaptureContext@4 + +PUBLIC _RtlCaptureContext@4 _RtlCaptureContext@4: /* Preserve EBX and put the context in it */ @@ -61,10 +65,9 @@ _RtlCaptureContext@4: /* Capture the other regs */ jmp CaptureRest -.endfunc -.func RtlpCaptureContext@4 -.globl _RtlpCaptureContext@4 + +PUBLIC _RtlpCaptureContext@4 _RtlpCaptureContext@4: /* Preserve EBX and put the context in it */ @@ -107,10 +110,9 @@ CaptureRest: /* Return to the caller */ pop ebx ret 4 -.endfunc -.func RtlpExecuteHandlerForException@20 -.globl _RtlpExecuteHandlerForException@20 + +PUBLIC _RtlpExecuteHandlerForException@20 _RtlpExecuteHandlerForException@20: /* Copy the routine in EDX */ @@ -118,16 +120,14 @@ _RtlpExecuteHandlerForException@20: /* Jump to common routine */ jmp _RtlpExecuteHandler@20 -.endfunc -.func RtlpExecuteHandlerForUnwind@20 -.globl _RtlpExecuteHandlerForUnwind@20 + +PUBLIC _RtlpExecuteHandlerForUnwind@20 _RtlpExecuteHandlerForUnwind@20: /* Copy the routine in EDX */ mov edx, offset _RtlpUnwindProtector -.endfunc -.func RtlpExecuteHandler@20 + _RtlpExecuteHandler@20: /* Save non-volatile */ @@ -142,22 +142,21 @@ _RtlpExecuteHandler@20: xor edi, edi /* Call the 2nd-stage executer */ - push [esp+0x20] - push [esp+0x20] - push [esp+0x20] - push [esp+0x20] - push [esp+0x20] + push [esp+32] + push [esp+32] + push [esp+32] + push [esp+32] + push [esp+32] call _RtlpExecuteHandler2@20 /* Restore non-volatile */ pop edi pop esi pop ebx - ret 0x14 -.endfunc + ret 20 + -.func RtlpExecuteHandler2@20 -.globl _RtlpExecuteHandler2@20 +PUBLIC _RtlpExecuteHandler2@20 _RtlpExecuteHandler2@20: /* Set up stack frame */ @@ -165,7 +164,7 @@ _RtlpExecuteHandler2@20: mov ebp, esp /* Save the Frame */ - push [ebp+0xC] + push [ebp+12] /* Push handler address */ push edx @@ -177,11 +176,11 @@ _RtlpExecuteHandler2@20: mov [fs:TEB_EXCEPTION_LIST], esp /* Call the handler */ - push [ebp+0x14] - push [ebp+0x10] - push [ebp+0xC] + push [ebp+20] + push [ebp+16] + push [ebp+12] push [ebp+8] - mov ecx, [ebp+0x18] + mov ecx, [ebp+24] call ecx /* Unlink us */ @@ -193,10 +192,9 @@ _RtlpExecuteHandler2@20: /* Undo stack frame and return */ mov esp, ebp pop ebp - ret 0x14 -.endfunc + ret 20 + -.func RtlpExceptionProtector _RtlpExceptionProtector: /* Assume we'll continue */ @@ -222,9 +220,8 @@ _RtlpExceptionProtector: return: ret 16 -.endfunc -.func RtlpUnwindProtector + _RtlpUnwindProtector: /* Assume we'll continue */ @@ -250,10 +247,9 @@ _RtlpUnwindProtector: .return: ret 16 -.endfunc -.func RtlRaiseException@4 -.globl _RtlRaiseException@4 + +PUBLIC _RtlRaiseException@4 _RtlRaiseException@4: /* Set up stack frame */ @@ -325,10 +321,9 @@ RaiseStatus1: /* If we returned, raise a status */ push eax call _RtlRaiseStatus@4 -.endfunc -.func RtlRaiseStatus@4 -.globl _RtlRaiseStatus@4 + +PUBLIC _RtlRaiseStatus@4 _RtlRaiseStatus@4: /* Set up stack frame */ @@ -398,4 +393,5 @@ RaiseStatus2: /* If we returned, raise a status */ push eax call _RtlRaiseStatus@4 -.endfunc + +END diff --git a/reactos/lib/rtl/i386/interlck.S b/reactos/lib/rtl/i386/interlck.S index 5b95e4c5429..7ad7a085216 100644 --- a/reactos/lib/rtl/i386/interlck.S +++ b/reactos/lib/rtl/i386/interlck.S @@ -6,20 +6,20 @@ * PROGRAMMERS: Timo Kreuzer */ -.intel_syntax noprefix +#include /* FUNCTIONS ****************************************************************/ - +.code /* PSLIST_ENTRY * NTAPI * RtlInterlockedPopEntrySList( * IN PSLIST_HEADER ListHead); */ -.global _ExpInterlockedPopEntrySListResume@0 -.global _ExpInterlockedPopEntrySListEnd@0 -.global _ExpInterlockedPopEntrySListFault@0 -.global _RtlInterlockedPopEntrySList@4 +PUBLIC _ExpInterlockedPopEntrySListResume@0 +PUBLIC _ExpInterlockedPopEntrySListEnd@0 +PUBLIC _ExpInterlockedPopEntrySListFault@0 +PUBLIC _RtlInterlockedPopEntrySList@4 _RtlInterlockedPopEntrySList@4: /* Save registers */ @@ -35,10 +35,9 @@ _ExpInterlockedPopEntrySListResume@0: /* Load ListHead->Depth and ListHead->Sequence into edx */ mov edx, [ebp + 4] -1: /* Check if ListHead->Next is NULL */ or eax, eax - jz 2f + jz _ExpInterlockedPopEntrySList2 /* Copy Depth and Sequence number and adjust Depth */ lea ecx, [edx - 1] @@ -54,7 +53,7 @@ _ExpInterlockedPopEntrySListEnd@0: jnz _ExpInterlockedPopEntrySListResume@0 /* Restore registers and return */ -2: +_ExpInterlockedPopEntrySList2: pop ebp pop ebx ret 4 @@ -66,7 +65,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSLIST_HEADER ListHead, * IN PSLIST_ENTRY ListEntry); */ -.global _RtlInterlockedPushEntrySList@8 +PUBLIC _RtlInterlockedPushEntrySList@8 _RtlInterlockedPushEntrySList@8: /* Save registers */ @@ -85,18 +84,18 @@ _RtlInterlockedPushEntrySList@8: /* Load ListHead->Depth and ListHead->Sequence into edx */ mov edx, [ebp + 4] -1: +_RtlpInterlockedPushEntrySListResume: /* Set ListEntry->Next to ListHead->Next */ mov [ebx], eax /* Copy ListHead->Depth and ListHead->Sequence and adjust them */ - lea ecx, [edx + 0x10001] + lea ecx, [edx + HEX(10001)] /* If [ebp] equals edx:eax, exchange it with ecx:ebx */ LOCK cmpxchg8b qword ptr [ebp] /* If not equal, retry with edx:eax, being the content of [ebp] now */ - jnz 1b + jnz _RtlpInterlockedPushEntrySListResume /* Restore registers and return */ pop ebp @@ -109,7 +108,7 @@ _RtlInterlockedPushEntrySList@8: * RtlInterlockedFlushSList( * IN PSINGLE_LIST_ENTRY ListHead); */ -.global _RtlInterlockedFlushSList@4 +PUBLIC _RtlInterlockedFlushSList@4 _RtlInterlockedFlushSList@4: /* Save registers */ @@ -128,10 +127,10 @@ _RtlInterlockedFlushSList@4: /* Load ListHead->Depth and ListHead->Sequence into edx */ mov edx, [ebp + 4] -1: +_RtlpInterlockedFlushSListResume: /* Check if ListHead->Next is NULL */ or eax, eax - jz 2f + jz _RtlpInterlockedFlushSListEnd /* Copy Depth and Sequence number to ecx */ mov ecx, edx @@ -143,10 +142,12 @@ _RtlInterlockedFlushSList@4: LOCK cmpxchg8b qword ptr [ebp] /* If not equal, retry with edx:eax, being the content of [ebp] now */ - jnz 1b + jnz _RtlpInterlockedFlushSListResume /* Restore registers and return */ -2: +_RtlpInterlockedFlushSListEnd: pop ebp pop ebx ret 4 + +END diff --git a/reactos/lib/rtl/i386/res_asm.s b/reactos/lib/rtl/i386/res_asm.s index 46c61e08d42..5af744c2308 100644 --- a/reactos/lib/rtl/i386/res_asm.s +++ b/reactos/lib/rtl/i386/res_asm.s @@ -1,11 +1,22 @@ -#include -.intel_syntax noprefix +/* + * COPYRIGHT: GNU GPL - See COPYING in the top level directory + * PROJECT: ReactOS Run-Time Library + * PURPOSE: + * FILE: lib/rtl/i386/res_asm.S + * PROGRAMER: + */ + +#include +#include + +EXTERN _LdrpAccessResource@16:PROC /* * On x86, Shrinker, an executable compressor, depends on the * "call access_resource" instruction being there. */ -.globl _LdrAccessResource@16 +.code +PUBLIC _LdrAccessResource@16 _LdrAccessResource@16: push ebp mov ebp, esp @@ -18,3 +29,5 @@ _LdrAccessResource@16: call _LdrpAccessResource@16 leave ret 16 + +END diff --git a/reactos/lib/rtl/i386/rtlmem.s b/reactos/lib/rtl/i386/rtlmem.s index dea3b6d920d..d26f5b4ec52 100644 --- a/reactos/lib/rtl/i386/rtlmem.s +++ b/reactos/lib/rtl/i386/rtlmem.s @@ -1,26 +1,26 @@ /* - * COPYRIGHT: See COPYING in the top level directory + * COPYRIGHT: GNU GPL - See COPYING in the top level directory * PROJECT: ReactOS Run-Time Library * PURPOSE: Memory functions * FILE: lib/rtl/i386/rtlswap.S * PROGRAMER: Alex Ionescu (alex.ionescu@reactos.org) */ -.intel_syntax noprefix +#include /* GLOBALS *******************************************************************/ -.globl _RtlCompareMemory@12 -.globl _RtlCompareMemoryUlong@12 -.globl _RtlFillMemory@12 -.globl _RtlFillMemoryUlong@12 -.globl _RtlMoveMemory@12 -.globl _RtlZeroMemory@8 -.globl @RtlPrefetchMemoryNonTemporal@8 +PUBLIC _RtlCompareMemory@12 +PUBLIC _RtlCompareMemoryUlong@12 +PUBLIC _RtlFillMemory@12 +PUBLIC _RtlFillMemoryUlong@12 +PUBLIC _RtlMoveMemory@12 +PUBLIC _RtlZeroMemory@8 +PUBLIC @RtlPrefetchMemoryNonTemporal@8 /* FUNCTIONS *****************************************************************/ +.code -.func RtlCompareMemory@12 _RtlCompareMemory@12: /* Save volatiles */ @@ -74,9 +74,8 @@ NotEqual2: pop edi pop esi ret 12 -.endfunc -.func RtlCompareMemoryUlong@12 + _RtlCompareMemoryUlong@12: /* Get pointers and size in ULONGs */ @@ -97,9 +96,8 @@ Done: mov eax, edi pop edi ret 12 -.endfunc -.func RtlFillMemory@12 + _RtlFillMemory@12: /* Get pointers and size */ @@ -134,9 +132,8 @@ ByteFill: rep stosb pop edi ret 12 -.endfunc -.func RtlFillMemoryUlong@12 + _RtlFillMemoryUlong@12: /* Get pointer, size and pattern */ @@ -150,9 +147,8 @@ _RtlFillMemoryUlong@12: rep stosd pop edi ret 12 -.endfunc -.func RtlFillMemoryUlonglong@16 + _RtlFillMemoryUlonglong@16: /* Save volatiles */ @@ -179,9 +175,8 @@ _RtlFillMemoryUlonglong@16: pop esi pop edi ret 16 -.endfunc -.func RtlZeroMemory@8 + _RtlZeroMemory@8: /* Get pointers and size */ @@ -212,9 +207,8 @@ ByteZero: rep stosb pop edi ret 8 -.endfunc -.func RtlMoveMemory@12 + _RtlMoveMemory@12: /* Save volatiles */ @@ -280,9 +274,8 @@ Overlap: rep movsb cld jmp DoneMove -.endfunc -.func @RtlPrefetchMemoryNonTemporal@8, @RtlPrefetchMemoryNonTemporal@8 + @RtlPrefetchMemoryNonTemporal@8: /* @@ -306,8 +299,10 @@ FetchLine: /* Keep looping for the next line, or return if done */ ja FetchLine ret -.endfunc + /* FIXME: HACK */ _Ke386CacheAlignment: - .long 0x40 + .long 64 + +END diff --git a/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s b/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s index 4008d4f5eab..b1486dea898 100644 --- a/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s +++ b/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s @@ -8,11 +8,10 @@ /* INCLUDES ******************************************************************/ -#include +#include -.intel_syntax noprefix -.global MsgUnimplemented +PUBLIC MsgUnimplemented MsgUnimplemented: .asciz "WARNING: %s at %s:%d is UNIMPLEMENTED!\n" @@ -27,4 +26,5 @@ MsgUnimplemented: ret .endp +END /* EOF */ diff --git a/reactos/lib/sdk/crt/except/amd64/seh.s b/reactos/lib/sdk/crt/except/amd64/seh.s index e784457e9f8..9d44d3ffd4d 100644 --- a/reactos/lib/sdk/crt/except/amd64/seh.s +++ b/reactos/lib/sdk/crt/except/amd64/seh.s @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include #define DISPOSITION_DISMISS 0 #define DISPOSITION_CONTINUE_SEARCH 1 @@ -54,3 +54,5 @@ _except_handler2: _except_handler3: ret .endfunc + +END diff --git a/reactos/lib/sdk/crt/except/i386/chkstk_asm.s b/reactos/lib/sdk/crt/except/i386/chkstk_asm.s index 5104a35b1c4..58879f18d0f 100644 --- a/reactos/lib/sdk/crt/except/i386/chkstk_asm.s +++ b/reactos/lib/sdk/crt/except/i386/chkstk_asm.s @@ -7,8 +7,43 @@ * PROGRAMER: KJK::Hyperion */ -.globl __chkstk -.globl __alloca_probe +#include +#include + +#define PAGE_SIZE 4096 + +PUBLIC __chkstk +PUBLIC __alloca_probe +PUBLIC __alloca_probe_16 +.code + + /* 16 byte aligned alloca probe + * EAX = size to be allocated */ +__alloca_probe_16: + /* save the ECX register */ + push ecx + + /* ecx = top of the previous stack frame */ + lea ecx, [esp + 8] + + /* Calculate end of allocation */ + sub ecx, eax + + /* Get the misalignment */ + and ecx, 15 + + /* Add the misalignment to the original alloc size */ + add eax, ecx + + /* Check for overflow */ + jnc l1 + + /* Set maximum value */ + mov eax, HEX(0ffffffff) +l1: + /* Restore ecx */ + pop ecx + /* Fall through to __chkstk */ /* _chkstk() is called by all stack allocations of more than 4 KB. It grows the @@ -18,49 +53,49 @@ __chkstk: __alloca_probe: -/* EAX = size to be allocated */ -/* save the ECX register */ - pushl %ecx + /* EAX = size to be allocated */ + /* save the ECX register */ + push ecx -/* ECX = top of the previous stack frame */ - leal 8(%esp), %ecx + /* ECX = top of the previous stack frame */ + lea ecx, [esp + 8] -/* probe the desired memory, page by page */ - cmpl $0x1000, %eax - jge .l_MoreThanAPage - jmp .l_LessThanAPage + /* probe the desired memory, page by page */ + cmp eax, PAGE_SIZE + jl .l_LessThanAPage .l_MoreThanAPage: -/* raise the top of the stack by a page and probe */ - subl $0x1000, %ecx - testl %eax, 0(%ecx) + /* raise the top of the stack by a page and probe */ + sub ecx, PAGE_SIZE + test [ecx], eax -/* loop if still more than a page must be probed */ - subl $0x1000, %eax - cmpl $0x1000, %eax - jge .l_MoreThanAPage + /* loop if still more than a page must be probed */ + sub eax, PAGE_SIZE + cmp eax, PAGE_SIZE + jge .l_MoreThanAPage .l_LessThanAPage: -/* raise the top of the stack by EAX bytes (size % 4096) and probe */ - subl %eax, %ecx - testl %eax, 0(%ecx) + /* raise the top of the stack by EAX bytes (size % 4096) and probe */ + sub ecx, eax + test [ecx], eax -/* EAX = top of the stack */ - movl %esp, %eax + /* EAX = top of the stack */ + mov eax, esp -/* allocate the memory */ - movl %ecx, %esp + /* allocate the memory */ + mov esp, ecx -/* restore ECX */ - movl 0(%eax), %ecx + /* restore ECX */ + mov ecx, [eax] -/* restore the return address */ - movl 4(%eax), %eax - pushl %eax + /* restore the return address */ + mov eax, [eax + 4] + push eax -/* return */ - ret + /* return */ + ret /* EOF */ +END diff --git a/reactos/lib/sdk/crt/except/i386/prolog.s b/reactos/lib/sdk/crt/except/i386/prolog.s index 5ff588d6746..ebbf4ee412d 100644 --- a/reactos/lib/sdk/crt/except/i386/prolog.s +++ b/reactos/lib/sdk/crt/except/i386/prolog.s @@ -8,20 +8,23 @@ /* INCLUDES ******************************************************************/ -#include +#include +#include -/* GLOBALS *******************************************************************/ - -.globl __EH_prolog +/* FUNCTIONS *****************************************************************/ +.code +PUBLIC __EH_prolog // Copied from Wine. __EH_prolog: - pushl $-1 - pushl %eax - pushl %fs:0 - movl %esp, %fs:0 - movl 12(%esp), %eax - movl %ebp, 12(%esp) - leal 12(%esp), %ebp - pushl %eax + push -1 + push eax + push fs:0 + mov fs:0, esp + mov eax, [esp + 12] + mov [esp + 12], ebp + lea ebp, [esp + 12] + push eax ret + +END diff --git a/reactos/lib/sdk/crt/except/i386/seh.s b/reactos/lib/sdk/crt/except/i386/seh.s index 15a8cc5777a..6fde1e181f7 100644 --- a/reactos/lib/sdk/crt/except/i386/seh.s +++ b/reactos/lib/sdk/crt/except/i386/seh.s @@ -8,24 +8,29 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include #define DISPOSITION_DISMISS 0 #define DISPOSITION_CONTINUE_SEARCH 1 #define DISPOSITION_COLLIDED_UNWIND 3 +#define EXCEPTION_EXIT_UNWIND 4 +#define EXCEPTION_UNWINDING 2 + + +EXTERN _RtlUnwind@16:PROC + /* GLOBALS *******************************************************************/ -.globl __global_unwind2 -.globl __local_unwind2 -.globl __abnormal_termination -.globl __except_handler2 -.globl __except_handler3 +PUBLIC __global_unwind2 +PUBLIC __local_unwind2 +PUBLIC __abnormal_termination +PUBLIC __except_handler2 +PUBLIC __except_handler3 /* FUNCTIONS *****************************************************************/ -.func unwind_handler +.code _unwind_handler: /* Check if we were unwinding and continue search if not */ @@ -56,9 +61,8 @@ _unwind_handler: unwind_handler_return: ret -.endfunc -.func _global_unwind2 + __global_unwind2: /* Create stack and save all registers */ @@ -85,9 +89,8 @@ glu_return: mov esp, ebp pop ebp ret -.endfunc -.func _abnormal_termination + __abnormal_termination: /* Assume false */ @@ -112,9 +115,8 @@ __abnormal_termination: /* Return */ ab_return: ret -.endfunc -.func _local_unwind2 + __local_unwind2: /* Save volatiles */ @@ -175,9 +177,8 @@ unwind_return: pop esi pop ebx ret -.endfunc -.func _except_handler2 + __except_handler2: /* Setup stack and save volatiles */ @@ -256,7 +257,7 @@ except_loop2: mov [ebx+12], eax /* Call except handler */ - call [edi+ecx*4+8] + call dword ptr [edi+ecx*4+8] except_continue2: /* Reload try level and except again */ @@ -297,9 +298,8 @@ except_return2: mov esp, ebp pop ebp ret -.endfunc -.func _except_handler3 + __except_handler3: /* Setup stack and save volatiles */ @@ -437,4 +437,5 @@ except_return3: mov esp, ebp pop ebp ret -.endfunc + +END diff --git a/reactos/lib/sdk/crt/float/i386/logb.c b/reactos/lib/sdk/crt/float/i386/logb.c index 0c02c0e0f11..e4b61949fc4 100644 --- a/reactos/lib/sdk/crt/float/i386/logb.c +++ b/reactos/lib/sdk/crt/float/i386/logb.c @@ -30,7 +30,7 @@ double _logb (double __x) ("fxtract\n\t" : "=t" (__junk), "=u" (__val) : "0" (__x)); #else -#error REVIEW ME +#pragma message ("REVIEW ME") __asm fld [__x]; __asm fxtract; __asm fstp st(0); diff --git a/reactos/lib/sdk/crt/math/amd64/alldiv.S b/reactos/lib/sdk/crt/math/amd64/alldiv.S index 831ef50981b..b4018cc4739 100644 --- a/reactos/lib/sdk/crt/math/amd64/alldiv.S +++ b/reactos/lib/sdk/crt/math/amd64/alldiv.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/atan.S b/reactos/lib/sdk/crt/math/amd64/atan.S index 3ba194931f4..889f10e2825 100644 --- a/reactos/lib/sdk/crt/math/amd64/atan.S +++ b/reactos/lib/sdk/crt/math/amd64/atan.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/atan2.S b/reactos/lib/sdk/crt/math/amd64/atan2.S index 7cd29b93269..fd611101f0a 100644 --- a/reactos/lib/sdk/crt/math/amd64/atan2.S +++ b/reactos/lib/sdk/crt/math/amd64/atan2.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/ceil.S b/reactos/lib/sdk/crt/math/amd64/ceil.S index dbee413f491..17ae0150717 100644 --- a/reactos/lib/sdk/crt/math/amd64/ceil.S +++ b/reactos/lib/sdk/crt/math/amd64/ceil.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/ceilf.S b/reactos/lib/sdk/crt/math/amd64/ceilf.S index e3a948fff8a..2b2d14b03f0 100644 --- a/reactos/lib/sdk/crt/math/amd64/ceilf.S +++ b/reactos/lib/sdk/crt/math/amd64/ceilf.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -17,24 +17,30 @@ PUBLIC ceilf ceilf: + sub rsp, 16 + /* Put parameter on the stack */ - movss [rsp - 0x10], xmm0 - fld dword ptr [rsp] + movss [rsp], xmm0 + fld dword ptr [rsp] /* Change fpu control word to round up */ - fstcw [rsp - 0x10] - mov eax, [rsp - 0x10] - or eax, 0x00800 - and eax, 0x0fbff - mov [rsp - 0x08], eax - fldcw [rsp - 0x08] + fstcw [rsp + 8] + mov eax, [rsp + 8] + or eax, HEX(00800) + and eax, HEX(0fbff) + mov [rsp + 12], eax + fldcw [rsp + 12] /* Round to integer */ frndint /* Restore fpu control word */ - fldcw [rsp - 0x10] + fldcw [rsp + 8] - fstp dword ptr [rsp - 0x10] - movss xmm0, [rsp - 0x10] + fstp dword ptr [rsp] + movss xmm0, [rsp] + + add rsp, 16 ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/exp.S b/reactos/lib/sdk/crt/math/amd64/exp.S index ca3dc993182..44b324e4267 100644 --- a/reactos/lib/sdk/crt/math/amd64/exp.S +++ b/reactos/lib/sdk/crt/math/amd64/exp.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -20,3 +20,4 @@ exp: UNIMPLEMENTED exp ret +END diff --git a/reactos/lib/sdk/crt/math/amd64/fabs.S b/reactos/lib/sdk/crt/math/amd64/fabs.S index e58b960ecab..3c1e8f2dcf1 100644 --- a/reactos/lib/sdk/crt/math/amd64/fabs.S +++ b/reactos/lib/sdk/crt/math/amd64/fabs.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/floor.S b/reactos/lib/sdk/crt/math/amd64/floor.S index f1c3b9305af..c0fba3dd066 100644 --- a/reactos/lib/sdk/crt/math/amd64/floor.S +++ b/reactos/lib/sdk/crt/math/amd64/floor.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -19,3 +19,5 @@ PUBLIC floor floor: UNIMPLEMENTED floor ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/floorf.S b/reactos/lib/sdk/crt/math/amd64/floorf.S index e2d02202df7..0ac9098b9a3 100644 --- a/reactos/lib/sdk/crt/math/amd64/floorf.S +++ b/reactos/lib/sdk/crt/math/amd64/floorf.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -17,24 +17,29 @@ PUBLIC floorf floorf: + sub rsp, 16 + /* Put parameter on the stack */ - movss [rsp - 0x10], xmm0 + movss [rsp], xmm0 fld dword ptr [rsp] /* Change fpu control word to round down */ - fstcw [rsp - 0x10] - mov eax, [rsp - 0x10] + fstcw [rsp] + mov eax, [rsp] or eax, 0x00400 and eax, 0x0f7ff - mov [rsp - 0x08], eax - fldcw [rsp - 0x08] + mov [rsp + 8], eax + fldcw [rsp + 8] /* Round to integer */ frndint /* Restore fpu control word */ - fldcw [rsp - 0x10] + fldcw [rsp] - fstp dword ptr [rsp - 0x10] - movss xmm0, [rsp - 0x10] + fstp dword ptr [rsp] + movss xmm0, [rsp] + add rsp, 16 ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/fmod.S b/reactos/lib/sdk/crt/math/amd64/fmod.S index 4ca67f55bfb..697257ab368 100644 --- a/reactos/lib/sdk/crt/math/amd64/fmod.S +++ b/reactos/lib/sdk/crt/math/amd64/fmod.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ @@ -17,3 +16,5 @@ PUBLIC fmod fmod: UNIMPLEMENTED fmod ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/fmodf.S b/reactos/lib/sdk/crt/math/amd64/fmodf.S index e109c387cc8..d0e24ef9529 100644 --- a/reactos/lib/sdk/crt/math/amd64/fmodf.S +++ b/reactos/lib/sdk/crt/math/amd64/fmodf.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ @@ -17,3 +16,5 @@ PUBLIC fmodf fmodf: UNIMPLEMENTED fmodf ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/ldexp.S b/reactos/lib/sdk/crt/math/amd64/ldexp.S index d0265629bf6..a83660ae7a3 100644 --- a/reactos/lib/sdk/crt/math/amd64/ldexp.S +++ b/reactos/lib/sdk/crt/math/amd64/ldexp.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ @@ -17,3 +16,5 @@ PUBLIC ldexp ldexp: UNIMPLEMENTED ldexp ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/log.S b/reactos/lib/sdk/crt/math/amd64/log.S index 9fa02763b9e..1289a745cba 100644 --- a/reactos/lib/sdk/crt/math/amd64/log.S +++ b/reactos/lib/sdk/crt/math/amd64/log.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/log10.S b/reactos/lib/sdk/crt/math/amd64/log10.S index 007f0d80e98..f8014aa5bc6 100644 --- a/reactos/lib/sdk/crt/math/amd64/log10.S +++ b/reactos/lib/sdk/crt/math/amd64/log10.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/pow.S b/reactos/lib/sdk/crt/math/amd64/pow.S index 37988801b11..48adf3961f3 100644 --- a/reactos/lib/sdk/crt/math/amd64/pow.S +++ b/reactos/lib/sdk/crt/math/amd64/pow.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/sqrt.S b/reactos/lib/sdk/crt/math/amd64/sqrt.S index 758d8768d4f..282419e78a5 100644 --- a/reactos/lib/sdk/crt/math/amd64/sqrt.S +++ b/reactos/lib/sdk/crt/math/amd64/sqrt.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ @@ -17,3 +17,5 @@ PUBLIC sqrt sqrt: UNIMPLEMENTED sqrt ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/sqrtf.S b/reactos/lib/sdk/crt/math/amd64/sqrtf.S index a4ee3fa6cc5..da75fcf42f5 100644 --- a/reactos/lib/sdk/crt/math/amd64/sqrtf.S +++ b/reactos/lib/sdk/crt/math/amd64/sqrtf.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ @@ -17,3 +17,5 @@ PUBLIC sqrtf sqrtf: sqrtss xmm0, xmm0 ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/tan.S b/reactos/lib/sdk/crt/math/amd64/tan.S index a7c66d0ccd7..93e5d01d762 100644 --- a/reactos/lib/sdk/crt/math/amd64/tan.S +++ b/reactos/lib/sdk/crt/math/amd64/tan.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ @@ -17,3 +17,5 @@ PUBLIC tan tan: UNIMPLEMENTED tan ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/alldiv_asm.s b/reactos/lib/sdk/crt/math/i386/alldiv_asm.s index 043a8af95c3..5061fb7c21f 100644 --- a/reactos/lib/sdk/crt/math/i386/alldiv_asm.s +++ b/reactos/lib/sdk/crt/math/i386/alldiv_asm.s @@ -33,18 +33,22 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - - .globl __alldiv - .globl __fltused - + +#include + +PUBLIC __alldiv +PUBLIC __fltused + /* DATA ********************************************************************/ +.data +ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING __fltused: - .long 0x9875 + .long HEX(9875) -.intel_syntax noprefix /* FUNCTIONS ***************************************************************/ +.code // // lldiv - signed long divide @@ -222,3 +226,5 @@ L8: pop edi ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s b/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s index 8f775d6dac3..a055d55d62e 100644 --- a/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s +++ b/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __alldvrm - -.intel_syntax noprefix +#include + +PUBLIC __alldvrm + /* FUNCTIONS ***************************************************************/ +.code __alldvrm: push edi @@ -88,7 +89,7 @@ __alldvrm: mov eax,DVNDHI // hi word of a or eax,eax // test to see if signed - jge short ....L1 // skip rest if a is already positive + jge short .L1 // skip rest if a is already positive inc edi // complement result sign flag inc ebp // complement result sign flag mov edx,DVNDLO // lo word of a @@ -97,10 +98,10 @@ __alldvrm: sbb eax,0 mov DVNDHI,eax // save positive value mov DVNDLO,edx -....L1: +.L1: mov eax,DVSRHI // hi word of b or eax,eax // test to see if signed - jge short ....L2 // skip rest if b is already positive + jge short .L2 // skip rest if b is already positive inc edi // complement the result sign flag mov edx,DVSRLO // lo word of a neg eax // make b positive @@ -108,7 +109,7 @@ __alldvrm: sbb eax,0 mov DVSRHI,eax // save positive value mov DVSRLO,edx -....L2: +.L2: // // Now do the divide. First look to see if the divisor is less than 4194304K. @@ -119,7 +120,7 @@ __alldvrm: // or eax,eax // check to see if divisor < 4194304K - jnz short ....L3 // nope, gotta do this the hard way + jnz short .L3 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -137,24 +138,24 @@ __alldvrm: mov eax,esi // set up low word of quotient mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR add edx,ecx // EDX:EAX = QUOT * DVSR - jmp short ....L4 // complete remainder calculation + jmp short .L4 // complete remainder calculation // // Here we do it the hard way. Remember, eax contains the high word of DVSR // -....L3: +.L3: mov ebx,eax // ebx:ecx <- divisor mov ecx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -....L5: +.L5: shr ebx,1 // shift divisor right one bit rcr ecx,1 shr edx,1 // shift dividend right one bit rcr eax,1 or ebx,ebx - jnz short ....L5 // loop until divisor < 4194304K + jnz short .L5 // loop until divisor < 4194304K div ecx // now divide, ignore remainder mov esi,eax // save quotient @@ -170,7 +171,7 @@ __alldvrm: mov eax,DVSRLO mul esi // QUOT * DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short ....L6 // carry means Quotient is off by 1 + jc short .L6 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -179,18 +180,18 @@ __alldvrm: // cmp edx,DVNDHI // compare hi words of result and original - ja short ....L6 // if result > original, do subtract - jb short ....L7 // if result < original, we are ok + ja short .L6 // if result > original, do subtract + jb short .L7 // if result < original, we are ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short ....L7 // if less or equal we are ok, else subtract -....L6: + jbe short .L7 // if less or equal we are ok, else subtract +.L6: dec esi // subtract 1 from quotient sub eax,DVSRLO // subtract divisor from result sbb edx,DVSRHI -....L7: +.L7: xor ebx,ebx // ebx:esi <- quotient -....L4: +.L4: // // Calculate remainder by subtracting the result from the original dividend. // Since the result is already in a register, we will do the subtract in the @@ -208,7 +209,7 @@ __alldvrm: // dec ebp // check result sign flag - jns short ....L9 // result is ok, set up the quotient + jns short .L9 // result is ok, set up the quotient neg edx // otherwise, negate the result neg eax sbb edx,0 @@ -216,7 +217,7 @@ __alldvrm: // // Now we need to get the quotient into edx:eax and the remainder into ebx:ecx. // -....L9: +.L9: mov ecx,edx mov edx,ebx mov ebx,ecx @@ -229,7 +230,7 @@ __alldvrm: // dec edi // check to see if result is negative - jnz short ....L8 // if EDI == 0, result should be negative + jnz short .L8 // if EDI == 0, result should be negative neg edx // otherwise, negate the result neg eax sbb edx,0 @@ -238,9 +239,11 @@ __alldvrm: // Restore the saved registers and return. // -....L8: +.L8: pop ebp pop esi pop edi ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/allmul_asm.s b/reactos/lib/sdk/crt/math/i386/allmul_asm.s index ddfa7cf7b46..b9a47baafcc 100644 --- a/reactos/lib/sdk/crt/math/i386/allmul_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allmul_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allmul -.intel_syntax noprefix +#include + +PUBLIC __allmul /* FUNCTIONS ***************************************************************/ +.code // // llmul - long multiply routine @@ -113,3 +114,4 @@ hard: ret 16 // callee restores the stack +END diff --git a/reactos/lib/sdk/crt/math/i386/allrem_asm.s b/reactos/lib/sdk/crt/math/i386/allrem_asm.s index a8e222e25bf..2c3e68c5578 100644 --- a/reactos/lib/sdk/crt/math/i386/allrem_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allrem_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allrem - -.intel_syntax noprefix +#include + +PUBLIC __allrem + /* FUNCTIONS ***************************************************************/ +.code // // llrem - signed long remainder @@ -227,3 +228,5 @@ __allrem : pop ebx ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/allshl_asm.s b/reactos/lib/sdk/crt/math/i386/allshl_asm.s index b5d574aff01..48d06b7dd5a 100644 --- a/reactos/lib/sdk/crt/math/i386/allshl_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allshl_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allshl -.intel_syntax noprefix +#include + +PUBLIC __allshl /* FUNCTIONS ***************************************************************/ +.code // // llshl - long shift left @@ -92,3 +93,5 @@ RETZERO: xor eax,eax xor edx,edx ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/allshr_asm.s b/reactos/lib/sdk/crt/math/i386/allshr_asm.s index 575fc92db9a..e2b60bd97aa 100644 --- a/reactos/lib/sdk/crt/math/i386/allshr_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allshr_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allshr - -.intel_syntax noprefix +#include + +PUBLIC __allshr + /* FUNCTIONS ***************************************************************/ +.code // // llshr - long shift right @@ -93,3 +94,5 @@ __allshr: sar edx,31 mov eax,edx ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/atan2_asm.s b/reactos/lib/sdk/crt/math/i386/atan2_asm.s new file mode 100644 index 00000000000..699b02d3530 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/atan2_asm.s @@ -0,0 +1,18 @@ + +#include + +PUBLIC _atan2 + +.code +_atan2: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fld qword ptr [ebp + 16] + fpatan + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/atan_asm.s b/reactos/lib/sdk/crt/math/i386/atan_asm.s index 37554c940ae..9cd08752369 100644 --- a/reactos/lib/sdk/crt/math/i386/atan_asm.s +++ b/reactos/lib/sdk/crt/math/i386/atan_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _atan - -.intel_syntax noprefix +#include + +PUBLIC _atan + /* FUNCTIONS ***************************************************************/ +.code _atan: push ebp @@ -48,3 +49,5 @@ _atan: fpatan // Take the arctangent pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s b/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s index 565914eb87b..b3a08787c1c 100644 --- a/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - - .globl __aulldiv -.intel_syntax noprefix +#include + +PUBLIC __aulldiv /* FUNCTIONS ***************************************************************/ +.code // // ulldiv - unsigned long divide @@ -105,7 +106,7 @@ __aulldiv: mov eax,DVSRHI // check to see if divisor < 4194304K or eax,eax - jnz short ..L1 // nope, gotta do this the hard way + jnz short .L1 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -114,24 +115,24 @@ __aulldiv: mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend div ecx // get low order bits of quotient mov edx,ebx // edx:eax <- quotient hi:quotient lo - jmp short ..L2 // restore stack and return + jmp short .L2 // restore stack and return // // Here we do it the hard way. Remember, eax contains DVSRHI // -..L1: +.L1: mov ecx,eax // ecx:ebx <- divisor mov ebx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -..L3: +.L3: shr ecx,1 // shift divisor right one bit// hi bit <- 0 rcr ebx,1 shr edx,1 // shift dividend right one bit// hi bit <- 0 rcr eax,1 or ecx,ecx - jnz short ..L3 // loop until divisor < 4194304K + jnz short .L3 // loop until divisor < 4194304K div ebx // now divide, ignore remainder mov esi,eax // save quotient @@ -147,7 +148,7 @@ __aulldiv: mov eax,DVSRLO mul esi // QUOT * DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short ..L4 // carry means Quotient is off by 1 + jc short .L4 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -156,13 +157,13 @@ __aulldiv: // cmp edx,DVNDHI // compare hi words of result and original - ja short ..L4 // if result > original, do subtract - jb short ..L5 // if result < original, we are ok + ja short .L4 // if result > original, do subtract + jb short .L5 // if result < original, we are ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short ..L5 // if less or equal we are ok, else subtract -..L4: + jbe short .L5 // if less or equal we are ok, else subtract +.L4: dec esi // subtract 1 from quotient -..L5: +.L5: xor edx,edx // edx:eax <- quotient mov eax,esi @@ -171,9 +172,11 @@ __aulldiv: // Restore the saved registers and return. // -..L2: +.L2: pop esi pop ebx ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s b/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s index 6f7de08f2b2..ed1d4a10832 100644 --- a/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __aulldvrm - -.intel_syntax noprefix +#include + +PUBLIC __aulldvrm + /* FUNCTIONS ***************************************************************/ +.code __aulldvrm: @@ -101,7 +102,7 @@ __aulldvrm: mov eax,DVSRHI // check to see if divisor < 4194304K or eax,eax - jnz short .....L1 // nope, gotta do this the hard way + jnz short .L1 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -120,24 +121,24 @@ __aulldvrm: mov eax,esi // set up low word of quotient mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR add edx,ecx // EDX:EAX = QUOT * DVSR - jmp short .....L2 // complete remainder calculation + jmp short .L2 // complete remainder calculation // // Here we do it the hard way. Remember, eax contains DVSRHI // -.....L1: +.L1: mov ecx,eax // ecx:ebx <- divisor mov ebx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -.....L3: +.L3: shr ecx,1 // shift divisor right one bit// hi bit <- 0 rcr ebx,1 shr edx,1 // shift dividend right one bit// hi bit <- 0 rcr eax,1 or ecx,ecx - jnz short .....L3 // loop until divisor < 4194304K + jnz short .L3 // loop until divisor < 4194304K div ebx // now divide, ignore remainder mov esi,eax // save quotient @@ -153,7 +154,7 @@ __aulldvrm: mov eax,DVSRLO mul esi // QUOT * DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short .....L4 // carry means Quotient is off by 1 + jc short .L4 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -162,18 +163,18 @@ __aulldvrm: // cmp edx,DVNDHI // compare hi words of result and original - ja short .....L4 // if result > original, do subtract - jb short .....L5 // if result < original, we are ok + ja short .L4 // if result > original, do subtract + jb short .L5 // if result < original, we are ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short .....L5 // if less or equal we are ok, else subtract -.....L4: + jbe short .L5 // if less or equal we are ok, else subtract +.L4: dec esi // subtract 1 from quotient sub eax,DVSRLO // subtract divisor from result sbb edx,DVSRHI -.....L5: +.L5: xor ebx,ebx // ebx:esi <- quotient -.....L2: +.L2: // // Calculate remainder by subtracting the result from the original dividend. // Since the result is already in a register, we will do the subtract in the @@ -202,3 +203,5 @@ __aulldvrm: pop esi ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/aullrem_asm.s b/reactos/lib/sdk/crt/math/i386/aullrem_asm.s index bfcb0efb2a0..4fde84a01ba 100644 --- a/reactos/lib/sdk/crt/math/i386/aullrem_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aullrem_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __aullrem - -.intel_syntax noprefix +#include + +PUBLIC __aullrem + /* FUNCTIONS ***************************************************************/ +.code // // ullrem - unsigned long remainder @@ -101,7 +102,7 @@ __aullrem: mov eax,DVSRHI // check to see if divisor < 4194304K or eax,eax - jnz short ...L1 // nope, gotta do this the hard way + jnz short .L1 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -110,24 +111,24 @@ __aullrem: div ecx // edx <- final remainder mov eax,edx // edx:eax <- remainder xor edx,edx - jmp short ...L2 // restore stack and return + jmp short .L2 // restore stack and return // // Here we do it the hard way. Remember, eax contains DVSRHI // -...L1: +.L1: mov ecx,eax // ecx:ebx <- divisor mov ebx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -...L3: +.L3: shr ecx,1 // shift divisor right one bit// hi bit <- 0 rcr ebx,1 shr edx,1 // shift dividend right one bit// hi bit <- 0 rcr eax,1 or ecx,ecx - jnz short ...L3 // loop until divisor < 4194304K + jnz short .L3 // loop until divisor < 4194304K div ebx // now divide, ignore remainder // @@ -142,7 +143,7 @@ __aullrem: xchg ecx,eax // put partial product in ECX, get quotient in EAX mul dword ptr DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short ...L4 // carry means Quotient is off by 1 + jc short .L4 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -151,14 +152,14 @@ __aullrem: // cmp edx,DVNDHI // compare hi words of result and original - ja short ...L4 // if result > original, do subtract - jb short ...L5 // if result < original, we're ok + ja short .L4 // if result > original, do subtract + jb short .L5 // if result < original, we're ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short ...L5 // if less or equal we're ok, else subtract -...L4: + jbe short .L5 // if less or equal we're ok, else subtract +.L4: sub eax,DVSRLO // subtract divisor from result sbb edx,DVSRHI -...L5: +.L5: // // Calculate remainder by subtracting the result from the original dividend. @@ -177,8 +178,10 @@ __aullrem: // Restore the saved registers and return. // -...L2: +.L2: pop ebx ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/aullshr_asm.s b/reactos/lib/sdk/crt/math/i386/aullshr_asm.s index 1b9f2af9f2e..5d65f4b2eea 100644 --- a/reactos/lib/sdk/crt/math/i386/aullshr_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aullshr_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __aullshr - -.intel_syntax noprefix +#include + +PUBLIC __aullshr + /* FUNCTIONS ***************************************************************/ +.code // // ullshr - long shift right @@ -65,13 +66,13 @@ __aullshr: // depends only on the high order bit of edx). // cmp cl,64 - jae short ..RETZERO + jae short .RETZERO // // Handle shifts of between 0 and 31 bits // cmp cl, 32 - jae short ..MORE32 + jae short .MORE32 shrd eax,edx,cl shr edx,cl ret @@ -79,7 +80,7 @@ __aullshr: // // Handle shifts of between 32 and 63 bits // -..MORE32: +.MORE32: mov eax,edx xor edx,edx and cl,31 @@ -89,7 +90,9 @@ __aullshr: // // return 0 in edx:eax // -..RETZERO: +.RETZERO: xor eax,eax xor edx,edx ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/ceil_asm.s b/reactos/lib/sdk/crt/math/i386/ceil_asm.s index aad69114f5a..0b6d2ffb7b3 100644 --- a/reactos/lib/sdk/crt/math/i386/ceil_asm.s +++ b/reactos/lib/sdk/crt/math/i386/ceil_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _ceil -.intel_syntax noprefix +#include + +PUBLIC _ceil /* FUNCTIONS ***************************************************************/ +.code _ceil: push ebp @@ -47,7 +48,7 @@ _ceil: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0xb63 // Rounding control word + mov word ptr [ebp-4], HEX(0b63) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +56,5 @@ _ceil: mov esp,ebp // Deallocate temporary space pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/ceilf.S b/reactos/lib/sdk/crt/math/i386/ceilf.S index 9eee272ecb3..79d66ce1cf2 100644 --- a/reactos/lib/sdk/crt/math/i386/ceilf.S +++ b/reactos/lib/sdk/crt/math/i386/ceilf.S @@ -3,53 +3,34 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#include <_mingw_mac.h> - - .file "ceilf.S" - .text - .align 4 -.globl __MINGW_USYMBOL(ceilf) - .def __MINGW_USYMBOL(ceilf); .scl 2; .type 32; .endef -__MINGW_USYMBOL(ceilf): -#ifdef _WIN64 - subq $24,%rsp - movss %xmm0,8(%rsp) - flds 8(%rsp) - - fstcw 4(%rsp) /* store fpu control word */ - - movl $0x0800,%edx /* round towards +oo */ - orl 4(%rsp),%edx - andl $0xfbff,%edx - movl %edx,(%rsp) - fldcw (%rsp) /* load modified control word */ - frndint /* round */ +#include - fldcw 4(%rsp) /* restore original control word */ - fstps 8(%rsp) - movss 8(%rsp),%xmm0 - addq $24,%rsp - ret -#else - flds 4(%esp) - subl $8,%esp +.code +.align 4 + +PUBLIC _ceilf +_ceilf: - fstcw 4(%esp) /* store fpu control word */ + fld dword ptr [esp + 4] + sub esp, 8 + + fstcw [esp + 4] /* store fpu control word */ /* We use here %edx although only the low 1 bits are defined. But none of the operations should care and they are faster than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ + mov edx, [esp + 4] + or edx, HEX(0800) /* round towards +oo */ + and edx, HEX(fbff) + mov [esp], edx + fldcw [esp] /* load modified control word */ frndint /* round */ - fldcw 4(%esp) /* restore original control word */ + fldcw [esp + 4] /* restore original control word */ - addl $8,%esp + add esp, 8 ret -#endif + +END diff --git a/reactos/lib/sdk/crt/math/i386/cos_asm.s b/reactos/lib/sdk/crt/math/i386/cos_asm.s index b1c6ada49b2..7732fe78734 100644 --- a/reactos/lib/sdk/crt/math/i386/cos_asm.s +++ b/reactos/lib/sdk/crt/math/i386/cos_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _cos -.intel_syntax noprefix +#include + +PUBLIC _cos /* FUNCTIONS ***************************************************************/ +.code _cos: push ebp @@ -47,3 +48,5 @@ _cos: fcos // Take the cosine pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/exp_asm.s b/reactos/lib/sdk/crt/math/i386/exp_asm.s new file mode 100644 index 00000000000..3dd5be060b9 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/exp_asm.s @@ -0,0 +1,29 @@ + +#include + +PUBLIC _exp + +/* FUNCTIONS ***************************************************************/ +.code + +_exp: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fldl2e + fmul st, st(1) + fst st(1) + frndint + fxch st(1) + fsub st, st(1) + f2xm1 + fld1 + faddp st(1), st + fscale + fstp st(1) + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/fabs_asm.s b/reactos/lib/sdk/crt/math/i386/fabs_asm.s index 5c6ce9214ef..c121f5205db 100644 --- a/reactos/lib/sdk/crt/math/i386/fabs_asm.s +++ b/reactos/lib/sdk/crt/math/i386/fabs_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _fabs - -.intel_syntax noprefix +#include + +PUBLIC _fabs + /* FUNCTIONS ***************************************************************/ +.code _fabs: push ebp @@ -47,3 +48,5 @@ _fabs: fabs // Take the absolute value pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/floor_asm.s b/reactos/lib/sdk/crt/math/i386/floor_asm.s index f03c85cb4e8..7a2ed174eb3 100644 --- a/reactos/lib/sdk/crt/math/i386/floor_asm.s +++ b/reactos/lib/sdk/crt/math/i386/floor_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _floor - -.intel_syntax noprefix +#include + +PUBLIC _floor + /* FUNCTIONS ***************************************************************/ +.code _floor: push ebp @@ -47,7 +48,7 @@ _floor: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0x763 // Rounding control word + mov word ptr [ebp-4], HEX(0763) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +56,5 @@ _floor: mov esp,ebp pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/floorf.S b/reactos/lib/sdk/crt/math/i386/floorf.S index eec073b2376..99ef5522038 100644 --- a/reactos/lib/sdk/crt/math/i386/floorf.S +++ b/reactos/lib/sdk/crt/math/i386/floorf.S @@ -7,57 +7,34 @@ * Removed header file dependency for use in libmingwex.a by * Danny Smith */ -#include <_mingw_mac.h> - - .file "floorf.S" - .text -#ifdef _WIN64 - .align 8 -#else - .align 4 -#endif -.globl __MINGW_USYMBOL(floorf) - .def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floorf): -#ifdef _WIN64 - subq $24,%rsp - movss %xmm0,8(%rsp) - flds 8(%rsp) - - fstcw 4(%rsp) /* store fpu control word */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%rsp),%edx - andl $0xf7ff,%edx - movl %edx,(%rsp) - fldcw (%rsp) /* load modified control word */ - frndint /* round */ +#include - fldcw 4(%rsp) /* restore original control word */ +.code +.align 4 - fstps 8(%rsp) - movss 8(%rsp),%xmm0 - addq $24,%rsp - ret -#else - flds 4(%esp) - subl $8,%esp +PUBLIC _floorf +_floorf: - fstcw 4(%esp) /* store fpu control word */ + fld dword ptr [esp + 4] + sub esp, 8 + + fstcw [esp + 4] /* store fpu control word */ /* We use here %edx although only the low 1 bits are defined. But none of the operations should care and they are faster than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ + mov edx, [esp + 4] + or edx, HEX(0400) /* round towards -oo */ + and edx, HEX(0f7ff) + mov [esp], edx + fldcw [esp] /* load modified control word */ frndint /* round */ - fldcw 4(%esp) /* restore original control word */ + fldcw [esp + 4] /* restore original control word */ - addl $8,%esp + add esp, 8 ret -#endif + +END diff --git a/reactos/lib/sdk/crt/math/i386/fmod_asm.s b/reactos/lib/sdk/crt/math/i386/fmod_asm.s new file mode 100644 index 00000000000..44be4c0b24a --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/fmod_asm.s @@ -0,0 +1,26 @@ + +#include + +PUBLIC _fmod + +/* FUNCTIONS ***************************************************************/ +.code + +_fmod: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fld qword ptr [ebp + 16] + fxch st(1) +l1: + fprem + fstsw ax + sahf + jp l1 + fstp st(1) + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/fmodf_asm.s b/reactos/lib/sdk/crt/math/i386/fmodf_asm.s new file mode 100644 index 00000000000..1a06ef98671 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/fmodf_asm.s @@ -0,0 +1,26 @@ + +#include + +PUBLIC _fmodf + +/* FUNCTIONS ***************************************************************/ +.code + +_fmodf: + push ebp + mov ebp, esp + + fld dword ptr [esp + 4] + fld dword ptr [esp + 8] + fxch st(1) +l1: + fprem + fstsw ax + sahf + jp l1 + fstp st(1) + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/ftol2_asm.s b/reactos/lib/sdk/crt/math/i386/ftol2_asm.s new file mode 100644 index 00000000000..12f55010312 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/ftol2_asm.s @@ -0,0 +1,28 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Run-Time Library + * FILE: lib/rtl/i386/ftol2.S + * PROGRAMER: + * + */ + +#include + +EXTERN __ftol:PROC +PUBLIC __ftol2 +PUBLIC __ftol2_sse + +/* FUNCTIONS ***************************************************************/ +.code + +/* + * 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. + */ +__ftol2: +__ftol2_sse: + jmp __ftol + +END diff --git a/reactos/lib/sdk/crt/math/i386/ftol_asm.s b/reactos/lib/sdk/crt/math/i386/ftol_asm.s index 4e1445a9988..9942f389f88 100644 --- a/reactos/lib/sdk/crt/math/i386/ftol_asm.s +++ b/reactos/lib/sdk/crt/math/i386/ftol_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __ftol - -.intel_syntax noprefix +#include + +PUBLIC __ftol + /* FUNCTIONS ***************************************************************/ +.code /* * This routine is called by MSVC-generated code to convert from floating point @@ -54,7 +55,7 @@ __ftol: fstcw [ebp-2] wait mov ax, [ebp-2] - or ah, 0xC + or ah, 12 mov [ebp-4], ax fldcw [ebp-4] @@ -71,3 +72,5 @@ __ftol: /* Remove stack frame and return*/ leave ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/log10_asm.s b/reactos/lib/sdk/crt/math/i386/log10_asm.s index 71731816429..a627ace1090 100644 --- a/reactos/lib/sdk/crt/math/i386/log10_asm.s +++ b/reactos/lib/sdk/crt/math/i386/log10_asm.s @@ -7,12 +7,13 @@ * PROGRAMER: Magnus Olsen (magnus@greatlord.com) * */ - -.globl _log10 -.intel_syntax noprefix +#include + +PUBLIC _log10 /* FUNCTIONS ***************************************************************/ +.code _log10: @@ -25,3 +26,4 @@ _log10: pop ebp ret +END diff --git a/reactos/lib/sdk/crt/math/i386/log_asm.s b/reactos/lib/sdk/crt/math/i386/log_asm.s index 0d98279ed41..472202fee92 100644 --- a/reactos/lib/sdk/crt/math/i386/log_asm.s +++ b/reactos/lib/sdk/crt/math/i386/log_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _log - -.intel_syntax noprefix +#include + +PUBLIC _log + /* FUNCTIONS ***************************************************************/ +.code _log: push ebp @@ -49,3 +50,5 @@ _log: fyl2x // Compute the natural log(x) pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/pow_asm.s b/reactos/lib/sdk/crt/math/i386/pow_asm.s index 0b79aa5883e..f418cd38c6e 100644 --- a/reactos/lib/sdk/crt/math/i386/pow_asm.s +++ b/reactos/lib/sdk/crt/math/i386/pow_asm.s @@ -19,41 +19,53 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -/* Reacros modifications */ +/* Reactos modifications */ +#include + #define ALIGNARG(log2) log2 #define ASM_TYPE_DIRECTIVE(name,typearg) #define ASM_SIZE_DIRECTIVE(name) #define cfi_adjust_cfa_offset(x) -#define ENTRY(x) -#define END(x) -.global _pow - .text +PUBLIC _pow + +.data +ASSUME nothing .align ALIGNARG(4) ASM_TYPE_DIRECTIVE(infinity,@object) + inf_zero: infinity: - .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f + .byte 0, 0, 0, 0, 0, 0, HEX(f0), HEX(7f) ASM_SIZE_DIRECTIVE(infinity) ASM_TYPE_DIRECTIVE(zero,@object) -zero: .double 0.0 +zero: + .double 0.0 ASM_SIZE_DIRECTIVE(zero) ASM_TYPE_DIRECTIVE(minf_mzero,@object) + minf_mzero: minfinity: - .byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff + .byte 0, 0, 0, 0, 0, 0, HEX(f0), HEX(ff) + mzero: - .byte 0, 0, 0, 0, 0, 0, 0, 0x80 + .byte 0, 0, 0, 0, 0, 0, 0, HEX(80) ASM_SIZE_DIRECTIVE(minf_mzero) ASM_TYPE_DIRECTIVE(one,@object) -one: .double 1.0 + +one: + .double 1.0 ASM_SIZE_DIRECTIVE(one) ASM_TYPE_DIRECTIVE(limit,@object) -limit: .double 0.29 + +limit: + .double 0.29 ASM_SIZE_DIRECTIVE(limit) ASM_TYPE_DIRECTIVE(p63,@object) -p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + +p63: + .byte 0, 0, 0, 0, 0, 0, HEX(e0), HEX(43) ASM_SIZE_DIRECTIVE(p63) #ifdef PIC @@ -61,308 +73,309 @@ p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 #define MOX(op,x,f) op##@GOTOFF(%ecx,x,f) #else #define MO(op) op -#define MOX(op,x,f) op(,x,f) +#define MOX(op,x,f) op[x*f] #endif - .text +.code _pow: -ENTRY(__ieee754_pow) - fldl 12(%esp) // y + fld qword ptr [esp + 12] // y fxam #ifdef PIC LOAD_PIC_REG (cx) #endif - fnstsw - movb %ah, %dl - andb $0x45, %ah - cmpb $0x40, %ah // is y == 0 ? - je 11f + fnstsw ax + mov dl, ah + and ah, HEX(045) + cmp ah, HEX(040) // is y == 0 ? + je L11 - cmpb $0x05, %ah // is y == ±inf ? - je 12f + cmp ah, 5 // is y == ±inf ? + je L12 - cmpb $0x01, %ah // is y == NaN ? - je 30f + cmp ah, 1 // is y == NaN ? + je L30 - fldl 4(%esp) // x : y + fld qword ptr [esp + 4] // x : y - subl $8,%esp + sub esp, 8 cfi_adjust_cfa_offset (8) fxam - fnstsw - movb %ah, %dh - andb $0x45, %ah - cmpb $0x40, %ah - je 20f // x is ±0 + fnstsw ax + mov dh, ah + and ah, HEX(45) + cmp ah, HEX(040) + je L20 // x is ±0 - cmpb $0x05, %ah - je 15f // x is ±inf + cmp ah, 5 + je L15 // x is ±inf - fxch // y : x + fxch st(1) // y : x /* fistpll raises invalid exception for |y| >= 1L<<63. */ - fld %st // y : y : x + fld st // y : y : x fabs // |y| : y : x - fcompl MO(p63) // y : x - fnstsw + fcomp qword ptr MO(p63) // y : x + fnstsw ax sahf - jnc 2f + jnc L2 /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ - fld %st // y : y : x - fistpll (%esp) // y : x - fildll (%esp) // int(y) : y : x - fucomp %st(1) // y : x - fnstsw + fld st // y : y : x + fistp qword ptr [esp] // y : x + fild qword ptr [esp] // int(y) : y : x + fucomp st(1) // y : x + fnstsw ax sahf - jne 2f + jne L2 /* OK, we have an integer value for y. */ - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - orl $0, %edx - fstp %st(0) // x - jns 4f // y >= 0, jump - fdivrl MO(one) // 1/x (now referred to as x) - negl %eax - adcl $0, %edx - negl %edx -4: fldl MO(one) // 1 : x - fxch - -6: shrdl $1, %edx, %eax - jnc 5f - fxch - fmul %st(1) // x : ST*x - fxch -5: fmul %st(0), %st // x*x : ST*x - shrl $1, %edx - movl %eax, %ecx - orl %edx, %ecx - jnz 6b - fstp %st(0) // ST*x + or edx, 0 + fstp st // x + jns L4 // y >= 0, jump + fdivr qword ptr MO(one) // 1/x (now referred to as x) + neg eax + adc edx, 0 + neg edx +L4: fld qword ptr MO(one) // 1 : x + fxch st(1) + +L6: shrd eax, edx, 1 + jnc L5 + fxch st(1) + fmul st, st(1) // x : ST*x + fxch st(1) +L5: fmul st, st // x*x : ST*x + shr edx, 1 + mov ecx, eax + or ecx, edx + jnz L6 + fstp st // ST*x ret /* y is ±NAN */ -30: fldl 4(%esp) // x : y - fldl MO(one) // 1.0 : x : y - fucomp %st(1) // x : y - fnstsw +L30: + fld qword ptr [esp + 4] // x : y + fld qword ptr MO(one) // 1.0 : x : y + fucomp st(1) // x : y + fnstsw ax sahf - je 31f - fxch // y : x -31: fstp %st(1) + je L31 + fxch st(1) // y : x +L31:fstp st(1) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -2: /* y is a real number. */ - fxch // x : y - fldl MO(one) // 1.0 : x : y - fldl MO(limit) // 0.29 : 1.0 : x : y - fld %st(2) // x : 0.29 : 1.0 : x : y - fsub %st(2) // x-1 : 0.29 : 1.0 : x : y +L2: /* y is a real number. */ + fxch st(1) // x : y + fld qword ptr MO(one) // 1.0 : x : y + fld qword ptr MO(limit) // 0.29 : 1.0 : x : y + fld st(2) // x : 0.29 : 1.0 : x : y + fsub st, st(2) // x-1 : 0.29 : 1.0 : x : y fabs // |x-1| : 0.29 : 1.0 : x : y fucompp // 1.0 : x : y - fnstsw - fxch // x : 1.0 : y + fnstsw ax + fxch st(1) // x : 1.0 : y sahf - ja 7f - fsub %st(1) // x-1 : 1.0 : y + ja L7 + fsub st, st(1) // x-1 : 1.0 : y fyl2xp1 // log2(x) : y - jmp 8f + jmp L8 -7: fyl2x // log2(x) : y -8: fmul %st(1) // y*log2(x) : y - fst %st(1) // y*log2(x) : y*log2(x) +L7: fyl2x // log2(x) : y +L8: fmul st, st(1) // y*log2(x) : y + fst st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) - fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) + fsubr st(1), st // int(y*log2(x)) : fract(y*log2(x)) fxch // fract(y*log2(x)) : int(y*log2(x)) f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x)) - faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) + fadd qword ptr MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x)) - addl $8, %esp + add esp, 8 cfi_adjust_cfa_offset (-8) - fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) + fstp st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret // pow(x,±0) = 1 .align ALIGNARG(4) -11: fstp %st(0) // pop y - fldl MO(one) +L11:fstp st(0) // pop y + fld qword ptr MO(one) ret // y == ±inf .align ALIGNARG(4) -12: fstp %st(0) // pop y - fldl MO(one) // 1 - fldl 4(%esp) // x : 1 +L12: fstp st(0) // pop y + fld qword ptr MO(one) // 1 + fld qword ptr [esp + 4] // x : 1 fabs // abs(x) : 1 fucompp // < 1, == 1, or > 1 - fnstsw - andb $0x45, %ah - cmpb $0x45, %ah - je 13f // jump if x is NaN - - cmpb $0x40, %ah - je 14f // jump if |x| == 1 - - shlb $1, %ah - xorb %ah, %dl - andl $2, %edx - fldl MOX(inf_zero, %edx, 4) + fnstsw ax + and ah, HEX(45) + cmp ah, HEX(45) + je L13 // jump if x is NaN + + cmp ah, HEX(40) + je L14 // jump if |x| == 1 + + shl ah, 1 + xor dl, ah + and edx, 2 + fld qword ptr MOX(inf_zero, edx, 4) ret .align ALIGNARG(4) -14: fldl MO(one) +L14:fld qword ptr MO(one) ret .align ALIGNARG(4) -13: fldl 4(%esp) // load x == NaN +L13:fld qword ptr [esp + 4] // load x == NaN ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) // x is ±inf -15: fstp %st(0) // y - testb $2, %dh - jz 16f // jump if x == +inf +L15: fstp st(0) // y + test dh, 2 + jz L16 // jump if x == +inf // We must find out whether y is an odd integer. - fld %st // y : y - fistpll (%esp) // y - fildll (%esp) // int(y) : y + fld st // y : y + fistp qword ptr [esp] // y + fild qword ptr [esp] // int(y) : y fucompp // - fnstsw + fnstsw ax sahf - jne 17f + jne L17 // OK, the value is an integer, but is the number of bits small // enough so that all are coming from the mantissa? - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - andb $1, %al - jz 18f // jump if not odd - movl %edx, %eax - orl %edx, %edx - jns 155f - negl %eax -155: cmpl $0x00200000, %eax - ja 18f // does not fit in mantissa bits + and al, 1 + jz L18 // jump if not odd + mov eax, edx + or edx, edx + jns L155 + neg eax +L155: + cmp eax, HEX(000200000) + ja L18 // does not fit in mantissa bits // It's an odd integer. - shrl $31, %edx - fldl MOX(minf_mzero, %edx, 8) + shr edx, 31 + fld qword ptr MOX(minf_mzero, edx, 8) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -16: fcompl MO(zero) - addl $8, %esp +L16:fcomp qword ptr MO(zero) + add esp, 8 cfi_adjust_cfa_offset (-8) - fnstsw - shrl $5, %eax - andl $8, %eax - fldl MOX(inf_zero, %eax, 1) + fnstsw ax + shr eax, 5 + and eax, 8 + fld qword ptr MOX(inf_zero, eax, 1) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -17: shll $30, %edx // sign bit for y in right position - addl $8, %esp +L17: shl ecx, 30 // sign bit for y in right position + add esp, 8 cfi_adjust_cfa_offset (-8) -18: shrl $31, %edx - fldl MOX(inf_zero, %edx, 8) +L18: shr edx, 31 + fld qword ptr MOX(inf_zero, edx, 8) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) // x is ±0 -20: fstp %st(0) // y - testb $2, %dl - jz 21f // y > 0 +L20: fstp st(0) // y + test dl, 2 + jz L21 // y > 0 // x is ±0 and y is < 0. We must find out whether y is an odd integer. - testb $2, %dh - jz 25f + test dh, 2 + jz L25 - fld %st // y : y - fistpll (%esp) // y - fildll (%esp) // int(y) : y + fld st // y : y + fistp qword ptr [esp] // y + fild qword ptr [esp] // int(y) : y fucompp // - fnstsw + fnstsw ax sahf - jne 26f + jne L26 // OK, the value is an integer, but is the number of bits small // enough so that all are coming from the mantissa? - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - andb $1, %al - jz 27f // jump if not odd - cmpl $0xffe00000, %edx - jbe 27f // does not fit in mantissa bits + and al, 1 + jz L27 // jump if not odd + cmp edx, HEX(0ffe00000) + jbe L27 // does not fit in mantissa bits // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. - fldl MO(one) - fdivl MO(zero) + fld qword ptr MO(one) + fdiv qword ptr MO(zero) fchs ret cfi_adjust_cfa_offset (8) -25: fstp %st(0) -26: addl $8, %esp +L25: fstp st(0) +L26: add esp, 8 cfi_adjust_cfa_offset (-8) -27: // Raise divide-by-zero exception and get infinity value. - fldl MO(one) - fdivl MO(zero) +L27: // Raise divide-by-zero exception and get infinity value. + fld qword ptr MO(one) + fdiv qword ptr MO(zero) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) // x is ±0 and y is > 0. We must find out whether y is an odd integer. -21: testb $2, %dh - jz 22f +L21:test dh, 2 + jz L22 - fld %st // y : y - fistpll (%esp) // y - fildll (%esp) // int(y) : y + fld st // y : y + fistp qword ptr [esp] // y + fild qword ptr [esp] // int(y) : y fucompp // - fnstsw + fnstsw ax sahf - jne 23f + jne L23 // OK, the value is an integer, but is the number of bits small // enough so that all are coming from the mantissa? - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - andb $1, %al - jz 24f // jump if not odd - cmpl $0xffe00000, %edx - jae 24f // does not fit in mantissa bits + and al, 1 + jz L24 // jump if not odd + cmp edx, HEX(0ffe00000) + jae L24 // does not fit in mantissa bits // It's an odd integer. - fldl MO(mzero) + fld qword ptr MO(mzero) ret cfi_adjust_cfa_offset (8) -22: fstp %st(0) -23: addl $8, %esp // Don't use 2 x pop +L22: fstp st(0) +L23: add esp, 8 // Don't use 2 x pop cfi_adjust_cfa_offset (-8) -24: fldl MO(zero) +L24: fld qword ptr MO(zero) ret -END(__ieee754_pow) +END diff --git a/reactos/lib/sdk/crt/math/i386/sin_asm.s b/reactos/lib/sdk/crt/math/i386/sin_asm.s index 39791a3e989..4a27af804b2 100644 --- a/reactos/lib/sdk/crt/math/i386/sin_asm.s +++ b/reactos/lib/sdk/crt/math/i386/sin_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _sin -.intel_syntax noprefix +#include + +PUBLIC _sin /* FUNCTIONS ***************************************************************/ +.code _sin: push ebp // Save register bp @@ -47,3 +48,5 @@ _sin: fsin // Take the sine pop ebp // Restore register bp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/sqrt_asm.s b/reactos/lib/sdk/crt/math/i386/sqrt_asm.s index c953a0350e9..3385204d572 100644 --- a/reactos/lib/sdk/crt/math/i386/sqrt_asm.s +++ b/reactos/lib/sdk/crt/math/i386/sqrt_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _sqrt - -.intel_syntax noprefix +#include + +PUBLIC _sqrt + /* FUNCTIONS ***************************************************************/ +.code _sqrt: push ebp @@ -47,3 +48,5 @@ _sqrt: fsqrt // Take the square root pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/tan_asm.s b/reactos/lib/sdk/crt/math/i386/tan_asm.s index 34af2614f89..3b64b360f17 100644 --- a/reactos/lib/sdk/crt/math/i386/tan_asm.s +++ b/reactos/lib/sdk/crt/math/i386/tan_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _tan - -.intel_syntax noprefix +#include + +PUBLIC _tan + /* FUNCTIONS ***************************************************************/ +.code _tan: push ebp @@ -50,3 +51,5 @@ _tan: mov esp,ebp // Deallocate temporary space pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/mem/i386/memchr_asm.s b/reactos/lib/sdk/crt/mem/i386/memchr_asm.s index f6e8037fc31..40cd3dc8cef 100644 --- a/reactos/lib/sdk/crt/mem/i386/memchr_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memchr_asm.s @@ -5,28 +5,34 @@ * FILE: lib/sdk/crt/mem/i386/memchr.s */ +#include +#include + /* * void* memchr(const void* s, int c, size_t n) */ -.globl _memchr +PUBLIC _memchr +.code _memchr: - push %ebp - mov %esp,%ebp - push %edi - mov 0x8(%ebp),%edi - mov 0xc(%ebp),%eax - mov 0x10(%ebp),%ecx + push ebp + mov ebp, esp + push edi + mov edi, [ebp + 8] + mov eax, [ebp + 12] + mov ecx, [ebp + 16] cld - jecxz .Lnotfound - repne scasb - je .Lfound + jecxz .Lnotfound + repne scasb + je .Lfound .Lnotfound: - mov $1,%edi + mov edi, 1 .Lfound: - mov %edi,%eax - dec %eax - pop %edi + mov eax, edi + dec eax + pop edi leave ret + +END diff --git a/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s b/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s index 36a1a079513..e69de29bb2d 100644 --- a/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s @@ -1,114 +0,0 @@ -/* - * void *memcpy (void *to, const void *from, size_t count) - * - * NOTE: This code is a duplicate of memmove function from memmove_asm.s - */ - -.globl _memcpy - -_memcpy: - push %ebp - mov %esp,%ebp - - push %esi - push %edi - - mov 8(%ebp),%edi - mov 12(%ebp),%esi - mov 16(%ebp),%ecx - - cmp %esi,%edi - jbe .CopyUp - mov %ecx,%eax - add %esi,%eax - cmp %eax,%edi - jb .CopyDown - -.CopyUp: - cld - - cmp $16,%ecx - jb .L1 - mov %ecx,%edx - test $3,%edi - je .L2 -/* - * Make the destination dword aligned - */ - mov %edi,%ecx - and $3,%ecx - sub $5,%ecx - not %ecx - sub %ecx,%edx - rep movsb - mov %edx,%ecx -.L2: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx -.L1: - test %ecx,%ecx - je .L3 - rep movsb -.L3: - mov 8(%ebp),%eax - pop %edi - pop %esi - leave - ret - -.CopyDown: - std - - add %ecx,%edi - add %ecx,%esi - - cmp $16,%ecx - jb .L4 - mov %ecx,%edx - test $3,%edi - je .L5 - -/* - * Make the destination dword aligned - */ - mov %edi,%ecx - and $3,%ecx - sub %ecx,%edx - dec %esi - dec %edi - rep movsb - mov %edx,%ecx - - sub $3,%esi - sub $3,%edi -.L6: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx - je .L7 - add $3,%esi - add $3,%edi -.L8: - rep movsb -.L7: - cld - mov 8(%ebp),%eax - pop %edi - pop %esi - leave - ret -.L5: - sub $4,%edi - sub $4,%esi - jmp .L6 - -.L4: - test %ecx,%ecx - je .L7 - dec %esi - dec %edi - jmp .L8 - diff --git a/reactos/lib/sdk/crt/mem/i386/memmove_asm.s b/reactos/lib/sdk/crt/mem/i386/memmove_asm.s index e27006e3bed..476f843befe 100644 --- a/reactos/lib/sdk/crt/mem/i386/memmove_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memmove_asm.s @@ -1,114 +1,120 @@ /* - * void *memmove (void *to, const void *from, size_t count) + * void *memcpy (void *to, const void *from, size_t count) * - * NOTE: This code is duplicated in memcpy_asm.s */ -.globl _memmove +#include +#include +PUBLIC _memcpy +PUBLIC _memmove +.code + +_memcpy: _memmove: - push %ebp - mov %esp,%ebp + push ebp + mov ebp, esp - push %esi - push %edi + push esi + push edi - mov 8(%ebp),%edi - mov 12(%ebp),%esi - mov 16(%ebp),%ecx + mov edi, [ebp + 8] + mov esi, [ebp + 12] + mov ecx, [ebp + 16] - cmp %esi,%edi + cmp edi, esi jbe .CopyUp - mov %ecx,%eax - add %esi,%eax - cmp %eax,%edi - jb .CopyDown - + mov eax, ecx + add eax, esi + cmp edi, eax + jb .CopyDown + .CopyUp: cld - cmp $16,%ecx - jb .L1 - mov %ecx,%edx - test $3,%edi - je .L2 + cmp ecx, 16 + jb .L1 + mov edx, ecx + test edi, 3 + je .L2 /* * Make the destination dword aligned */ - mov %edi,%ecx - and $3,%ecx - sub $5,%ecx - not %ecx - sub %ecx,%edx - rep movsb - mov %edx,%ecx + mov ecx, edi + and ecx, 3 + sub ecx, 5 + not ecx + sub edx, ecx + rep movsb + mov ecx, edx .L2: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx + shr ecx, 2 + rep movsd + mov ecx, edx + and ecx, 3 .L1: - test %ecx,%ecx - je .L3 - rep movsb + test ecx, ecx + je .L3 + rep movsb .L3: - mov 8(%ebp),%eax - pop %edi - pop %esi + mov eax, [ebp + 8] + pop edi + pop esi leave ret .CopyDown: - std + std - add %ecx,%edi - add %ecx,%esi + add edi, ecx + add esi, ecx - cmp $16,%ecx - jb .L4 - mov %ecx,%edx - test $3,%edi - je .L5 + cmp ecx, 16 + jb .L4 + mov edx, ecx + test edi, 3 + je .L5 /* * Make the destination dword aligned */ - mov %edi,%ecx - and $3,%ecx - sub %ecx,%edx - dec %esi - dec %edi - rep movsb - mov %edx,%ecx + mov ecx, edi + and ecx, 3 + sub edx, ecx + dec esi + dec edi + rep movsb + mov ecx, edx - sub $3,%esi - sub $3,%edi + sub esi, 3 + sub edi, 3 .L6: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx - je .L7 - add $3,%esi - add $3,%edi + shr ecx, 2 + rep movsd + mov ecx, edx + and ecx, 3 + je .L7 + add esi, 3 + add edi, 3 .L8: - rep movsb + rep movsb .L7: cld - mov 8(%ebp),%eax - pop %edi - pop %esi + mov eax, [ebp + 8] + pop edi + pop esi leave ret .L5: - sub $4,%edi - sub $4,%esi - jmp .L6 - + sub edi, 4 + sub esi, 4 + jmp .L6 + .L4: - test %ecx,%ecx - je .L7 - dec %esi - dec %edi - jmp .L8 + test ecx, ecx + je .L7 + dec esi + dec edi + jmp .L8 +END diff --git a/reactos/lib/sdk/crt/mem/i386/memset_asm.s b/reactos/lib/sdk/crt/mem/i386/memset_asm.s index 4f7c9436e71..81430472f4a 100644 --- a/reactos/lib/sdk/crt/mem/i386/memset_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memset_asm.s @@ -2,46 +2,51 @@ * $Id$ */ +#include +#include + /* * void *memset (void *src, int val, size_t count) */ -.globl _memset +PUBLIC _memset +.code _memset: - push %ebp - mov %esp,%ebp - push %edi - mov 0x8(%ebp),%edi - movzb 0xc(%ebp),%eax - mov 0x10(%ebp),%ecx + push ebp + mov ebp, esp + push edi + mov edi, [ebp + 8] + movzx eax, byte ptr [ebp + 12] + mov ecx, [ebp + 16] cld - cmp $16,%ecx - jb .L1 - mov $0x01010101,%edx - mul %edx - mov %ecx,%edx - test $3,%edi - je .L2 - mov %edi,%ecx - and $3,%ecx - sub $5,%ecx - not %ecx - sub %ecx,%edx - rep stosb - mov %edx,%ecx + cmp ecx, 16 + jb .L1 + mov edx, HEX(01010101) + mul edx + mov edx, ecx + test edi, 3 + je .L2 + mov ecx, edi + and ecx, 3 + sub ecx, 5 + not ecx + sub edx, ecx + rep stosb + mov ecx, edx .L2: - shr $2,%ecx - rep stosl - mov %edx,%ecx - and $3,%ecx + shr ecx, 2 + rep stosd + mov ecx, edx + and ecx, 3 .L1: - test %ecx,%ecx - je .L3 - rep stosb + test ecx, ecx + je .L3 + rep stosb .L3: - pop %edi - mov 0x8(%ebp),%eax + pop edi + mov eax, [ebp + 8] leave ret +END diff --git a/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s b/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s index 56459ae7665..a969bc43db5 100644 --- a/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s +++ b/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #define JUMP_BUFFER_Frame 0x00 #define JUMP_BUFFER_Rbx 0x08 @@ -156,3 +156,5 @@ PUBLIC longjmp inc rax 2: jmp r8 .endp longjmp + +END diff --git a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s index 7cf257cca24..dc0e9656b3a 100644 --- a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s +++ b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s @@ -9,6 +9,8 @@ * complete implementation */ +#include + #define JB_BP 0 #define JB_BX 1 #define JB_DI 2 @@ -20,6 +22,7 @@ #define JMPBUF 4 +.code /* * int * _setjmp(jmp_buf env); @@ -33,20 +36,20 @@ * Notes: * Sets up the jmp_buf */ -.globl __setjmp +PUBLIC __setjmp __setjmp: - xorl %eax, %eax - movl JMPBUF(%esp), %edx + xor eax, eax + mov edx, JMPBUF[esp] /* Save registers. */ - movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */ - movl %ebx, (JB_BX*4)(%edx) - movl %edi, (JB_DI*4)(%edx) - movl %esi, (JB_SI*4)(%edx) - leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */ - movl %ecx, (JB_SP*4)(%edx) - movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */ - movl %ecx, (JB_IP*4)(%edx) + mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */ + mov [edx + JB_BX*4], ebx + mov [edx + JB_DI*4], edi + mov [edx + JB_SI*4], esi + lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */ + mov [edx + JB_SP*4], ecx + mov ecx, PCOFF[esp] /* Save PC we are returning to now. */ + mov [edx + JB_IP*4], ecx ret /* @@ -62,24 +65,22 @@ __setjmp: * Notes: * Sets up the jmp_buf */ -.globl __setjmp3 +PUBLIC __setjmp3 __setjmp3: - xorl %eax, %eax - movl JMPBUF(%esp), %edx + xor eax, eax + mov edx, JMPBUF[esp] /* Save registers. */ - movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */ - movl %ebx, (JB_BX*4)(%edx) - movl %edi, (JB_DI*4)(%edx) - movl %esi, (JB_SI*4)(%edx) - leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */ - movl %ecx, (JB_SP*4)(%edx) - movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */ - movl %ecx, (JB_IP*4)(%edx) + mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */ + mov [edx + JB_BX*4], ebx + mov [edx + JB_DI*4], edi + mov [edx + JB_SI*4], esi + lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */ + mov [edx + JB_SP*4], ecx + mov ecx, PCOFF[esp] /* Save PC we are returning to now. */ + mov [edx + JB_IP*4], ecx ret -#define VAL 8 - /* * void * longjmp(jmp_buf env, int value); @@ -94,18 +95,20 @@ __setjmp3: * Notes: * Non-local goto */ -.globl _longjmp +PUBLIC _longjmp _longjmp: - movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */ + mov ecx, JMPBUF[esp] /* User's jmp_buf in %ecx. */ - movl VAL(%esp), %eax /* Second argument is return value. */ + mov eax, [esp + 8] /* Second argument is return value. */ /* Save the return address now. */ - movl (JB_IP*4)(%ecx), %edx + mov edx, [edx + JB_IP*4] /* Restore registers. */ - movl (JB_BP*4)(%ecx), %ebp - movl (JB_BX*4)(%ecx), %ebx - movl (JB_DI*4)(%ecx), %edi - movl (JB_SI*4)(%ecx), %esi - movl (JB_SP*4)(%ecx), %esp + mov ebp, [edx + JB_BP*4] + mov ebx, [edx + JB_BX*4] + mov edi, [edx + JB_DI*4] + mov esi, [edx + JB_SI*4] + mov esp, [edx + JB_SP*4] /* Jump to saved PC. */ - jmp *%edx + jmp dword ptr [edx] + +END diff --git a/reactos/lib/sdk/crt/string/i386/strcat_asm.s b/reactos/lib/sdk/crt/string/i386/strcat_asm.s index 1241e78f7bb..6f7b8052d23 100644 --- a/reactos/lib/sdk/crt/string/i386/strcat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strcat_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcscat.h" +#include "tcscat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strchr_asm.s b/reactos/lib/sdk/crt/string/i386/strchr_asm.s index b90e86d3303..f8085f25485 100644 --- a/reactos/lib/sdk/crt/string/i386/strchr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strchr_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcschr.h" +#include "tcschr.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strcmp_asm.s b/reactos/lib/sdk/crt/string/i386/strcmp_asm.s index 3ee6573f700..8618f17c076 100644 --- a/reactos/lib/sdk/crt/string/i386/strcmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strcmp_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcscmp.h" +#include "tcscmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strcpy_asm.s b/reactos/lib/sdk/crt/string/i386/strcpy_asm.s index 1b77403847c..168d2921ba8 100644 --- a/reactos/lib/sdk/crt/string/i386/strcpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strcpy_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcscpy.h" +#include "tcscpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strlen_asm.s b/reactos/lib/sdk/crt/string/i386/strlen_asm.s index 9bb10b6d91b..66a8ba27299 100644 --- a/reactos/lib/sdk/crt/string/i386/strlen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strlen_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcslen.h" +#include "tcslen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncat_asm.s b/reactos/lib/sdk/crt/string/i386/strncat_asm.s index 52b20671625..d7fefe417a7 100644 --- a/reactos/lib/sdk/crt/string/i386/strncat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strncat_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsncat.h" +#include "tcsncat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncmp_asm.s b/reactos/lib/sdk/crt/string/i386/strncmp_asm.s index 30c64e6b664..d4db767c207 100644 --- a/reactos/lib/sdk/crt/string/i386/strncmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strncmp_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsncmp.h" +#include "tcsncmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncpy_asm.s b/reactos/lib/sdk/crt/string/i386/strncpy_asm.s index 7409b4ed6c7..584dbb8cce5 100644 --- a/reactos/lib/sdk/crt/string/i386/strncpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strncpy_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsncpy.h" +#include "tcsncpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strnlen_asm.s b/reactos/lib/sdk/crt/string/i386/strnlen_asm.s index be35b3ca2c2..5c1f8dfccf7 100644 --- a/reactos/lib/sdk/crt/string/i386/strnlen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strnlen_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsnlen.h" +#include "tcsnlen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strrchr_asm.s b/reactos/lib/sdk/crt/string/i386/strrchr_asm.s index a8a9d5e79ac..c94f29ec0d7 100644 --- a/reactos/lib/sdk/crt/string/i386/strrchr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strrchr_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsrchr.h" +#include "tcsrchr.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tchar.h b/reactos/lib/sdk/crt/string/i386/tchar.h index ce2f1b9666d..a313e86111e 100644 --- a/reactos/lib/sdk/crt/string/i386/tchar.h +++ b/reactos/lib/sdk/crt/string/i386/tchar.h @@ -21,12 +21,12 @@ #define _tlods lodsw #define _tstos stosw -#define _tsize $2 +#define _tsize 2 #define _treg(_O_) _O_ ## x -#define _tdec(_O_) sub $2, _O_ -#define _tinc(_O_) add $2, _O_ +#define _tdec(_O_) sub _O_, 2 +#define _tinc(_O_) add _O_, 2 #else @@ -45,7 +45,7 @@ #define _tlods lodsb #define _tstos stosb -#define _tsize $1 +#define _tsize 1 #define _treg(_O_) _O_ ## l diff --git a/reactos/lib/sdk/crt/string/i386/tcscat.h b/reactos/lib/sdk/crt/string/i386/tcscat.h deleted file mode 100644 index e50676528d8..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcscat.h +++ /dev/null @@ -1,32 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcscat - -_tcscat: - push %esi - push %edi - mov 0x0C(%esp), %edi - mov 0x10(%esp), %esi - - xor %eax, %eax - mov $-1, %ecx - cld - - repne _tscas - _tdec(%edi) - -.L1: - _tlods - _tstos - test %_treg(a), %_treg(a) - jnz .L1 - - mov 0x0C(%esp), %eax - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscat.inc b/reactos/lib/sdk/crt/string/i386/tcscat.inc new file mode 100644 index 00000000000..d587128f447 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscat.inc @@ -0,0 +1,35 @@ +/* $Id: tcscat.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcscat +.code + +_tcscat: + push esi + push edi + mov edi, [esp + 12] + mov esi, [esp + 16] + + xor eax, eax + mov ecx, -1 + cld + + repne _tscas + _tdec(edi) + +.L1: + _tlods + _tstos + test _treg(a), _treg(a) + jnz .L1 + + mov eax, [esp + 12] + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcschr.h b/reactos/lib/sdk/crt/string/i386/tcschr.h deleted file mode 100644 index ea08bb8d22e..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcschr.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcschr - -_tcschr: - push %esi - mov 0x8(%esp), %esi - mov 0xC(%esp), %edx - - cld - -.L1: - _tlods - cmp %_treg(a), %_treg(d) - je .L2 - test %_treg(a), %_treg(a) - jnz .L1 - mov _tsize, %esi - -.L2: - mov %esi, %eax - _tdec(%eax) - - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcschr.inc b/reactos/lib/sdk/crt/string/i386/tcschr.inc new file mode 100644 index 00000000000..9554ac3cbcd --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcschr.inc @@ -0,0 +1,32 @@ +/* $Id: tcschr.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcschr +.code + +_tcschr: + push esi + mov esi, [esp + 8] + mov edx, [esp + 12] + cld + +.L1: + _tlods + cmp _treg(d), _treg(a) + je .L2 + test _treg(a), _treg(a) + jnz .L1 + mov esi, _tsize + +.L2: + mov eax, esi + _tdec(eax) + + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscmp.h b/reactos/lib/sdk/crt/string/i386/tcscmp.h deleted file mode 100644 index 6830a0ba0dc..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcscmp.h +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcscmp - -_tcscmp: - push %esi - push %edi - mov 0x0C(%esp), %esi - mov 0x10(%esp), %edi - xor %eax, %eax - cld - -.L1: - _tlods - _tscas - jne .L2 - test %eax, %eax - jne .L1 - xor %eax, %eax - jmp .L3 - -.L2: - sbb %eax, %eax - or $1, %al - -.L3: - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscmp.inc b/reactos/lib/sdk/crt/string/i386/tcscmp.inc new file mode 100644 index 00000000000..3bcf453e7b7 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscmp.inc @@ -0,0 +1,37 @@ +/* $Id: tcscmp.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcscmp +.code + +_tcscmp: + push esi + push edi + mov esi, [esp + 12] + mov edi, [esp + 16] + xor eax, eax + cld + +.L1: + _tlods + _tscas + jne .L2 + test eax, eax + jne .L1 + xor eax, eax + jmp .L3 + +.L2: + sbb eax, eax + or al, 1 + +.L3: + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscpy.h b/reactos/lib/sdk/crt/string/i386/tcscpy.h deleted file mode 100644 index cb89a43a4a8..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcscpy.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcscpy - -_tcscpy: - push %esi - push %edi - mov 0x0C(%esp), %edi - mov 0x10(%esp), %esi - cld - -.L1: - _tlods - _tstos - test %_treg(a), %_treg(a) - jnz .L1 - - mov 0x0C(%esp), %eax - - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscpy.inc b/reactos/lib/sdk/crt/string/i386/tcscpy.inc new file mode 100644 index 00000000000..b16b4ccea32 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscpy.inc @@ -0,0 +1,30 @@ +/* $Id: tcscpy.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcscpy +.code + +_tcscpy: + push esi + push edi + mov edi, [esp + 12] + mov esi, [esp + 16] + cld + +.L1: + _tlods + _tstos + test _treg(a), _treg(a) + jnz .L1 + + mov eax, [esp + 12] + + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcslen.h b/reactos/lib/sdk/crt/string/i386/tcslen.h deleted file mode 100644 index 8c9586da70d..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcslen.h +++ /dev/null @@ -1,29 +0,0 @@ -/* $Id$ -*/ - -#include "tchar.h" - -.globl _tcslen - -_tcslen: - push %edi - mov 0x8(%esp), %edi - xor %eax, %eax - test %edi,%edi - jz _tcslen_end - - mov $-1, %ecx - cld - - repne _tscas - - not %ecx - dec %ecx - - mov %ecx, %eax - -_tcslen_end: - pop %edi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcslen.inc b/reactos/lib/sdk/crt/string/i386/tcslen.inc new file mode 100644 index 00000000000..f749b9d88c4 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcslen.inc @@ -0,0 +1,32 @@ +/* $Id: tcslen.inc 49591 2010-11-15 01:29:12Z tkreuzer $ +*/ + +#include "tchar.h" +#include + +PUBLIC _tcslen +.code + +_tcslen: + push edi + mov edi, [esp + 8] + xor eax, eax + test edi, edi + jz _tcslen_end + + mov ecx, -1 + cld + + repne _tscas + + not ecx + dec ecx + + mov eax, ecx + +_tcslen_end: + pop edi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncat.h b/reactos/lib/sdk/crt/string/i386/tcsncat.h deleted file mode 100644 index f7a3b616396..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsncat.h +++ /dev/null @@ -1,42 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsncat - -_tcsncat: - push %esi - push %edi - mov 0x0C(%esp), %edi - mov 0x10(%esp), %esi - cld - - xor %eax, %eax - mov $-1, %ecx - repne _tscas - _tdec(%edi) - - mov 0x14(%esp),%ecx - -.L1: - dec %ecx - js .L2 - _tlods - _tstos - test %_treg(a), %_treg(a) - jne .L1 - jmp .L3 - -.L2: - xor %eax, %eax - _tstos - -.L3: - mov 0x0C(%esp), %eax - pop %edi - pop %esi - - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncat.inc b/reactos/lib/sdk/crt/string/i386/tcsncat.inc new file mode 100644 index 00000000000..b03bb87785f --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncat.inc @@ -0,0 +1,45 @@ +/* $Id: tcsncat.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsncat +.code + +_tcsncat: + push esi + push edi + mov edi, [esp + 12] + mov esi, [esp + 16] + cld + + xor eax, eax + mov ecx, -1 + repne _tscas + _tdec(edi) + + mov ecx, [esp + 20] + +.L1: + dec ecx + js .L2 + _tlods + _tstos + test _treg(a), _treg(a) + jne .L1 + jmp .L3 + +.L2: + xor eax, eax + _tstos + +.L3: + mov eax, [esp + 12] + pop edi + pop esi + + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncmp.h b/reactos/lib/sdk/crt/string/i386/tcsncmp.h deleted file mode 100644 index 58a30859e73..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsncmp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsncmp - -_tcsncmp: - push %esi - push %edi - mov 0x0C(%esp), %esi /* s1 */ - mov 0x10(%esp), %edi /* s2 */ - mov 0x14(%esp), %ecx /* n */ - - xor %eax,%eax - cld - -.L1: - dec %ecx - js .L2 - _tlods - _tscas - jne .L3 - test %eax, %eax - jne .L1 - -.L2: - xor %eax, %eax - jmp .L4 - -.L3: - sbb %eax, %eax - or $1, %al - -.L4: - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncmp.inc b/reactos/lib/sdk/crt/string/i386/tcsncmp.inc new file mode 100644 index 00000000000..9545e583bec --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncmp.inc @@ -0,0 +1,43 @@ +/* $Id: tcsncmp.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsncmp +.code + +_tcsncmp: + push esi + push edi + mov esi, [esp + 12] /* s1 */ + mov edi, [esp + 16] /* s2 */ + mov ecx, [esp + 20] /* n */ + + xor eax, eax + cld + +.L1: + dec ecx + js .L2 + _tlods + _tscas + jne .L3 + test eax, eax + jne .L1 + +.L2: + xor eax, eax + jmp .L4 + +.L3: + sbb eax, eax + or al, 1 + +.L4: + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncpy.h b/reactos/lib/sdk/crt/string/i386/tcsncpy.h deleted file mode 100644 index ed15334d036..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsncpy.h +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsncpy - -_tcsncpy: - push %esi - push %edi - mov 0x0C(%esp), %edi /* s1 */ - mov 0x10(%esp), %esi /* s2 */ - mov 0x14(%esp), %ecx /* n */ - - xor %eax, %eax - cld - -.L1: - dec %ecx - js .L2 - _tlods - _tstos - test %_treg(a), %_treg(a) - jnz .L1 - rep _tstos - -.L2: - mov 0x0C(%esp), %eax - - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncpy.inc b/reactos/lib/sdk/crt/string/i386/tcsncpy.inc new file mode 100644 index 00000000000..248c5ce9a20 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncpy.inc @@ -0,0 +1,37 @@ +/* $Id: tcsncpy.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsncpy +.code + +_tcsncpy: + push esi + push edi + mov edi, [esp + 12] /* s1 */ + mov esi, [esp + 16] /* s2 */ + mov ecx, [esp + 20] /* n */ + + xor eax, eax + cld + +.L1: + dec ecx + js .L2 + _tlods + _tstos + test _treg(a), _treg(a) + jnz .L1 + rep _tstos + +.L2: + mov eax, [esp + 12] + + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsnlen.h b/reactos/lib/sdk/crt/string/i386/tcsnlen.h deleted file mode 100644 index 90a4ec6c88c..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsnlen.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $Id$ -*/ - -#include "tchar.h" - -.globl _tcsnlen - -_tcsnlen: - push %edi - mov 0x8(%esp), %edi - mov 0xC(%esp), %ecx - xor %eax, %eax - test %ecx, %ecx - jz .L1 - mov %ecx, %edx - - cld - - repne _tscas - - sete %al - sub %ecx, %edx - sub %eax, %edx - mov %edx, %eax - -.L1: - pop %edi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsnlen.inc b/reactos/lib/sdk/crt/string/i386/tcsnlen.inc new file mode 100644 index 00000000000..fc72607adb2 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsnlen.inc @@ -0,0 +1,33 @@ +/* $Id: tcsnlen.inc 49591 2010-11-15 01:29:12Z tkreuzer $ +*/ + +#include "tchar.h" +#include + +PUBLIC _tcsnlen +.code + +_tcsnlen: + push edi + mov edi, [esp + 8] + mov ecx, [esp + 12] + xor eax, eax + test ecx, ecx + jz .L1 + mov edx, ecx + + cld + + repne _tscas + + sete al + sub edx, ecx + sub edx, eax + mov eax, edx + +.L1: + pop edi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsrchr.h b/reactos/lib/sdk/crt/string/i386/tcsrchr.h deleted file mode 100644 index 61d3a4dd863..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsrchr.h +++ /dev/null @@ -1,31 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsrchr - -_tcsrchr: - push %esi - mov 0x8(%esp), %esi - mov 0xC(%esp), %edx - - cld - mov _tsize, %ecx - -.L1: - _tlods - cmp %_treg(a), %_treg(d) - jne .L2 - mov %esi, %ecx - -.L2: - test %_treg(a), %_treg(a) - jnz .L1 - - mov %ecx, %eax - _tdec(%eax) - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsrchr.inc b/reactos/lib/sdk/crt/string/i386/tcsrchr.inc new file mode 100644 index 00000000000..9527853122a --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsrchr.inc @@ -0,0 +1,34 @@ +/* $Id: tcsrchr.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsrchr +.code + +_tcsrchr: + push esi + mov esi, [esp + 8] + mov edx, [esp + 12] + + cld + mov ecx, _tsize + +.L1: + _tlods + cmp _treg(d), _treg(a) + jne .L2 + mov ecx, esi + +.L2: + test _treg(a), _treg(a) + jnz .L1 + + mov eax, ecx + _tdec(eax) + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscat_asm.s b/reactos/lib/sdk/crt/string/i386/wcscat_asm.s index 56beb026aa3..b833d0ddab3 100644 --- a/reactos/lib/sdk/crt/string/i386/wcscat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcscat_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcscat.h" +#include "tcscat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcschr_asm.s b/reactos/lib/sdk/crt/string/i386/wcschr_asm.s index a493a48d237..8fc6c360baf 100644 --- a/reactos/lib/sdk/crt/string/i386/wcschr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcschr_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcschr.h" +#include "tcschr.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s b/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s index 2377a026b78..b4f5425beba 100644 --- a/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcscmp.h" +#include "tcscmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s b/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s index 7e76864972d..78b6fe2a6d2 100644 --- a/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcscpy.h" +#include "tcscpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcslen_asm.s b/reactos/lib/sdk/crt/string/i386/wcslen_asm.s index f70390048ad..5d4bfe054aa 100644 --- a/reactos/lib/sdk/crt/string/i386/wcslen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcslen_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcslen.h" +#include "tcslen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s index 36e2cf15dc6..d28bbc3e3a4 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsncat.h" +#include "tcsncat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s index 594e2c49340..5ae53efa7c9 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsncmp.h" +#include "tcsncmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s index 601e70cdafe..b4591cfdb10 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsncpy.h" +#include "tcsncpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s b/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s index 65bd605231c..39349927757 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsnlen.h" +#include "tcsnlen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s b/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s index 872403a8956..a845ee53203 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsrchr.h" +#include "tcsrchr.inc" /* EOF */ diff --git a/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S b/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S index f09edfd3b9c..566f37f5a0c 100644 --- a/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S +++ b/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S @@ -8,14 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include /* FUNCTIONS ****************************************************************/ .code32 -.text /* * NOTE: These functions must obey the following rules: @@ -30,7 +29,7 @@ *ExInterlockedAddLargeStatistic(IN PLARGE_INTEGER Addend, * IN ULONG Increment) */ -.global @ExInterlockedAddLargeStatistic@8 +PUBLIC @ExInterlockedAddLargeStatistic@8 @ExInterlockedAddLargeStatistic@8: #ifdef CONFIG_SMP @@ -38,10 +37,10 @@ lock add [ecx], edx /* Check for carry bit and return */ - jb 1f + jb .l1 ret -1: +.l1: /* Add carry */ lock adc dword ptr [ecx+4], 0 #else @@ -58,7 +57,7 @@ * IN ULONG Increment, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedAddUlong@12 +PUBLIC @ExfInterlockedAddUlong@12 @ExfInterlockedAddUlong@12: /* Save flags */ @@ -103,7 +102,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedInsertHeadList@12 +PUBLIC @ExfInterlockedInsertHeadList@12 @ExfInterlockedInsertHeadList@12: #ifdef CONFIG_SMP @@ -139,11 +138,11 @@ /* Check if list was empty */ xor eax, ecx - jz 2f + jz .l2 /* Return list pointer */ xor eax, ecx -2: +.l2: ret 4 #ifdef CONFIG_SMP @@ -159,7 +158,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedInsertTailList@12 +PUBLIC @ExfInterlockedInsertTailList@12 @ExfInterlockedInsertTailList@12: #ifdef CONFIG_SMP @@ -195,11 +194,11 @@ /* Check if list was empty */ xor eax, ecx - jz 2f + jz .l3 /* Return list pointer */ xor eax, ecx -2: +.l3: ret 4 #ifdef CONFIG_SMP @@ -214,7 +213,7 @@ *ExfInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedRemoveHeadList@8 +PUBLIC @ExfInterlockedRemoveHeadList@8 @ExfInterlockedRemoveHeadList@8: /* Save flags and disable interrupts */ @@ -228,7 +227,7 @@ /* Check if it's empty */ cmp eax, ecx - je 2f + je .l4 /* Get the next entry and do the deletion */ #ifdef CONFIG_SMP @@ -254,7 +253,7 @@ /* Return */ ret -2: +.l4: /* Release lock */ RELEASE_SPINLOCK(edx) @@ -276,7 +275,7 @@ *ExfInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPopEntryList@8 +PUBLIC @ExfInterlockedPopEntryList@8 @ExfInterlockedPopEntryList@8: /* Save flags and disable interrupts */ @@ -290,7 +289,7 @@ /* Check if it's empty */ or eax, eax - je 3f + je .l6 /* Get next entry and do deletion */ #ifdef CONFIG_SMP @@ -302,7 +301,7 @@ pop edx #endif -2: +.l5: /* Release lock */ RELEASE_SPINLOCK(edx) @@ -312,10 +311,10 @@ /* Return */ ret -3: +.l6: /* Return empty list */ xor eax, eax - jmp 2b + jmp .l5 #ifdef CONFIG_SMP .spin5: @@ -329,7 +328,7 @@ * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPushEntryList@12 +PUBLIC @ExfInterlockedPushEntryList@12 @ExfInterlockedPushEntryList@12: /* Save flags */ @@ -383,11 +382,11 @@ *ExInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedPopEntrySList@8 -.global @InterlockedPopEntrySList@4 -.global _ExpInterlockedPopEntrySListResume@0 -.global _ExpInterlockedPopEntrySListFault@0 -.global _ExpInterlockedPopEntrySListEnd@0 +PUBLIC @ExInterlockedPopEntrySList@8 +PUBLIC @InterlockedPopEntrySList@4 +PUBLIC _ExpInterlockedPopEntrySListResume@0 +PUBLIC _ExpInterlockedPopEntrySListFault@0 +PUBLIC _ExpInterlockedPopEntrySListEnd@0 @ExInterlockedPopEntrySList@8: @InterlockedPopEntrySList@4: @@ -405,7 +404,7 @@ _ExpInterlockedPopEntrySListResume@0: /* Check if the list is empty */ or eax, eax - jz 2f + jz .l7 /* Copy sequence number and adjust it */ lea ecx, [edx-1] @@ -418,7 +417,7 @@ _ExpInterlockedPopEntrySListEnd@0: jnz _ExpInterlockedPopEntrySListResume@0 /* Restore registers and return */ -2: +.l7: pop ebp pop ebx ret @@ -429,13 +428,13 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedPushEntrySList@12 +PUBLIC @ExInterlockedPushEntrySList@12 @ExInterlockedPushEntrySList@12: /* So we can fall through below */ pop [esp] -.global @InterlockedPushEntrySList@8 +PUBLIC @InterlockedPushEntrySList@8 @InterlockedPushEntrySList@8: /* Save registers */ @@ -450,19 +449,18 @@ _ExpInterlockedPopEntrySListEnd@0: mov edx, [ebp+4] mov eax, [ebp] -1: +.l8: /* Set link pointer */ mov [ebx], eax /* Copy sequence number and adjust it */ - lea ecx, [edx+0x10001] + lea ecx, [edx + HEX(10001)] /* Do the exchange */ LOCK cmpxchg8b qword ptr [ebp] - jnz 1b + jnz .l8 /* Restore registers and return */ -2: pop ebp pop ebx ret @@ -471,7 +469,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *ExInterlockedFlushSList(IN PSINGLE_LIST_ENTRY ListHead) */ -.global @ExInterlockedFlushSList@4 +PUBLIC @ExInterlockedFlushSList@4 @ExInterlockedFlushSList@4: /* Save registers */ @@ -488,10 +486,10 @@ _ExpInterlockedPopEntrySListEnd@0: mov edx, [ebp+4] mov eax, [ebp] -1: +.l9: /* Check if the list is empty */ or eax, eax - jz 2f + jz .l10 /* Clear sequence and pointer */ mov ecx, edx @@ -499,10 +497,10 @@ _ExpInterlockedPopEntrySListEnd@0: /* Do the exchange */ LOCK cmpxchg8b qword ptr [ebp] - jnz 1b + jnz .l9 /* Restore registers and return */ -2: +.l10: pop ebp pop ebx ret @@ -511,7 +509,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *Exfi386InterlockedIncrementLong(IN PLONG Addend) */ -.global @Exfi386InterlockedIncrementLong@4 +PUBLIC @Exfi386InterlockedIncrementLong@4 @Exfi386InterlockedIncrementLong@4: /* Do the op */ @@ -526,7 +524,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *Exfi386InterlockedDecrementLong(IN PLONG Addend) */ -.global @Exfi386InterlockedDecrementLong@4 +PUBLIC @Exfi386InterlockedDecrementLong@4 @Exfi386InterlockedDecrementLong@4: /* Do the op */ @@ -542,7 +540,7 @@ _ExpInterlockedPopEntrySListEnd@0: *Exfi386InterlockedExchangeUlong(IN PULONG Taget, * IN ULONG Value) */ -.global @Exfi386InterlockedExchangeUlong@8 +PUBLIC @Exfi386InterlockedExchangeUlong@8 @Exfi386InterlockedExchangeUlong@8: #ifdef CONFIG_SMP @@ -552,9 +550,9 @@ _ExpInterlockedPopEntrySListEnd@0: #else /* On UP, use cmpxchg */ mov eax, [ecx] -1: +.l11: cmpxchg [ecx], edx - jnz 1b + jnz .l11 #endif /* Return */ @@ -566,7 +564,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Exchange, * IN PLONGLONG Comperand) */ -.global @ExfInterlockedCompareExchange64@12 +PUBLIC @ExfInterlockedCompareExchange64@12 @ExfInterlockedCompareExchange64@12: /* Save registers */ @@ -598,7 +596,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Comperand, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedCompareExchange64@16 +PUBLIC @ExInterlockedCompareExchange64@16 @ExInterlockedCompareExchange64@16: /* Save registers */ @@ -630,7 +628,7 @@ _ExpInterlockedPopEntrySListEnd@0: *ExfInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPopEntrySList@8 +PUBLIC @ExfInterlockedPopEntrySList@8 @ExfInterlockedPopEntrySList@8: /* Save flags */ @@ -646,7 +644,7 @@ _ExpInterlockedPopEntrySListEnd@0: /* Get the next link and check if it's empty */ mov eax, [ecx] or eax, eax - jz 1f + jz .l12 /* Get address of the next link and store it */ push [eax] @@ -655,7 +653,7 @@ _ExpInterlockedPopEntrySListEnd@0: /* Decrement list depth */ dec dword ptr [ecx+4] -1: +.l12: #ifdef CONFIG_SMP /* Release spinlock */ RELEASE_SPINLOCK(edx) @@ -678,7 +676,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPushEntrySList@12 +PUBLIC @ExfInterlockedPushEntrySList@12 @ExfInterlockedPushEntrySList@12: /* Save flags */ @@ -727,7 +725,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Comperand, * IN PKSPIN_LOCK Lock) */ -.global @ExpInterlockedCompareExchange64@16 +PUBLIC @ExpInterlockedCompareExchange64@16 @ExpInterlockedCompareExchange64@16: /* Save registers */ @@ -802,4 +800,6 @@ NoMatch: pushfd SPIN_ON_LOCK(esi, .startc) #endif + +END /* EOF */ diff --git a/reactos/ntoskrnl/ex/i386/interlck_asm.S b/reactos/ntoskrnl/ex/i386/interlck_asm.S index 954091cee85..755813e80d8 100644 --- a/reactos/ntoskrnl/ex/i386/interlck_asm.S +++ b/reactos/ntoskrnl/ex/i386/interlck_asm.S @@ -8,14 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include /* FUNCTIONS ****************************************************************/ .code32 -.text /* * NOTE: These functions must obey the following rules: @@ -31,7 +30,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedAddLargeInteger@16 +PUBLIC _ExInterlockedAddLargeInteger@16 _ExInterlockedAddLargeInteger@16: /* Prepare stack frame */ @@ -97,7 +96,7 @@ _ExInterlockedAddLargeInteger@16: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedAddUlong@12 +PUBLIC _ExInterlockedAddUlong@12 _ExInterlockedAddUlong@12: /* Save flags and disable interrupts */ @@ -153,7 +152,7 @@ _ExInterlockedAddUlong@12: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedInsertHeadList@12 +PUBLIC _ExInterlockedInsertHeadList@12 _ExInterlockedInsertHeadList@12: /* Save lock pointer */ @@ -189,12 +188,12 @@ _ExInterlockedInsertHeadList@12: /* check if the list was empty and return NULL */ xor eax, edx - jz 2f + jz .l2 /* Return pointer */ mov eax, edx -2: +.l2: ret 12 #ifdef CONFIG_SMP @@ -209,7 +208,7 @@ _ExInterlockedInsertHeadList@12: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedInsertTailList@12 +PUBLIC _ExInterlockedInsertTailList@12 _ExInterlockedInsertTailList@12: /* Save lock pointer */ @@ -245,12 +244,12 @@ _ExInterlockedInsertTailList@12: /* Check if the list was empty and return NULL */ xor eax, edx - jz 2f + jz .l3 /* Return pointer */ mov eax, edx -2: +.l3: ret 12 #ifdef CONFIG_SMP @@ -264,7 +263,7 @@ _ExInterlockedInsertTailList@12: *ExInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedRemoveHeadList@8 +PUBLIC _ExInterlockedRemoveHeadList@8 _ExInterlockedRemoveHeadList@8: /* Save lock pointer */ @@ -284,7 +283,7 @@ _ExInterlockedRemoveHeadList@8: /* Check if it's empty */ cmp eax, edx - je 2f + je .l4 /* Get next entry and do deletion */ mov ecx, [eax] @@ -303,7 +302,7 @@ _ExInterlockedRemoveHeadList@8: /* Return */ ret 8 -2: +.l4: /* Release lock */ #ifdef CONFIG_SMP mov edx, [esp+12] @@ -328,7 +327,7 @@ _ExInterlockedRemoveHeadList@8: *ExInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedPopEntryList@8 +PUBLIC _ExInterlockedPopEntryList@8 _ExInterlockedPopEntryList@8: /* Save lock pointer */ @@ -348,13 +347,13 @@ _ExInterlockedPopEntryList@8: /* Check if it's empty */ or eax, eax - je 3f + je .l6 /* Get next entry and do deletion */ mov edx, [eax] mov [ecx], edx -2: +.l5: /* Release lock */ #ifdef CONFIG_SMP mov ecx, [esp+12] @@ -367,10 +366,10 @@ _ExInterlockedPopEntryList@8: /* Return */ ret 8 -3: +.l6: /* Return empty list */ xor eax, eax - jmp 2b + jmp .l5 #ifdef CONFIG_SMP .spin6: @@ -384,7 +383,7 @@ _ExInterlockedPopEntryList@8: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedPushEntryList@12 +PUBLIC _ExInterlockedPushEntryList@12 _ExInterlockedPushEntryList@12: /* Save lock pointer */ @@ -430,7 +429,7 @@ _ExInterlockedPushEntryList@12: *ExInterlockedIncrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedIncrementLong@8 +PUBLIC _ExInterlockedIncrementLong@8 _ExInterlockedIncrementLong@8: /* Get addend */ @@ -449,7 +448,7 @@ _ExInterlockedIncrementLong@8: *ExInterlockedDecrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedDecrementLong@8 +PUBLIC _ExInterlockedDecrementLong@8 _ExInterlockedDecrementLong@8: /* Get addend */ @@ -469,7 +468,7 @@ _ExInterlockedDecrementLong@8: * IN ULONG Value, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedExchangeUlong@12 +PUBLIC _ExInterlockedExchangeUlong@12 _ExInterlockedExchangeUlong@12: /* Get pointers */ @@ -498,7 +497,7 @@ _ExInterlockedExchangeUlong@12: *Exi386InterlockedIncrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedIncrementLong@4 +PUBLIC _Exi386InterlockedIncrementLong@4 _Exi386InterlockedIncrementLong@4: /* Get addend */ @@ -517,7 +516,7 @@ _Exi386InterlockedIncrementLong@4: *Exi386InterlockedDecrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedDecrementLong@4 +PUBLIC _Exi386InterlockedDecrementLong@4 _Exi386InterlockedDecrementLong@4: /* Get addend */ @@ -537,7 +536,7 @@ _Exi386InterlockedDecrementLong@4: * IN ULONG Value, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedExchangeUlong@12 +PUBLIC _Exi386InterlockedExchangeUlong@12 _Exi386InterlockedExchangeUlong@12: /* Get pointers */ @@ -560,5 +559,6 @@ _Exi386InterlockedExchangeUlong@12: /* Return */ ret 8 - + +END /* EOF */ diff --git a/reactos/ntoskrnl/ex/i386/ioport.S b/reactos/ntoskrnl/ex/i386/ioport.S index c9c55a160f4..ba456c799f8 100644 --- a/reactos/ntoskrnl/ex/i386/ioport.S +++ b/reactos/ntoskrnl/ex/i386/ioport.S @@ -8,54 +8,52 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include /* GLOBALS *******************************************************************/ -.globl _READ_REGISTER_UCHAR@4 -.globl _READ_REGISTER_USHORT@4 -.globl _READ_REGISTER_ULONG@4 -.globl _READ_REGISTER_BUFFER_UCHAR@12 -.globl _READ_REGISTER_BUFFER_USHORT@12 -.globl _READ_REGISTER_BUFFER_ULONG@12 -.globl _WRITE_REGISTER_UCHAR@8 -.globl _WRITE_REGISTER_USHORT@8 -.globl _WRITE_REGISTER_ULONG@8 -.globl _WRITE_REGISTER_BUFFER_UCHAR@12 -.globl _WRITE_REGISTER_BUFFER_USHORT@12 -.globl _WRITE_REGISTER_BUFFER_ULONG@12 +PUBLIC _READ_REGISTER_UCHAR@4 +PUBLIC _READ_REGISTER_USHORT@4 +PUBLIC _READ_REGISTER_ULONG@4 +PUBLIC _READ_REGISTER_BUFFER_UCHAR@12 +PUBLIC _READ_REGISTER_BUFFER_USHORT@12 +PUBLIC _READ_REGISTER_BUFFER_ULONG@12 +PUBLIC _WRITE_REGISTER_UCHAR@8 +PUBLIC _WRITE_REGISTER_USHORT@8 +PUBLIC _WRITE_REGISTER_ULONG@8 +PUBLIC _WRITE_REGISTER_BUFFER_UCHAR@12 +PUBLIC _WRITE_REGISTER_BUFFER_USHORT@12 +PUBLIC _WRITE_REGISTER_BUFFER_ULONG@12 /* FUNCTIONS *****************************************************************/ -.func READ_REGISTER_UCHAR@4 +.code + _READ_REGISTER_UCHAR@4: /* Return the requested memory location */ mov edx, [esp+4] mov al, [edx] ret 4 -.endfunc -.func READ_REGISTER_USHORT@4 + _READ_REGISTER_USHORT@4: /* Return the requested memory location */ mov edx, [esp+4] mov ax, [edx] ret 4 -.endfunc -.func READ_REGISTER_ULONG@4 + _READ_REGISTER_ULONG@4: /* Return the requested memory location */ mov edx, [esp+4] mov eax, [edx] ret 4 -.endfunc -.func READ_REGISTER_BUFFER_UCHAR@12 + _READ_REGISTER_BUFFER_UCHAR@12: /* Save volatiles */ @@ -72,9 +70,8 @@ _READ_REGISTER_BUFFER_UCHAR@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func READ_REGISTER_BUFFER_USHORT@12 + _READ_REGISTER_BUFFER_USHORT@12: /* Save volatiles */ @@ -91,9 +88,8 @@ _READ_REGISTER_BUFFER_USHORT@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func READ_REGISTER_BUFFER_ULONG@12 + _READ_REGISTER_BUFFER_ULONG@12: /* Save volatiles */ @@ -110,9 +106,8 @@ _READ_REGISTER_BUFFER_ULONG@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_UCHAR@8 + _WRITE_REGISTER_UCHAR@8: /* Write to memory */ @@ -123,9 +118,8 @@ _WRITE_REGISTER_UCHAR@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_USHORT@8 + _WRITE_REGISTER_USHORT@8: /* Write to memory */ @@ -136,9 +130,8 @@ _WRITE_REGISTER_USHORT@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_ULONG@8 + _WRITE_REGISTER_ULONG@8: /* Write to memory */ @@ -149,9 +142,8 @@ _WRITE_REGISTER_ULONG@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_BUFFER_UCHAR@12 + _WRITE_REGISTER_BUFFER_UCHAR@12: /* Save volatiles */ @@ -171,9 +163,8 @@ _WRITE_REGISTER_BUFFER_UCHAR@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_BUFFER_USHORT@12 + _WRITE_REGISTER_BUFFER_USHORT@12: /* Save volatiles */ @@ -193,9 +184,8 @@ _WRITE_REGISTER_BUFFER_USHORT@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_BUFFER_ULONG@12 + _WRITE_REGISTER_BUFFER_ULONG@12: /* Save volatiles */ @@ -215,6 +205,6 @@ _WRITE_REGISTER_BUFFER_ULONG@12: mov edi, edx mov esi, eax ret 12 -.endfunc +END /* EOF */ diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index 6ddb9d015ad..2a64a938320 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -60,8 +60,8 @@ // @remark None. // MACRO(idt, Handler, Bits) - .long \Handler - .short \Bits + .long VAL(Handler) + .short VAL(Bits) .short KGDT_R0_CODE ENDM @@ -128,17 +128,17 @@ MACRO(KiEnterTrap, Flags) mov [esp + KTRAP_FRAME_EAX], eax /* Does the caller want nonvolatiles only? */ - if ((Flags AND KI_NONVOLATILES_ONLY) == 0) + if (NOT (Flags AND KI_NONVOLATILES_ONLY)) /* Otherwise, save the volatiles as well */ mov [esp + KTRAP_FRAME_ECX], ecx mov [esp + KTRAP_FRAME_EDX], edx endif /* Save segment registers? */ - if ((Flags AND KI_DONT_SAVE_SEGS) == 0) + if (NOT (Flags AND KI_DONT_SAVE_SEGS)) /* Check for V86 mode */ - test byte ptr [esp + KTRAP_FRAME_EFLAGS + 2], (EFLAGS_V86_MASK >> 16) + test byte ptr [esp + KTRAP_FRAME_EFLAGS + 2], (EFLAGS_V86_MASK / HEX(10000)) jz not_v86_trap /* Restore V8086 segments into Protected Mode segments */ @@ -173,7 +173,7 @@ set_sane_segs: mov es, ax /* Fast system calls have fs already fixed */ - if ((Flags AND KI_FAST_SYSTEM_CALL) == 0) + if (NOT (Flags AND KI_FAST_SYSTEM_CALL)) /* Otherwise fix fs now */ mov ax, KGDT_R0_PCR mov fs, ax @@ -296,7 +296,7 @@ PUBLIC @&Name&@4 mov ecx, [esp - OffsetEsp + KTRAP_FRAME_ESP] /* Keep interrupts disabled until the sti / sysexit */ - and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], ~(EFLAGS_INTERRUPT_MASK >> 8) + and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], NOT (EFLAGS_INTERRUPT_MASK / HEX(100)) endif diff --git a/reactos/ntoskrnl/kdbg/amd64/kdb_help.S b/reactos/ntoskrnl/kdbg/amd64/kdb_help.S index eb777010513..eca6dcfbdac 100644 --- a/reactos/ntoskrnl/kdbg/amd64/kdb_help.S +++ b/reactos/ntoskrnl/kdbg/amd64/kdb_help.S @@ -1,7 +1,9 @@ -#include -#include -.globl KdbEnter +#include + +#include + +PUBLIC KdbEnter KdbEnter: /* save flags */ @@ -149,4 +151,6 @@ KdbpStackSwitchAndCall: mov rsp, rax /* Return */ - ret \ No newline at end of file + ret + +END \ No newline at end of file diff --git a/reactos/ntoskrnl/kdbg/i386/kdb_help.S b/reactos/ntoskrnl/kdbg/i386/kdb_help.S index 00cb522c17c..e586f14c5e7 100644 --- a/reactos/ntoskrnl/kdbg/i386/kdb_help.S +++ b/reactos/ntoskrnl/kdbg/i386/kdb_help.S @@ -1,68 +1,72 @@ -#include -.text +#include +#include -.globl _KdbEnter +EXTERN _KdbEnterDebuggerException:PROC + +.code + +PUBLIC _KdbEnter _KdbEnter: /* * Set up a trap frame */ - pushfl /* Eflags */ - pushl %cs /* Cs */ - pushl $0 /* ErrorCode */ - pushl %ebp /* Ebp */ - pushl %ebx /* Ebx */ - movl 20(%esp), %ebp /* Eip */ - movl 16(%esp), %ebx /* Eflags */ - movl %ebx, 20(%esp) - movl 12(%esp), %ebx /* Cs */ - movl %ebx, 16(%esp) - movl %ebp, 12(%esp) - pushl %esi /* Esi */ - pushl %edi /* Edi */ - pushl %fs /* Fs */ - pushl $0 /* ExceptionList */ - pushl $0 /* PreviousMode */ - pushl %eax /* Eax */ - pushl %ecx /* Ecx */ - pushl %edx /* Edx */ - pushl %ds /* Ds */ - pushl %es /* Es */ - pushl %gs /* Gs */ - movl %dr7, %eax - pushl %eax /* Dr7 */ + pushf /* Eflags */ + push cs /* Cs */ + push 0 /* ErrorCode */ + push ebp /* Ebp */ + push ebx /* Ebx */ + mov ebp, [esp + 20] /* Eip */ + mov ebx, [esp + 16] /* Eflags */ + mov [esp + 20], ebx + mov ebx, [esp + 12] /* Cs */ + mov [esp + 16], ebx + mov [esp + 12], ebp + push esi /* Esi */ + push edi /* Edi */ + push fs /* Fs */ + push 0 /* ExceptionList */ + push 0 /* PreviousMode */ + push eax /* Eax */ + push ecx /* Ecx */ + push edx /* Edx */ + push ds /* Ds */ + push es /* Es */ + push gs /* Gs */ + mov eax, dr7 + push eax /* Dr7 */ /* Clear all breakpoint enables in dr7. */ - andl $0xFFFF0000, %eax - movl %eax, %dr7 - movl %dr6, %eax - pushl %eax /* Dr6 */ - movl %dr3, %eax - pushl %eax /* Dr3 */ - movl %dr2, %eax - pushl %eax /* Dr2 */ - movl %dr1, %eax - pushl %eax /* Dr1 */ - movl %dr0, %eax - pushl %eax /* Dr0 */ - leal 0x58(%esp), %eax - pushl %eax /* TempEsp */ - pushl %ss /* TempSegSs */ - pushl $0 /* DebugPointer */ - pushl $3 /* DebugArgMark (Exception number) */ - pushl 0x60(%esp) /* DebugEip */ - pushl %ebp /* DebugEbp */ + and eax, HEX(0FFFF0000) + mov dr7, eax + mov eax, dr6 + push eax /* Dr6 */ + mov eax, dr3 + push eax /* Dr3 */ + mov eax, dr2 + push eax /* Dr2 */ + mov eax, dr1 + push eax /* Dr1 */ + mov eax, dr0 + push eax /* Dr0 */ + lea eax, [esp + HEX(58)] + push eax /* TempEsp */ + push ss /* TempSegSs */ + push 0 /* DebugPointer */ + push 3 /* DebugArgMark (Exception number) */ + push [esp + HEX(60)] /* DebugEip */ + push ebp /* DebugEbp */ /* * Call KDB */ - movl %esp, %eax - pushl $1 /* FirstChance */ - pushl %eax /* Push a pointer to the trap frame */ - pushl $0 /* Context */ - pushl $0 /* PreviousMode (KernelMode) */ - pushl $0 /* ExceptionRecord */ - call _KdbEnterDebuggerException + mov eax, esp + push 1 /* FirstChance */ + push eax /* Push a pointer to the trap frame */ + push 0 /* Context */ + push 0 /* PreviousMode (KernelMode) */ + push 0 /* ExceptionRecord */ + call _KdbEnterDebuggerException /* * Pop the arguments and unused portions of the trap frame: @@ -73,41 +77,41 @@ _KdbEnter: * TempSegSs * TempEsp */ - addl $(11*4), %esp + add esp, 11*4 /* * Restore/update debugging registers. */ - popl %eax /* Dr0 */ - movl %eax, %dr0 - popl %eax /* Dr1 */ - movl %eax, %dr1 - popl %eax /* Dr2 */ - movl %eax, %dr2 - popl %eax /* Dr3 */ - movl %eax, %dr3 - popl %eax /* Dr6 */ - movl %eax, %dr6 - popl %eax /* Dr7 */ - movl %eax, %dr7 + pop eax /* Dr0 */ + mov dr0, eax + pop eax /* Dr1 */ + mov dr1, eax + pop eax /* Dr2 */ + mov dr2, eax + pop eax /* Dr3 */ + mov dr3, eax + pop eax /* Dr6 */ + mov dr6, eax + pop eax /* Dr7 */ + mov dr7, eax /* * Restore registers including any that might have been changed * inside the debugger. */ - popl %gs /* Gs */ - popl %es /* Es */ - popl %ds /* Ds */ - popl %edx /* Edx */ - popl %ecx /* Ecx */ - popl %eax /* Eax */ - addl $8, %esp /* PreviousMode, ExceptionList */ - popl %fs /* Fs */ - popl %edi /* Edi */ - popl %esi /* Esi */ - popl %ebx /* Ebx */ - popl %ebp /* Ebp */ - addl $4, %esp /* ErrorCode */ + pop gs /* Gs */ + pop es /* Es */ + pop ds /* Ds */ + pop edx /* Edx */ + pop ecx /* Ecx */ + pop eax /* Eax */ + add esp, 8 /* PreviousMode, ExceptionList */ + pop fs /* Fs */ + pop edi /* Edi */ + pop esi /* Esi */ + pop ebx /* Ebx */ + pop ebp /* Ebp */ + add esp, 4 /* ErrorCode */ /* * Return to the caller. @@ -115,26 +119,27 @@ _KdbEnter: iret -.globl _KdbpStackSwitchAndCall@8 +PUBLIC _KdbpStackSwitchAndCall@8 _KdbpStackSwitchAndCall@8: - pushl %ebp - movl %esp, %ebp + push ebp + mov ebp, esp - movl 0x8(%esp), %eax /* New stack */ - movl 0xC(%esp), %ecx /* Function to call */ - movl %esp, %edx /* Old stack */ + mov eax, [esp + 8] /* New stack */ + mov ecx, [esp + 12] /* Function to call */ + mov edx, esp /* Old stack */ /* Switch stack */ - movl %eax, %esp - pushl %edx + mov esp, eax + push edx /* Call function */ - call *%ecx + call ecx /* Switch back to old stack */ - popl %esp + pop esp /* Return */ - popl %ebp - ret $8 + pop ebp + ret 8 +END diff --git a/reactos/ntoskrnl/ke/amd64/boot.S b/reactos/ntoskrnl/ke/amd64/boot.S index f1715c6663e..4efbef3f94a 100644 --- a/reactos/ntoskrnl/ke/amd64/boot.S +++ b/reactos/ntoskrnl/ke/amd64/boot.S @@ -2,14 +2,14 @@ * FILE: ntoskrnl/ke/i386/boot.S * COPYRIGHT: See COPYING in the top level directory * PURPOSE: FreeLDR Wrapper Bootstrap Code and Bootstrap Trampoline - * PROGRAMMERs: Alex Ionescu (alex@relsoft.net) - * Thomas Weidenmueller + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) */ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include EXTERN KiInitializeKernelAndGotoIdleLoop:PROC diff --git a/reactos/ntoskrnl/ke/amd64/ctxswitch.S b/reactos/ntoskrnl/ke/amd64/ctxswitch.S index 61ce1473e53..1c9b13e5737 100644 --- a/reactos/ntoskrnl/ke/amd64/ctxswitch.S +++ b/reactos/ntoskrnl/ke/amd64/ctxswitch.S @@ -9,8 +9,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/ntoskrnl/ke/amd64/trap.S b/reactos/ntoskrnl/ke/amd64/trap.S index 532f6bbdb91..2b95b42894d 100644 --- a/reactos/ntoskrnl/ke/amd64/trap.S +++ b/reactos/ntoskrnl/ke/amd64/trap.S @@ -7,8 +7,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include EXTERN KiDispatchException:PROC EXTERN FrLdrDbgPrint:DWORD diff --git a/reactos/ntoskrnl/ke/i386/ctxswitch.S b/reactos/ntoskrnl/ke/i386/ctxswitch.S index 9a9c95f4db1..8fba093426f 100644 --- a/reactos/ntoskrnl/ke/i386/ctxswitch.S +++ b/reactos/ntoskrnl/ke/i386/ctxswitch.S @@ -10,22 +10,27 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include + +EXTERN @KiSwapContextEntry@8:PROC +EXTERN @KiSwapContextExit@8:PROC +EXTERN @KiRetireDpcList@4:PROC +EXTERN @KiEnterV86Mode@4:PROC +EXTERN @KiExitV86Mode@4:PROC /* FUNCTIONS ****************************************************************/ +.code -.globl @KiSwapContextInternal@0 -.func @KiSwapContextInternal@0, @KiSwapContextInternal@0 +PUBLIC @KiSwapContextInternal@0 @KiSwapContextInternal@0: /* Build switch frame */ sub esp, 2 * 4 mov ecx, esp jmp @KiSwapContextEntry@8 -.endfunc -.globl @KiSwapContext@8 -.func @KiSwapContext@8, @KiSwapContext@8 + +PUBLIC @KiSwapContext@8 @KiSwapContext@8: /* Save 4 registers */ sub esp, 4 * 4 @@ -51,10 +56,9 @@ /* Clean stack */ add esp, 4 * 4 ret -.endfunc -.globl @KiSwitchThreads@8 -.func @KiSwitchThreads@8, @KiSwitchThreads@8 + +PUBLIC @KiSwitchThreads@8 @KiSwitchThreads@8: /* Load the new kernel stack and switch OS to new thread */ mov esp, edx @@ -63,10 +67,9 @@ /* Now we're on the new thread. Return to the caller to restore registers */ add esp, 2 * 4 ret -.endfunc -.globl @KiRetireDpcListInDpcStack@8 -.func @KiRetireDpcListInDpcStack@8, @KiRetireDpcListInDpcStack@8 + +PUBLIC @KiRetireDpcListInDpcStack@8 @KiRetireDpcListInDpcStack@8: /* Switch stacks and retire DPCs */ mov eax, esp @@ -77,11 +80,10 @@ /* Return on original stack */ pop esp ret -.endfunc + /* FIXFIX: Move to C code ****/ -.globl _Ki386SetupAndExitToV86Mode@4 -.func Ki386SetupAndExitToV86Mode@4 +PUBLIC _Ki386SetupAndExitToV86Mode@4 _Ki386SetupAndExitToV86Mode@4: /* Enter V8086 mode */ @@ -90,9 +92,9 @@ _Ki386SetupAndExitToV86Mode@4: mov ecx, esp call @KiEnterV86Mode@4 jmp $ -.endfunc -.globl @Ki386BiosCallReturnAddress@4 + +PUBLIC @Ki386BiosCallReturnAddress@4 @Ki386BiosCallReturnAddress@4: /* Exit V8086 mode */ @@ -102,3 +104,4 @@ _Ki386SetupAndExitToV86Mode@4: popad ret 4 +END diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index adfcd322dd9..f3c99c48c77 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -9,8 +9,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include MACRO(GENERATE_IDT_STUB, Number) @@ -18,16 +18,19 @@ idt _KiUnexpectedInterrupt&Number, INT_32_DPL0 ENDM MACRO(GENERATE_INT_HANDLER, Number) -.func KiUnexpectedInterrupt&Number +//.func KiUnexpectedInterrupt&Number _KiUnexpectedInterrupt&Number: push PRIMARY_VECTOR_BASE + Number jmp _KiEndUnexpectedRange@0 -.endfunc +//.endfunc ENDM +EXTERN _KiTrap02:PROC + /* GLOBALS *******************************************************************/ .data +ASSUME nothing PUBLIC _KiIdt _KiIdt: @@ -52,9 +55,9 @@ idt _KiTrap10, INT_32_DPL0 /* INT 10: x87 FPU Error (#MF) */ idt _KiTrap11, INT_32_DPL0 /* INT 11: Align Check Exception (#AC) */ idt _KiTrap0F, INT_32_DPL0 /* INT 12: Machine Check Exception (#MC)*/ idt _KiTrap0F, INT_32_DPL0 /* INT 13: SIMD FPU Exception (#XF) */ -.rept 22 +REPEAT 22 idt _KiTrap0F, INT_32_DPL0 /* INT 14-29: UNDEFINED INTERRUPTS */ -.endr +ENDR idt _KiGetTickCount, INT_32_DPL3 /* INT 2A: Get Tick Count Handler */ idt _KiCallbackReturn, INT_32_DPL3 /* INT 2B: User-Mode Callback Return */ idt _KiRaiseAssertion, INT_32_DPL3 /* INT 2C: Debug Assertion Handler */ @@ -62,15 +65,15 @@ idt _KiDebugService, INT_32_DPL3 /* INT 2D: Debug Service Handler */ idt _KiSystemService, INT_32_DPL3 /* INT 2E: System Call Service Handler */ idt _KiTrap0F, INT_32_DPL0 /* INT 2F: RESERVED */ i = 0 -.rept 208 +REPEAT 208 GENERATE_IDT_STUB %i i = i + 1 -.endr +ENDR PUBLIC _KiIdtDescriptor _KiIdtDescriptor: .short 0 - .short 0x7FF + .short HEX(7FF) .long _KiIdt PUBLIC _KiUnexpectedEntrySize @@ -78,8 +81,7 @@ _KiUnexpectedEntrySize: .long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0 /******************************************************************************/ -.code32 -.text +.code TRAP_ENTRY KiTrap00, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY KiTrap01, KI_PUSH_FAKE_ERROR_CODE @@ -106,7 +108,7 @@ TRAP_ENTRY KiDebugService, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY KiUnexpectedInterruptTail, 0 ALIGN 4 -EXTERN @KiInterruptTemplateHandler@8 +EXTERN @KiInterruptTemplateHandler@8:PROC PUBLIC _KiInterruptTemplate _KiInterruptTemplate: KiEnterTrap KI_PUSH_FAKE_ERROR_CODE @@ -135,10 +137,10 @@ _KiFastCallEntry: PUBLIC _KiStartUnexpectedRange@0 _KiStartUnexpectedRange@0: i = 0 -.rept 208 +REPEAT 208 GENERATE_INT_HANDLER %i i = i + 1 -.endr +ENDR PUBLIC _KiEndUnexpectedRange@0 _KiEndUnexpectedRange@0: jmp _KiUnexpectedInterruptTail diff --git a/reactos/ntoskrnl/ke/i386/usercall_asm.S b/reactos/ntoskrnl/ke/i386/usercall_asm.S index 2da726882eb..dcdc7ba9e88 100644 --- a/reactos/ntoskrnl/ke/i386/usercall_asm.S +++ b/reactos/ntoskrnl/ke/i386/usercall_asm.S @@ -8,17 +8,18 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include -/* FUNCTIONS ****************************************************************/ +EXTERN _MmGrowKernelStack@4:PROC +EXTERN _KeUserCallbackDispatcher:PROC +EXTERN @KiServiceExit@8:PROC -.code32 -.text +/* FUNCTIONS ****************************************************************/ +.code -.globl _KiGetUserModeStackAddress@0 -.func KiGetUserModeStackAddress@0 +PUBLIC _KiGetUserModeStackAddress@0 _KiGetUserModeStackAddress@0: /* Get the current thread's trapframe and return the esp */ @@ -27,7 +28,6 @@ _KiGetUserModeStackAddress@0: lea eax, [eax+KTRAP_FRAME_ESP] ret -.endfunc /*++ * @name KiCallUserMode @@ -53,8 +53,7 @@ _KiGetUserModeStackAddress@0: * This call MUST be paired by interrupt 0x2B or NtCallbackReturn. * *--*/ -.globl _KiCallUserMode@8 -.func KiCallUserMode@8 +PUBLIC _KiCallUserMode@8 _KiCallUserMode@8: /* Save volatile registers */ @@ -102,7 +101,7 @@ ApcsEnabled: #endif /* Get the lowest stack limit and check if we can handle it */ - lea eax, [esp-0x3000] + lea eax, [esp-HEX(3000)] cmp eax, [ebx+KTHREAD_STACK_LIMIT] jnb StackOk @@ -130,7 +129,7 @@ StackOk: mov [ebx+KTHREAD_CALLBACK_STACK], esp /* Align stack on 16-byte boundary */ - and esp, ~15 + and esp, NOT 15 mov edi, esp /* Set destination and origin NPX Areas */ @@ -181,7 +180,7 @@ DontBias: /* Copy DR7 */ mov edi, [edx+KTRAP_FRAME_DR7] - test edi, ~DR7_RESERVED_MASK + test edi, NOT DR7_RESERVED_MASK mov [esp+KTRAP_FRAME_DR7], edi /* Check if we need to save debug registers */ @@ -226,7 +225,6 @@ GrowFailed: /* Return */ ret 8 -.endfunc /*++ * @name NtCallbackReturn @@ -251,8 +249,7 @@ GrowFailed: * @remark This call MUST be paired with KeUserModeCallback. * *--*/ -.globl _NtCallbackReturn@12 -.func NtCallbackReturn@12 +PUBLIC _NtCallbackReturn@12 _NtCallbackReturn@12: /* Get the current thread and make sure we have a callback stack */ @@ -316,7 +313,7 @@ CheckDebug: and dword ptr [edi+KTRAP_FRAME_DR7], 0 /* Check if debugging was active */ - test byte ptr [eax+KTHREAD_DEBUG_ACTIVE], 0xFF + test byte ptr [eax+KTHREAD_DEBUG_ACTIVE], HEX(0FF) jnz RestoreDebug RestoreStack: @@ -407,7 +404,6 @@ NoStack: /* Return failure */ mov eax, STATUS_NO_CALLBACK_ACTIVE ret 12 -.endfunc /*++ * @name KeSwitchKernelStack @@ -429,8 +425,7 @@ NoStack: * this routine. * *--*/ -.globl _KeSwitchKernelStack@8 -.func KeSwitchKernelStack@8 +PUBLIC _KeSwitchKernelStack@8 _KeSwitchKernelStack@8: /* Save volatiles */ @@ -515,4 +510,5 @@ V86Switch: pop edi pop esi ret 8 -.endfunc + +END diff --git a/reactos/ntoskrnl/rtl/i386/stack.S b/reactos/ntoskrnl/rtl/i386/stack.S index d71cc4f0c3e..7fbb6e0106a 100644 --- a/reactos/ntoskrnl/rtl/i386/stack.S +++ b/reactos/ntoskrnl/rtl/i386/stack.S @@ -8,13 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include /* FUNCTIONS *****************************************************************/ +.code -.func RtlpGetStackLimits@8 -.globl _RtlpGetStackLimits@8 +PUBLIC _RtlpGetStackLimits@8 _RtlpGetStackLimits@8: /* Get the current thread */ @@ -34,4 +34,5 @@ _RtlpGetStackLimits@8: /* return */ ret 8 -.endfunc + +END diff --git a/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s b/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s index 24451140f7c..1d36aa4bb9c 100644 --- a/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s +++ b/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s @@ -6,13 +6,12 @@ * PROGRAMMERS: Magnus Olsen */ -.globl _DIB_24BPP_HLine -.intel_syntax noprefix +#include + +.code + +PUBLIC _DIB_24BPP_HLine -.def _DIB_24BPP_HLine; -.scl 2; -.type 32; -.endef _DIB_24BPP_HLine: push edi push esi @@ -151,3 +150,5 @@ pop esi pop edi ret + +END diff --git a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s index fce9f7f84c0..00a83804a73 100644 --- a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s +++ b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s @@ -7,15 +7,16 @@ * Timo Kreuzer (timo.kreuzer@reactos.org) */ -.intel_syntax noprefix +#include +.code /* * BOOLEAN * _cdecl * DIB_32BPP_ColorFill(SURFOBJ* pso, RECTL* prcl, ULONG iColor); */ -.globl _DIB_32BPP_ColorFill +PUBLIC _DIB_32BPP_ColorFill _DIB_32BPP_ColorFill: push ebp mov ebp, esp @@ -27,22 +28,22 @@ _DIB_32BPP_ColorFill: mov edx, [ebp+12] /* edx = prcl */ mov ecx, [ebp+8] /* ecx = pso */ - mov ebx, [ecx+0x24] /* ebx = pso->lDelta; */ + mov ebx, [ecx+36] /* ebx = pso->lDelta; */ mov [esp], ebx /* lDelta = pso->lDelta; */ mov edi, [edx+4] /* edi = prcl->top; */ mov eax, edi /* eax = prcl->top; */ imul eax, ebx /* eax = prcl->top * pso->lDelta; */ - add eax, [ecx+0x20] /* eax += pso->pvScan0; */ + add eax, [ecx+32] /* eax += pso->pvScan0; */ mov ebx, [edx] /* ebx = prcl->left; */ lea esi, [eax+ebx*4] /* esi = pvLine0 = eax + 4 * prcl->left; */ mov ebx, [edx+8] /* ebx = prcl->right; */ sub ebx, [edx] /* ebx = prcl->right - prcl->left; */ - jbe end /* if (ebx <= 0) goto end; */ + jbe .end /* if (ebx <= 0) goto end; */ mov edx, [edx+12] /* edx = prcl->bottom; */ sub edx, edi /* edx -= prcl->top; */ - jbe end /* if (eax <= 0) goto end; */ + jbe .end /* if (eax <= 0) goto end; */ mov eax, [ebp+16] /* eax = iColor; */ cld @@ -55,7 +56,7 @@ for_loop: /* do { */ dec edx /* cy--; */ jnz for_loop /* } while (cy > 0); */ -end: +.end: mov eax, 1 add esp, 4 pop edi @@ -63,3 +64,5 @@ end: pop ebx pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s index f976b8741bf..c60d43d6343 100644 --- a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s +++ b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s @@ -6,13 +6,11 @@ * PROGRAMMERS: Magnus Olsen */ -.globl _DIB_32BPP_HLine -.intel_syntax noprefix +#include -.def _DIB_32BPP_HLine; -.scl 2; -.type 32; -.endef +.code + +PUBLIC _DIB_32BPP_HLine _DIB_32BPP_HLine: sub esp, 12 // rember the base is not hex it is dec @@ -55,3 +53,4 @@ _save_rest: add esp, 12 ret +END diff --git a/reactos/subsystems/win32/win32k/eng/i386/floatobj.S b/reactos/subsystems/win32/win32k/eng/i386/floatobj.S index 6a9a3324729..c046bcfbeec 100644 --- a/reactos/subsystems/win32/win32k/eng/i386/floatobj.S +++ b/reactos/subsystems/win32/win32k/eng/i386/floatobj.S @@ -6,6 +6,9 @@ * PROGRAMMER: Timo Kreuzer */ +#include + +.code /******************************************************************************* * IEEE 754-1985 single precision floating point @@ -72,9 +75,6 @@ * FLOATOBJ_SubLong - wrapper */ -.intel_syntax noprefix -.text - #define lMant 0 #define lExp 4 @@ -87,24 +87,24 @@ * FLOATOBJ_SetFloat(IN OUT PFLOATOBJ pf, IN FLOATL f); */ _FLOATOBJ_SetFloat@8: -.global _FLOATOBJ_SetFloat@8 +PUBLIC _FLOATOBJ_SetFloat@8 push ebp mov ebp, esp mov ecx, [esp + PARAM2] /* Load the float into ecx */ mov eax, ecx /* Copy float to eax for later */ - test ecx, 0x7f800000 /* Check for zero exponent - 0 or denormal */ + test ecx, HEX(7f800000) /* Check for zero exponent - 0 or denormal */ jz SetFloat0 /* If it's all zero, ... */ shl ecx, 7 /* Put the bits for the mantissa in place */ cdq /* Fill edx with the sign from the FLOATL in eax */ - and ecx, 0x7fffffff /* Mask out invalid field in the mantissa */ + and ecx, HEX(7fffffff) /* Mask out invalid field in the mantissa */ shr eax, 23 /* Shift the exponent in eax in place */ - or ecx, 0x40000000 /* Set bit for 1 in the mantissa */ - and eax, 0xff /* Mask out invalid fields in the exponent in eax */ + or ecx, HEX(40000000) /* Set bit for 1 in the mantissa */ + and eax, HEX(0ff) /* Mask out invalid fields in the exponent in eax */ xor ecx, edx /* Make use of the sign bit expanded to full edx */ @@ -136,7 +136,7 @@ SetFloat0: * */ _FLOATOBJ_GetFloat@4: -.global _FLOATOBJ_GetFloat@4 +PUBLIC _FLOATOBJ_GetFloat@4 push ebp mov ebp, esp @@ -152,13 +152,13 @@ _FLOATOBJ_GetFloat@4: sub eax, edx jz GetFloatRet - and ecx, 0xff /* Mask out invalid fields in the exponent */ - and eax, 0x3fffffff /* Mask out invalid fields in mantissa */ + and ecx, HEX(0ff) /* Mask out invalid fields in the exponent */ + and eax, HEX(3fffffff) /* Mask out invalid fields in mantissa */ shl ecx, 23 /* Shift exponent in place */ shr eax, 7 /* Shift mantissa in place */ - and edx, 0x80000000 /* Reduce edx to sign bit only */ + and edx, HEX(80000000) /* Reduce edx to sign bit only */ or eax, ecx /* Set exponent in result */ or eax, edx /* Set sign bit in result */ @@ -178,7 +178,7 @@ GetFloatRet: * Instead of using abs(l), which is 3 + 2 instructions, use a branch. */ _FLOATOBJ_SetLong@8: -.global _FLOATOBJ_SetLong@8 +PUBLIC _FLOATOBJ_SetLong@8 push ebp mov ebp, esp @@ -236,7 +236,7 @@ SetLong0: * */ _FLOATOBJ_GetLong@4: -.global _FLOATOBJ_GetLong@4 +PUBLIC _FLOATOBJ_GetLong@4 push ebp mov ebp, esp @@ -263,7 +263,7 @@ GetLong2: * FLOATOBJ_Equal(IN PFLOATOBJ pf1, IN PFLOATOBJ pf2); */ _FLOATOBJ_Equal@8: -.global _FLOATOBJ_Equal@8 +PUBLIC _FLOATOBJ_Equal@8 push ebp mov ebp, esp @@ -291,7 +291,7 @@ _FLOATOBJ_Equal@8: * FLOATOBJ_EqualLong(IN PFLOATOBJ pf, IN LONG l); */ _FLOATOBJ_EqualLong@8: -.global _FLOATOBJ_EqualLong@8 +PUBLIC _FLOATOBJ_EqualLong@8 push ebp mov ebp, esp @@ -325,7 +325,7 @@ EqualLongFalse: * */ _FLOATOBJ_GreaterThan@8: -.global _FLOATOBJ_GreaterThan@8 +PUBLIC _FLOATOBJ_GreaterThan@8 push ebp mov ebp, esp @@ -415,7 +415,7 @@ GreaterThan_neg2: * LOATOBJ_GreaterThan */ _FLOATOBJ_GreaterThanLong@8: -.global _FLOATOBJ_GreaterThanLong@8 +PUBLIC _FLOATOBJ_GreaterThanLong@8 push ebp mov ebp, esp @@ -445,7 +445,7 @@ _FLOATOBJ_GreaterThanLong@8: * */ _FLOATOBJ_LessThan@8: -.global _FLOATOBJ_LessThan@8 +PUBLIC _FLOATOBJ_LessThan@8 push ebp mov ebp, esp @@ -536,7 +536,7 @@ LessThan_neg2: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_LessThan */ _FLOATOBJ_LessThanLong@8: -.global _FLOATOBJ_LessThanLong@8 +PUBLIC _FLOATOBJ_LessThanLong@8 push ebp mov ebp, esp @@ -569,7 +569,7 @@ _FLOATOBJ_LessThanLong@8: * No special handling for 0, where mantissa is 0 */ _FLOATOBJ_Mul@8: -.global _FLOATOBJ_Mul@8 +PUBLIC _FLOATOBJ_Mul@8 push ebp mov ebp, esp @@ -620,7 +620,7 @@ MulNeg: lea edx, [edx + ecx -2] /* Normalize exponent in edx */ - or eax, 0x80000000 /* Set sign bit */ + or eax, HEX(80000000) /* Set sign bit */ mov ecx, [esp + PARAM1] /* Load pf1 into ecx */ mov [ecx + lMant], eax /* Save back mantissa */ @@ -646,7 +646,7 @@ Mul0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Mul */ _FLOATOBJ_MulFloat@8: -.global _FLOATOBJ_MulFloat@8 +PUBLIC _FLOATOBJ_MulFloat@8 push ebp mov ebp, esp @@ -675,7 +675,7 @@ _FLOATOBJ_MulFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Mul */ _FLOATOBJ_MulLong@8: -.global _FLOATOBJ_MulLong@8 +PUBLIC _FLOATOBJ_MulLong@8 push ebp mov ebp, esp @@ -703,7 +703,7 @@ _FLOATOBJ_MulLong@8: * */ _FLOATOBJ_Div@8: -.global _FLOATOBJ_Div@8 +PUBLIC _FLOATOBJ_Div@8 push ebp mov ebp, esp push ebx @@ -736,7 +736,7 @@ _FLOATOBJ_Div@8: div ecx /* Do an unsigned divide */ xor ecx, ecx /* Adjust result */ - test eax, 0x80000000 + test eax, HEX(80000000) setnz cl shr eax, cl @@ -773,7 +773,7 @@ Div0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Div */ _FLOATOBJ_DivFloat@8: -.global _FLOATOBJ_DivFloat@8 +PUBLIC _FLOATOBJ_DivFloat@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -802,7 +802,7 @@ _FLOATOBJ_DivFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Div */ _FLOATOBJ_DivLong@8: -.global _FLOATOBJ_DivLong@8 +PUBLIC _FLOATOBJ_DivLong@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -829,7 +829,7 @@ _FLOATOBJ_DivLong@8: * */ _FLOATOBJ_Add@8: -.global _FLOATOBJ_Add@8 +PUBLIC _FLOATOBJ_Add@8 push ebp mov ebp, esp push ebx @@ -928,7 +928,7 @@ AddIs0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Add */ _FLOATOBJ_AddFloat@8: -.global _FLOATOBJ_AddFloat@8 +PUBLIC _FLOATOBJ_AddFloat@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -957,7 +957,7 @@ _FLOATOBJ_AddFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Add */ _FLOATOBJ_AddLong@8: -.global _FLOATOBJ_AddLong@8 +PUBLIC _FLOATOBJ_AddLong@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -985,7 +985,7 @@ _FLOATOBJ_AddLong@8: * */ _FLOATOBJ_Sub@8: -.global _FLOATOBJ_Sub@8 +PUBLIC _FLOATOBJ_Sub@8 push ebp mov ebp, esp push ebx @@ -1083,7 +1083,7 @@ SubIs0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Sub */ _FLOATOBJ_SubFloat@8: -.global _FLOATOBJ_SubFloat@8 +PUBLIC _FLOATOBJ_SubFloat@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -1112,7 +1112,7 @@ _FLOATOBJ_SubFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Sub */ _FLOATOBJ_SubLong@8: -.global _FLOATOBJ_SubLong@8 +PUBLIC _FLOATOBJ_SubLong@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -1140,7 +1140,7 @@ _FLOATOBJ_SubLong@8: * */ _FLOATOBJ_Neg@4: -.global _FLOATOBJ_Neg@4 +PUBLIC _FLOATOBJ_Neg@4 push ebp mov ebp, esp @@ -1150,5 +1150,5 @@ _FLOATOBJ_Neg@4: pop ebp /* Return */ ret 4 - +END /* EOF */ diff --git a/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s b/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s index 1ce05320559..75aca5f7b30 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _atan2 - -.intel_syntax noprefix +#include + /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _atan2 _atan2: push ebp mov ebp,esp @@ -49,3 +49,5 @@ _atan2: mov esp,ebp pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s b/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s index aad69114f5a..1256fa1cf00 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _ceil -.intel_syntax noprefix +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _ceil _ceil: push ebp mov ebp,esp @@ -47,7 +47,7 @@ _ceil: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0xb63 // Rounding control word + mov word ptr [ebp-4],HEX(b63) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +55,5 @@ _ceil: mov esp,ebp // Deallocate temporary space pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s b/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s index b1c6ada49b2..8b525755b17 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _cos -.intel_syntax noprefix +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _cos _cos: push ebp mov ebp,esp // Point to the stack frame @@ -47,3 +47,5 @@ _cos: fcos // Take the cosine pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s b/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s index f03c85cb4e8..1f5f2b107df 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _floor - -.intel_syntax noprefix + +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _floor _floor: push ebp mov ebp,esp @@ -47,7 +47,7 @@ _floor: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0x763 // Rounding control word + mov word ptr [ebp-4],HEX(763) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +55,5 @@ _floor: mov esp,ebp pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s b/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s index 39791a3e989..7ec0fa69c23 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _sin -.intel_syntax noprefix +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _sin _sin: push ebp // Save register bp mov ebp,esp // Point to the stack frame @@ -47,3 +47,5 @@ _sin: fsin // Take the sine pop ebp // Restore register bp ret + +END diff --git a/reactos/tools/nci/ncitool.c b/reactos/tools/nci/ncitool.c index 07838af1efa..ca10a815a5b 100644 --- a/reactos/tools/nci/ncitool.c +++ b/reactos/tools/nci/ncitool.c @@ -50,16 +50,15 @@ * This stubs calls into KUSER_SHARED_DATA where either a * sysenter or interrupt is performed, depending on CPU support. */ -#if defined(__GNUC__) -#define UserModeStub_x86 " movl $0x%x, %%eax\n" \ - " movl $KUSER_SHARED_SYSCALL, %%ecx\n" \ - " call *(%%ecx)\n" \ - " ret $0x%x\n\n" - -#define UserModeStub_amd64 " movl $0x%x, %%eax\n" \ - " movq %%rcx, %%r10\n" \ +#define UserModeStub_x86 " mov eax, %d\n" \ + " mov ecx, KUSER_SHARED_SYSCALL\n" \ + " call dword ptr [ecx]\n" \ + " ret %d\n\n" + +#define UserModeStub_amd64 " mov eax, %d\n" \ + " mov r10, rcx\n" \ " syscall\n" \ - " ret $0x%x\n\n" + " ret %d\n\n" #define UserModeStub_ppc " stwu 1,-16(1)\n" \ " mflr 0\n\t" \ @@ -79,32 +78,21 @@ #define UserModeStub_arm " swi #0x%x\n" \ " bx lr\n\n" -#elif defined(_MSC_VER) -#define UserModeStub_x86 " asm { \n" \ - " mov eax, %xh\n" \ - " mov ecx, KUSER_SHARED_SYSCALL\n" \ - " call [ecx]\n" \ - " ret %xh\n" \ - " }\n" -#else -#error Unknown compiler for inline assembler -#endif /* * This stub calls KiSystemService directly with a fake INT2E stack. * Because EIP is pushed during the call, the handler will return here. */ -#if defined(__GNUC__) -#define KernelModeStub_x86 " movl $0x%x, %%eax\n" \ - " leal 4(%%esp), %%edx\n" \ - " pushfl\n" \ - " pushl $KGDT_R0_CODE\n" \ +#define KernelModeStub_x86 " mov eax, %d\n" \ + " lea edx, [esp + 4]\n" \ + " pushf\n" \ + " push KGDT_R0_CODE\n" \ " call _KiSystemService\n" \ - " ret $0x%x\n\n" + " ret %d\n\n" -#define KernelModeStub_amd64 " movl $0x%x, %%eax\n" \ +#define KernelModeStub_amd64 " mov eax, %d\n" \ " call KiSystemService\n" \ - " ret $0x%x\n\n" + " ret %d\n\n" /* For now, use the usermode stub. We'll optimize later */ #define KernelModeStub_ppc UserModeStub_ppc @@ -116,19 +104,6 @@ " swi #0x%x\n" \ " bx ip\n\n" -#elif defined(_MSC_VER) -#define KernelModeStub_x86 " asm { \n" \ - " mov eax, %xh\n" \ - " lea edx, [esp+4]\n" \ - " pushf\n" \ - " push KGDT_R0_CODE\n" \ - " call _KiSystemService\n" \ - " ret %xh\n" \ - " }\n" -#else -#error Unknown compiler for inline assembler -#endif - /***** Arch Dependent Stuff ******/ struct ncitool_data_t { const char *arch; @@ -141,9 +116,9 @@ struct ncitool_data_t { struct ncitool_data_t ncitool_data[] = { { "i386", 4, KernelModeStub_x86, UserModeStub_x86, - ".global _%s@%d\n", "_%s@%d:\n" }, + "PUBLIC _%s@%d\n", "_%s@%d:\n" }, { "amd64", 4, KernelModeStub_amd64, UserModeStub_amd64, - ".global %s\n", "%s:\n" }, + "PUBLIC %s\n", "%s:\n" }, { "powerpc", 4, KernelModeStub_ppc, UserModeStub_ppc, "\t.globl %s\n", "%s:\n" }, { "mips", 4, KernelModeStub_mips, UserModeStub_mips, @@ -192,14 +167,14 @@ WriteFileHeader(FILE * StubFile, " * PURPOSE: %s\n" " * PROGRAMMER: Computer Generated File. See tools/nci/ncitool.c\n" " * REMARK: DO NOT EDIT OR COMMIT MODIFICATIONS TO THIS FILE\n" - " */\n\n\n" - "#include \n\n", + " */\n\n\n", + FileDescription, FileLocation); } /*++ - * WriteFileHeader + * WriteStubHeader * * Prints out the File Header for a Stub File. * @@ -393,6 +368,7 @@ CreateStubs(FILE * SyscallDb, char *SyscallArguments; int SyscallId; unsigned StackBytes; + unsigned int i; /* We loop, incrementing the System Call Index, until the end of the file */ for (SyscallId = 0; ((!feof(SyscallDb)) && (fgets(Line, sizeof(Line), SyscallDb) != NULL));) { @@ -408,26 +384,23 @@ CreateStubs(FILE * SyscallDb, if (NtSyscallName) { /* Create Usermode Stubs for Nt/Zw syscalls in each Usermode file */ - int i; for (i= 0; i < UserFiles; i++) { - /* Write the Nt Version */ - WriteUserModeStub(UserModeFiles[i], - NtSyscallName, - StackBytes, - SyscallId | Index); + /* Write the Stub Header and export the Function */ + WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes); /* If a Zw Version is needed (was specified), write it too */ if (NeedsZw) { NtSyscallName[0] = 'Z'; NtSyscallName[1] = 'w'; - WriteUserModeStub(UserModeFiles[i], - NtSyscallName, - StackBytes, - SyscallId | Index); + + /* Write the Stub Header and export the Function */ + WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes); } + /* Write the Stub Code */ + fprintf(UserModeFiles[i], UserModeStub, SyscallId | Index, StackBytes); } /* Create the Kernel coutnerparts (only Zw*, Nt* are the real functions!) */ @@ -445,6 +418,11 @@ CreateStubs(FILE * SyscallDb, SyscallId++; } } + +#if defined(_MSC_VER) + for (i= 0; i < UserFiles; i++) fprintf(UserModeFiles[i], "END\n"); + fprintf(KernelModeFile, "END\n"); +#endif } /*++ @@ -627,7 +605,7 @@ CreateSpec(FILE * SyscallDb, /* Make sure we really extracted something */ if (NtSyscallName) { - int i; + unsigned int i; for (i= 0; i < CountFiles; i++) { if (!UseZw) { @@ -670,7 +648,7 @@ void usage(char * argv0) int main(int argc, char* argv[]) { - FILE * Files[Arguments] = { }; + FILE * Files[Arguments] = {0}; int FileNumber, ArgOffset = 1; char * OpenType = "r"; @@ -710,15 +688,24 @@ int main(int argc, char* argv[]) WriteFileHeader(Files[NtosUserStubs], "System Call Stubs for Native API", argv[NtosUserStubs + ArgOffset]); + fputs("#include \n" + "#include \n" + ".code\n\n", Files[NtosUserStubs]); WriteFileHeader(Files[NtosKernelStubs], "System Call Stubs for Native API", argv[NtosKernelStubs + ArgOffset]); - fputs("#include \n\n", Files[NtosKernelStubs]); + fputs("#include \n" + "#include \n" + ".code\n" + "EXTERN _KiSystemService:PROC\n\n", Files[NtosKernelStubs]); WriteFileHeader(Files[Win32kStubs], "System Call Stubs for Native API", argv[Win32kStubs + ArgOffset]); + fputs("#include \n" + "#include \n" + ".code\n\n", Files[Win32kStubs]); /* Create the System Stubs */ CreateStubs(Files[NativeSystemDb], @@ -772,3 +759,4 @@ int main(int argc, char* argv[]) return(0); } + -- 2.17.1