(This tutorial was originally written in 2004 and featured in http://asm.inightmare.org/)
Hello this was the first assembly tutorial I wrote. It was in my Language (Lithuanian), but now I decided to make English site and translate my tutorials to English.
The aim of tutorial is to teach VGA graphics programming in VGA mode 13h (320x200x8bit). So now I’m going to explain how to switch to the mode and put a pixel on the screen.
So switching to the mode 13h is as simple as that:
mov ax, 13h ; AH=0 (Change video mode), AL=13h (Mode) |
OK. We have the mode switched. Lets put a single pixel on the screen:
mov ax, 0A000h ; The offset to video memory |
Easy, but not very comfortable when you want to write to coords like (45, 66) or (183, 112). So now lets write a little function that helps us.
mov ax,67 ; Y coord |
Or we can write a little “procedure” that puts pixel on the screen:
putpixel: |
Before calling it we set ax with Y coord, _bx_ with X and _dl_ with the color.
mov ax, 10, |
To get the pixel from video memory we just change the last assembly line in our putpixel procedure to:
mov dl, [es:di] |
Now lets set back the old mode (usually 3):
mov ax,3 |
I hope I helped a little. ;) Here’s the source for the tutorial. Good luck!