delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/11/17:15:33

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Unoptimal implementation of pc.h
Date: Tue, 11 Nov 1997 21:35:54 +0000
Organization: None
Distribution: world
Message-ID: <O55Q6BC6+Ma0Ew7W@talula.demon.co.uk>
References: <199711112016 DOT MAA18274 AT adit DOT ap DOT net>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 26
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Nate Eldredge writes:
>>so I think using "Nd" instead of "d" should save few instrucions and
>register or not?
>
>No. The "N" constraint is only intended for the compiler. It doesn't 
>make sense to use it for inline asm, since the compiler doesn't know
>ahead-of-time what port will be written to. Its only choice is to load
the port number into the dx register.

I think it would make sense in many situations, since the port functions
are inlined. When you call outportb(0x20, 0x20) at the end of an
interrupt handler, the compiler knows exactly what value to use, so it
could easily make use of the 'N' constraint.

>(Also, the constant-port form of `in'/`out' only works for port numbers 
>up to 0xFF, which is pretty useless.)

That is why it would have to use 'N' (a constant ranging 0-255) rather
than the more generic 'i' or 'n'. Sure, it wouldn't make any difference
for code that uses larger port values, but it would certainly help when
using small and fixed port addresses...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Pigs use it for a tambourine" - Frank Zappa

- Raw text -


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