vx32

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

label.S (1259B)


      1 #ifdef __APPLE__
      2 #define EXT(s) _ ## s
      3 #else
      4 #define EXT(s) s
      5 #endif
      6 
      7 #ifdef i386
      8 
      9 .globl EXT(setlabel)
     10 EXT(setlabel):
     11 	movl	4(%esp), %eax
     12 	
     13 	movl %ebp, 0(%eax)
     14 	movl %ebx, 8(%eax)
     15 	movl %esi, 16(%eax)
     16 	movl %edi, 24(%eax)
     17 	movl %esp, 32(%eax)
     18 
     19 	movl 0(%esp), %ecx
     20 	movl %ecx, 40(%eax)
     21 	
     22 	movl $0, %eax
     23 	ret
     24 
     25 .globl EXT(gotolabel)
     26 EXT(gotolabel):
     27 	movl	4(%esp), %eax
     28 	
     29 	movl 0(%eax), %ebp
     30 	movl 8(%eax), %ebx
     31 	movl 16(%eax), %esi
     32 	movl 24(%eax), %edi
     33 	movl 32(%eax), %esp
     34 	
     35 	movl 40(%eax), %ecx
     36 	movl %ecx, 0(%esp)
     37 	
     38 	movl $1, %eax
     39 	ret
     40 
     41 #else
     42 
     43 // first param is %rdi
     44 // need to save %rbp, %rbx, %rsp, %rip, %r12-%r15.
     45 // %rsi and %rdi are not callee-save, unlike i386.
     46 
     47 .globl EXT(setlabel)
     48 EXT(setlabel):
     49 	movq %rbp, 0(%rdi)
     50 	movq %rbx, 8(%rdi)
     51 	// 16(%rdi) is saved si (not used)
     52 	// 24(%rdi) is saved di (not used)
     53 	movq %rsp, 32(%rdi)
     54 	movq 0(%rsp), %rax
     55 	movq %rax, 40(%rdi)	// %rip
     56 	movq %r12, 48(%rdi)
     57 	movq %r13, 56(%rdi)
     58 	movq %r14, 64(%rdi)
     59 	movq %r15, 72(%rdi)
     60 	movq $0, %rax
     61 	ret
     62 
     63 .globl EXT(gotolabel)
     64 EXT(gotolabel):
     65 	movq 0(%rdi), %rbp
     66 	movq 8(%rdi), %rbx
     67 	movq 32(%rdi), %rsp
     68 	movq 40(%rdi), %rax
     69 	movq %rax, 0(%rsp)	// %rip
     70 	movq 48(%rdi), %r12
     71 	movq 56(%rdi), %r13
     72 	movq 64(%rdi), %r14
     73 	movq 72(%rdi), %r15
     74 	movq $1, %rax
     75 	cld
     76 	ret
     77 
     78 #endif