1 // Copyright 2025 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 "go_asm.h"
6 #include "textflag.h"
7
8 TEXT ·StdCall<ABIInternal>(SB),NOSPLIT,$4-8
9 MOVL fn+0(FP), AX
10 MOVL AX, 0(SP)
11 CALL ·asmstdcall(SB)
12 MOVL AX, ret+4(FP)
13 RET
14
15 TEXT ·asmstdcall(SB),NOSPLIT,$0-4
16 MOVL fn+0(FP), BX
17 MOVL SP, BP // save stack pointer
18
19 // SetLastError(0).
20 MOVL $0, 0x34(FS)
21
22 MOVL StdCallInfo_N(BX), CX
23
24 // Fast version, do not store args on the stack.
25 CMPL CX, $0
26 JE docall
27
28 // Copy args to the stack.
29 MOVL CX, AX
30 SALL $2, AX
31 SUBL AX, SP // room for args
32 MOVL SP, DI
33 MOVL StdCallInfo_Args(BX), SI
34 CLD
35 REP; MOVSL
36
37 docall:
38 // Call stdcall or cdecl function.
39 // DI SI BP BX are preserved, SP is not
40 CALL StdCallInfo_Fn(BX)
41 MOVL BP, SP
42
43 // Return result.
44 MOVL fn+0(FP), BX
45 MOVL AX, StdCallInfo_R1(BX)
46 MOVL DX, StdCallInfo_R2(BX)
47
48 // GetLastError().
49 MOVL 0x34(FS), AX
50
51 RET
52
View as plain text