libvx32/OSX: add forgotten darwin-asm.S - vx32 - Local 9vx git repository for patches.
Log
Files
Refs
---
commit 261ae7f9ebdff175fc43fa6067de6abb4df1d52f
parent c144c04d93a9215b1749322cbebef45f043474a6
Author: Russ Cox 
Date:   Sat, 28 Jun 2008 12:35:40 -0400

libvx32/OSX: add forgotten darwin-asm.S

Diffstat:
  src/libvx32/darwin-asm.S            |      37 +++++++++++++++++++++++++++++++

1 file changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/libvx32/darwin-asm.S b/src/libvx32/darwin-asm.S
@@ -0,0 +1,37 @@
+// Context routines for OS X
+
+// vx32_getcontext(struct i386_thread_state *ss);  
+// see /usr/include/mach/i386/thread_status.h for layout.
+// not traditional intel layout!
+
+.globl _vx32_getcontext
+_vx32_getcontext:
+        movl 4(%esp), %eax
+        
+        movl $1, 0(%eax) /* %eax */
+        movl %ebx, 4(%eax)
+        movl %ecx, 8(%eax)
+        movl %edx, 12(%eax)
+        movl %edi, 16(%eax)
+        movl %esi, 20(%eax)
+        movl %ebp, 24(%eax)
+        /* 28(%eax) is esp */
+        movl %ss, 32(%eax)
+        pushfl
+        popl 36(%eax)
+        /* 40(%eax) is eip */
+        movl %cs, 44(%eax)
+        movl %ds, 48(%eax)
+        movl %es, 52(%eax)
+        movl %fs, 56(%eax)
+        movl %gs, 60(%eax)
+        
+        movl 0(%esp), %ecx                /* %eip */
+        movl %ecx, 40(%eax)
+        leal 4(%esp), %ecx                /* %esp */
+        movl %ecx, 28(%eax)
+        
+        movl 8(%eax), %ecx                /* restore %ecx */
+        movl $0, %eax
+        ret
+