VGA video RAM

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nitroglycerin

VGA video RAM

Post by nitroglycerin »

hi!
i've got some problems using vga video ram:
[tt]
   mov ax,0xb800
mov gs,ax

   mov al, 'X'
   mov byte [gs:0],al
   mov byte [gs:1],0x04[/tt]

I get it that this code will print a red "X" to upper left position (if text mode). Now, how to go 1 position right? if I do this:

[tt]   mov ax,0xb801
mov gs,ax
   mov al, 'X'
   mov byte [gs:0],al
   mov byte [gs:1],0x04[/tt]

it won't go 1 char to the right but 6 chars. howcome?
Tim

Re:VGA video RAM

Post by Tim »

You might find that the second character is in column 7, not 6 as you imply.

This is because you've added 1 to the GS segment register (you went from 0xB800 to 0xB801). This had the effect of adding 16 to the final memory address, which is equal to 8 video memory cells.

You should leave GS as it is and use GS:2 and GS:3 instead. You should also revise real-mode addressing.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:VGA video RAM

Post by df »

you seriously need to go and read a tutorial on how real-mode addressing works, to properly understand whats going on in your example.

see the link thread at the start of the os-dev board.
-- Stu --
nitroglycerin

Re:VGA video RAM

Post by nitroglycerin »

I read that one already before, and understand rmode addresing, just seems I overlooked offsets :-\
My bad.

Thanks!
slacker

Re:VGA video RAM

Post by slacker »

nitro:
0xb8000 linear is the base of video memory but in real mode you need to use a segment:offset pair to reference this memory location. read Perica's tutorial:http://osdev.neopages.net/tutorials/rm_addressing.php

it is the best ive ever read and if you dont understand real mode addressing after reading this, you never will.
nitroglycerin

Re:VGA video RAM

Post by nitroglycerin »

You don't get me. I know rmode addresing (and read perica's doc). The thing is that I totaly forgot to increase offsets instead of segs.
Post Reply