www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/26/14:28:31

From: Tom Burgess <Tom_Burgess AT bc DOT sympatico DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline asm macro problem.
Date: Tue, 22 Apr 1997 20:37:00 -0700
Organization: BCTEL Advanced Communications
Lines: 32
Message-ID: <335D83DC.1A04@bc.sympatico.ca>
References: <5jhum0$575 AT lion DOT cs DOT latrobe DOT edu DOT au>
NNTP-Posting-Host: pntn02m02-111.bctel.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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