TC-Y FAQ
- How to compile and test?
To generate a binary from an ARM assembly file:
let function add(x: int, y: int) : int = x + y in print_int(add(1,(add(2, 3)))); print("\n") end
$ tc -e --target-arm --asm-compute --inst-display add-arm.tig # Tiger final assembler ouput. # Routine: add .global tc_l0 .text tc_l0: push {fp, lr} sub fp, sp, #4 sub sp, sp, #4 str r1, [fp, #0] l2: add r0, r2, r3 l3: add sp, sp, #4 pop {fp, pc} .ltorg .data l1: .word 1 .asciz "\n" # Routine: _main .global tc_main .text tc_main: push {fp, lr} sub fp, sp, #4 sub sp, sp, #0 l4: mov r1, fp ldr r2, =2 ldr r3, =3 bl tc_l0 mov r3, r0 mov r1, fp ldr r2, =1 bl tc_l0 mov r1, r0 bl tc_print_int ldr r1, =l1 bl tc_print l5: add sp, sp, #0 pop {fp, pc} .ltorg $ echo $? 0
$ tc -e --target-arm --asm-display add-arm.tig > add-arm.s $ echo $? 0
$ arm-linux-gnueabihf-gcc -march=armv7-a -oadd-arm add-arm.s /usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: warning: /tmp/ccxBfGqt.o: missing .note.GNU-stack section implies executable stack /usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker $ echo $? 0
To run your code, use QEMU:
$ qemu-arm -L /usr/arm-linux-gnueabihf ./add-arm 6 $ echo $? 0
QEMU (Quick Emulator) is a machine emulator and virtualizer. It can emulate a full system, including processor and peripherals. We are using it to emulate an ARM processor.