GCC and simple VGA graphics?

Programming, for all ages and all languages.
Post Reply
xlar54
Posts: 12
Joined: Mon Sep 16, 2013 1:12 pm

GCC and simple VGA graphics?

Post by xlar54 »

Hey folks,

Im working on a kernal that needs some simple VGA routines (setpixel, etc). Are there some examples out there that I can look at? Right now, I have the following. It compiles, but in Qemu, it just reboots back to GRUB:

Code: Select all

	
        asm("mov %ax, 0x13");
	asm("int $0x10");
	
	unsigned char* p = (unsigned char*)0xa0000;
	for(zz=0; zz=100; zz++)
		p[zz]=1;
From what Ive read, I should be seeing a blue line. Do we have any very simple graphics routines out there, or can someone tell me what Im doing wrong? I dont think Im using protected mode. (Im using this tutorial: http://wiki.osdev.org/Bare_bones). Im wanting just a simple 320 x 200 8bit screen.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: GCC and simple VGA graphics?

Post by neon »

Hello,

GrUB executes the image in protected mode thus BIOS services cannot be used without resulting in triple fault. To rectify, do one of the following:

General options
1. Real mode. Not recommended; provided for completeness only.
2. Use v8086 mode. Requires user mode task switching.
3. VGA video driver. Complicated but does not require a specific processor mode.

Specific to multi-boot compliant boot loaders
4. Set the requested video mode width, height, and bit depth in the multi-boot information header and set the bit 2 of the flags field set. This will tell the loader to set the video mode for you.

Note that most loaders use Vesa Bios Extensions (VBE) and thus may also support high resolution modes supported through VBE. VBE and VGA Bios services can also be used directly by methods (1) and (2) above.

We recommend options (2) and (3) over the others though for maximum compatibility. Option (4) would be a good idea for something quick though for you to test with.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: GCC and simple VGA graphics?

Post by sortie »

You are in 32-bit protected mode after being booted by GRUB using multiboot. You cannot call the BIOS directly.
Post Reply