Re: The Linear Address Space
From: Cameron Gibbs (odly_at_hotmail.com)
Date: Fri, 30 Apr 2004 10:40:39 +0000 (UTC)
I think the penny has dropped with Bjarni's post but everyone else has
Of course I may still have a few things to clear up.
-- ______________________________ Reply to the group. ______________________________ Procedurized mind at work. Adhere to the sequence. The PC & Electronic Data Map Project: http://members.dodo.com.au/~cameron111 Bjarni Juliusson <firstname.lastname@example.org_remove_the_animal> wrote in message news:lTbkc.57607$mU6.email@example.com... > The virtual address space is > a 4Gb space of addresses that you access with instructions like > > mov eax, [ebx] > > Here, ebx contains a 32 bit address in the 2^32 bytes = 4G bytes virtual > address space. Now I'm getting somewhere practical :) > A physical address > is an address as it appears electrically on the system bus outside of > the CPU. The virtual address space exists only inside the CPU. The CPU > itself performs a translation from virtual addresses to physical > addresses when a program makes an address reference. On startup, various > devices on the bus have either already been assigned hardwired physical > addresses, or set their addresses up by some means. How this works on > PCI busses is not my field, but that is not important for this > discussion. The RAM in the computer is one of the devices that are > mapped from start. Usually, it is simply mapped from physical address 0 > and up, for as many addresses as there is RAM in the machine. One > address in that range corresponds to one byte of storage in a RAM chip. > One address somewhere else might correspond to a byte in a device > register in, for example, a hard drive. Yay!! That's what I needed to know. Now I understand what "mapping" actually is and where this map actually resides. Now I know what I have to do and what is already done for me (at least in a clean system -no OS). Basically from this I can conclude that RAM (where a program sits as it is executing) has addresses 00 up. So when I write a program, I can see it inside of this space and I can point to it and manage it as necesary. In actual fact, there is an I/O Address Space, a Memory Address Space and a Virtual Address space which is managed by an Operating System. The Virtual and Memory Address Spaces often overlap because if there is no Operating System then the Virtual Address Space for a program is the RAM part of the Memory Address Space. Now below to the question of what happens in the presence of an Operating System. > When a program needs to read a sector (usually 512 bytes) of data from a > hard drive, it in essence writes a read command to the drive, and > provides the drive with a physical address where it wants the read data. > In reality this involves a little more fiddling with things like DMA, > and direct interfacing to hard drives is usually only done by the OS. > The OS knows about the physical addresses and is responsible for setting > up the virtual address space, and user programs run only in a virtual > address space. In principle, anyway. > > > So if you want to access a byte of Hard Disk space, one first commands it's > > HDD sector to read it into RAM and then one can select the byte with it's > > Virtual Address which would automatically make itself relative when you use > > the paging mechanism.... I think. > > The sector is put somewhere in RAM, and each byte in it is readable to > the CPU at the base address which you provided to the HD, plus the > offset within the sector. Usually, a user program demands some data from > a hard drive, and the OS reads it in. It then sees to it that the > physical addresses that contain the data are accesible in the virtual > address space of the user program. So this is where writing a program is OS specific. Every OS would have a different protocol for managing how a program is given it's own Virtual Address Space. Can I assume then that if you have an Assembler running in Windows that it w ould compile a program based on the Window's protocols and likewise for an Assembler for another OS? I guess it would also be likely that you could get an Assembler running under Windows to compile a program to run under Linux or to run on a clean, OS free system. Thanks again to all who are helping. >>From Cameron. I actually wrote a lot more on this but understanding is as much about what you throw away (put aside for another day) as it is about what you keep :) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.669 / Virus Database: 431 - Release Date: 4/26/04