Date: Sun, 30 Nov 1997 12:05:27 -0500 (EST) From: Michael Phelps To: Robert McNulty cc: djgpp AT delorie DOT com Subject: Re: general protection fault In-Reply-To: <3481152A.F796F31C@www.the-link.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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 > #include > #include > 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----- > >