Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: boylesgj AT lion DOT cs DOT latrobe DOT edu DOT au (Gregary J Boyles), djgpp AT delorie DOT com Date: Tue, 22 Apr 1997 15:31:32 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Inline asm macro problem. Precedence: bulk boylesgj AT lion DOT cs DOT latrobe DOT edu DOT au (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 which causes the error > messages below. > > There must be a way around this because I can happily pass KeyBoardPort to > the dos library function inportb(...). > > Can any one help me out? 1) Isn't DJGPP generating the right code when you use the library functions? (use -O2 or at least -O). 2) Why KeyBoardPort is a variable instead of a constant? do you plan to modify the value?! 3) The problem is that you are using the g constraint so the code generated is right, take a look to the Brennan's page he explains the meaning of these constraints, or look in other related pages. You can find a link to it in my pages (see the signature). SET ------------------------------------ 0 -------------------------------- Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552 Salvador Eduardo Tropea (SET). (Electronics Engineer) Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013