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.file "gcc_386.S"
6
7/*
8 * Windows still insists on underscore prefixes for C function names.
9 */
10#if defined(_WIN32)
11#define EXT(s) _##s
12#else
13#define EXT(s) s
14#endif
15
16/*
17 * void crosscall1(void (*fn)(void), void (*setg_gcc)(void*), void *g)
18 *
19 * Calling into the gc tool chain, where all registers are caller save.
20 * Called from standard x86 ABI, where %ebp, %ebx, %esi,
21 * and %edi are callee-save, so they must be saved explicitly.
22 */
23.globl EXT(crosscall1)
24EXT(crosscall1):
25	pushl %ebp
26	movl %esp, %ebp
27	pushl %ebx
28	pushl %esi
29	pushl %edi
30
31	movl 16(%ebp), %eax	/* g */
32	pushl %eax
33	movl 12(%ebp), %eax	/* setg_gcc */
34	call *%eax
35	popl %eax
36
37	movl 8(%ebp), %eax	/* fn */
38	call *%eax
39
40	popl %edi
41	popl %esi
42	popl %ebx
43	popl %ebp
44	ret
45
46#ifdef __ELF__
47.section .note.GNU-stack,"",@progbits
48#endif
49