Mail Archives: djgpp/1996/03/21/07:54:17
Xref: | news2.mv.net comp.os.msdos.djgpp:2013
|
From: | gaggi AT cs DOT unibo DOT it (Nicola Gaggi)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Help me solving my first Page Fault!
|
Date: | 20 Mar 1996 09:24:31 GMT
|
Organization: | Department of Computer Science, University of Bologna, Italy
|
Lines: | 96
|
Message-ID: | <4ioisf$ms9@leporello.cs.unibo.it>
|
NNTP-Posting-Host: | 130.136.1.164
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hello guys,
I'm using DJGPP for the first time and i'm learnimg protected mode
programming too. Just as an exercize I'm trying to code a simple .PCX file
viewer but the only result is that I get Page Fault errors, I have
seen the sources of XLIB porting under DJGPP and everything seems correct
and working. I have tried to use the same techincs but with no result.
Here is the code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <go32.h>
#include <dpmi.h>
/* ------------------------------------------------------------- */
static unsigned char Line[1024];
static unsigned char Palette[768];
static unsigned short LinearMem;
/* ------------------------------------------------------------- */
void BlastLine(unsigned Offset)
{
asm("
pushw %es
pushl %esi
pushl %edi
pushl %ecx
movw _LinearMem, %ax
movw %ax, %es
movl 8(%ebp), %edi
addl $0x0a00000, %edi
movl $_Line, %esi
movl $320, %ecx
cld
rep
movsb <---- Here is the istruction generating the fault!
popl %ecx
popl %edi
popl %esi
popw %es
");
}
void DisplayPCX(FILE *fp)
{
unsigned RowOffset;
register unsigned i;
/* Reads and sets the palette */
....
fseek(fp, 128L, SEEK_SET);
for (RowOffset= 0; RowOffset < 64000; RowOffset += 320) {
DecodeLine(fp); /* Reads and decode a PCX line, the read
line is stored in the Line[] array */
BlastLine(RowOffset); /* Draws the line on the screen */
};
}
int main(int argc, char *argv[])
{
FILE *fd;
LinearMem= _go32_conventional_mem_selector();
....
/* Open the file set graphic, mode etc ... */
DisplayPCX(fd);
fclose(fd);
/* Waiting for keyboard input and return */
}
Pleas tell me where I go wrong ...
Reply via e-mail or via newsgroup ...
Thank you,
--
--------------------------------------------------------------------
Nicola Gaggi University of Bologna.
e-mail : gaggi AT cs DOT unibo DOT it WWW page: http://www.cs.unibo.it/~gaggi
--------------------------------------------------------------------
... Be yourself, no matter what they say
from "Englishman in New York" by Sting
- Raw text -