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