How to change pixel color with PC BIOS calls?

1.1k Views Asked by At

I am trying to make a rather simple graphical game in 16-bit x86 assembly. Especially, I want to be able to change the color of a pixel.

I already have an emulated bootloader(qemu) and a piece of code which makes it possible for the game to run on boot so that it can acces certain graphics related components.

After some research I came across the following paper which documents the use of the interupt 10h and thus giving us the following code for changing the color of a pixel:

mov al, 13h     #Desired video mode: graphics mode
mov ah, 0       #Set video mode
int 10h         #Interrupt
mov al, 1100b   #Set color of the pixel(I believe it is light red)
mov cx, 10      #Set x coordinate
mov dx, 20      #Set y coordinate
mov ah, 0ch
int 10h

However I am making the game with AT&T syntax(Education purposes). So I tried and figure it out using that syntax resulting in the following code:

mov $0x00, %ah   #00h interpreted as hexadecimal
mov $0x13, %al   #13h interpreted as hexadecimal  
int $0x10        #10h interpreted as hexadecimal
mov $12, %al     #1100 interpreted as bits    
mov $5, %cx      #Set x coordinate to immediate value 5
mov $5, %dx      #Set y coordinate to immediate value 5
mov $0x0c, %ah   #0ch interpeted as hexadecimal
int $0x10        #10h interpreted as hexadecimal 

However, that does not work and I do not really understand why. Therefore I am hoping someone could point me in the right direction on how to change the color of a pixel.

0

There are 0 best solutions below