Recently, I've been trying to learn ARM assembly (ARM because my Mac can run it), but all the tutorials and recources that I can find all have slightly different variations, and the version that I have working is different again!
Some of the versions I've seen have .section .text
and .section .data
, and other websites have a bunch of svc
calls (or whatever they're called) that are completly different for what I have. I haven't found any places that have code that works with me (except this video, but I already know how to do everything in it)
Here's my hello world program that runs on my laptop:
// Print 'Hello, world!" to stdout"
.global _main
.p2align 3 // no bus error idk
_main:
// Print 'Hello, world!'
mov x0, #1 // Use file stdout
mov x16, #4 // Write to stdout
adr x1, message // Address of message to print
mov x2, #13 // Length of message
svc 0 // Execute
// Exit
mov x0, #0 // Move return code to register 0
mov x16, #1 // Service command code 1 terminates this program
svc 0 // Call service call 0 (exit program)
message: .ascii "Hello, world!"
Input to terminal:
user@laptop folder % make src=helloWorld
as -o helloWorld.o helloWorld.s
ld -o helloWorld helloWorld.o
make clean
rm *.o
user@laptop folder % ./helloWorld
Hello, world!%
In summary, I need some sources that can teach me how to write assembly for my M1 Mac (2020 touchbar)
So basically, apple has their own weird version. Can't run on other platorms, only apple :/