github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/pkg/runtime/cgo/asm_amd64.s (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "../../../cmd/ld/textflag.h" 6 7 /* 8 * void crosscall2(void (*fn)(void*, int32), void*, int32) 9 * Save registers and call fn with two arguments. 10 */ 11 TEXT crosscall2(SB),NOSPLIT,$0 12 SUBQ $0x58, SP /* keeps stack pointer 32-byte aligned */ 13 MOVQ BX, 0x10(SP) 14 MOVQ BP, 0x18(SP) 15 MOVQ R12, 0x20(SP) 16 MOVQ R13, 0x28(SP) 17 MOVQ R14, 0x30(SP) 18 MOVQ R15, 0x38(SP) 19 20 #ifdef GOOS_windows 21 // Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15 22 MOVQ DI, 0x40(SP) 23 MOVQ SI, 0x48(SP) 24 25 MOVQ DX, 0(SP) /* arg */ 26 MOVQ R8, 8(SP) /* argsize (includes padding) */ 27 28 CALL CX /* fn */ 29 30 MOVQ 0x40(SP), DI 31 MOVQ 0x48(SP), SI 32 #else 33 MOVQ SI, 0(SP) /* arg */ 34 MOVQ DX, 8(SP) /* argsize (includes padding) */ 35 36 CALL DI /* fn */ 37 #endif 38 39 MOVQ 0x10(SP), BX 40 MOVQ 0x18(SP), BP 41 MOVQ 0x20(SP), R12 42 MOVQ 0x28(SP), R13 43 MOVQ 0x30(SP), R14 44 MOVQ 0x38(SP), R15 45 46 ADDQ $0x58, SP 47 RET