1
0
mirror of https://github.com/golang/go synced 2024-10-05 00:21:21 -06:00
go/src/pkg/runtime/cgo/asm_amd64.s
Russ Cox d17506e52d runtime/cgo: make crosscall2 5a/6a/8a-assembled
There is a #pragma dynexport crosscall2, to help SWIG,
and 6l cannot export the symbol if it doesn't get to see it.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7448044
2013-02-28 22:14:55 -08:00

46 lines
985 B
ArmAsm

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
* void crosscall2(void (*fn)(void*, int32), void*, int32)
* Save registers and call fn with two arguments.
*/
TEXT crosscall2(SB),7,$0
SUBQ $0x58, SP /* keeps stack pointer 32-byte aligned */
MOVQ BX, 0x10(SP)
MOVQ BP, 0x18(SP)
MOVQ R12, 0x20(SP)
MOVQ R13, 0x28(SP)
MOVQ R14, 0x30(SP)
MOVQ R15, 0x38(SP)
#ifdef GOOS_windows
// Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15
MOVQ DI, 0x40(SP)
MOVQ SI, 0x48(SP)
MOVQ DX, 0(SP) /* arg */
MOVQ R8, 8(SP) /* argsize (includes padding) */
CALL CX /* fn */
MOVQ 0x40(SP), DI
MOVQ 0x48(SP), SI
#else
MOVQ SI, 0(SP) /* arg */
MOVQ DX, 8(SP) /* argsize (includes padding) */
CALL DI /* fn */
#endif
MOVQ 0x10(SP), BX
MOVQ 0x18(SP), BP
MOVQ 0x20(SP), R12
MOVQ 0x28(SP), R13
MOVQ 0x30(SP), R14
MOVQ 0x38(SP), R15
ADDQ $0x58, SP
RET