EGA Registers

Most register references you will find online are for the VGA exclusively, or else intermingle EGA and VGA to the point where it can be confusing if you are looking for a EGA specific reference.

Every bit listed in this section is specific to the original IBM EGA, unless where noted.

NOTE: The original IBM EGA and several clones have jumpers that can invert address line A09 during port decoding. This causes all the 3XX range registers to be decoded at 2XX. This is a fairly obscure feature and I am not aware of anything that uses it - even video BIOS routines will typically fail to control the card with this jumper set.

The EGA can switch between a port base of 3DX and 3BX for the CRTC and Input Status Register 1 registers - this is primarily for MDA compatibility. The EGA may configure itself this way on boot depending on the status of the EGA DIP Switches.

Indexed Registers

Register indexing is a common way to reduce the complexity of address decoding and conserve the IO address space. In its most common form, it consists of a pair of registers - an address port and a data port. First, a byte address or register index is written to the address port. This selects the desired register, assuming it represents a valid index. Then, with the desired register selected, the new value for the register is written to the data port. The address port and data port are typically consecutive IO addresses, with the address port at an even address. There is a good reason for this.

A consequence of the 8088’s transparent 8-bit bus is that an indexed register can be selected and written to via a single word-sized OUT. The data byte is typically packed into AH, with the address in AL. The 8088’s BIU will convert the word write into two 8-bit writes at the base IO address and then the base address + 1. On the AT and subsequent 16-bit architectures, this conversion had to be specifically emulated by hardware on the motherboard.

Indexed registers can also be implemented via an internal flip-flop, where only a single IO port is required. The first write will set the register index, the second write will set the corresponding register data. Under this scheme there must be a way to reset the flip-flop to a known state. This technique is used for the EGA’s single Attribute Controller IO port, which can be reset by reading Input Status Register 1 at either 3DAh or 3BAh, depending on the EGA’s current base address.

Register File Overview

I/O AddressRead FunctionWrite Function
3B4 / 3D4Not ReadableCRTC Address Register
3B5 / 3D5Not ReadableCRTC Data Register
3BA / 3DAInput Status Register 1Feature Control Register
3C0Not ReadableAttribute Controller
3C2Input Status Register 0Miscellaneous Output Register
3C4Not ReadableSequencer Address Register
3C5Not ReadableSequencer Data Register
3CENot ReadableGraphics Controller Address Register
3CFNot ReadableGraphics Controller Data Register

Register Set Details Index

CRTC Registers

The EGA uses a custom LSI CRTC chip. It is very similar in operation to the Motorola 6845, but defines most vertical counters in units of scanlines. Using scanlines as the vertical unit is more convenient for a graphics-mode oriented video adapter. It also has the big advantage of not requiring any memory-addressing tricks that lead to inconvenient video memory layouts on the CGA and Hercules cards.

Most of the EGA CRTC registers are write-only, with the exception of the three register pairs that hold memory addresses - the Start Address, Cursor Location, and Light Pen address registers can be read out. The inability to read the EGA CRTC registers was an annoyance for graphics and games programmers everywhere. This was rectified on the VGA which made most of the register file readable, but much software written for 4bpp modes did not rely on this to maintain backwards compatibility.

IndexRegister NameAccessDescription
00hHorizontal TotalWTotal character clocks in a scanline, minus 2
01hHorizontal Display EndWNumber of characters visible per line
02hStart Horizontal BlankWCharacter position where horizontal blanking begins
03hEnd Horizontal BlankWCharacter position where horizontal blanking ends
04hStart Horizontal RetraceWCharacter position where horizontal retrace begins
05hEnd Horizontal RetraceWCharacter position where horizontal retrace ends
06hVertical TotalWTotal number of scanlines per frame
07hOverflowWHigh bits for V-Total, V-Display, V-Sync
08hPreset Row ScanWStarting scanline within a character cell
09hMax Scan LineWHeight of character cell minus 1
0AhCursor StartWTop scanline of cursor
0BhCursor EndWBottom scanline of cursor
0ChStart Address HighRWHigh byte of display memory start pointer
0DhStart Address LowRWLow byte of display memory start pointer
0EhCursor Location HighRWHigh byte of cursor memory address
0FhCursor Location LowRWLow byte of cursor memory address
10hVertical Retrace StartWScanline where Vertical Retrace begins
10hLight Pen Address HighRHigh byte of Light Pen latched memory address
11hVertical Retrace EndWScanline where Vertical Retrace ends (Bits 0-3)
11hLight Pen Address LowRLow byte of Light Pen latched memory address
12hVertical Display EndWLast visible scanline (low 8 bits)
13hOffsetWSpan width of logical scanline
14hUnderline LocationWScanline within cell for underline
15hStart Vertical BlankWScanline where blanking starts
16hEnd Vertical BlankWScanline where blanking ends
17hMode ControlWHardware compatibility/timing toggles
18hLine CompareWScanline on which CRTC start address is reset

Graphics Controller Registers

PortRegister NameAccess
3CCGraphics 1 PositionW
3CAGraphics 2 PositionW
3CEGraphics AddressW
3CFGraphics DataW

On the original IBM EGA, there are two separate Graphics Controller chips. They can generally be treated as a single entity except for the two Graphics Position registers. These two registers are used to tell each of the graphics controllers which pair of graphics planes they will be managing.

The Graphics Controller chips lack an IOW pin, thus all their registers are write-only.

Graphics Controller Indexed Registers

IndexRegister Name
00hSet/Reset
01hEnable Set/Reset
02hColor Compare
03hData Rotate
04hRead Map Select
05hMode Register
06hMiscellaneous
07hColor Don’t Care
08hBit Mask

Sequencer Registers

PortRegister NameAccess
3C4Sequencer AddressW
3C5Sequencer DataW

Sequencer Indexed Registers

IndexRegister Name
00hReset
01hClocking Mode
02hMap Mask
03hCharacter Map Select
04hMemory Mode

Attribute Controller Registers

PortRegister NameAccess
3BA / 3CAReset Attribute Flip-FlopR
3C0Address / Data (Flip-flops on each write)W

Attribute Controller Indexed Registers

IndexRegister NameAccess
00h-0FhAttribute Palette Entries [0-F]W*
10hMode ControlW
11hOverscan ColorW
12hColor Plane EnableW
13hHorizontal Pel PanningW

The first sixteen registers in the Attribute Controller define a 4bpp palette.

External Register Details

Miscellaneous Output RegisterControls basic hardware configuration such as IO address and clock selectionMiscellaneous Output RegisterControls basic hardware configuration such as IO address and clock selection3C2 (Write-Only)76543210VSPHSPPAGEDISABLECLKERAMIO
BitsNameDescription
0IOI/O Address (0=3Bx mono, 1=3Dx color)
1ERAMEnable RAM (1=Enabled)
2:3CLKClock Select (00=14MHz, 01=16MHz, 10=External, 11=Unused)
4DISABLEDisable Video Drivers (1=Disable)
5PAGEPage bit for Odd/Even mode
6HSPHorizontal Sync Polarity (0=Pos, 1=Neg)
7VSPVertical Sync Polarity (0=Pos, 1=Neg)
Feature Control RegisterSet control signals sent to the EGA Feature ConnectorFeature Control RegisterSet control signals sent to the EGA Feature Connector3BA / 3DA (Write-Only)76543210--ReservedFC1FC0
BitsNameDescription
0FC0Feature Control Bit 0
1FC1Feature Control Bit 1
2:3ReservedReserved
4:7Unused
Input Status Register 0Read DIP switches and interrupt statusInput Status Register 0Read DIP switches and interrupt status3C2 (Read-Only)76543210INTFEAT1FEAT0SENSE--
BitsNameDescription
0:3Unused
4SENSESwitch Sense - State of selected configuration switch
5FEAT0State of FEAT0 pin on Feature Connector
6FEAT1State of FEAT1 pin on Feature Connector
7INTCRT Interrupt Pending (1=Yes)

Attribute Controller Register Details

Attribute Palette EntryUsed by the Attribute Controller to look up an output color from a 4bpp pixel indexAttribute Palette EntryUsed by the Attribute Controller to look up an output color from a 4bpp pixel index3C0 Index 0-Fh (Write-Only)76543210UnusedSRSG/ISB/IRGB
BitsNameDescription
0BBlue
1GGreen
2RRed
3SB/ISecondary Blue / Mono Intensity
4SG/ISecondary Green / Intensity
5SRSecondary Red
6:7UnusedUnused
Attribute Mode ControlSpecifies general mode options for Attribute Controller operationAttribute Mode ControlSpecifies general mode options for Attribute Controller operation3C0 Index 10h (Write-Only)76543210UnusedB/ILGDTG/A
BitsNameDescription
0G/AVideo Mode:
1: Graphics Mode
0: Alphanumeric Mode
1DTText Attribute Type:
0: Color
1: MDA
2LGEnable Line Graphics Characters
3B/IAttribute Bit 7 interpreted as:
1: Blink Enabled
0: Background Intensity
4:7UnusedUnused
Overscan Color RegisterSelects the color to use when drawing the overscan areaOverscan Color RegisterSelects the color to use when drawing the overscan area3C0 Index 11h (Write-Only)76543210UnusedSRSG/ISB/IRGB
BitsNameDescription
0BBlue
1GGreen
2RRed
3SB/ISecondary Blue
4SG/ISecondary Green / Intensity
5SRSecondary Red
6:7UnusedUnused
Color Plane Enable RegisterControls which bits are enabled when addressing the palette registersColor Plane Enable RegisterControls which bits are enabled when addressing the palette registers3C0 Index 12h (Write-Only)76543210UnusedMUXECP
BitsNameDescription
0:3ECPEnable Color Planes
Each bit set in this field enables the corresponding plane 0-3.
4:5MUXVideo Status MUX
6:7UnusedUnused
Horizontal Pel Panning RegisterShifts the display horizontally to the leftHorizontal Pel Panning RegisterShifts the display horizontally to the left3C0 Index 13h (Write-Only)76543210UnusedPAN
BitsNameDescription
0:3PANHorizontal Pel Panning Value
EGA Mode: 0-7
Monochrome Mode: 8,0-7
4:7UnusedUnused