Click to See Complete Forum and Search --> : A RAM Paradox...


lord loh
January 31st, 2003, 01:19 AM
What I understand from all the books I have read so far and experience I have gained in the past 8 years of being in intimate terms with computers, is that each byte of Random Access Memory (RAM) has an address of it's own.

If I am not wrong, there address are some 7-8 digit long(hex and all that)

The question that really amuses me is that how does a computer programme know where exactly in the RAM has it stored a given variable ?

By that 8 digit number? If so, 8 bytes will be used up to address 1 byte!

Certainly! there is something missing in the theory...I do know that infinite RAM cannot be added to a system. (The addable RAM is limited by the processor capacity or something).

Someone please explain me how RAM really works!
(an exact location of an article will also be appreciated)

Thank You!

dimm_coder
January 31st, 2003, 06:54 AM
Every modern OS doesn't allow any procees to work with physical memory (RAM) directly (and processors has internal realization for this). It uses Virtual Memory mechanisms to provide to every process own address space. Do U hear about protected mode...
The best way for U, if U are interested, is to buy some good book about modern OS organization.
I can give you some recomendations.
Those are classical books for OS architecture:
W.Stallings "Operating Systems" (www.williamstallings.com - where U can get some articles from book, discrabed Unix, NT organization);
A.Tannenbaum "Modern Operating Systems".

lord loh
January 31st, 2003, 10:58 PM
Yes I do know of protected mode...

But what I wanted to know was

==>How is RAM memory addressed?

==>Is every byte addressed ?

==>How does the programme / OS know where to look for a certain piece of information that it saved to the RAM ?

==>How and where are the addressed stored ?

==>How much space is required to store these addresses ?

The book may answer these...But it may take some time before I get my hand on one(if I ever get my hands on one...)

If someone answers these on the forum or links a webpage, It would be helpful to me and others...

CBasicNet
February 1st, 2003, 05:37 AM
I'm a Electronics guy. So I try to explain in a simplistic way of what I know from a EEE guy perspective.

CPU has a address bus and a data bus.

Whenever CPU wants to read from the memory, it sets the read/write strobe to 'read', and puts the address on the address bus and after some time(known as latency), the data is available on the data bus.

It is almost the same thing with writing, it's just that the CPU sets the strobe to 'write'.

(RAM)Memory don't store its addresses. When the address is available on the addr bus, the control circuitry, on the RAM, would know where is the exact location, the addr. referring to, automatically.

Lastly, I want to tell you 1 hex digit needs only 4 bits(known as a nibble) to represent.

lord loh
February 2nd, 2003, 11:27 PM
CBasicNet's post explained a good deal.
(RAM)Memory don't store its addresses. When the address is available on the addr bus, the control circuitry, on the RAM, would know where is the exact location, the addr. referring to, automatically.
==> So where are the addresses stored ?

==> And how much space does it require?

==> If 100 bytes are to be called, are 100 addresses supplied?
If so, in case of a 100 byte variable called, 100 address are sent via the address bus!(am I right ?)


Thank You!

Kdr Kane
February 3rd, 2003, 10:39 AM
Please bear with me because I'm only going to explain how a 32-bit Intel-type CPU works.

==>How is RAM memory addressed?
A 32-bit CPU addresses 4 bytes on any memory access. That's because the CPU returns 4 bytes on the 32-bit data bus on each memory fetch. This is confusing considering each byte technically has it's own address. But, this is mainly a hold-over from the early days where every byte counted.

And how much space does it require?
Addresses are 32 bits (4 bytes) long. When a memory location is accessed, you always get 4 bytes back, even though you might only use one byte. Actually, this has become very rare to only need one byte. For example, int's are 4 bytes long. char's can be 2 bytes long if the program supports unicode. (Somebody correct me if I'm wrong)

==>How does the programme / OS know where to look for a certain piece of information that it saved to the RAM ?
The compiler converts your code into machine code. Programs are usually split up into different sections. Code is usually segregated from data. The code contains the pointers (addresses) to data. You don't have to store the address of every single memory location to access the data. Your code and the CPU instructions will actually interate through the data to acquire, store or manipulate it.

==>How and where are the addressed stored ?
==>How much space is required to store these addresses ?
I think I just answered those questions. Addresses (pointers) are in your code. The compiler converts the pointers into the machine code the CPU understands.

==> If 100 bytes are to be called, are 100 addresses supplied? If so, in case of a 100 byte variable called, 100 address are sent via the address bus!(am I right ?)
Not at all. A base address pointer is usually incremented through the hypothetical 100 bytes. So, in this example, there is only one 32 bit address for 100 bytes. It is the same way with strings. Your preferred computer language and it's associated compiler take on the task of simplifying this for you. The code generated by the compiler will actually interate through the 100 bytes in 4 byte increments.

If you really need to understand this to get past your mind block, then search for Win32ASM on the net. There's plenty of information for you to burn your brain with.