You can think of memory as being like the safety deposit boxes in a bank vault:
Each box is numbered so you can find the right one and each box can hold some contents. In computer memory the number of the ‘box’ is referred to as the address and the contents being stored at that address are referred to as the value.
Here’s a diagrammatic representation of some hypothetical and somewhat simplified computer memory:
Here, we’ve got five memory locations (the rounded rectangles numbered 1 to 5 in the top left corner) each of which is the equivalent of a safety deposit box in our bank vault.
The memory at address 1 (the safety deposit box with the number 1 on the door) contains the value 231 and the memory at address 3 (the safety deposit box with the number 3 on the door) contains the value 34 and likewise for the other memory locations.
Well sure but…
- How come I’m seeing decimal numbers stored at these memory addresses? I thought computers only understood 1s and 0s.
- What are these 0x blah blah addresses I keep seeing?
- How come the addresses I’ve seen elsewhere go up in fours (or eights or some other number) rather than one by one?
- OK But what about the electronics? What’s really going on here?
This is just a stub for now but in order to avoid your inevitable disappointment have a lovely link.
Memory addresses are often written in hexadecimal and will look something like
0x1234abcd. Hexadecimal is a base 16 number system in the same way binary is base 2 and decimal is base ten. Instead of numbers being made up of the binary digits 0 and 1 or the decimal digits 0,1,2,3,4,5,6,7,8 and 9 they are instead made up of the hexadecimal digits 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e and f.
At the most fundamental level computers are dealing with voltage levels. In reality these voltages vary quite a bit but one of the jobs of the electronics is to ‘condition’ or ‘tidy up’ these voltages to ensure they can be considered either a low voltage or a high voltage. Now, what exactly these voltages are and how low and high are defined varies quite widely between machines but for our purposes just assume that voltages in a computer are low or high.
So, we’ve got two voltage states – low and high. These correspond to what are called bit values, short for binary digit, which are digital 0s and 1s. A low voltage represents a 0 and a high voltage represents a 1. Computer memory stores 0s and 1s. And that’s all it stores.
But it can group these bits together using the conventions of the binary number system into nibbles (4 bits), bytes (generally 8 bits) and words (often 16, 32 or 64 bits – so-called 16, 32 or 64 bit architectures). Why would you want to do that? For two reasons.
Firstly for semantic reasons, in a similar manner to the way we group decimal digits together into numbers. For example the digits 3, 7 and 9 have meaning on their own as individual digits but to express the notion of the number 379 you need to combine the three digits together and treat them as a group.
Secondly, for efficiency reasons. If you only have one wire you can only pass one bit (either a high or low voltage) at any one time (unless you do clever multiplexing things that are not relevant here). It’s quicker to be able to transfer information in parallel which you can do if you have, say, eight individual wires bundled together in a cable (often referred to as a bus in computing) all running in parallel and each carrying its own bit or voltage.
When we’re addressing computer memory we’re usually addressing (or accessing) words rather than individual bits or bytes.