github.com/aloncn/graphics-go@v0.0.1/src/runtime/cgo/asm_arm64.s (about)

     1  // Copyright 2015 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 "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,$-8
    12  	/*
    13  	 * We still need to save all callee save register as before, and then
    14  	 *  push 2 args for fn (R1 and R2).
    15  	 * Also note that at procedure entry in gc world, 8(RSP) will be the
    16  	 *  first arg.
    17  	 * TODO(minux): use LDP/STP here if it matters.
    18  	 */
    19  	SUB	$128, RSP
    20  	MOVD	R1, (8*1)(RSP)
    21  	MOVD	R2, (8*2)(RSP)
    22  	MOVD	R19, (8*3)(RSP)
    23  	MOVD	R20, (8*4)(RSP)
    24  	MOVD	R21, (8*5)(RSP)
    25  	MOVD	R22, (8*6)(RSP)
    26  	MOVD	R23, (8*7)(RSP)
    27  	MOVD	R24, (8*8)(RSP)
    28  	MOVD	R25, (8*9)(RSP)
    29  	MOVD	R26, (8*10)(RSP)
    30  	MOVD	R27, (8*11)(RSP)
    31  	MOVD	g, (8*12)(RSP)
    32  	MOVD	R29, (8*13)(RSP)
    33  	MOVD	R30, (8*14)(RSP)
    34  
    35  	MOVD	R0, R19
    36  
    37  	// Initialize Go ABI environment
    38  	BL      runtimeĀ·reginit(SB)
    39  	BL	runtimeĀ·load_g(SB)
    40  	BL	(R19)
    41  
    42  	MOVD	(8*1)(RSP), R1
    43  	MOVD	(8*2)(RSP), R2
    44  	MOVD	(8*3)(RSP), R19
    45  	MOVD	(8*4)(RSP), R20
    46  	MOVD	(8*5)(RSP), R21
    47  	MOVD	(8*6)(RSP), R22
    48  	MOVD	(8*7)(RSP), R23
    49  	MOVD	(8*8)(RSP), R24
    50  	MOVD	(8*9)(RSP), R25
    51  	MOVD	(8*10)(RSP), R26
    52  	MOVD	(8*11)(RSP), R27
    53  	MOVD	(8*12)(RSP), g
    54  	MOVD	(8*13)(RSP), R29
    55  	MOVD	(8*14)(RSP), R30
    56  	ADD	$128, RSP
    57  	RET