delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/15/13:30:22

From: Vik Heyndrickx <Vik DOT Heyndrickx AT rug DOT ac DOT be>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline assembly question
Date: Mon, 15 Dec 1997 11:42:32 +0100
Organization: University of Ghent, Belgium
Lines: 47
Message-ID: <34950998.37ED@rug.ac.be>
References: <01bd0717$ffc6c1e0$3ca1f482 AT default> <882164794 DOT 925368334 AT dejanews DOT com>
NNTP-Posting-Host: eduserv1.rug.ac.be
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

lturcott AT compuserve DOT com wrote:
> 
> Hi Peter
> 
> > using __djgpp_nearptr_enable and then use direct acces to videomem.
> > (SCREEN[offset]=col).
> >
> > put_pixel (int x,int y,unsigned char col)
> > {
> > asm ("
> > movw _dos_page,%%es                   (dos_page is preloaded with _dos_ds)
> > movl $0xa0000,%%edi
> > addl %%ebx,%%edi
> > stosb
> > :
> > :"a"(col),"b"((y<<8)+(y<<6)+x)
> > :"%eax,"%ebx",%edi"
> > }
> >
> > It this way of plotting a pixel the same as the farpokeb (...) version??
> 
> Using __djgpp_nearptr_enable should be a bit faster because you avoid
> loading the ES register. But  !..., It may not work from a DPMI server to
> an other.

If you use the 'no selector' versions of the _far* function you don't
have this load. 
BTW this load takes more cycles than you may think because loading a
selector register involves loading a descriptor, checking access rights,
...

One advantage by using the near pointer versions is that the compiler
generates the code and that maybe further optimizations can be
performed. But do not expect too much from that. IMHO it is not worth it
using the near pointer functions. Now that I think of this, these
optimizations may even break your code, since accessing video memory is
always tricker than accessing 'normal' RAM. If the compiler manages to
combine two consecutive by writes into a single double-byte write, your
code may not work anymore. I do not know whether the gnu compiler is
intelligent enough at this time to do this, but I wouldn't be surprised
and eventually this optimization strategy may get in, and your code that
once ran perfectly won't run anymore after recompilation.

-- 
 \ Vik /-_-_-_-_-_-_/   
  \___/ Heyndrickx /          
   \ /-_-_-_-_-_-_/

- Raw text -


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