Mail Archives: djgpp/1997/04/26/14:28:31
Gregary J Boyles wrote:
>
> I have the following macro which I am using in an ISR.
>
> #define INPORTB(Port,Byte) asm volatile ( \
> "\ninb %1,%%al\n" \
> "movb %%al,%0\n" \
> : "=g"(Byte) \
> : "g"(Port) \
> : "memory","al" \
> )
> Inside the ISR I have two variables : KeyBoardPort and ScanCode.
>
> I want to call the macro as follows : INPORTB(KeyBoardPort,ScanCode).
>
> The problem is that the macro expands to : inb -4(%ebp),%al; movb %al,-9(%ebp);
> and the first argument of inb ends up as a non literal.
If you really want a variable keyboard port, you could use the "in DX,AL"
form, e.g.
#define INPORTB(Port,Byte) asm volatile ( \
"\nmovw %1, %%dx\n"\
"inb %%dx,%%al\n" \
"movb %%al,%0\n" \
: "=g"(Byte) \
: "g"(Port) \
: "memory","%al","%dx" \
)
(not sure the clobber list %syntax is quite correct).
regards, tom.
- Raw text -