int main(void) { asm volatile("syscall" : : "a"(1), "d"(14), "D"(1), "S"("hello world!\n")); return 0; }
long ax; asm volatile("syscall" : "=a"(ax) : "0"(1), "D"(1), "S"("hello world!\n"), "d"(14));
long ax = 1; asm volatile("syscall" : "+a"(ax) : "D"(1), "S"("hello world!\n"), "d"(14));
long ax = 1; asm volatile("syscall" : "+a"(ax) : "D"(1), "S"("hello world!\n"), "d"(14) : "rcx", "r11");
my_write: mov $4,%eax syscall ret
A sibling comment pointed at https://chromium.googlesource.com/linux-syscall-support/+/re... which suggests none are clobbered outside of the arguments used by a given call which is possible but seems unlikely
static privileged int GetPid(void) { int res; #ifdef __x86_64__ asm volatile("syscall" : "=a"(res) : "0"(__NR_linux_getpid) : "rcx", "r11", "memory"); #elif defined(__aarch64__) register long res_x0 asm("x0"); asm volatile("mov\tx8,%1\n\t" "svc\t0" : "=r"(res_x0) : "i"(__NR_linux_getpid) : "x8", "memory"); res = res_x0; #endif return res; }