A video mode available on all VGA adapters, with a resolution of 320x200 with and 8-bit palette (or 256 colors at a time, available from 262,144 total color available from 64 shades each of red, green and blue). The "13h" comes from the fact that it is the 16th (or number 13 in hexadecimal) display mode listed in the BIOS documentation (see Int 10h), and the hexadecimal number 13 is commonly written as 13h in most x86 assemblers such as using Intel syntax, such as the Microsoft's Macro Assembler or MASM, Borland's Turbo Assembler or TASM, and Simon Tatham's Netwide Assembler or NASM.

Sometimes it is referred to simply as "Mode 13" because it was usually accessed through C or assembly language, where it would be implicity defined to be in hexadecimal, or through QBASIC, where it was accessed using the command SCREEN 13.

One of the reasons for its popularity was its extreme ease of use. It required a single interrupt call to enter (as opposed to all sorts of crazy register reads and writes to enter ModeX or the less-famous ModeQ). The video buffer began at 0xA0000 and ran for 64,000 bytes (so it could be accessed without switching segment registers), and each byte was a single pixel, making all graphical operations very easy (other modes had the bad habit of splitting the bits for pixels across several pixel planes, or using multiple bytes per pixel, or both). Changing the palette was a piece of cake, simply by reading and writing a few I/O ports on the system.

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

start:
    ; 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
ret
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 -omain.com
and
dosbox ./main.com -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:

n main.com
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
ret

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

rcx
1d
w
q

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

main.com

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

Notice how small this executable is. :-)

Enjoy!

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

Log in or registerto write something here or to contact authors.