i was trying to do scanf in the inline assembly function but it kept giving me 0 or segfault. any ideas? i want to read the %d from rax, put the result of the scanf into rcx, and then it will assign rcx to out via the =c
int bruh() {
int out;
char * x = "%d";
asm(
"mov %%rax, %%rdi;"
"mov %%rcx, %%rsi;"
"mov $0, %%al;"
"call scanf;"
: "=c" (out)
: "a" (x)
);
return out;
}
void main() {
printf("val: %d\n", bruh());
}
```i expect the output ```
val: 32
``` given the stdin of `32`
here is the tio link https://tio.run/##PY9BCoMwEEX3OcWQNpAUW0q709qTdDOdaA3EWGIUoXh2m6C4mnkPhv@Hzh@iZTkYR3bQFTz6oE13aZ6MGRfg7YdGKvgxgITdEIq4UoMeTjBBCVxonhT2rWS87UYQwuOUpaFNwXdHq@t3d7wmgTYxobXQE7o6EsuBl8RBxjSVAOM@qRiiUpKvwuDdWmVmbOyMhhaN22p@fSxaSz6izUHol@PZ9kW8npflfvsD