Page 1 of 1
VGA video RAM
Posted: Tue Apr 22, 2003 3:53 pm
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?
Re:VGA video RAM
Posted: Tue Apr 22, 2003 4:27 pm
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.
Re:VGA video RAM
Posted: Tue Apr 22, 2003 4:27 pm
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.
Re:VGA video RAM
Posted: Wed Apr 23, 2003 1:55 am
by nitroglycerin
I read that one already before, and understand rmode addresing, just seems I overlooked offsets :-\
My bad.
Thanks!
Re:VGA video RAM
Posted: Wed Apr 23, 2003 1:40 pm
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.
Re:VGA video RAM
Posted: Wed Apr 23, 2003 2:15 pm
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.