Created
December 26, 2010 13:55
-
-
Save bellbind/755433 to your computer and use it in GitHub Desktop.
[arm][linux] Assembly main on ARM linux eabi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ 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