This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to compile hello word code with aarch64 gcc

Assembly code:

    .syntax unified

    @ --------------------------------
.global main
main:
    @ Stack the return address (lr) in addition to a dummy register (ip) to
    @ keep the stack 8-byte aligned.
    push    {ip, lr}

    @ Load the argument and perform the call. This is like 'printf("...")' in C.
    ldr     r0, =message
    bl      printf

    @ Exit from 'main'. This is like 'return 0' in C.
    mov     r0, #0    @ Return 0.

    @ Pop the dummy ip to reverse our alignment fix, and pop the original lr
    @ value directly into pc — the Program Counter — to return.
    pop     {ip, pc}

    @ --------------------------------
    @ Data for the printf calls. The GNU assembler's ".asciz" directive
    @ automatically adds a NULL character termination.
message:
    .asciz "Hello, world.\n"

It's successfully when I use armv7-a compiler to compile it.

Currently I have aarch64 compiler. Can I use it to compile the above code?

Parents Reply Children