Pregunta

I really do tried to understand the Von Neumann architecture, but there is one thing I can't understand, how can the user know the number in the computer's memory if this command or if it is a data ?

I know there is a 'stored-program concept', but I understood nothing...

Can someone explain it to me in a two sentences ?

thnx !

¿Fue útil?

Solución

Put simply, the user cannot look at a memory address and determine if it is a command or data. It can be both.

Its all in the interpretation; if the program counter points to a memory address, it will be interpreted as a command. If it is referenced by a read instruction, it is data.

The point of this is flexibility. A program can write (or re-write) programs into memory, that can then be executed by setting the program counter to the start address.

Modern operating systems limit this behaviour by data execution prevention, keeping parts of the memory from being interpreted as commands.

Otros consejos

The Basic concept of Stored program concept is the idea of storing data and instructions together in main memory.

NOTE: This is a vastly oversimplified answer. I intentionally left a lot of things out for the sake of making the point


Remember that all computer memory is, for all intents and purposes on modern machines, a long list of bytes. The numbers are meaningless unless the thing that put them there has a specific purpose for them.

I could put number 5 at address 0. It could represent the 5th instruction specified by my CPU's instruction-set manual. It could represent the number of hours of sleep I had last week. It's meaningless unless it's assigned some value.

So how do computers know what to actually "do" with the numbers?

It's a large combination of standards and specifications, which are documents or code that specify which data should go where, which each piece of data means, what acceptable values for the data are, etc. Such standards are (usually) agreed upon by the masses.

Standards exist everywhere. Your BIOS has specifications as to where to look for the main operating system entry point on the boot media (your hard disk, a live CD, a bootable USB stick, etc.).

From there, the operating system adheres to standards that dictate where in memory the VGA buffer exists (0xb8000 on x86 machines, for example) in order to output all of that boot up text you see when you start your machine.

So on and so forth.

A portable executable (windows) or an ELF image (linux) or a Mach-O image (MacOS) are just files that also follow a specification, usually mandated by the operating system manufacturer, that put pieces of code at specific positions in the file. Then that file is simply loaded into memory, given a specific virtual address in user space, and then the operating system knows exactly where the entry point for your program is.

From there, it sets up the instruction pointer (IP) to point to the current instruction byte. On most CPUs, the current byte pointed to by the IP activates specific circuits in the CPU to perform some action.

For example, on x86 CPUs, byte 0x04 is the ADD instruction that takes the next byte (so IP + 1), reads it as an unsigned 8 bit number, and adds it to the al register. This is mandated by the x86 specification, which all x86 CPUs have agreed to implement.

That means when the IP register is pointing to a byte with the value of 0x04, it will perform the add and increase the IP by 2 - the first is to skip the ADD instruction itself, and the second is to skip the "argument" (operand) to the ADD instruction.

The IP advances as fast as the CPU (and the operating system's scheduler) will allow it to - which amounts to a "running" program.


What the data mean is defined entirely by what's creating the data and what's using it. In the best of circumstances, the two parties agree, usually via a standard or specification of some sort.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top