Created
August 24, 2022 01:54
-
-
Save vhxs/28518aac1631fdc257e9b39e92a54f49 to your computer and use it in GitHub Desktop.
arm64 assembly example
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
/* | |
Hello world in arm64 | |
https://peterdn.com/post/2020/08/22/hello-world-in-arm64-assembly/ | |
as -o hello.o hello.s | |
ld -s -o hello hello.o | |
./hello | |
*/ | |
.data | |
/* Data segment: define our message string and calculate its length. */ | |
msg: | |
.ascii "Hello, ARM64!\n" | |
len = . - msg | |
.text | |
/* Our application's entry point. */ | |
.globl _start | |
_start: | |
/* syscall write(int fd, const void *buf, size_t count) */ | |
mov x0, #1 /* fd := STDOUT_FILENO */ | |
ldr x1, =msg /* buf := msg */ | |
ldr x2, =len /* count := len */ | |
mov w8, #64 /* write is syscall #64 */ | |
svc #0 /* invoke syscall */ | |
/* syscall exit(int status) */ | |
mov x0, #0 /* status := 0 */ | |
mov w8, #93 /* exit is syscall #93 */ | |
svc #0 /* invoke syscall */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment