Search unanswered questions...
Enter a question here...

How does the CPU differentiate between command and data?

[Edit]

Answer

In general the only difference between commands, or instructions, and data is the context in which each appears. If the CPU is fetching the contents of memory to get the next instruction, then it assumes that the Program Counter register points to commands. If the CPU is executing an instruction that needs to fetch data from memory, the data at the address specified by the instruction are fetched, assuming that the address points to data.

This is what allows a program to be loaded into memory in the first place; the part of the operation system responsible for this operation treats the program as data, loading it into memory as instructed in the file. Then the OS branches to a specified place within that memory and begins fetching instructions there.

This blurring between instructions and data has also been used in the past to allow a program to modify itself as it executes. This is usually considered poor practice; some operating systems, such as HP's OpenVMS, even set up memory page protections to keep this from happening.

Improve Answer Discuss the question "How does the CPU differentiate between command and data?" Watch Question

First answer by Joe Sewell. Last edit by Joe Sewell. Contributor trust: 940 [recommend contributor]. Question popularity: 1 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Programming > JAVA > How does the CPU differentiate between command and data?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
Cpu processes data?  How do the CPU could differentiate between command and data?  This part of the CPU temporarily stores data and keep track of the operation?