The inline assembly is not idiomatic. Today you should be using register asm. Here is a RISC-V example:
register long a0 asm("a0") = arg0;
register long syscall_id asm("a7") = n;
asm volatile ("ecall" : "+r"(a0) : "r"(syscall_id));
return a0;
This is an example where a0 is an in/out integer. For memory, change long a0 to a pointer to some struct and add a "m" input or "+m" in/out. It's even easier in other languages like Rust and Zig.