Function 0Bh comes from the CGA, whose colour select register controlled three things at once, and the EGA and VGA BIOSes keep its meaning. With BH = 0, BL is a colour 0–15: in text modes it sets the border, the overscan area around the text; in CGA graphics it sets the background, colour 0, together with the border. With BH = 1, BL chooses between the CGA's two sets of colours 1–3 for 320×200 graphics:
| Palette | Colour 1 | Colour 2 | Colour 3 |
|---|---|---|---|
| 0 | green | red | brown |
| 1 | cyan | magenta | light grey / white |
Each palette also exists in a bright version, chosen on the CGA by an intensity bit that goes with the background colour. Mode 04h starts with palette 1. Here three bars are drawn in colours 1, 2 and 3 on a blue background, then the palette is switched under them:
MOV AX, 0004h ; mode 04h: CGA 320x200, 4 coloursINT 10hMOV AH, 0BhMOV BX, 0001h ; BH = 0: background; BL = 1: blueINT 10hMOV AH, 0BhMOV BX, 0101h ; BH = 1: palette; BL = 1INT 10hMOV BX, 0001h ; BH = page 0, BL = colour of the first barMOV DX, 70 ; first rowBAND1:MOV SI, 10 ; 10 rows per barLINE1:MOV CX, 80 ; x from 80 to 239DOT1:MOV AH, 0Ch ; write a pixel: AL = colour, CX = x, DX = yMOV AL, BLINT 10hINC CXCMP CX, 240JB DOT1INC DXDEC SIJNZ LINE1ADD DX, 10 ; a gap of 10 rowsINC BL ; the next colourCMP BL, 4JB BAND1CALL WAIT1 ; a second with palette 1MOV AH, 0BhMOV BX, 0100h ; BH = 1, BL = 0: palette 0INT 10hCALL WAIT1 ; a second with palette 0MOV AX, 0003h ; mode 03h again: 80x25 text, clears the screenINT 10hMOV AH, 09hMOV DX, OFFSET MSG1INT 21hMSG1 DB "Palette 1, then palette 0", 13, 10, "$"WAIT1: ; wait 1 s: CX:DX = 0F4240h microsecondsMOV CX, 000FhMOV DX, 4240hMOV AH, 86hINT 15hRET
Nothing is redrawn when the palette changes: the pixels still hold the numbers 1, 2 and 3, and only their meaning changes. That is why the switch is instant.
On EGA and VGA
The general way to change colours on these cards is INT 10h AH=10h, the palette registers and the DAC; 0Bh remains for the CGA modes and the border. In the 16-colour EGA and VGA graphics modes, BH = 0 sets the background colour. The text-mode border is a narrow strip on a VGA, and many monitors and emulators show little or nothing of it, depending on their settings.