delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/20/22:22:11

From: brennan AT mack DOT rt66 DOT com (Brennan "The Rev. Bas" Underwood)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Far Pointers in Protected Mode
Date: 20 Oct 1996 19:00:22 -0600
Organization: Rasterfari
Lines: 48
Message-ID: <54ehv6$o4s@mack.rt66.com>
References: <54bsg5$c6b AT news DOT stealth DOT net>
NNTP-Posting-Host: mack.rt66.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Mohan Khurana (mohan AT stealth DOT net) wrote:
: Lets say I wanted to fill an area of the screen.  Under something like
: Borland C, I would just use 
: 
: memset(0xA000, 15, 0xffff)
: 
: right?
: 
: This doesn't seem to work in DJGPP.  I was thinking about setting each
: pixel individually in a for loop using _farnspokeb, but this is slow.
: Is there a better way?  I want to set chunks of data to a certain
: value.  I checked farptr.h, but there wasn't really much documentation
: in the file.  I also checked the info documentation and the
: information about far pointers, but the information on the individual
: functions wasn't very helpful.

If you don't mind using near pointers, you could snag the rep_stosl
asm macro from http://brennan.home.ml.org/djgpp/djgpp_asm.html.

It would also be trivial to modify it to set %es, farptr style.

Hell, I'll do that right now:
#define rep_stosl(value, dest, numwords, seg) \
__asm__ __volatile__ ( \
  "pushw %%es\n\t" \
  "movw %%bx, %%es\n\t" \
  "cld\n\t" \
  "rep\n\t" \
  "stosl\n\t" \
  "popw %%es"
  : : "a" (value), "D" (dest), "c" (numwords), "b" (seg) \
  : "%ecx", "%edi" )

Notice you must fill it a 4-byte longword at a time.

You would call it like this:
rep_stosl(0, 0xa0000, 320*200/4, _dos_ds);

to clear a mode 0x13 VGA screen.

I'm pretty sure that'll work, but caveat emptor.


--Brennan
-- 
brennan AT rt66 DOT com  |  Personal Goal #67: Drag Carmack and win.
                  |  
  Rasterfarian    |  <http://brennan.home.ml.org>

- Raw text -


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