www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/23/04:07:03

Date: Wed, 23 Apr 1997 03:24:05 +0300 (EET DST)
From: Samuli Takala <tax AT cc DOT hut DOT fi>
To: Gregary J Boyles <boylesgj AT lion DOT cs DOT latrobe DOT edu DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: Inline asm macro problem.
In-Reply-To: <5jhum0$575@lion.cs.latrobe.edu.au>
Message-ID: <Pine.OSF.3.96.970423031443.28273A-100000@alpha.hut.fi>
MIME-Version: 1.0

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

- Raw text -


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