Skip to content

Instantly share code, notes, and snippets.

@bellbind
Created December 26, 2010 13:55
Show Gist options
  • Save bellbind/755433 to your computer and use it in GitHub Desktop.
Save bellbind/755433 to your computer and use it in GitHub Desktop.
[arm][linux] Assembly main on ARM linux eabi
@ Assembly main on ARM linux eabi
@ [build and run on ubuntu x64]
@ arm-linux-gnueabi-gcc hello.s -o hello
@ qemu-arm -L /usr/arm-linux-gnueabi/ hello
stdout = 1
.text
.align 2
.global main
main:
push {r4-r11, lr}
@ char * str = msg
movw r11, #:lower16:msg
movt r11, #:upper16:msg
@ int len = strlen(str)
mov r0, r11
bl strlen
@ int tmp = write(stdout, str, len)
mov r2, r0
mov r1, r11
mov r0, #stdout
bl write
@ return 0
mov r0, #0
pop {r4-r11, pc}
.section .rodata
.align 2
msg:
.asciz "Hello World\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment