enable making tcc using libtcc
[tinycc.git] / win32 / lib / chkstk.S
blob837d8af2b3d9f6a1c356d7e5ea919de84eaf879e
1 // =================================================
2 // chkstk.s
4 .text
5 .globl __chkstk
7 __chkstk:
8         xchg    (%esp), %ebp   // store ebp, get ret.addr
9         push    %ebp           // push ret.addr
10         lea     4(%esp), %ebp  // setup frame ptr
11         push    %ecx           // save ecx
12         mov     %ebp, %ecx
13 P0:
14         sub     $4096,%ecx
15         test    %eax,(%ecx)
16         sub     $4096,%eax
17         cmp     $4096,%eax
18         jge     P0
20         sub     %eax,%ecx
21         mov     %esp,%eax
22         test    %eax,(%ecx)
23         mov     %ecx,%esp
25         mov     (%eax),%ecx     // restore ecx
26         mov     4(%eax),%eax
27         push    %eax
28         ret