Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This has been on my mind today.

If RAM's ICs contain bits stored in capacitors sitting there, how can you pull bits from somewhere and put them where something already is?

For example, on bootup, I'll be pedantic here to illustrate my confusion:

MOV AL, 07h

That is code, not data, so it will be part of the instruction loaded in to RAM - but the RAM IC has bits "sitting" inside of it. By that logic, how can a bit be moved to where another already is?

Because generally the processor will pull bytes in through a bus from RAM, regardless if it's code or data, to determine whether what to do with it.

So my question, if it wasn't clear, is:

How does it make sense that bytes/bits are moved to RAM when RAM occupies bits already, i.e. "2 GB DIMM unbuffered".

The RAM has the bits sitting in capacitors, so how does it make sense that BIOS/firmware sets the CPU's IP register to the next instruction when RAM ALWAYS occupies bits before bootup?

Sorry if off-topic.

share|improve this question
the question is better suited in electrical engineering, not here. –  Sickest Sep 14 '13 at 21:09
They told me it was off-topic there. –  user254272 Sep 14 '13 at 21:12
Albeit very technical in nature, this is still about computer hardware, so it's fine to stay here. cc @Sickest –  slhck Sep 14 '13 at 21:13
honestly, if its off topic there, then i wish you good luck here, lol :) –  Sickest Sep 14 '13 at 21:14
Thanks I will need it! lol –  user254272 Sep 14 '13 at 21:23
show 2 more comments

5 Answers

If RAM's ICs contain bits stored in capacitors sitting there, ...

RAM (Random Access Memory) is a general term, but you are using it in a specific way.
In general computers have used three main types of RAM for their main memory:

  • ferrite (core) memory: This type of RAM was used in computers until semiconductor memory took over in the 1970s and 1980s. This was a non-volatile memory; you could turn the power off to the computer, and turn it on the next day or week and your program would still be in memory.
  • static memory: a semiconductor memory that is fast but expensive and less dense than DRAM. This memory uses active circuitry (i.e. transistors) to hold the bit state.
  • dynamic memory: a semiconductor memory that is most commonly used for PC main memory. DRAM uses a capacitor and refresh logic to retain its bit values.

... how can you pull bits from somewhere and put them where something already is?

This is worded as if bits were physical entities that cannot be displaced.
"Bits" that are moved around are merely values, and are not physical entities (unless actually referring to something physical like a register or memory cell), even though these values are often treated as items.

The "bits" in RAM are merely logic states or a condition of being. You can have your hand raised, or you can have your hand down: that's two states.
Each cell in the RAM can change its state (just like you can raise or lower your hand).
A write operation instigates this changing of state. The previous state of the memory cell is lost forever.

... when RAM occupies bits already, i.e. "2 GB DIMM unbuffered".

That's rather awkward wording.
RAM (a physical item) cannot "occupy" "bits" (which are logical states).
DRAM (and SRAM) will have garbage (random) values when powered up until each location is written.
In general reading memory which has not been previously written to (and hence has a known value) is a programming/logic error.

The RAM has the bits sitting in capacitors, ...

Avoid treating "bits" as physical entities when the attribute you are actually concerned with is merely their value.

... so how does it make sense that BIOS/firmware sets the CPU's IP register to the next instruction ...

The first step in "bootup" is a "reset" operation that initializes the Program Counter (PC) or you seem to prefer the "IP register" (instruction pointer?) to a known value.
A boot program is presumed to exist at that "reset address".
Computers that used ferrite memory often set aside this memory region at the "reset address" to hold the bootstrap program.
Modern computers employ a nonvolatile memory such as PROM, EPROM, EEPROM or flash at the "reset address" to hold the bootstrap program.

when RAM ALWAYS occupies bits before bootup?

Here's that awkward phrase again.
The computer is typically built so that the "reset address" points to the bootstrap program in non-volatile memory.
If the memory is volatile, then some mechanism (independent from the power-on and reset circuitry) would have to initialize this RAM with a proper bootstrap program. The front panel of a computer (something never included in an IBM-compatible PC) can be used to hand-enter a bootstrap program into RAM.


Perhaps what my first programming teacher drummed into our heads may help:

  • A read operation (of memory or register or variable) is non-destructive.
    The location will not change its value when read. Repeated reads will return the same value.
    (Yes, there are some exceptions: auto-incrementing memory locations; memory-mapped I/O ports; some types of RAM have destructive reads and are internally rewritten after each read.)
  • A write operation (of memory or register or variable) is destructive.
    The new value will replace the previous value. You cannot retrieve the previous value once it has been written over.
share|improve this answer
add comment

Understand that a "bit" is not a real physical entity, it is a "state" of the memory cell. A given memory cell can have a value of 0 or 1, and that is a bit.

When data is "moved" into memory, what that means is that the data is read from disk as electrical signals (sort of like telegraph signals) and then the data is used to set the new state of individual memory cells.

In a very simplistic model ("real life" is of course much more complex) imagine that the data come from the disk as a series zeros and ones. We'll assume this is a very slow disk and one bit per second arrives from disk. So your MOV instruction might be something like 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1, with each 1 represented by 1 volt on the wire and each 0 represented by 0 volts on the wire. And we'll say that each bit (1 or 0) is separated from the next by one second.

Next we need some "logic" ("gates" and "flip-flops" in integrated circuits) which receives this data and puts it into RAM.

RAM is arranged in an X-Y matrix. Assume we have a very small RAM that is only 8x8 bits (64 bits total) in size. To select a particular memory cell, there are 16 wires running through the array, 8 horizontal and 8 vertical. At the junction of each wire is a memory cell (a capacitor, in most cases). Also, running to all the cells are three other wires: DataIn, DataOut, and Write.

The memory looks something like this:

   Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8
X1 b  b  b  b  b  b  b  b
X2 b  b  b  b  b  b  b  b
X3 b  b  b  b  b  b  b  b
X4 b  b  b  b  b  b  b  b
X5 b  b  b  b  b  b  b  b
X6 b  b  b  b  b  b  b  b
X7 b  b  b  b  b  b  b  b
X8 b  b  b  b  b  b  b  b

Where each "b" is a memory cell that can hold either 1 or 0. (The DataIn, DataOut, and Write wires are not shown.)

If I put 1 volt in the very top horizontal wire and the left-most vertical wire then whatever value is stored in the cell (capacitor) at the junction of those two wires (either a 1 or a 0) will be "read" and will come out through the DataOut wire. If, on the other hand, I put a 1 or a 0 on the DataIn wire and put a pulse on the Write wire, the old contents of the selected cell are forgotten (the voltage stored in the capacitor is changed) and whatever value is on the DataIn wire is saved in the cell.

So if I simply connect that wire from the disk drive to the DataIn wire of the memory and then begin toggling the other wires, I can write the disk data into RAM. I need to have "logic" that will select different X and Y wires of the memory array once a second. If the X and Y wires are numbered X1...X8 and Y1...Y8, they would be selected (ie, have +1 volt applied) in this order: X1&Y1, X1&Y2, X1&Y3,...X1&Y8, X2&Y1, X2&Y2,...X8&Y8. And each time the wires were changed the Write wire would be pulsed.

To keep this little orchestra in time there needs to be a conductor, so the computer has a "clock" signal that pulses once a second and "marks time" for the arriving data and all the other signal changes.

Anyway, as the above data is read in, it will land in in our 8x8 RAM like this:

1 0 0 1 1 0 0 0 
0 0 0 0 0 1 1 1
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x

Once the entire program has been read in, the computer can begin to "fetch" instruction from this little piece of memory and execute them. (Essentially, in the boot sequence case, the BIOS firmware executes a branch instruction, using the RAM address of our fetched instruction as the target of the branch.) "Fetching" involves basically repeating the above sequence only without pulsing the Write wire, so the RAM data comes out on the DataOut wire.

share|improve this answer
add comment

A memory write operation will change existing bits to a desired state. There is no such thing as "unset" bits, they are at all times 0 or 1.

What about on power up? Generally will be a random state, but a defined state nonetheless. If not much time has passed since the previous poweroff, you can possibly recover valid data.

share|improve this answer
I always wondered if RAM (e.g. DDR3 SDRAM) that has been powered off for, say, 24 hours actually contains RANDOM values or actually contains 0's (or perhaps only MOSTLY contains 0's). –  ChrisInEdmonton Sep 15 '13 at 2:27
add comment

Your core question seems to be this: "how can a bit be moved to where another already is?"

You can think of a bit as a switch that is either in the "0" position or the "1" position. You can think of memory as a bunch of switches, each of which is either in the "0" position or the "1" position, thus storing bits of information. To move a bit to where another already is, you just set the second switch so that its position matches the first.

share|improve this answer
add comment

I can see you're quite confused. :-)

First, code is data, it is just data that has a specific meaning to the processor[1].

Second, the "bits" are charge levels moving like piped water along the wires of the logic. Note that charge level (voltage) isn't actual electrons zipping around: though electrons do move, they move quite slowly compared to the change in voltage.

RAM means Random access memory, and the D in DRAM is for "Dynamic", because it doesn't last long without refresh. Modern chips have internal refresh logic, which reads all bits and writes them back again, resulting in recharging the store. Almost all RAM stores bits as two levels of charge, for example a potential of 0 volts for logic 0 and a potential of 1.5 volts for a logic 1. It is possible, though not at all common, to have multi-valued bits, so 0.. 0.1 volts for 0, 0.9 .. 1.1 volts for 1, 1.9 .. 2.1 volts for 2 and 2.9 .. 3.1 volts for 3, for a cell storing 2 bits (binary digits) of data.

The actual voltages used in logic (memory or otherwise) aren't important, but of course each end of the wire linking components must agree on what they are. If you look at electronic datasheets, you will find a statement as to the voltages that the chip interprets as each logic level. A common one for TTL logic at 5 volt (nominal) was between 0 and 0.5V is logic 0, and 3.5 volts to 5.1 volts is logic 1.

When a location in memory is written to, the electronics is set such that whatever was there is overwritten - whether it was a 0 or a 1. Sometimes, this logic works the "wrong" way: the "natural" value is logic 1 and the value that has to be forced is a 0. Either way, that's all in the DRAM chip: everything else considers the memory to be a place that can be written and rewritten as much and as frequently as needed. If you're wondering what happened to the "old" data, the charge is sent to ground, and it forms part of the reason that chips consume power.

When a processor fetches code from memory, it is sent through a pipeline of stages: these serve to speed the processor up. Many modern processors are also microprogrammed: the internal logic runs multiple "instructions" from the one incoming one, and those internal instructions are even lower level. To understand all this properly you need to understand the internals of the processor, and x86 is not the place to start on that!! Something simpler would be the Rockwell 6502 (Acorn BBC / C= 64 et al). Moreover, people have written emulators so you can play all sorts of games very easily.

On bootup, most of the processor will be held in reset state until all the external logic has settled down into a stable condition. It will then either load a value into the instruction pointer and fetch instructions from that point, or load a value from a fixed point in memory into the instruction pointer, then fetch instructions from that point. The latter is called indirect addressing.

The BIOS, on a PC, is the code an x86 processor runs on boot. At one time, it was also used throughout execution of the OS too. At boot, it's job is to put all the hardware into a good (not just stable) state, set up a table describing the hardware that the OS will use later, find a bootable disk and, if successful load the first sector from disk into RAM and jump into it, expecting that sector to contain the boot code.

Real PCs are more complicated than this and EFI is complicating matters too, so I strongly suggest sticking with the 8bit micros to begin with as they're simpler inside as well as narrower.


[1] Some processors differentiate memory chips used for code from those used for data, which is called "Harvard" architecture memory. However, "code is data" is still true even then.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.