www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/30/12:11:27

Date: Sun, 30 Nov 1997 12:05:27 -0500 (EST)
From: Michael Phelps <loverns AT welchlink DOT welch DOT jhu DOT edu>
To: Robert McNulty <bobbymcn AT www DOT the-link DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: general protection fault
In-Reply-To: <3481152A.F796F31C@www.the-link.net>
Message-ID: <Pine.SOL.3.96.971130120351.20882A-100000@welchlink.welch.jhu.edu>
MIME-Version: 1.0

On Sun, 30 Nov 1997, Robert McNulty wrote:

> 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";

Looks like a problem here.  Try allocating memory for it:
	string = (char *)malloc(strlen("Hello Bobby")+1);
	strcpy(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