g++ is complaining to me about a missing bracket in the following code:
1 2 3
v v v
__asm__ volatile("inb %1, %0" : : "=a" (result) : "Nd" (portnumber) );
^ ^ ^
1 2 3
as you can see the brackets are matching and there are three open brackets and three close brackets.
also for more information i am following a youtube tutorial
You have an extra :
before the output, so you ended up with your output declaration in the input part. And the reason for that error: your input operand declaration where the compiler expects the clobber list. The clobber list can only include string literals (register names and "memory"
and/or "cc"
1), not ()
.
__asm__ volatile("inb %1, %0"
: "=a" (result) // output
: "Nd" (portnumber) // input
// : "memory" // optional, clobber list
);
You might want a "memory"
clobber list to make sure this is ordered wrt. memory accesses. Or not, if you're sure it doesn't need to be.
Footnote 1: asm statements on x86 implicitly clobber the condition codes, "cc"
. You can use it for documentation if you like. But you don't want it here because inb
doesn't touch EFLAGS.