How do you paint pixels in NASM, could someone tell me about it and mabey give me an example?

Painting pixels, not so much tedious work.

Try MCGA mode 13h you can set this using the video bios,
if you are in 32-bit code try passing down the call to the
BIOS through the DPMI server.
AH=0000 AL=0013 INT 10h

INT 10/AH=00 Set Video Mode
10/AH=0C Write Pixel
10/AH=0D Read Pixel

If you are a 32-bit app the EGA Video Ram is located at
ulong 000A0000
or for a 16-bit app it will be located at A000:0000
You can draw pixels by directly writing to the above locations.
Each pixel's color is defined by a byte's value yielding 256 colors,
and the position of the byte in the segment defines its location
on a screen,
the pallete for these colors can be manipulated using I/O

When using a XY coordinate it needs to be turned into its
corresponding position in the video ram.
To do so for zero-base coordinates do:
Hence for a 320x200 pixel screen you would perform
the following calculation:

I'll come back with some example code later.
Good day.

*NOTE: This all applies to DOS programs...

PAINT_A_PIXEL example code...

bits 16
org 100h

mov ax, 0xa000
mov es, ax
call govideo
mov bx, 0
mov cx, 0
mov dl, 0xe
call plotpixel
call waitkey

push ax
mov ax,0013h
int 10h
pop ax

mov ah,06
mov dl,0ffh
int 21h
jz waitkey
mov ax,0003h
int 10h
mov ax,4c00h
int 21h

push dx
mov ax,320
xor dx,dx
mul bx
mov si,ax
add si,cx
pop dx
mov [es:si],dl
This article has been dead for over six months. Start a new discussion instead.