vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

darwin-asm.S (751B)


      1 // Context routines for OS X
      2 
      3 // vx32_getcontext(struct i386_thread_state *ss);  
      4 // see /usr/include/mach/i386/thread_status.h for layout.
      5 // not traditional intel layout!
      6 
      7 .globl _vx32_getcontext
      8 _vx32_getcontext:
      9 	movl 4(%esp), %eax
     10 	
     11 	movl $1, 0(%eax) /* %eax */
     12 	movl %ebx, 4(%eax)
     13 	movl %ecx, 8(%eax)
     14 	movl %edx, 12(%eax)
     15 	movl %edi, 16(%eax)
     16 	movl %esi, 20(%eax)
     17 	movl %ebp, 24(%eax)
     18 	/* 28(%eax) is esp */
     19 	movl %ss, 32(%eax)
     20 	pushfl
     21 	popl 36(%eax)
     22 	/* 40(%eax) is eip */
     23 	movl %cs, 44(%eax)
     24 	movl %ds, 48(%eax)
     25 	movl %es, 52(%eax)
     26 	movl %fs, 56(%eax)
     27 	movl %gs, 60(%eax)
     28 	
     29 	movl 0(%esp), %ecx		/* %eip */
     30 	movl %ecx, 40(%eax)
     31 	leal 4(%esp), %ecx		/* %esp */
     32 	movl %ecx, 28(%eax)
     33 	
     34 	movl 8(%eax), %ecx		/* restore %ecx */
     35 	movl $0, %eax
     36 	ret
     37