- I'm not sure where exactly your syntax error stems from, because you didn't post the error in full, however I do know that the '\n' is not required.
- the "int" instruction takes an immediate operand. That is, one which is known at compile time. You cannot use a register value for it.
- All inline asm statements, as a rule, should be declared volatile.
- You're writing C code and expecting it to emit 16-bit asm, on a linux box. How you've managed it I don't know because a lot of people here have tried and failed (I think borland (?) was the only compiler that worked in 16 bit mode). Be careful. Double check everything with a disassembler.
What I would do is just put this inline assembly into the same function as the others and put the line in when you need it so that you don't have to deal with the immediate operand issue and the overhead of calling a seperate function.
But if you're calling the interrupt, you're also setting some registers (like AX) and calling the function will change those registers due to C's calling convention. So also remember to include the register setting stuff in the same piece of inline assembly.
PS: The error was caused because "r" (x) should have been "r"(x)
"Sufficiently advanced stupidity is indistinguishable from malice."
karekare0 wrote:What I would do is just put this inline assembly into the same function as the others and put the line in when you need it so that you don't have to deal with the immediate operand issue and the overhead of calling a seperate function.
But if you're calling the interrupt, you're also setting some registers (like AX) and calling the function will change those registers due to C's calling convention. So also remember to include the register setting stuff in the same piece of inline assembly.
PS: The error was caused because "r" (x) should have been "r"(x)
I turn my code into a macro, so I can use it to execute any interrupt number. Thanks for the ideas.
- You're writing C code and expecting it to emit 16-bit asm, on a linux box. How you've managed it I don't know because a lot of people here have tried and failed (I think borland (?) was the only compiler that worked in 16 bit mode).
The ".code16gcc" directive is the key here. It works perfectly.
The boot code in Linux was rewritten recently using .code16gcc. You might want to take a look.