Article View: comp.os.msdos.programmer
Article #6264Need help with Phar Lap DOS Extender and assembly
From: Scott Lewis
Date: Sun, 03 Jan 1993 08:29
Date: Sun, 03 Jan 1993 08:29
79 lines
2637 bytes
2637 bytes
I am trying to program a graphics application with BC++ 3.1 and
Phar Lap 286 Dos Extender Lite. I need to write directly to the
video memory, but can't seem to do this successfully. Perhaps
someone could help me solve this problem.
Before using the Dos extender I was writing directly to segment
A000h in VGA mode 13h. Now I'm calling DosMapRealSeg () to
create a selector to A000h, but when I use that selector in an
assembly routine to write to the screen, I get a general protection
fault.
The function DosMapRealSeg () seems to be returning a legitimate
selector (22CFh), but I get a fault at this line in the ASM code:
mov es:[di], al ;ES contains the selector to A000h, di the offset
Can anyone offer any suggestions to solve this problem? Attached
below is the C code with inline assembly and the error message.
Thanks in advance,
Scott Lewis
cslewis@hydra.unm.edu
----
#include <dos.h>
#include <conio.h>
#include "vga.h"
#ifdef DOSX286
#include <phapi.h>
#endif
int drawPixel (int x, int y, int color);
main ()
{
int i;
extern unsigned short vga_seg; // vga_seg is initialized with
// DosMapRealSeg (), in another
vgaInit (0x0013); // module, which contains
// vgaInit () and vgaClose ().
for (i=0; i<320; i++)
drawPixel (i, 100, 4);
getch ();
vgaClose ();
return 0;
}
drawPixel (int x, int y, int color)
{
extern unsigned short vga_seg;
asm mov ax, vga_seg
asm mov es, ax
asm mov ax, 320
asm mul y // The fault is occuring in this
asm add ax, y // routine, at the last line,
asm mov di, ax // I believe.
asm mov ax, color
asm mov es:[di], al
return 0;
}
When run, the code gives this error message:
Fatal error 286.3330: General protection fault detected.
PID=0001 TID=0001 SID=0001 ERRORCODE=0000
AX=0004 BX=0017 CX=0013 DX=0000 SI=0000 DI=7D64 BP=0FE2
CS:IP=024F:004C DS=0267 ES=22CF SS:SP=026F:0FE0 FLAGS=2202
--
---------------------
Scott Lewis
cslewis@vesta.unm.edu
---------------------
Technical Details
Message-ID:
<g8trrpd@lynx.unm.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!news.cs.indiana.edu!lynx!hydra.unm.edu!cslewisShow Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer,rec.games.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!news.cs.indiana.edu!lynx!hydra.unm.edu!cslewis From: cslewis@hydra.unm.edu (Scott Lewis) Subject: Need help with Phar Lap DOS Extender and assembly Message-ID: <g8trrpd@lynx.unm.edu> Date: Sun, 03 Jan 93 08:29:53 GMT Organization: University of New Mexico, Albuquerque Lines: 79