What actually happens when data is stored/moved?

  • #1
I am taking advanced course in computer architecture. I have one question that is bothering me. I want to explain my question by taking use of assembly language.
When I write instruction such
mov ax, 5, what is exactly happening at the transistor level, how data is stored? How assembler/compiler is playing it's role in storing that data?
Any answers will be greatly appreciated!
 

Answers and Replies

  • #2
634
1
I'll try to answer.
You might of heard of the phrase - programming is just like flipping a bunch of switches.

Data (1s, 0s) is nothing but charge stored in a capacitor.
You can think of memory as a bunch of capacitors.

Lets assume both the address and data are 4 bits. So 5 would be 0101 in binary.
Let the address be 0001b
When you execute that instruction -

the address lines select the four capacitors to store the data - 5
It's like selecting a bunch of cells in excel.
For writing a 1 - the capacitor is charged.
For writing a 0, the capacitor is discharged.

Moving doesn't involving charging/discharging. You just select the cells and transfer them to the output buffer or a register/accumulator.
 
  • #3
How does/can a assembler or compiler tells the hardware that it has to store those bits in capacitor?
 
  • #4
634
1
The assembly instruction - MOV has a hex code assigned to it like 3F
The microprocessor CPU will fetch this hex code, decode it and execute the mov instruction. This is called the fetch-decode-execute cycle.
 
  • #5
phinds
Science Advisor
Insights Author
Gold Member
2019 Award
16,430
6,725
How does/can a assembler or compiler tells the hardware that it has to store those bits in capacitor?
HUH ??? What on earth does a capacitor have to do with it?
 
  • #6
The assembly instruction - MOV has a hex code assigned to it like 3F
The microprocessor CPU will fetch this hex code, decode it and execute the mov instruction. This is called the fetch-decode-execute cycle.
Cool, so, when the data is fetched from the memory there must be something which reads the data from the disk - some electronic component.
 
  • #7
DaveC426913
Gold Member
18,934
2,425
There seems to be a bit of confusion between volatile memory and long-term memory.

RAM - There are memory registers in on-board chips that store bits in capacitors - one bit per capacitor. This is volatile memory, that will get wiped out when the power is turned off.

Hard drive - There are storage constructs on hard disks that store bits in various physical constructs, depending on the type of storage - hard drives store bits in magnetic cells (on or off), CDs store them as warped bumps of plastic that reflect laster light.

This is a bit simplistic, for example, there are types of on-board storage that are non-volatile.
 
  • #8
DaveC426913
Gold Member
18,934
2,425
Cool, so, when the data is fetched from the [STRIKE]memory[/STRIKE] disk there must be something which reads the data from the disk - some electronic component.
Yes, there is an arm, equivalent to the arm of a record player that swings out to the right track and reads or writes the bits.

On a hard drive, it is a magnetic reader-writer; on a CD it is a laser reader-writer.



On more step, considering your original question. When you write your assembly language, it acts upon RAM, storing your data in volatile memory registers. It is only once you send a command to save that data to disk, that the block of memory in its entirety its copied onto the hard drive.
 
  • #9
828
1
OP, I'll try to give a not-so-comprehensive, quasi-bottom to top description of the process.

We start with transistors, and in the CMOS technology of transistors, the basic logic building block of an inverter can be made with two FETs. All of your AND, OR, NOR, and more complex logic building blocks are made of these transistors. They are usually run with a clock signal, which is created by an oscillating circuit. These all operate like a machine, to move a signal or a bus of signals from an input to an output, and the output depends on what the input was to give you certain functions. So at all stages, you have inputs constantly being moved to outputs as time progresses.

The start of these inputs are "hard-wired" in the truth tables of the logic blocks, and then later these inputs can be switched to other sources, where they can be accessed from non-volatile memory. One class of these signals are the instructions to start the chip running whatever programs it is meant to run. The logic blocks are hardwired to "boot" or start executing from non-volatile memory as soon as power is applied to the hardware. At this point is where the microcontroller is going to start running from code rather than the innate starting states of the machine. The microcontroller can also switch from its start up state to a state where it begins taking its instructions from other sources than just non-volatile memory, but these are usually more advanced special operating cases like JTAG or other debug modes.

The interface to the non-volatile memory varies, but its always some physical mechanism that is being controlled by the logic blocks of the microcontroller. It can be a burn into a flash memory block using high voltage components or it can be an interface to an electro-mechanical device like a hard drive, but remember the process is always being controlled by logic-blocks that are constantly giving an output based on their inputs over time. Now, all the data in the non-volatile memory can be transferred to volatile memory, and the distinction between volatile and non-volatile memory is not so important at this point other than that volatile memory is usually much faster and has a more direct access to the logic blocks of the microcontroller.

At this point, the logic machines of the micrcontroller are running off inputs of the code you have written and many instructions will have temporary information that needs to wait for other information, such as when you take two values from memory and wish to add them together. If the logic is not designed to take both values at the same time, one value must be taken first and wait for the other value. Hence why some instructions take multiple clock cycles. The intermediate logic stages between the memory and its end location can store these bytes of information while waiting through the use of flip-flops.

You may or may not have heard of flip flops; these are digital circuits that have a memory ability. They stay in a high or low state depending on whether a high or low voltage is applied to their input even after the input goes away because they also have an enable/disable input to control when they accept a new state. The transistors used to make the flip-flop are used in circuits called bistable multivibrators, and these circuits are used to implement the temporary memory in the logic blocks of the electronics.

Finally the interface to the logic that decodes what it takes from the instruction memory and determines the truth tables of all the other logic to perform their functions based on these decoded values is the instruction set. So all the logic of the chip is designed to operate based on the instruction set. You simply give the microcontroller the instructions, which include all the information relevant to the instruction (a memory location of where to take the data), and its hardware takes care of all details without you having to think about it.

You could write these instructions in their 1s and 0s into the memory that the decoding logic will read it out of, or you can let your PC write these 1s and 0s after its assembler software has translated your assembly instructions into machine instructions. So assembly and programming languages are just the abstraction from what your human thinking brain wants to the machine code the microcontroller wants. The assembler is not playing any more of a role in storing the data than what you have told it to do with your assembly in the instructions.

However, there is additional abstraction in the assembler/compiler software because it is very impracticle for a human to write a program where you have to manually specify every memory location you wish to read or write values. This is where the assembler and compiler start to automate your instructions. You can intentionally write more abstract code and let the assembler/compiler decide what addresses to use for memory locations based on a set of rules you give it. The assembler/compiler software usually has a model of the device you're programming, and additionally, you define a memory map that tells the assembler/compiler what addresses it can use for the different kinds of memory. Now when you define a variable, you are giving that variable a memory location indirectly because you have automated your assembler/compiler to pick a memory location for you . . as long as it is following the rules and memory map you gave it, you don't really care what memory location that variable is given. The assembler/compiler keeps track of all these locations automatically for you, but in the end you could have picked all of these memory locations yourself, because they are just going into the instruction set interface either way. It would just take you a lifetime to write modern programs doing this manually.
 
Last edited:
  • #10
uart
Science Advisor
2,776
9
I am taking advanced course in computer architecture. I have one question that is bothering me. I want to explain my question by taking use of assembly language.
When I write instruction such
mov ax, 5, what is exactly happening at the transistor level, how data is stored? How assembler/compiler is playing it's role in storing that data?
Any answers will be greatly appreciated!
Hi pairofstrings. I've noticed that you've asked several question recently regarding some of really low level hardware aspects of computers. They're good questions but the problem is that we have no idea of what is your current state of knowledge on the subject, so with this type of question it's very difficult to know exactly where to start. It would be helpful if you gave us a summary of what current background you have on basic logic circuits like gates latches counters shift registers etc. Tell us if you've ever done any digital circuit design of any kind.

If the answer is "no prior knowledge" then let me suggest some points to study up on, and if you like to ask some specific question on.

1. Simple switch (relay) logic, basic AND OR NOT gates. If you don’t currently understand transistor operation then no need to bother too much with the "nitty gritty" detail. Just accept that transistors an can be used for the controlled switches to make these simple gates.

2. Implementation of simple combinational logic. Look at simple half and full adder circuits.

3. Basic bistable circuits (aka flipflops and latches). You want to look in particular at the cross-coupled NOR gate RS "flipflip" and the basic transparent D latch.

4. Introduction to sequential circuits. Edge triggered flipflops. Simple counters and shift registers.

5. Look at the operation of a basic ALU chip like the 74181. Perhaps you could look at using a data latch to make the ALU into a simple accumulator.

If you follow though with the above 5 steps then you'll be amazed at how much it increases your ability to comprehend more advanced digital architectures.
 
Last edited:
  • #11
Thank you all for the wonderful answers. Honestly, my thinking was that assembler/compiler was somehow doing the work of reading and writing data to the memory locations by interacting directly with the capacitors in the memory(volatile). I wondered how assemblers/compilers of such high abstraction could ever be able to interact with memories. That was my main doubt.
And thank you for clearing the volatile and non-volatile memory concepts.
 
Last edited:
  • #12
uart
Science Advisor
2,776
9
Dynamic memory (RAM) basically stores data as simple charge on a capacitor, while static ram stores it in "bistable" elements like flipflops. The advantage of dynamic ram is it's much higher density than static ram. For this reason just about all large scale memory is dynamic these days. The disadvantage of dynamic ram that it needs periodic "refreshing" (cell data is effectively read and then rewritten) or the capacitors lose their charge and hence their data. Both static and dynamic RAM are typically volatile (lose data at after power off).

What about my question. How much of my five points to you already have some knowledge of?
 
  • #13
What about my question. How much of my five points to you already have some knowledge of?
I have done all except point 5.
 
  • #14
828
1
Thank you all for the wonderful answers. Honestly, my thinking was that assembler/compiler was somehow doing the work of reading and writing data to the memory locations by interacting directly with the capacitors in the memory(volatile). I wondered how assemblers/compilers of such high abstraction could ever be able to interact with memories. That was my main doubt.
And thank you for clearing the volatile and non-volatile memory concepts.
The assembler/compiler does not interact with the memories directly, although they can indirectly through programming/debugger hardware. In production, the memories are programmed with the machine code your assembler made using devices like in-circuit-test programmers. Basically a factory will have a machine with pins on it that can connect to the memory device's pins and directly and write all the machine codes into the memory without even having to involve the microcontroller.
 
  • #15
uart
Science Advisor
2,776
9
I have done all except point 5.
Ok that's good. Based on some your question I thought you might have had no background here. (sorry if that sounds a bit like an insult, it wasn't meant to be.)

I wondered how assemblers/compilers of such high abstraction could ever be able to interact with memories.
The reading of memory (for both instructions and data) is fundamentally what a CPU does! The compilers and assemblers simply generate the code that goes into the memory that the CPU reads (at run time). The "interaction" you speak of is really THAT simple.

Take for example your specific first question about "mov ax,05". It really this simple, the assembler generates the correct operation code (a binary number) that tells CPU that the next word it reads from the instruction sequence will not be an instruction, but instead will be a data word that it should (instead of trying to interpret as another operation code) simply store in the ax register. It then inserts the data 0005 into the next word of the instruction stream. This is fundamentally what a cpu does, reads sequences of "operation codes" from memory, where each op-code tells the cpu what to do for that particular operation cycle (as determined by the system clock). The assembler/compiler simply generates the correct series of these "op-codes" to perform the desired instructions.
 
Last edited:
  • #16
Can you put light on new technology of memory that they are talking about ?
It's called DFG-FET = dual-floating gate field effect transistors
http://www.bit-tech.net/news/hardware/2011/01/25/dfg-fet-memory-tech/1" [Broken]
 
Last edited by a moderator:

Related Threads on What actually happens when data is stored/moved?

Replies
1
Views
807
Replies
8
Views
8K
Replies
3
Views
17K
Replies
6
Views
5K
Replies
4
Views
2K
  • Last Post
Replies
19
Views
9K
Replies
5
Views
396
Replies
1
Views
5K
Replies
5
Views
1K
Replies
15
Views
4K
Top