diff options
| author | Michael Matz <matz@suse.de> | 2017-11-22 17:57:43 +0100 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2017-11-22 17:57:43 +0100 |
| commit | e7c71e24730ae07241980812c8b747963f216260 (patch) | |
| tree | 6fc0609791b351c7f83da07c3f8d2548d747094c /tests/asm-c-connect-1.c | |
| parent | 330c01bfc6fa6721fd455911a966bce041df31d8 (diff) | |
| download | tinycc-e7c71e24730ae07241980812c8b747963f216260.tar.gz tinycc-e7c71e24730ae07241980812c8b747963f216260.tar.bz2 | |
tccasm: synch C and asm symtab tighter
See testcase. The C and asm symtab are still separate,
but integrated tighter: the asm labels are only synched at file
end, not after each asm snippet (this fixes references from one
to another asm block), the C and asm syms are synched both ways,
so defining things in asm and refering from C, or the other way
around works. In effect this model reflects what happens with
GCC better.
For this the asm labels aren't using the C label namespace anymore,
but their own, which increases the size of each TokenSym by a pointer.
Diffstat (limited to 'tests/asm-c-connect-1.c')
| -rw-r--r-- | tests/asm-c-connect-1.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/asm-c-connect-1.c b/tests/asm-c-connect-1.c new file mode 100644 index 0000000..3f7b010 --- /dev/null +++ b/tests/asm-c-connect-1.c @@ -0,0 +1,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); |
