xref: /openbmc/qemu/tests/tcg/aarch64_be/hello.c (revision 646b5378)
1 /*
2  * Non-libc syscall hello world for Aarch64 BE
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 
7 #define __NR_write 64
8 #define __NR_exit 93
9 
10 int write(int fd, char *buf, int len)
11 {
12     register int x0 __asm__("x0") = fd;
13     register char *x1 __asm__("x1") = buf;
14     register int x2 __asm__("x2") = len;
15     register int x8 __asm__("x8") = __NR_write;
16 
17     asm volatile("svc #0" : : "r"(x0), "r"(x1), "r"(x2), "r"(x8));
18 
19     return len;
20 }
21 
22 void exit(int ret)
23 {
24     register int x0 __asm__("x0") = ret;
25     register int x8 __asm__("x8") = __NR_exit;
26 
27     asm volatile("svc #0" : : "r"(x0), "r"(x8));
28     __builtin_unreachable();
29 }
30 
31 void _start(void)
32 {
33     write(1, "Hello World\n", 12);
34     exit(0);
35 }
36