Programming, for all ages and all languages.
matias_beretta
Member
Posts: 101 Joined: Mon Feb 26, 2007 3:39 pm
Post
by matias_beretta » Sat Oct 27, 2007 12:54 pm
After a month, I am again interested in osdev and i continued my real mode os.
One month ago i asked in the forum about a pointer to video memory. I didn't get the answers i wanted so i investigated for myself and i found this:
This pointer is based in the _es value: lets suppose that es is 0xb800 and the pointer is 3, so it will point 0xb803.
This works in Turbo C++ 3.0...
Bye
MatÃas Beretta
XCHG
Member
Posts: 416 Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:
Post
by XCHG » Sat Oct 27, 2007 2:00 pm
When the CPU wants to translate a Real Mode address to its physical address, it will shift the segment value to the left 4 bits and then add the offset to it. So the 3rd byte (0..2 = 3) in the Video RAM is:
(0xB800 << 0x04) + 0x0002 = 0x000B8000 + 0x0002 = 0x000B8002.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.