I'm currently trying to learn assembly, I'm on mac M2, so with ARM64, and I can't find a way to display an user input. Here is my code:
.global _main
.align 2
_main:
b _printf
b _read
b _prinfbuffer
b _terminate
_printf:
mov X0, #1 // stdout
adr X1, prompt // address of string
mov X2, #17 // nbyte
mov X16, #4 // write
svc 0 // call syscall
_read:
mov X0, #0 // stdin
adr X1, buffer // address of buffer
mov X2, #1024 // maximum number of bytes to read
mov X16, #3 // read
svc 0 // call syscall
_prinfbuffer:
mov X0, 1 // stdout
adr X1, buffer // address of buffer
mov X2, #1024 // nbyte
mov X16, #4 // write
svc 0 // call syscall
_terminate:
mov X0, #0 // return 0
mov X16, #1 // terminate
svc 0 // call syscall
// hello world string
prompt: .ascii "Say something: \n"
.align 2
buffer: .space 1024
The output is this:
❯ ./hello
Say something:
a
❯
Yes, an empty space, after that it close the program.
Does anyone know how to fix this.
And yes I already took a look at the syscalls.master docs.
I tried to send back the input of the user with ARM64 assembly.