www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/22/14:41:48

Message-Id: <m0wJeTU-000S1vC@natacha.inti.edu.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT edu DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT edu DOT ar>
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
Subject: Re: Inline asm macro problem.

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019