Mode 13h is a graphics mode that exists on virtually every x86-type computer. The resolution is 320x200, with 256 colors (8 bits per pixel).

The memory area where all the pixels are stored starts at 0a000h (not 0a0000h) and stops at 019a00h (64000 bytes later). You could write 0ffffh bytes from 0a000h (instead of 64000), but that is considered bad practice, even though it usually won't crash your computer. Each pixel in mode 13h is the size of a byte, which is very practical.

While in mode 13h, you can only show 256 colors at once, but you can choose for yourself exactly what 256 colors should be available. This information is stored in the 768-byte palette, and manipulated with "in" and "out" assembly instructions, or some of the common BIOS-interrupts.

If you're in an adventerous mood, you could emulate more than 256 colors, by quickly changing the colors in the palette, or by dithering.

Using dosbox, you can still use good old mode 13h in GNU/Linux.

Here is a small assembly program I've written, that can be compiled to a .com with nasm, and run via dosbox. All lines that starts with a ";" are just comments. I don't think the section-lines are needed, but they were mentioned on the nasm-manpages, so I'll include them anyways. Here goes:

org 100h
section .text

    ; put your code here
; The classical "fill the screen with the color red" program ;)

; Graphics mode 320x200x8bpp
mov     al, 13h
int     10h
; Segment a000h
mov     ax, 0a000h
mov     es, ax
; Offset 0
xor     di, di
; Colorword red red
mov     ax, 2727h
; Looplength (320*200)/2 = 7d00
mov     cx, 7d00h
; Draw pixels, one word at a time
rep     stosw
; Wait for keypress
xor     ah, ah
int     16h
; Textmode
mov     ax, 0003h
int     10h
; Exit
section .data
    ; put data items here
section .bss
    ; put uninitialized data here

Now, if you save this file as main.asm, and have installed both nasm and dosbox, you can try the following commands:

nasm main.asm -fbin
dosbox ./ -exit

You should now get a completely red window that will be closed by a keypress.

If you, by a chance, are using Windows, a similar result can be achieved by using the built-in debug.exe.

Okay, first hold down the windows-key and press r. Then type "cmd" and press enter. If "cmd" doesn't work, try "command". Then, in the commandline window, type "debug" and press enter.

Now, you should get a "-" on the screen. Type in the following:

a 100
mov al,13
int 10
mov ax,a000
mov es,ax
xor di,di
mov ax,2727
mov cx,7d00
rep stosw
xor ah,ah
int 16
mov ax,0003
int 10

Press enter an extra time, so that you get the "-" again. Now type in the following:


You have now created a .com-file, congratulations. Now, type in

in order to get a screenfull of red, until you press a key.

Notice how small this executable is. :-)


This node has some similar information, but is not as cool: Writing .com files with DOS debug ;-)