0

I finally managed to set a VBE mode and it worked perfectly.
Now I wanna get the physical address of the linear framebuffer to start plotting pixels in my kernel etc...

For that purpose, I used the function 01h to return the VBE mode information but it didn't work.

Here's a part of my code:

[BITS 16]
[ORG 0x7c00]

ModeInfoBlock: times 256 db 0

start:
   mov ax, 1A00h
   int 10h
   cmp al, 1Ah
   jne error_no_video

   mov ax, 4F02h
   mov bx, 1000111000000010b
   int 10h
   cmp ax, 0x004F
   jne error_set

   mov ax, 4F01h
   mov cx, 100011100b
   mov di, ModeInfoBlock
   cmp ax, 0x004F
   jne error_vbe
   jmp $
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
MARSHMALLOW
  • 1,315
  • 2
  • 12
  • 24
  • 2
    It looks like `return VBE Mode Information` wants the pointer to the ModeInfoBlock structure in `ES:DI`, but you don't set ES here? Also, you are calling Set before Get? And I don't see an int 10h for Get? – David Wohlferd May 21 '20 at 05:55
  • 2
    In addition to David Wohlferd's comments (which covers the main mistakes); don't use fixed mode numbers (they've been deprecated for 25+ years), don't require a specific resolution and color depth/pixel format (no guarantee it will be supported on other computers); use sections (e.g. `section .bss`) to avoid wasting precious space in the "< 512 usable bytes is never enough" sector; and (assuming NASM) use "user form directives" and not "low level form directives" (e.g. `BITS 16` and `ORG 0x7C00`, without the square brackets) unless you have a very good reason (in special purpose macros). – Brendan May 21 '20 at 06:36
  • @Brendan What are fixed mode numbers? – MARSHMALLOW May 21 '20 at 11:28
  • 1
    @MARSHMALLOW: Originally (for VBE 1.0 in 1989) VESA defined fixed mode numbers (like "0x0100 = 640*400 with 256 colors; 0x0101 = 640*480 with 256 colours; etc"), so you can just shove the number into the lowest 9 bits of `bx` and set that video mode (if the video card supports it) and get the video mode you expected. Later (for VBE 2.0, in 1994) they deprecated the fixed mode numbers, and did it in a way where its only "recommended" that video cards don't give you something completely different if you use a (previously defined) fixed mode number to set a video mode. – Brendan May 21 '20 at 11:42
  • 1
    @MARSHMALLOW: Mostly, you're supposed to use something like the method described here: https://stackoverflow.com/questions/54945084/switch-to-vesa-vbe/54952393#54952393 . Note that I (incorrectly) assumed your `mov bx, 1000111000000010b` was using a fixed mode number, but it's actually just a random (likely erroneous - the higher bits don't make sense) value that wasn't ever defined. – Brendan May 21 '20 at 11:45
  • 1
    I see you deleted your answer on https://stackoverflow.com/a/61963064/224132. It only needed a minor fix which I described in a comment (and using a register other than AX, parts of which are used by `int 16h`), unless there was some other bigger flaw with the whole idea that you later noticed. – Peter Cordes May 22 '20 at 20:58

0 Answers0