asm_linux_amd64.s raw

   1  // Copyright 2022 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  // func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
   8  //
   9  // We need to convert to the syscall ABI.
  10  //
  11  // arg | ABIInternal | Syscall
  12  // ---------------------------
  13  // num | AX          | AX
  14  // a1  | BX          | DI
  15  // a2  | CX          | SI
  16  // a3  | DI          | DX
  17  // a4  | SI          | R10
  18  // a5  | R8          | R8
  19  // a6  | R9          | R9
  20  //
  21  // r1  | AX          | AX
  22  // r2  | BX          | DX
  23  // err | CX          | part of AX
  24  //
  25  // Note that this differs from "standard" ABI convention, which would pass 4th
  26  // arg in CX, not R10.
  27  TEXT ·Syscall6<ABIInternal>(SB),NOSPLIT,$0
  28  	// a6 already in R9.
  29  	// a5 already in R8.
  30  	MOVQ	SI, R10 // a4
  31  	MOVQ	DI, DX  // a3
  32  	MOVQ	CX, SI  // a2
  33  	MOVQ	BX, DI  // a1
  34  	// num already in AX.
  35  	SYSCALL
  36  	CMPQ	AX, $0xfffffffffffff001
  37  	JLS	ok
  38  	NEGQ	AX
  39  	MOVQ	AX, CX  // errno
  40  	MOVQ	$-1, AX // r1
  41  	MOVQ	$0, BX  // r2
  42  	RET
  43  ok:
  44  	// r1 already in AX.
  45  	MOVQ	DX, BX // r2
  46  	MOVQ	$0, CX // errno
  47  	RET
  48