forked from mkrautz/variadic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variadic_amd64.S
55 lines (45 loc) · 1.08 KB
/
variadic_amd64.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2012 Mikkel Krautz. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "asmregs_amd64.h"
.globl _VariadicCall
_VariadicCall:
.globl _VariadicCallFloat
_VariadicCallFloat:
.globl _VariadicCallDouble
_VariadicCallDouble:
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rax
movq REGS_RDI(%rax), %rdi
movq REGS_RSI(%rax), %rsi
movq REGS_RDX(%rax), %rdx
movq REGS_RCX(%rax), %rcx
movq REGS_R8(%rax), %r8
movq REGS_R9(%rax), %r9
movsd REGS_XMM0(%rax), %xmm0
movsd REGS_XMM1(%rax), %xmm1
movsd REGS_XMM2(%rax), %xmm2
movsd REGS_XMM3(%rax), %xmm3
movsd REGS_XMM4(%rax), %xmm4
movsd REGS_XMM5(%rax), %xmm5
movsd REGS_XMM6(%rax), %xmm6
movsd REGS_XMM7(%rax), %xmm7
movq REGS_NMEMORY(%rax), %r11
movq REGS_MEMORY(%rax), %r10
cmpq $0, %r11
je memdone
imulq $8, %r11
addq %r10, %r11
mem:
subq $8, %r11
pushq (%r11)
cmpq %r11, %r10
jne mem
memdone:
movq REGS_ADDR(%rax), %r10
movq REGS_NFLOAT(%rax), %rax
callq *%r10
movq %rbp, %rsp
popq %rbp
retq