aboutsummaryrefslogtreecommitdiff
path: root/tests/asm-c-connect-1.c
blob: 3f7b0100ac670f1b28b28f47322b93b903196a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>

#if defined _WIN32 && !defined __TINYC__
# define U "_"
#else
# define U
#endif

const char str[] = "x1\n";
#ifdef __x86_64__
asm(U"x1: push %rbp; mov $"U"str, %rdi; call "U"printf; pop %rbp; ret");
#elif defined (__i386__)
asm(U"x1: push $"U"str; call "U"printf; pop %eax; ret");
#endif

int main(int argc, char *argv[])
{
    asm("call "U"x1");
    asm("call "U"x2");
    asm("call "U"x3");
    return 0;
}

static
int x2(void)
{
    printf("x2\n");
    return 2;
}

extern int x3(void);