Text file src/syscall/asm_unix_386.s

     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  //go:build freebsd || netbsd
     6  
     7  #include "textflag.h"
     8  #include "funcdata.h"
     9  
    10  //
    11  // System call support for some 386 unixes
    12  //
    13  
    14  // func Syscall(trap int32, a1, a2, a3 int32) (r1, r2, err int32);
    15  // func Syscall6(trap int32, a1, a2, a3, a4, a5, a6 int32) (r1, r2, err int32);
    16  // Trap # in AX, args on stack above caller pc.
    17  
    18  TEXT	·Syscall(SB),NOSPLIT,$0-28
    19  	CALL	runtime·entersyscall(SB)
    20  	MOVL	trap+0(FP), AX	// syscall entry
    21  	// slide args down on top of system call number
    22  	LEAL		a1+4(FP), SI
    23  	LEAL		trap+0(FP), DI
    24  	CLD
    25  	MOVSL
    26  	MOVSL
    27  	MOVSL
    28  	INT	$0x80
    29  	JAE	ok
    30  	MOVL	$-1, r1+16(FP)	// r1
    31  	MOVL	$-1, r2+20(FP)	// r2
    32  	MOVL	AX, err+24(FP)	// errno
    33  	CALL	runtime·exitsyscall(SB)
    34  	RET
    35  ok:
    36  	MOVL	AX, r1+16(FP)	// r1
    37  	MOVL	DX, r2+20(FP)	// r2
    38  	MOVL	$0, err+24(FP)	// errno
    39  	CALL	runtime·exitsyscall(SB)
    40  	RET
    41  
    42  TEXT	·Syscall6(SB),NOSPLIT,$0-40
    43  	CALL	runtime·entersyscall(SB)
    44  	MOVL	trap+0(FP), AX	// syscall entry
    45  	// slide args down on top of system call number
    46  	LEAL		a1+4(FP), SI
    47  	LEAL		trap+0(FP), DI
    48  	CLD
    49  	MOVSL
    50  	MOVSL
    51  	MOVSL
    52  	MOVSL
    53  	MOVSL
    54  	MOVSL
    55  	INT	$0x80
    56  	JAE	ok6
    57  	MOVL	$-1, r1+28(FP)	// r1
    58  	MOVL	$-1, r2+32(FP)	// r2
    59  	MOVL	AX, err+36(FP)	// errno
    60  	CALL	runtime·exitsyscall(SB)
    61  	RET
    62  ok6:
    63  	MOVL	AX, r1+28(FP)	// r1
    64  	MOVL	DX, r2+32(FP)	// r2
    65  	MOVL	$0, err+36(FP)	// errno
    66  	CALL	runtime·exitsyscall(SB)
    67  	RET
    68  
    69  TEXT	·Syscall9(SB),NOSPLIT,$0-52
    70  	CALL	runtime·entersyscall(SB)
    71  	MOVL	num+0(FP), AX	// syscall entry
    72  	// slide args down on top of system call number
    73  	LEAL		a1+4(FP), SI
    74  	LEAL		num+0(FP), DI
    75  	CLD
    76  	MOVSL
    77  	MOVSL
    78  	MOVSL
    79  	MOVSL
    80  	MOVSL
    81  	MOVSL
    82  	MOVSL
    83  	MOVSL
    84  	MOVSL
    85  	INT	$0x80
    86  	JAE	ok9
    87  	MOVL	$-1, r1+40(FP)	// r1
    88  	MOVL	$-1, r2+44(FP)	// r2
    89  	MOVL	AX, err+48(FP)	// errno
    90  	CALL	runtime·exitsyscall(SB)
    91  	RET
    92  ok9:
    93  	MOVL	AX, r1+40(FP)	// r1
    94  	MOVL	DX, r2+44(FP)	// r2
    95  	MOVL	$0, err+48(FP)	// errno
    96  	CALL	runtime·exitsyscall(SB)
    97  	RET
    98  
    99  TEXT ·RawSyscall(SB),NOSPLIT,$0-28
   100  	MOVL	trap+0(FP), AX	// syscall entry
   101  	// slide args down on top of system call number
   102  	LEAL		a1+4(FP), SI
   103  	LEAL		trap+0(FP), DI
   104  	CLD
   105  	MOVSL
   106  	MOVSL
   107  	MOVSL
   108  	INT	$0x80
   109  	JAE	ok1
   110  	MOVL	$-1, r1+16(FP)	// r1
   111  	MOVL	$-1, r2+20(FP)	// r2
   112  	MOVL	AX, err+24(FP)	// errno
   113  	RET
   114  ok1:
   115  	MOVL	AX, r1+16(FP)	// r1
   116  	MOVL	DX, r2+20(FP)	// r2
   117  	MOVL	$0, err+24(FP)	// errno
   118  	RET
   119  
   120  TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
   121  	MOVL	trap+0(FP), AX	// syscall entry
   122  	// slide args down on top of system call number
   123  	LEAL		a1+4(FP), SI
   124  	LEAL		trap+0(FP), DI
   125  	CLD
   126  	MOVSL
   127  	MOVSL
   128  	MOVSL
   129  	MOVSL
   130  	MOVSL
   131  	MOVSL
   132  	INT	$0x80
   133  	JAE	ok2
   134  	MOVL	$-1, r1+28(FP)	// r1
   135  	MOVL	$-1, r2+32(FP)	// r2
   136  	MOVL	AX, err+36(FP)	// errno
   137  	RET
   138  ok2:
   139  	MOVL	AX, r1+28(FP)	// r1
   140  	MOVL	DX, r2+32(FP)	// r2
   141  	MOVL	$0, err+36(FP)	// errno
   142  	RET
   143  

View as plain text