Hi guys this might seem like a stupid question...
ok the bios data area 40:00 - right
how do u use segments in c, or do i need to say if im using a flat memory model???
Help With Memory
Re:Help With Memory
Hi,
to translate a linear real-mode address to a physical address you first have to multiply the segment by 16 and then add the offset.
cheers,
gaf
to translate a linear real-mode address to a physical address you first have to multiply the segment by 16 and then add the offset.
Code: Select all
BIOS data area: 0x40:0x0000 (seg:offset)
physial address: 0x400+0x0000 = 0x400
gaf
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Help With Memory
If you have sufficient knowledge of your environment, you can use the well-known base of the current data segment to access the linear address computed with real_segment*16+real_offset ...
Otherwise, you can simply write a small function in ASM that will access the requested byte/word/dword and return it.
Just updated http://www.osdev.org/osfaq2/index.php/S ... eFunctions with far_peek and far_poke functions ...
Otherwise, you can simply write a small function in ASM that will access the requested byte/word/dword and return it.
Code: Select all
//! reads a 32bits word located in sel:off (check your Intel Manuals)
/*! \note this function temporarily change the "Extended Segment" register
*/
static __inline__ dword peek(word sel,void *off)
{
dword ret;
asm("push %%es;mov %1,%%es;"
"mov %%es:(%2),%0;"
"pop %%es":"=r"(ret):"g"(sel),"r"(off));
return ret;
}
Just updated http://www.osdev.org/osfaq2/index.php/S ... eFunctions with far_peek and far_poke functions ...