Date: Wed, 23 Apr 1997 03:24:05 +0300 (EET DST) From: Samuli Takala To: Gregary J Boyles cc: djgpp AT delorie DOT com Subject: Re: Inline asm macro problem. In-Reply-To: <5jhum0$575@lion.cs.latrobe.edu.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On 22 Apr 1997, Gregary J Boyles wrote: > #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. The port must be loaded to the %edx register, that's the only one in and out can use. Either load Port to %edx and use that with inb, or tell asm to put Port directly to %edx: : "d" (Port) Hope this helps, Samppa Samuli Takala Samuli DOT Takala AT hut DOT fi finger -l tax AT hut DOT fi for long version