www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/18/11:29:24

Newsgroups: comp.os.msdos.djgpp
From: Butler Owen scm2211 <s9708172 AT tiger DOT vut DOT edu DOT au>
Subject: GPF when trying to access VGA adapter
Message-ID: <Pine.SOL.3.95.980617235959.21339B-100000@tiger.vut.edu.au>
Sender: news AT matilda DOT vut DOT edu DOT au
Organization: Victoria University of Technology
Mime-Version: 1.0
Date: Wed, 17 Jun 1998 14:07:26 GMT
Lines: 51
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I am having trouble making a pointer to my VGA card memory using djgpp.

here is my code:
// start
#include <dos.h>
#include <iostream.h>

void setgmode()
{
  union REGS r;
  r.x.ax = 0x13;
  int86(0x10, &r, &r);
}

int main()
{
  setgmode();	// sets vga adapter to mode 13h
  char * screen = (char *) 0xa0000000;

  for (int x = 0; x < 320; x++)
    for (int y = 0; y < 200; y++)
      screen[y*320+y] = (char) y;

  return 0;
}
//end

This compiles fine, but when I try to run it, I get the following:

General Protection Fault at eip=000015d4
eax=00000000 ebx=000221a0 ecx=00000000 edx=a0000000 esi=00000054
edi=0000a6d4
ebp=009c3fd4 esp=009c3fc8 program=C:\OWEN\CODE\A.EXE
cs: sel=00a7  base=8266e000  limit=009c3fff
ds: sel=00af  base=8266e000  limit=009c3fff
es: sel=00af  base=8266e000  limit=009c3fff
fs: sel=0087  base=0000a310  limit=0000ffff
gs: sel=00bf  base=00000000  limit=ffffffff
ss: sel=00af  base=8266e000  limit=009c3fff

Call frame traceback EIPs:
  0x000015d4
  0x00001b42

eek.

Am I declaring the pointer wrong?  using it wrong?  got the address wrong?

Owen Butler

- Raw text -


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