www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/06/10:15:46

Message-ID: <8hYRtBARuejxEwB6@johnhamp.demon.co.uk>
Date: Mon, 6 May 1996 13:07:45 +0100
To: djgpp AT delorie DOT com
From: David Hampson <David AT johnhamp DOT demon DOT co DOT uk>
Subject: Nearptrs not quicker?
MIME-Version: 1.0

(Please be nice - I'm new/inexperienced/stupid at DJGPP version 2 and
the Internet in general...)

I'm a little bit confused about DJGPP2's nearptrs and the Fat DS method.
My problem is using __djgpp_conventional_base doesn't seem to be any 
faster than dosmemput. I've timed two versions of a routine which
'blasts' a screen buffer into the 0xa0000 area, one using the Fat DS and
one using dosmemput, and they both seem to be just as fast.
Am I doing something hideously wrong? (Is my CopyLongs routine okay?)

Here are some fragments of my C code:

#include "daves.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys\movedata.h> /* For dosmemput() */
#include <sys\nearptr.h> /* For Fat DS */

int BlastScreen(char *ScrArea,int Page);
int FatDSBlastScreen(char *ScrArea,int Page);

...
    /* Draw the screen on DrawPage here */
    if (!__djgpp_nearptr_enable())  
    {
      FatDSBlastScreen(MyScr,DrawPage);
      __djgpp_nearptr_disable();
    }  
    else 
    { 
      BlastScreen(MyScr,DrawPage);
      FatDSFail=1;
    }
...

int FatDSBlastScreen(char *ScrArea,int Page)
{
  char *ScreenBase;

  /* Uses Fat DS method */
  ScreenBase=(char *)(__djgpp_conventional_base+0xa0000+0x4000*Page);

  BitMask(1);
  CopyLongs(ScrArea+0x0000,ScreenBase,0x1000);
  BitMask(2);
  CopyLongs(ScrArea+0x4000,ScreenBase,0x1000);
  BitMask(4);
  CopyLongs(ScrArea+0x8000,ScreenBase,0x1000);
  BitMask(8);
  CopyLongs(ScrArea+0xc000,ScreenBase,0x1000);
  BitMask(15);
  return 0;
}

int BlastScreen(char *ScrArea,int Page)
{
  unsigned long ScreenBase;

  /* Uses conventional method */
  ScreenBase=0xa0000+0x4000*Page;
  
  BitMask(1);
  dosmemput(ScrArea+0x0000,0x4000,ScreenBase);
  BitMask(2);
  dosmemput(ScrArea+0x4000,0x4000,ScreenBase);
  BitMask(4);
  dosmemput(ScrArea+0x8000,0x4000,ScreenBase);
  BitMask(8);
  dosmemput(ScrArea+0xc000,0x4000,ScreenBase);
  BitMask(15);
  return 0;
}

Here's the CopyLongs routine and the BitMask routine in my assembler
module:

.globl _CopyLongs
_CopyLongs:
  pushl %ebp  
  movl %esp,%ebp
  pushl %edi  
  pushl %esi  
  
  movl  8(%ebp),%esi
  movl 12(%ebp),%edi
  movl 16(%ebp),%ecx
  rep
  movsl
  
  popl %esi   
  popl %edi   

  movl %ebp,%esp
  popl %ebp
  ret

.globl _BitMask
_BitMask:
/*
  Replaces:
    outportb(0x3c4,0x02);
    outportb(0x3c5,1<<Plane);
*/
  
  pushl %ebp
  movl %esp,%ebp
  
  movw $0x3c4,%dx
  movb $0x02,%al
  outb %al,%dx
  inc %dx
  movb 8(%ebp),%al
  outb %al,%dx
  
  movl %ebp,%esp
  popl %ebp
  ret

Thanks for your patience!

-- 
David Hampson
David AT johnhamp DOT demon DOT co DOT uk

- Raw text -


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