TC-X FAQ
- How to compile and test?
To generate a binary from an IA-32 assembly file:
add-ia32.tiglet function add(x: int, y: int) : int = x + y in print_int(add(1,(add(2, 3)))); print("\n") end
tc -e --target-ia32 --asm-compute --inst-display add-ia32.tig$ tc -e --target-ia32 --asm-compute --inst-display add-ia32.tig /** Tiger final assembler ouput. */ /** Routine: add */ .text .globl tc_l0 .type tc_l0,@function tc_l0: pushl %ebp subl $4, %esp movl %esp, %ebp subl $4, %esp movl 12(%ebp), %ecx movl %ecx, (%ebp) movl 16(%ebp), %eax movl 20(%ebp), %ecx l7: addl %ecx, %eax l1: addl $4, %ebp leave ret $12 l9: .size tc_l0,l9-tc_l0 .section .rodata l2: .long 1 .asciz "\n" /** Routine: _main */ .text .globl tc_main .type tc_main,@function tc_main: pushl %ebp subl $4, %esp movl %esp, %ebp subl $4, %esp movl %ebx, (%ebp) l8: movl %ebp, %ebx movl $3, %ecx pushl %ecx movl $2, %ecx pushl %ecx pushl %ebp call tc_l0 pushl %eax movl $1, %ecx pushl %ecx pushl %ebx call tc_l0 pushl %eax call tc_print_int lea l2, %ecx pushl %ecx call tc_print l3: movl (%ebp), %ebx addl $4, %ebp leave ret $0 l10: .size tc_main,l10-tc_main .ident "LRDE Tiger Compiler" $ echo $? 0
tc -e --target-ia32 --asm-display add-ia32.tig > add-ia32.s$ tc -e --target-ia32 --asm-display add-ia32.tig > add-ia32.s $ echo $? 0
gcc -m32 -oadd-ia32 add-ia32.s$ gcc -m32 -oadd-ia32 add-ia32.s /nix/store/42pzy4ahwk8p41hwfmz2nldgvsdws8q1-binutils-2.44/bin/ld: skipping incompatible /nix/store/0pwkh9wzlv86spdcqjc7qmfjwvbx01wy-gcc-14.3.0-lib/lib64/libgcc_s.so.1 when searching for libgcc_s.so.1 /nix/store/42pzy4ahwk8p41hwfmz2nldgvsdws8q1-binutils-2.44/bin/ld: skipping incompatible /nix/store/0pwkh9wzlv86spdcqjc7qmfjwvbx01wy-gcc-14.3.0-lib/lib64/libgcc_s.so.1 when searching for libgcc_s.so.1 /nix/store/42pzy4ahwk8p41hwfmz2nldgvsdws8q1-binutils-2.44/bin/ld: skipping incompatible /nix/store/z278ahc30pvayk4lqnhyj6q70zmza1kd-glibc-multi-2.40-66/lib/libc.so when searching for -lc /nix/store/42pzy4ahwk8p41hwfmz2nldgvsdws8q1-binutils-2.44/bin/ld: skipping incompatible /nix/store/0pwkh9wzlv86spdcqjc7qmfjwvbx01wy-gcc-14.3.0-lib/lib64/libgcc_s.so.1 when searching for libgcc_s.so.1 /nix/store/42pzy4ahwk8p41hwfmz2nldgvsdws8q1-binutils-2.44/bin/ld: skipping incompatible /nix/store/0pwkh9wzlv86spdcqjc7qmfjwvbx01wy-gcc-14.3.0-lib/lib64/libgcc_s.so.1 when searching for libgcc_s.so.1 $ echo $? 0./add-ia32$ ./add-ia32 6 $ echo $? 0