I finally managed to draw a pixel on the screen using the VESA BIOS Extensions in the protected mode. But I'm having a problem putting it in a different position (for example I want it to be in x=100, y=50).
According to http://www.brokenthorn.com/Resources/OSDevVid2.html, we plot pixels using this C code:
void pixel_16RGB (unsigned short color, unsigned short x, unsigned short y) {
unsigned short* fb = (unsigned short*) _modeInfo.physBasePtr;
unsigned short offset = x + y * (_modeInfo.bytesPerScanLine / 2);
fb [offset] = color;
}
I tried to write it in assembly, so the result looks like this:
;first part
mov si, word[ModeInfoBlock + 10h]
mov edx, 0
lea eax, [si]
mov ecx, 2
div ecx
mov ecx, 100
mul ecx
add eax, 50
;second part
mov edx, dword[ModeInfoBlock + 28h]
add edx, eax
mov ebx, 0x3296fa
mov [edx], ebx
jmp $
I expected a blue pixel showing up in the coordinates (100, 50) but I'm seeing just a red one in a random position.
I think I'm wrong in this part:
add edx, eax
Am I right?