arm64 hello world

arm64 hello world

使用wsl2

win10系统

wsl --install

// hello.s
.section .datamsg: .ascii "Hello ARM64 from AMD 5600!\n"len = . - msg        // 计算字符串长度.section .text
.global _start_start:// 1. 调用 write(int fd, const void *buf, size_t count)mov x0, #1           // 参数1: fd = 1 (标准输出)ldr x1, =msg         // 参数2: buf = 字符串地址mov x2, len          // 参数3: count = 字符串长度mov x8, #64          // write 的系统调用号是 64svc #0               // 执行系统调用// 2. 调用 exit(int status)mov x0, #0           // 参数1: status = 0mov x8, #93          // exit 的系统调用号是 93svc #0               // 执行系统调用