summary refs log tree commit diff stats
path: root/tinyc/win32/lib/chkstk.S
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2010-08-28 22:33:07 +0200
committerAraq <rumpf_a@web.de>2010-08-28 22:33:07 +0200
commit47886978c79a3246295114a853a9cd945d368708 (patch)
treef006dc90bb9c8c166214ca751af3739b89a73621 /tinyc/win32/lib/chkstk.S
parentb2075302b10b88047ea16007895bff4e46a2fa9c (diff)
downloadNim-47886978c79a3246295114a853a9cd945d368708.tar.gz
tiny C support; cosmetic improvements for the docs
Diffstat (limited to 'tinyc/win32/lib/chkstk.S')
-rwxr-xr-xtinyc/win32/lib/chkstk.S29
1 files changed, 29 insertions, 0 deletions
diff --git a/tinyc/win32/lib/chkstk.S b/tinyc/win32/lib/chkstk.S
new file mode 100755
index 000000000..837d8af2b
--- /dev/null
+++ b/tinyc/win32/lib/chkstk.S
@@ -0,0 +1,29 @@
+// =================================================
+// chkstk.s
+
+.text
+.globl __chkstk
+
+__chkstk:
+	xchg    (%esp), %ebp   // store ebp, get ret.addr
+	push    %ebp           // push ret.addr
+	lea     4(%esp), %ebp  // setup frame ptr
+	push    %ecx           // save ecx
+	mov     %ebp, %ecx
+P0:
+	sub     $4096,%ecx
+	test    %eax,(%ecx)
+	sub     $4096,%eax
+	cmp     $4096,%eax
+	jge     P0
+
+	sub     %eax,%ecx
+	mov     %esp,%eax
+	test    %eax,(%ecx)
+	mov     %ecx,%esp
+
+	mov     (%eax),%ecx     // restore ecx
+	mov     4(%eax),%eax
+	push    %eax
+	ret
+