www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/30/03:33:36

Message-ID: <3481152A.F796F31C@www.the-link.net>
Date: Sun, 30 Nov 1997 01:26:35 -0600
From: Robert McNulty <bobbymcn AT www DOT the-link DOT net>
Reply-To: bobbymcn AT www DOT the-link DOT net
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: general protection fault
NNTP-Posting-Host: dialin250.mgm.the-link.net
Lines: 112
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have a problem. I get a "general protection fault at 160a".
I can't fund the bug. I ried everything I could. here is the source
code.
---------------snip---------------------------------
#include <stdio.h>
#include <dpmi.h>
#include <go32.h>
void SetMode13();
void SlowPutPxl(int x, int y, int color);
void SetText();

static int dos_seg, length;
static char *string;

main()
{
 int x=100, y = 240, color = 5;
 dos_seg = _go32_conventional_mem_selector();
 string  = "Hello Bobby";
 length  = 10;

 asm ("
  pushw %es

  movw  _dos_seg, %es

  movl  _string, %esi
  movl  $0xb8000, %edi

  movw  _length, %cx

  rep ; movsb

  popw  %es
 ");

SetMode13();
SlowPutPxl(x, y, color);
}



 void SetMode13()

 {

 dos_seg = _go32_conventional_mem_selector();

asm("
  pushw %es

  movw  _dos_seg, %es


     mov $0x002, %ax
     movw $0xA0000, %bx
     int $0x02f
     xor  %ah, %ah
     mov   $0x013, %al
     int  $0x010


    movw  $0x0A0000, %edi
    movw %di ,%es
    xor  %di, %di
           ret
");
}




void SetText()
{    asm("        movl  $0x003, %ax
                  int $0x10
                  ret
                  ");
}

void SlowPutPxl(int x, int y, int color)
{
   dos_seg = _go32_conventional_mem_selector();
asm("
               pushw %es

                 movw  _dos_seg, %es

                  push %ebp
                  movl %sp, %bp
                  pushw %es
                  pushw %di

                  movw $0xA0000, %ax
                  movw %ax, %es
                  movw %bp+8, %ax
                  movw  320, %cx
                  mul %cx
                   add %bp+6, %ax
                    movw  %ax, %di

                  movw  %bp+10, %di
                  movw  %di, %di
                  popw %di
                  popw %es

                  movw %bp, %sp
                  popw %bp
                  ret
");
}
---------nd of program-----

- Raw text -


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