Mail Archives: djgpp/1997/11/30/03:33:36
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 -