How to draw a pixel on the screen in protected mode in x86 assembly?

前端 未结 3 1090
野性不改
野性不改 2021-02-01 07:46

I am creating a little bootloader+kernel and till now I managed to read disk, load second sector, load GDT, open A20 and enable pmode.

I jumped to the 32-bits function t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-01 08:05

    It depends on the graphics mode in use, and there are a lot a differences. BIOS VGA video mode 13h (320x200 at 8 bits/pixel) is probably the easiest to get started with (and it's the only BIOS VGA video mode with 256 colors, however you can create your own modes by writing directly to the ports of the video card): in BIOS video mode 13h the video memory mapped to screen begins at 0x0A0000 and it runs continuosly 1 byte for each pixel, and only 1 bit plane, so each coordinate's memory address is 0x0A000 + 320*y + x:

    To change to BIOS video mode 13h (320 x 200 at 8 bits/pixel) while in real mode:

    mov ax,0x13
    int 0x10
    

    To draw a pixel in the upper left corner (in video mode 13h) while in protected mode:

    mov edi,0x0A0000
    mov al,0x0F      ; the color of the pixel
    mov [edi],al
    

提交回复
热议问题