github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/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  /*
     6   * void crosscall2(void (*fn)(void*, int32), void*, int32)
     7   * Save registers and call fn with two arguments.
     8   */
     9  TEXT crosscall2(SB),7,$0
    10  	SUBQ	$0x58, SP	/* keeps stack pointer 32-byte aligned */
    11  	MOVQ	BX, 0x10(SP)
    12  	MOVQ	BP, 0x18(SP)
    13  	MOVQ	R12, 0x20(SP)
    14  	MOVQ	R13, 0x28(SP)
    15  	MOVQ	R14, 0x30(SP)
    16  	MOVQ	R15, 0x38(SP)
    17  
    18  #ifdef GOOS_windows
    19  	// Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15
    20  	MOVQ	DI, 0x40(SP)
    21  	MOVQ	SI, 0x48(SP)
    22  
    23  	MOVQ	DX, 0(SP)	/* arg */
    24  	MOVQ	R8, 8(SP)	/* argsize (includes padding) */
    25  	
    26  	CALL	CX	/* fn */
    27  	
    28  	MOVQ	0x40(SP), DI
    29  	MOVQ	0x48(SP), SI
    30  #else
    31  	MOVQ	SI, 0(SP)	/* arg */
    32  	MOVQ	DX, 8(SP)	/* argsize (includes padding) */
    33  
    34  	CALL	DI	/* fn */
    35  #endif
    36  
    37  	MOVQ	0x10(SP), BX
    38  	MOVQ	0x18(SP), BP
    39  	MOVQ	0x20(SP), R12
    40  	MOVQ	0x28(SP), R13
    41  	MOVQ	0x30(SP), R14
    42  	MOVQ	0x38(SP), R15
    43  	
    44  	ADDQ	$0x58, SP
    45  	RET