I've this code:
void geninterrupt (int x) {
__asm__(
"movb x, %al \n"
"movb %al, genint+1 \n"
"jmp genint \n"
"genint: \n"
"int $0 \n"
);
}
How can I make movb use the argument of geninterrupt()?
I've this code:
void geninterrupt (int x) {
__asm__(
"movb x, %al \n"
"movb %al, genint+1 \n"
"jmp genint \n"
"genint: \n"
"int $0 \n"
);
}
How can I make movb use the argument of geninterrupt()?
You need to use the constraints fields correctly:
void geninterrupt (int x) {
__asm__(" movb %[x], %%al \n"
" movb %%al, genint+1 \n"
" jmp genint \n"
"genint: \n"
" int $0 \n"
: /* no outputs */
: [x] "m" (x) /* use x as input */
: "al" /* clobbers %al */
);
}
Here's a good how-to about GCC inline assembly and a link to the relevant GCC documentation.
Edit: since your GCC seems to not be able to handle the labeled operands
% signs. Fixed now. I also had to change to an m constraint.