delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/22/17:18:49

Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: Endlisnis <s257m AT unb DOT ca>
Date: Sat, 22 Aug 1998 22:16:25 +0000
MIME-Version: 1.0
Subject: Re: VESA: hints, clue but no examples
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com
Message-Id: <E0zAL2k-0004UN-00@sable.ox.ac.uk>

On 22 Aug 98 at 15:35, Endlisnis wrote:

> > anyway...i've got a question about selectors...well, perhaps a couple... i'd have to use _farpokeb do
> > access the .....selected memory right?...or movedata(..) to copy a buffer?
> 
>     Yes.  I've made my own 'setdata' function to use a bunch of _farnspokel calls to quickly write a single
> value to a bunch of contiguous locations.

For a reasonable number of locations, this would probably be faster
if you used an inline assembler routine; push ES, load it with the
selector, load EDI with the offset, EAX with the value and ECX with
the number of longs, then "rep ; stosl" and finally pop ES back
again.  Perhaps this:

    inline void flmemset (int selector, int offset, int value, int num_longs)
    {
        asm (
            " pushl %%es ; movw %%dx, %%es ; cld ;  rep ; stosl ; popl %%es "
            :
            : "c" (num_longs), "a" (value), "d" (selector), "D" (offset) 
            : "%ecx", "%edi"
        );
    }

In case you don't know, `stosl' stores the 4-byte value in EAX to
ES:EDI, increasing EDI by 4 (if the direction flag is clear; `cld'
arranges this).  `rep ; stosl' does this ECX times.  We need to save 
then restore ES because we're not allowed to clobber it.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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