[CRT] Remove useless #undef abort from process.h
[reactos.git] / sdk / lib / crt / except / i386 / chkstk_ms.s
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Stack checker
5 * PROGRAMERS: KJK::Hyperion <noog@libero.it>
6 * Richard Henderson <rth@redhat.com>
7 * Kai Tietz <kai.tietz@onevision.com>
8 * Timo Kreuzer <timo.kreuzer@reactos.org>
9 */
10
11 #include <asm.inc>
12 #include <ks386.inc>
13
14 #define PAGE_SIZE 4096
15
16 PUBLIC ___chkstk_ms
17 .code
18
19 /* Special version, that does only probe and not allocate */
20 ___chkstk_ms:
21
22 /* EAX = size to be allocated */
23 /* save the ECX and EAX register */
24 push ecx
25 push eax
26
27 /* ECX = top of the previous stack frame */
28 lea ecx, [esp + 12]
29
30 /* probe the desired memory, page by page */
31 cmp eax, PAGE_SIZE
32 jl .l_LessThanAPage
33
34 .l_MoreThanAPage:
35
36 /* raise the top of the stack by a page and probe */
37 sub ecx, PAGE_SIZE
38 test [ecx], eax
39
40 /* loop if still more than a page must be probed */
41 sub eax, PAGE_SIZE
42 cmp eax, PAGE_SIZE
43 jge .l_MoreThanAPage
44
45 .l_LessThanAPage:
46
47 /* raise the top of the stack by EAX bytes (size % 4096) and probe */
48 sub ecx, eax
49 test [ecx], eax
50
51 /* restore ECX and EAX */
52 pop eax
53 pop ecx
54
55 /* return */
56 ret
57
58 /* EOF */
59 END