Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I want to know if there's any documentation, tutorials, or anything really that can help me better grasp the idea of how this is done from the hardware level directly(not just RAMDAC and analog signals, but how the processor sends the binary data, and how it exactly must be done).

For example, I want two pixels ... do Assembly languages come with any well-documented instructions or tutorials on how I can access video memory through VGA or the like?

What are the basics done here? I just want some little help.

share|improve this question
1  
What hardware are you looking at specifically? – Philip Dec 20 '12 at 21:31
Intel G41 Express Chipset, onboard Intel graphics I believe with an x86-64 Intel processor. – leslar Bonar Dec 20 '12 at 21:33
I would just like some pointers here because I need this information for low-level programming, such as with operating system development. I figured I'd ask here rather than on those sites. – leslar Bonar Dec 20 '12 at 21:34

3 Answers

This itself is hardly possible on modern hardware. It might be, for example in Linux by accessing /dev/fb or /dev/fb0 framebuffer devices. However, this requires a framebuffer support built on the kernel and root privileges.

In Windows I believe it becomes even more problematic.

However, because your question seems to be about low-level implementation, I can point you to take a look at how BIOS manages the video mode for real-mode x86 code. The basic idea is that you first specify BIOS interrupt dealing with video modes. This is done by the following code:

mov ax, 13h
int 10h

You move the desired video mode(in this case mode 13h, which is 320x200x256 mode) to the lower bits of ax register and then call the appropriate BIOS interrupt which deals with video modes, which in this case happens to be 10h.

After that point, the video mode is being set for you. To actually access the framebuffer contents, you need to read/write from address 0xA000 onwards, which is the base address for the framebuffer. Basically your best way to do this is to set the di register to point to 0xA000 and your si register to hold the value you want to write to the buffer next. Then just use stosb instruction to copy contents from si to di and increment both.

share|improve this answer

First off, the hardware (the Intel G41 Express Chipset) is proprietary but Intel has done some work to help make linux drivers, which would obviously help you make your own.

I'd start by reading the documentation and source code for the linux drivers. The G41 express chipset is supported.

But if you want to directly control the pixels on the screen, I'd start with simpler and more open hardware. And if you really want to make your own driver, I'd look into open video hardware.

share|improve this answer
1  
For completeness (but unrelated to Intel G41), here's the equivalent for AMD's GPUs: x.org/docs/AMD – luiscubal Dec 21 '12 at 1:18

It depends on the environment where your code is running. This answer is about PC (x86) architecture.

BIOS provides limited direct access to video memory. You can write to video memory without any operating system support by setting the correct video mode using BIOS calls and writing to specific address in the memory. Same is true when using DOS.

320x200x8bpp resolution is easy. See the answer by zxcdw and VGA on Wikipedia. Same is true for some other resolutions such as text mode. Video modes with larger resolution (where the video memory doesn't fit to 64kB) is a little bit trickier. With VGA you can use video modes up to 256kB by switching which of the 4 video planes are active when writing to the video memory.

If you want to use better resolutions and/or access the video memory in linear manner, you need to use either hardware specific system calls or more easily use VESA BIOS Extensions (VBE) standard. It's a bit more effort to setup proper video modes using VBE than a single BIOS call. I think DOS games with high resolutions (SVGA) used both of these approaches.

With newer operating systems such as Windows and Linux, the access to video memory depends on the platform. The drivers and APIs abstract the whole video memory access and can provide you a linear memory address where you can write pixels directly, but that is unlikely to write directly to the visible video memory itself. Instead the memory is managed and blitted or flipped to the screen by the driver.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.