In a graphics mode function 0Ch sets the pixel at column CX, row DX to colour AL, counting from 0 at the top left. The BIOS works out which byte and which bits hold that pixel in the current mode (two bits of an interleaved line in CGA mode 04h, one bit in each of four planes in the EGA modes, a whole byte in mode 13h), so the same code draws in every mode. The colour runs up to what the mode offers: 0–3 in mode 04h, 0–15 in modes 0Dh–12h, 0–255 in mode 13h.
With bit 7 of AL set, the BIOS XORs the colour into the pixel instead of replacing it, except in the 256-colour mode, where bit 7 is part of the colour. Drawing the same thing twice with XOR restores the picture underneath, the old way to move a crosshair or stretch a rubber-band line. Here every colour of mode 13h's default palette is drawn in a band across the middle:
MOV AX, 0013h ; 320x200, 256 coloursINT 10hMOV DX, 92 ; rows 92 to 107ROW1:MOV CX, 32 ; x from 32 to 287DOT1:MOV AL, CLSUB AL, 32 ; colour = x - 32: 0..255 along the lineMOV AH, 0Ch ; write the pixelMOV BH, 0 ; page 0INT 10hINC CXCMP CX, 288JB DOT1INC DXCMP DX, 108JB ROW1MOV CX, 001Eh ; wait 2 s: CX:DX = 1E8480h microsecondsMOV DX, 8480hMOV AH, 86h ; BIOS: waitINT 15hMOV AX, 0003h ; mode 03h again: 80x25 text, clears the screenINT 10hMOV AH, 09hMOV DX, OFFSET MSG1INT 21hMSG1 DB "Back in mode 03h", 13, 10, "$"
Speed, and the direct way
Each pixel costs an interrupt, the BIOS's register saves and a look at the mode: fine for a few thousand dots, far too slow to fill a screen. In mode 13h writing video memory is trivial, one byte at offset y × 320 + x in segment A000h, and nearly every mode 13h program does that:
MOV AX, 0A000hMOV ES, AXMOV AX, 100 ; yMOV BX, 320MUL BX ; AX = y * 320 (DX = 0)ADD AX, 160 ; + xMOV DI, AXMOV BYTE PTR ES:[DI], 15 ; a white pixel
Pitfalls
In text modes the call does nothing useful; check the mode first. Coordinates are not checked: a pixel past the right edge lands on the next line, one below the bottom in memory beyond the screen. BH counts only in modes with several pages; keep it 0.