Calling conventions are different, let's use functions without any arguments.
Unified · Split
| @@ -1,23 +1,24 @@ | ||
| 1 | 1 | #include <stdio.h> |
| 2 | 2 | |
| 3 | 3 | #if defined _WIN32 && !defined __TINYC__ |
| 4 | −# define U "_" | |
| 4 | +# define _ "_" | |
| 5 | 5 | #else |
| 6 | −# define U | |
| 6 | +# define _ | |
| 7 | 7 | #endif |
| 8 | 8 | |
| 9 | −const char str[] = "x1\n"; | |
| 10 | −#ifdef __x86_64__ | |
| 11 | −asm(U"x1: push %rbp; mov $"U"str, %rdi; call "U"printf; pop %rbp; ret"); | |
| 12 | −#elif defined (__i386__) | |
| 13 | −asm(U"x1: push $"U"str; call "U"printf; pop %eax; ret"); | |
| 14 | −#endif | |
| 9 | +static int x1_c(void) | |
| 10 | +{ | |
| 11 | + printf("x1\n"); | |
| 12 | + return 1; | |
| 13 | +} | |
| 14 | + | |
| 15 | +asm(".text;"_"x1: call "_"x1_c; ret"); | |
| 15 | 16 | |
| 16 | 17 | int main(int argc, char *argv[]) |
| 17 | 18 | { |
| 18 | − asm("call "U"x1"); | |
| 19 | − asm("call "U"x2"); | |
| 20 | − asm("call "U"x3"); | |
| 19 | + asm("call "_"x1"); | |
| 20 | + asm("call "_"x2"); | |
| 21 | + asm("call "_"x3"); | |
| 21 | 22 | return 0; |
| 22 | 23 | } |
| 23 | 24 | |