x86 programming for Ms Dos Computers in CGA , EGA and VGA

This page is Under Construction.... 'Learn 8086 is planned for 2020'

The IBM 8086 took the world by storm!

Although inferior to the 68000 - the x86 soon took over, and is the basis for all the computers we have today...

Starting with the 8086, and soon moving to the 286, 386 and so on... each iteration has added more commands and power, and along the way the PC has gained functionality...

In these tutorials, we'll take a look at the early  basic machines, and learn how we can use Assembly to write games that can be used in MSDos via DosBox!

We'll cover 3 graphics modes...

CGA 320x200 4 color (Cyan,Magenta,White or Green,Red,Yellow)
EGA 320x200 16 color fixed palette
VGA 320x200 256 color palette

Amstrad PC1512 IBM Compatible

If you want to learn 8086 get the Cheatsheet! it has all the 8086 commands, It will help you get started with ASM programming, and let you quickly look up commands when you get confused!

CGA color Palette

Palette 0 Dark Palette 0
Palette 1 Dark Palette 1 Bright




EGA color Palette

The EGA system uses 16 colors - it's 320x200 can only use a palette of 16 colors (the same colors!)

Each color has a logical number from 0-16, and a Hardware number (used for palette definitions) from 0-63

0 - 0 1 - 1 2 - 2 3 - 3 4 - 4 5 - 5 6 - 20 7 - 7
8 - 56 9 - 57 10 - 58 11 - 59 12 - 60 13 - 61 14 - 62 15 - 63

Screen Layouts

CGA is a 2bpp screen mode, it's memory is at B800:0000h

EGA use 4 bitplanes, it's address is A000:0000... to change the bitplanes we need to OUT to 03C4h

VGA is a 8bpp screen mode, it's memory is at A000:0000h

Screen Mode Bits per pixel Pixels per byte Address Plane Mask 7 6 5 4 3 2 1 0
CGA - 4 2 bpp 4 B800:0000h
b1 b0 b1 b0 b1 b0 b1 b0
EGA - 13 4 bitplanes 8 A000:0000h out 03c4h,0102h p0-b7 p0-b6 p0-b5 p0-b4 p0-b3 p0-b2 p0-b1 p0-b0
out 03c4h,0202h p1-b7 p1-b6 p1-b5 p1-b4 p1-b3 p1-b2 p1-b1 p1-b0
out 03c4h,0302h p2-b7 p2-b6 p2-b5 p2-b4 p2-b3 p2-b2 p2-b1 p2-b0
out 03c4h,0402h p3-b7 p3-b6 p3-b5 p3-b4 p3-b3 p3-b2 p3-b1 p3-b0
out 03c4h,0F02h All-b7 All-b6 All-b5 All-b4 All-b3 All-b2 All-b1 All-b0
VGA 8bpp 1 A000:0000h
b7 b6 b5 b4 b3 b2 b1 b0


View Options
Default Dark
Simple (Hide this menu)
Print Mode (white background)

Top Menu
***Main Menu***
Youtube channel
ASM Programming Forums
Dec/Bin/Hex/Oct/Ascii Table

Z80 Content
***Z80 Tutorial List***
Learn Z80 Assembly
Hello World
Advanced Series
Multiplatform Series
Platform Specific Series
ChibiAkumas Series
Grime Z80
Z80 Downloads
Z80 Cheatsheet
DevTools kit
Z80 Platforms
Amstrad CPC
Elan Enterprise
Gameboy & Gameboy Color
Master System & GameGear
Sam Coupe
ZX Spectrum
Spectrum NEXT
Camputers Lynx

6502 Content
***6502 Tutorial List***
Learn 6502 Assembly
Advanced Series
Platform Specific Series
Grime 6502
6502 Cheatsheet
DevTools kit
6502 Platforms
Apple IIe
Atari 800 and 5200
Atari Lynx
BBC Micro
Commodore 64
Commander x16
Super Nintendo (SNES)
Nintendo NES / Famicom
PC Engine (Turbografx-16)
Vic 20

68000 Content
***68000 Tutorial List***
Learn 68000 Assembly
Platform Specific Series
Grime 68000
68000 Cheatsheet
DevTools kit
68000 Platforms
Amiga 500
Atari ST
Neo Geo
Sega Genesis / Mega Drive
Sinclair QL (Quantum Leap)
X68000 (Sharp x68k)

8086 Content
Learn 8086 Assembly
8086 Cheatsheet
DevTools kit
8086 Platforms

ARM Content
Learn ARM Assembly
ARM Downloads
ARM Cheatsheet
DevTools kit
ARM Platforms
Gameboy Advance
Risc Os

Risc-V Content
Learn Risc-V Assembly
Risc-V Downloads
Risc-V Cheatsheet
DevTools kit

PDP-11 Content
Learn PDP-11 Assembly
PDP-11 Downloads
PDP-11 Cheatsheet
DevTools kit

My Game projects
Chibi Aliens
Chibi Akumas

Work in Progress
Learn 6809 Assembly
Learn 65816 Assembly
Learn 6809 Assembly
Learn TMS9900 Assembly
Dragon 32/Tandy Coco
Fujitsu FM7
Ti 99

Misc bits
Ruby programming

If you want to support my work, please consider backing me on patreon!

Buy Chibi Akuma(s) from PolyPlay
Buy ChibiAkuma(s) games now!

If you want to support my work, please consider backing me on patreon!

Buy Chibi Akuma(s) from PolyPlay
Buy ChibiAkuma(s) games now!

If you want to support my work, please consider backing me on patreon!

Buy Chibi Akuma(s) from PolyPlay
Buy ChibiAkuma(s) games now!