Unified · Split
| @@ -13,7 +13,7 @@ CFLAGS+=-m386 -malign-functions=0 -mpreferred-stack-boundary=2 · 12 unmodified lines | ||
| 13 | 13 | CFLAGS+=-DCONFIG_TCC_PREFIX=\"$(prefix)\" |
| 14 | 14 | DISAS=objdump -d |
| 15 | 15 | INSTALL=install |
| 16 | −VERSION=0.9.15 | |
| 16 | +VERSION=0.9.16 | |
| 17 | 17 | |
| 18 | 18 | # run local version of tcc with local libraries and includes |
| 19 | 19 | TCC=./tcc -B. -I. |
| @@ -103,7 +103,7 @@ ex3: ex3.c · 83 unmodified lines | ||
| 103 | 103 | |
| 104 | 104 | # Native Tiny C Compiler |
| 105 | 105 | |
| 106 | −tcc_g: tcc.c i386-gen.c tccelf.c tcctok.h libtcc.h Makefile | |
| 106 | +tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile | |
| 107 | 107 | gcc $(CFLAGS) -o $@ $< $(LIBS) |
| 108 | 108 | |
| 109 | 109 | tcc: tcc_g |
| @@ -128,17 +128,9 @@ install: tcc libtcc1.o bcheck.o · 18 unmodified lines | ||
| 128 | 128 | clean: |
| 129 | 129 | rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \ |
| 130 | 130 | core gmon.out test.out test.ref a.out tcc_p \ |
| 131 | − *.exe iltcc iltcc_g tcc-doc.html \ | |
| 131 | + *.exe tcc-doc.html \ | |
| 132 | 132 | tcctest[1234] test[1234].out |
| 133 | 133 | |
| 134 | −# IL TCC | |
| 135 | − | |
| 136 | −iltcc_g: tcc.c il-gen.c bcheck.c Makefile | |
| 137 | − gcc $(CFLAGS) -DTCC_TARGET_IL -o $@ $< $(LIBS) | |
| 138 | − | |
| 139 | −iltcc: iltcc_g | |
| 140 | − strip -s -R .comment -R .note -o $@ $< | |
| 141 | − | |
| 142 | 134 | # win32 TCC |
| 143 | 135 | tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile |
| 144 | 136 | i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $< |
| @@ -176,6 +168,22 @@ libtest: libtcc_test · 31 unmodified lines | ||
| 176 | 168 | instr: instr.o |
| 177 | 169 | objdump -d instr.o |
| 178 | 170 | |
| 171 | +# tiny assembler testing | |
| 172 | + | |
| 173 | +asmtest.ref: asmtest.S | |
| 174 | + gcc -c -o asmtest.ref.o asmtest.S | |
| 175 | + objdump -D asmtest.ref.o > $@ | |
| 176 | + | |
| 177 | +# XXX: we compute tcc.c to go faster during development ! | |
| 178 | +asmtest.out: asmtest.S tcc | |
| 179 | +# ./tcc tcc.c -c asmtest.S | |
| 180 | +#asmtest.out: asmtest.S tcc | |
| 181 | + ./tcc -c asmtest.S | |
| 182 | + objdump -D asmtest.o > $@ | |
| 183 | + | |
| 184 | +asmtest: asmtest.out asmtest.ref | |
| 185 | + @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi | |
| 186 | + | |
| 179 | 187 | instr.o: instr.S |
| 180 | 188 | gcc -O2 -Wall -g -c -o $@ $< |
| 181 | 189 | |
| @@ -191,9 +199,8 @@ FILES= Makefile Makefile.uClibc \ · 9 unmodified lines | ||
| 191 | 199 | README TODO COPYING \ |
| 192 | 200 | Changelog tcc-doc.texi tcc-doc.html \ |
| 193 | 201 | tcc.1 \ |
| 194 | − tcc.c i386-gen.c tccelf.c tcctok.h \ | |
| 202 | + tcc.c i386-gen.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h\ | |
| 195 | 203 | bcheck.c libtcc1.c \ |
| 196 | − il-opcodes.h il-gen.c \ | |
| 197 | 204 | elf.h stab.h stab.def \ |
| 198 | 205 | stddef.h stdarg.h stdbool.h float.h varargs.h \ |
| 199 | 206 | tcclib.h libtcc.h libtcc_test.c \ |
| @@ -1,21 +1,33 @@ | ||
| 1 | 1 | TODO list: |
| 2 | 2 | |
| 3 | −- add statment expressions (linux kernel compilation) | |
| 4 | −- implement minimal 'asm' extension (linux kernel compilation) | |
| 5 | −- handle static inline, then normal prototype. | |
| 3 | +- fix asm without input/output (no % preprocessing) | |
| 4 | +- handle inline functions as macros. | |
| 5 | +- see transparent union pb in /urs/include/sys/socket.h | |
| 6 | +- precise behaviour of typeof with arrays ? (__put_user macro) | |
| 7 | +- #include_next support for /usr/include/limits ? | |
| 8 | + but should suffice for most cases) | |
| 9 | +- handle '? x, y : z' in reversed function arguments or unsized | |
| 10 | + variable initialization (',' is considered incorrectly as separator | |
| 11 | + in preparser) : change func argument code generator ? | |
| 12 | +- function pointers/lvalues in ? : (linux kernel net/core/dev.c) | |
| 13 | +- add A x86 asm constraint (linux asm-i386/div64.h) | |
| 14 | +- transform functions to function pointers in function parameters (net/ipv4/ip_output.c) | |
| 15 | +- fix function pointer type display | |
| 16 | +- fix bound exit on RedHat 7.3 | |
| 17 | +- fix static link on RedHat 7.3 | |
| 18 | +- check lcc test suite -> fix bitfield binary operations | |
| 19 | +- check section alignment in C | |
| 20 | +- fix invalid cast in comparison 'if (v == (int8_t)v)' | |
| 21 | +- packed attribute | |
| 22 | +- look at patches from Scott Lafferty | |
| 23 | +- look at bugs from Jason Petrasko. | |
| 6 | 24 | - support link once trick (gcc 3.2 / glibc compilation issue) |
| 7 | 25 | - finish varargs.h support (gcc 3.2 testsuite issue) |
| 8 | 26 | - add alloca() |
| 9 | 27 | - fix static functions declared inside block |
| 10 | −- fix bitfield binary operations | |
| 11 | 28 | - C99: add variable size arrays (gcc 3.2 testsuite issue) |
| 12 | 29 | - C99: add complex types (gcc 3.2 testsuite issue) |
| 13 | −- ignore __extension__ keyword (see 20010328-1.c). | |
| 14 | −- Add __restrict keyword (20010611-1.c). | |
| 15 | 30 | - postfix compound literals (see 20010124-1.c) |
| 16 | −- handle '? x, y : z' in reversed function arguments or unsized | |
| 17 | − variable initialization (',' is considered incorrectly as separator | |
| 18 | − in preparser) : use a "record" parse mode ? | |
| 19 | 31 | - fix multiple unions init |
| 20 | 32 | - test includes in libtcc_test. |
| 21 | 33 | - look at GCC 3.2 compatibility problems. |
| @@ -17,7 +17,7 @@ TCC compiles so @emph{fast} that even for big projects @code{Makefile}s may · 16 unmodified lines | ||
| 17 | 17 | not be necessary. |
| 18 | 18 | |
| 19 | 19 | TCC not only supports ANSI C, but also most of the new ISO C99 |
| 20 | −standard and many GNUC extensions. | |
| 20 | +standard and many GNUC extensions including inline assembly. | |
| 21 | 21 | |
| 22 | 22 | TCC can also be used to make @emph{C scripts}, i.e. pieces of C source |
| 23 | 23 | that you run as a Perl or Python script. Compilation is so fast that |
| @@ -70,6 +70,14 @@ link a.o and b.o together and generate the executable myprog. · 46 unmodified lines | ||
| 70 | 70 | @item tcc -c a.c |
| 71 | 71 | Compile a.c and generate object file a.o |
| 72 | 72 | |
| 73 | +@item tcc -c asmfile.S | |
| 74 | +Preprocess with C preprocess and assemble asmfile.S and generate | |
| 75 | +object file asmfile.o. | |
| 76 | + | |
| 77 | +@item tcc -c asmfile.s | |
| 78 | +Assemble (but not preprocess) asmfile.s and generate object file | |
| 79 | +asmfile.o. | |
| 80 | + | |
| 73 | 81 | @item tcc -r -o ab.o a.c b.c |
| 74 | 82 | Compile a.c and b.c, link them together and generate the object file ab.o. |
| 75 | 83 | |
| @@ -332,6 +340,31 @@ to get the alignment of a type or an expression. · 256 unmodified lines | ||
| 332 | 340 | @code{void *} on the goto label @code{label}. @code{goto *expr} can be |
| 333 | 341 | used to jump on the pointer resulting from @code{expr}. |
| 334 | 342 | |
| 343 | +@item Inline assembly with asm instruction: | |
| 344 | +@example | |
| 345 | +static inline void * my_memcpy(void * to, const void * from, size_t n) | |
| 346 | +{ | |
| 347 | +int d0, d1, d2; | |
| 348 | +__asm__ __volatile__( | |
| 349 | + "rep ; movsl\n\t" | |
| 350 | + "testb $2,%b4\n\t" | |
| 351 | + "je 1f\n\t" | |
| 352 | + "movsw\n" | |
| 353 | + "1:\ttestb $1,%b4\n\t" | |
| 354 | + "je 2f\n\t" | |
| 355 | + "movsb\n" | |
| 356 | + "2:" | |
| 357 | + : "=&c" (d0), "=&D" (d1), "=&S" (d2) | |
| 358 | + :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) | |
| 359 | + : "memory"); | |
| 360 | +return (to); | |
| 361 | +} | |
| 362 | +@end example | |
| 363 | + | |
| 364 | +TCC includes its own x86 inline assembler with a @code{gas}-like (GNU | |
| 365 | +assembler) syntax. No intermediate files are generated. GCC 3.x named | |
| 366 | +operands are supported. | |
| 367 | + | |
| 335 | 368 | @end itemize |
| 336 | 369 | |
| 337 | 370 | @section TinyCC extensions |
| @@ -350,6 +383,98 @@ indicate that you use TCC. · 12 unmodified lines | ||
| 350 | 383 | |
| 351 | 384 | @end itemize |
| 352 | 385 | |
| 386 | +@chapter TinyCC Assembler | |
| 387 | + | |
| 388 | +Since version 0.9.16, TinyCC integrates its own assembler. TinyCC | |
| 389 | +assembler supports a gas-like syntax (GNU assembler). You can | |
| 390 | +desactivate assembler support if you want a smaller TinyCC executable | |
| 391 | +(the C compiler does not rely on the assembler). | |
| 392 | + | |
| 393 | +TinyCC Assembler is used to handle files with @file{.S} (C | |
| 394 | +preprocessed assembler) and @file{.s} extensions. It is also used to | |
| 395 | +handle the GNU inline assembler with the @code{asm} keyword. | |
| 396 | + | |
| 397 | +@section Syntax | |
| 398 | + | |
| 399 | +TinyCC Assembler supports most of the gas syntax. The tokens are the | |
| 400 | +same as C. | |
| 401 | + | |
| 402 | +@itemize | |
| 403 | + | |
| 404 | +@item C and C++ comments are supported. | |
| 405 | + | |
| 406 | +@item Identifiers are the same as C, so you cannot use '.' or '$'. | |
| 407 | + | |
| 408 | +@item Only 32 bit integer numbers are supported. | |
| 409 | + | |
| 410 | +@end itemize | |
| 411 | + | |
| 412 | +@section Expressions | |
| 413 | + | |
| 414 | +@itemize | |
| 415 | + | |
| 416 | +@item Integers in decimal, octal and hexa are supported. | |
| 417 | + | |
| 418 | +@item Unary operators: +, -, ~. | |
| 419 | + | |
| 420 | +@item Binary operators in decreasing priority order: | |
| 421 | + | |
| 422 | +@enumerate | |
| 423 | +@item *, /, % | |
| 424 | +@item &, |, ^ | |
| 425 | +@item +, - | |
| 426 | +@end enumerate | |
| 427 | + | |
| 428 | +@item A value is either an absolute number or a label plus an offset. | |
| 429 | +All operators accept absolute values except '+' and '-'. '+' or '-' can be | |
| 430 | +used to add an offset to a label. '-' supports two labels only if they | |
| 431 | +are the same or if they are both defined and in the same section. | |
| 432 | + | |
| 433 | +@end itemize | |
| 434 | + | |
| 435 | +@section Labels | |
| 436 | + | |
| 437 | +@itemize | |
| 438 | + | |
| 439 | +@item All labels are considered as local, except undefined ones. | |
| 440 | + | |
| 441 | +@item Numeric labels can be used as local @code{gas}-like labels. | |
| 442 | +They can be defined several times in the same source. Use 'b' | |
| 443 | +(backward) or 'f' (forward) as suffix to reference them: | |
| 444 | + | |
| 445 | +@example | |
| 446 | + 1: | |
| 447 | + jmp 1b /* jump to '1' label before */ | |
| 448 | + jmp 1f /* jump to '1' label after */ | |
| 449 | + 1: | |
| 450 | +@end example | |
| 451 | + | |
| 452 | +@end itemize | |
| 453 | + | |
| 454 | +@section Directives | |
| 455 | + | |
| 456 | +All directives are preceeded by a '.'. The following directives are | |
| 457 | +supported: | |
| 458 | + | |
| 459 | +@itemize | |
| 460 | +@item .align n[,value] | |
| 461 | +@item .skip n[,value] | |
| 462 | +@item .space n[,value] | |
| 463 | +@item .byte value1[,value2...] | |
| 464 | +@item .word value1[,value2...] | |
| 465 | +@item .short value1[,value2...] | |
| 466 | +@item .int value1[,value2...] | |
| 467 | +@item .long value1[,value2...] | |
| 468 | +@end itemize | |
| 469 | + | |
| 470 | +@section X86 Assembler | |
| 471 | + | |
| 472 | +All X86 opcodes are supported. Only ATT syntax is supported (source | |
| 473 | +then destination operand order). If no size suffix is given, TinyCC | |
| 474 | +tries to guess it from the operand sizes. | |
| 475 | + | |
| 476 | +Currently, MMX opcodes are supported but not SSE ones. | |
| 477 | + | |
| 353 | 478 | @chapter TinyCC Linker |
| 354 | 479 | |
| 355 | 480 | @section ELF file generation |
| @@ -67,6 +67,9 @@ void relocation_test(void); · 66 unmodified lines | ||
| 67 | 67 | void old_style_function(void); |
| 68 | 68 | void sizeof_test(void); |
| 69 | 69 | void typeof_test(void); |
| 70 | +void local_label_test(void); | |
| 71 | +void statement_expr_test(void); | |
| 72 | +void asm_test(void); | |
| 70 | 73 | |
| 71 | 74 | int fib(int n); |
| 72 | 75 | void num(int n); |
| @@ -200,7 +203,7 @@ void macro_test(void) · 127 unmodified lines | ||
| 200 | 203 | #line 203 "test" |
| 201 | 204 | printf("__LINE__=%d __FILE__=%s\n", |
| 202 | 205 | __LINE__, __FILE__); |
| 203 | −#line 200 "tcctest.c" | |
| 206 | +#line 206 "tcctest.c" | |
| 204 | 207 | |
| 205 | 208 | /* not strictly preprocessor, but we test it there */ |
| 206 | 209 | #ifdef C99_MACROS |
| @@ -467,6 +470,9 @@ int main(int argc, char **argv) · 260 unmodified lines | ||
| 467 | 470 | old_style_function(); |
| 468 | 471 | sizeof_test(); |
| 469 | 472 | typeof_test(); |
| 473 | + statement_expr_test(); | |
| 474 | + local_label_test(); | |
| 475 | + asm_test(); | |
| 470 | 476 | return 0; |
| 471 | 477 | } |
| 472 | 478 | |
| @@ -839,6 +845,16 @@ void bool_test() · 366 unmodified lines | ||
| 839 | 845 | } |
| 840 | 846 | } |
| 841 | 847 | |
| 848 | + /* test ? : GCC extension */ | |
| 849 | + { | |
| 850 | + static int v1 = 34 ? : -1; /* constant case */ | |
| 851 | + static int v2 = 0 ? : -1; /* constant case */ | |
| 852 | + int a = 30; | |
| 853 | + | |
| 854 | + printf("%d %d\n", v1, v2); | |
| 855 | + printf("%d %d\n", a - 30 ? : a * 2, a + 1 ? : a * 2); | |
| 856 | + } | |
| 857 | + | |
| 842 | 858 | /* again complex expression */ |
| 843 | 859 | for(i=0;i<256;i++) { |
| 844 | 860 | if (toupper1 (i) != TOUPPER (i)) |
| @@ -846,7 +862,13 @@ void bool_test() · 1 unmodified line | ||
| 846 | 862 | } |
| 847 | 863 | } |
| 848 | 864 | |
| 865 | +/* GCC accepts that */ | |
| 866 | +static int tab_reinit[]; | |
| 867 | +static int tab_reinit[10]; | |
| 849 | 868 | |
| 869 | +//int cinit1; /* a global variable can be defined several times without error ! */ | |
| 870 | +int cinit1; | |
| 871 | +int cinit1; | |
| 850 | 872 | int cinit1 = 0; |
| 851 | 873 | int *cinit2 = (int []){3, 2, 1}; |
| 852 | 874 | |
| @@ -1072,6 +1094,12 @@ struct bar { · 219 unmodified lines | ||
| 1072 | 1094 | "a2", 1 |
| 1073 | 1095 | }; |
| 1074 | 1096 | |
| 1097 | +int sinit18[10] = { | |
| 1098 | + [2 ... 5] = 20, | |
| 1099 | + 2, | |
| 1100 | + [8] = 10, | |
| 1101 | +}; | |
| 1102 | + | |
| 1075 | 1103 | void init_test(void) |
| 1076 | 1104 | { |
| 1077 | 1105 | int linit1 = 2; |
| @@ -1161,8 +1189,12 @@ void init_test(void) · 83 unmodified lines | ||
| 1161 | 1189 | printf("sinit17=%s %d %s %d\n", |
| 1162 | 1190 | sinit17[0].s, sinit17[0].len, |
| 1163 | 1191 | sinit17[1].s, sinit17[1].len); |
| 1192 | + for(i=0;i<10;i++) | |
| 1193 | + printf("%x ", sinit18[i]); | |
| 1194 | + printf("\n"); | |
| 1164 | 1195 | } |
| 1165 | 1196 | |
| 1197 | + | |
| 1166 | 1198 | void switch_test() |
| 1167 | 1199 | { |
| 1168 | 1200 | int i; |
| @@ -1659,3 +1691,150 @@ void typeof_test(void) · 490 unmodified lines | ||
| 1659 | 1691 | c = 3.5; |
| 1660 | 1692 | printf("a=%f b=%f c=%f\n", a, b, c); |
| 1661 | 1693 | } |
| 1694 | + | |
| 1695 | +void statement_expr_test(void) | |
| 1696 | +{ | |
| 1697 | + int a, i; | |
| 1698 | + | |
| 1699 | + a = 0; | |
| 1700 | + for(i=0;i<10;i++) { | |
| 1701 | + a += 1 + | |
| 1702 | + ( { int b, j; | |
| 1703 | + b = 0; | |
| 1704 | + for(j=0;j<5;j++) | |
| 1705 | + b += j; b; | |
| 1706 | + } ); | |
| 1707 | + } | |
| 1708 | + printf("a=%d\n", a); | |
| 1709 | + | |
| 1710 | +} | |
| 1711 | + | |
| 1712 | +void local_label_test(void) | |
| 1713 | +{ | |
| 1714 | + int a; | |
| 1715 | + goto l1; | |
| 1716 | + l2: | |
| 1717 | + a = 1 + ({ | |
| 1718 | + __label__ l1, l2, l3; | |
| 1719 | + goto l4; | |
| 1720 | + l5: | |
| 1721 | + printf("aa1\n"); | |
| 1722 | + goto l1; | |
| 1723 | + l2: | |
| 1724 | + printf("aa3\n"); | |
| 1725 | + goto l3; | |
| 1726 | + l1: | |
| 1727 | + printf("aa2\n"); | |
| 1728 | + goto l2; | |
| 1729 | + l3:; | |
| 1730 | + 1; | |
| 1731 | + }); | |
| 1732 | + printf("a=%d\n", a); | |
| 1733 | + return; | |
| 1734 | + l1: | |
| 1735 | + printf("bb1\n"); | |
| 1736 | + goto l2; | |
| 1737 | + l4: | |
| 1738 | + printf("bb2\n"); | |
| 1739 | + goto l5; | |
| 1740 | +} | |
| 1741 | + | |
| 1742 | +/* inline assembler test */ | |
| 1743 | +#ifdef __i386__ | |
| 1744 | + | |
| 1745 | +/* from linux kernel */ | |
| 1746 | +static char * strncat1(char * dest,const char * src,size_t count) | |
| 1747 | +{ | |
| 1748 | +int d0, d1, d2, d3; | |
| 1749 | +__asm__ __volatile__( | |
| 1750 | + "repne\n\t" | |
| 1751 | + "scasb\n\t" | |
| 1752 | + "decl %1\n\t" | |
| 1753 | + "movl %8,%3\n" | |
| 1754 | + "1:\tdecl %3\n\t" | |
| 1755 | + "js 2f\n\t" | |
| 1756 | + "lodsb\n\t" | |
| 1757 | + "stosb\n\t" | |
| 1758 | + "testb %%al,%%al\n\t" | |
| 1759 | + "jne 1b\n" | |
| 1760 | + "2:\txorl %2,%2\n\t" | |
| 1761 | + "stosb" | |
| 1762 | + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) | |
| 1763 | + : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count) | |
| 1764 | + : "memory"); | |
| 1765 | +return dest; | |
| 1766 | +} | |
| 1767 | + | |
| 1768 | +static inline void * memcpy1(void * to, const void * from, size_t n) | |
| 1769 | +{ | |
| 1770 | +int d0, d1, d2; | |
| 1771 | +__asm__ __volatile__( | |
| 1772 | + "rep ; movsl\n\t" | |
| 1773 | + "testb $2,%b4\n\t" | |
| 1774 | + "je 1f\n\t" | |
| 1775 | + "movsw\n" | |
| 1776 | + "1:\ttestb $1,%b4\n\t" | |
| 1777 | + "je 2f\n\t" | |
| 1778 | + "movsb\n" | |
| 1779 | + "2:" | |
| 1780 | + : "=&c" (d0), "=&D" (d1), "=&S" (d2) | |
| 1781 | + :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) | |
| 1782 | + : "memory"); | |
| 1783 | +return (to); | |
| 1784 | +} | |
| 1785 | + | |
| 1786 | +static __inline__ void sigaddset1(unsigned int *set, int _sig) | |
| 1787 | +{ | |
| 1788 | + __asm__("btsl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc"); | |
| 1789 | +} | |
| 1790 | + | |
| 1791 | +static __inline__ void sigdelset1(unsigned int *set, int _sig) | |
| 1792 | +{ | |
| 1793 | + asm("btrl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc"); | |
| 1794 | +} | |
| 1795 | + | |
| 1796 | +static __inline__ __const__ unsigned int swab32(unsigned int x) | |
| 1797 | +{ | |
| 1798 | + __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ | |
| 1799 | + "rorl $16,%0\n\t" /* swap words */ | |
| 1800 | + "xchgb %b0,%h0" /* swap higher bytes */ | |
| 1801 | + :"=q" (x) | |
| 1802 | + : "0" (x)); | |
| 1803 | + return x; | |
| 1804 | +} | |
| 1805 | + | |
| 1806 | +unsigned int set; | |
| 1807 | + | |
| 1808 | +void asm_test(void) | |
| 1809 | +{ | |
| 1810 | + char buf[128]; | |
| 1811 | + unsigned int val; | |
| 1812 | + | |
| 1813 | + printf("inline asm:\n"); | |
| 1814 | + memcpy1(buf, "hello", 6); | |
| 1815 | + strncat1(buf, " worldXXXXX", 3); | |
| 1816 | + printf("%s\n", buf); | |
| 1817 | + | |
| 1818 | + set = 0xff; | |
| 1819 | + sigdelset1(&set, 2); | |
| 1820 | + sigaddset1(&set, 16); | |
| 1821 | + /* NOTE: we test here if C labels are correctly restored after the | |
| 1822 | + asm statement */ | |
| 1823 | + goto label1; | |
| 1824 | + label2: | |
| 1825 | + __asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc"); | |
| 1826 | + printf("set=0x%x\n", set); | |
| 1827 | + val = 0x01020304; | |
| 1828 | + printf("swab32(0x%08x) = 0x%0x\n", val, swab32(val)); | |
| 1829 | + return; | |
| 1830 | + label1: | |
| 1831 | + goto label2; | |
| 1832 | +} | |
| 1833 | + | |
| 1834 | +#else | |
| 1835 | + | |
| 1836 | +void asm_test(void) | |
| 1837 | +{ | |
| 1838 | +} | |
| 1839 | + | |
| 1840 | +#endif | |