Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Differentiate the numbers as either data or instructions

0 views
Skip to first unread message

karthikbalaguru

unread,
Oct 21, 2007, 4:50:57 AM10/21/07
to
Hi,

How is a processor able to differentiate the numbers as either data or
instructions ?

Thx in advans,
Karthik Balaguru

FreeRTOS.org

unread,
Oct 21, 2007, 5:40:59 AM10/21/07
to
"karthikbalaguru" <karthikb...@gmail.com> wrote in message
news:1192956657.3...@t8g2000prg.googlegroups.com...


Some processors have separate data and instruction buses, and some
protection mechanisms to generate exceptions, but other than that, it cant
differentiate between the two. It just does with the 'numbers' what your
software tells it to do. If you set the program counter to an address that
was within data it would attempt to execute the data.
--
Regards,
Richard.

+ http://www.FreeRTOS.org
13 official architecture ports, 1000 downloads per week.

+ http://www.SafeRTOS.com
Certified by TÜV as meeting the requirements for safety related systems.


Chris Maryan

unread,
Oct 21, 2007, 6:42:27 AM10/21/07
to
It's essentially part of the compiler and the hardware memory
management to store code in one place and data in another, that's the
only difference. The expectation is that the code is such that any
jumps and branches only go from one code memory location to another.
Thus, it is conceptually possible to execute something from data,
though the resulting instruction may or may not be meaningful.

The exception is a Harvard architecture which has a separate memory
for data and instructions. This is common in microcontrollers. But
most more advanced processors use the Von Neumann (sp?) architecture
where data and code memory is combined.

Chris

On Oct 21, 4:50 am, karthikbalaguru <karthikbalagur...@gmail.com>
wrote:

Vladimir Vassilevsky

unread,
Oct 21, 2007, 9:22:39 AM10/21/07
to

"karthikbalaguru" <karthikb...@gmail.com> wrote in message
news:1192956657.3...@t8g2000prg.googlegroups.com...
> Hi,
>
> How is a processor able to differentiate the numbers as either data or
> instructions ?


If somebody asks a really clueless question in a technical newsgroup, it is
90% chance that it is a Balamalagurumuru or a Abdulgazizhamid. I don't think
that Balamalagurumurus and Abgulgazizhamids are inferior to Johns Smiths;
most likely it tells that Johns Smiths don't want to go to school.

VLV


msg

unread,
Oct 21, 2007, 11:40:09 AM10/21/07
to
karthikbalaguru wrote:
> Hi,
>
> How is a processor able to differentiate the numbers as either data or
> instructions ?
>

Hope you don't mind the question (Sunday morning diversion, I suppose)
but are there a number of different people posting under the moniker
'karthikbalaguru'? Some posts are like this one (terse and non-specific)
and others are very verbose, with different grammatical styles and
more specific content. Perhaps this account is in a classroom somewhere?

BTW, why so many crossposted groups?

Regards,

Michael

Paul Keinanen

unread,
Oct 21, 2007, 12:10:18 PM10/21/07
to
On Sun, 21 Oct 2007 01:50:57 -0700, karthikbalaguru
<karthikb...@gmail.com> wrote:


>How is a processor able to differentiate the numbers as either data or
>instructions ?

It shouldn't differentiate instructions or data if you want to write
self modifying code. Stupid inventions, such as the Harvard
architecture make it hard or even impossible to write such creative
programs :-).

Paul

Jerry Avins

unread,
Oct 21, 2007, 12:36:33 PM10/21/07
to
karthikbalaguru wrote:
> Hi,
>
> How is a processor able to differentiate the numbers as either data or
> instructions ?

Any stored element can be either. It depends on the structure of the
program. You really should address this question to a group that deals
more directly with how computers work, rather than what they work on.

A related question is treating data as numbers or as text. The answer is
always the same.

Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Jerry Avins

unread,
Oct 21, 2007, 12:47:06 PM10/21/07
to

Clueless is better than willfully ignorant. When a recent graduate
(Master of Computer Science) heard that I actually designed computers,
he asked me how they distinguish between ASCII and numbers. He dismissed
me as an ignoramus when I told him that the distinction isn't made in
hardware.

Donald Harris

unread,
Oct 21, 2007, 2:23:07 PM10/21/07
to

"Jerry Avins" <j...@ieee.org> wrote in message
news:_N6dnSyIkb0RH4ba...@rcn.net...

> Vladimir Vassilevsky wrote:
>> "karthikbalaguru" <karthikb...@gmail.com> wrote in message
>> news:1192956657.3...@t8g2000prg.googlegroups.com...
>>> Hi,
>>>
>>> How is a processor able to differentiate the numbers as either data or
>>> instructions ?
>>
>>
>> If somebody asks a really clueless question in a technical newsgroup, it
>> is
>> 90% chance that it is a Balamalagurumuru or a Abdulgazizhamid. I don't
>> think
>> that Balamalagurumurus and Abgulgazizhamids are inferior to Johns Smiths;
>> most likely it tells that Johns Smiths don't want to go to school.
>
> Clueless is better than willfully ignorant. When a recent graduate (Master
> of Computer Science) heard that I actually designed computers, he asked me
> how they distinguish between ASCII and numbers. He dismissed me as an
> ignoramus when I told him that the distinction isn't made in hardware.
>
> Jerry

Not all Computer Scientists are completely clueless, just many of them.

Unfortunately, most of the Computer Scientists I have the misfortune to have
to
deal with know nothing about either computers or science. They seem to have
a liberal arts degree in high level languages. They seem to think that it
is more
important to have the documentation their way than for the program to work!

Documentation their way doesn't use flow charts, they are out of style. To
me,
flow charts show the flow of the program, the decisions made, and in what
order.

They tell management that assembly language programming should never be
allowed as it is too cryptic. To me, some HOL programmers take great pride
in doing as much as possible in one instruction which makes it very cryptic!

They tell management that my program structure is wrong. They say that I
should not have a separate initialization section. I say that proper
initialization
is VERY important. Some of my programs operate destruct systems. Even
though the S&A devices are multi step with delays, they need to be commanded
to full safe. People will die if the destruct system unexpectedly goes off.

Don


Andrew Smallshaw

unread,
Oct 21, 2007, 3:46:52 PM10/21/07
to
On 2007-10-21, karthikbalaguru <karthikb...@gmail.com> wrote:
>
> How is a processor able to differentiate the numbers as either data or
> instructions ?

In a word, context. In a Von Neumann architechure, there is no
fundamental difference between the two. It is only that code should
usually only ever branch to code, and not to data. On reset, the
processor will begin executing at some predefined memory location,
and things are contrived such that that location contains code.
It is the responsibility of it and other code to ensure that
execution only ever passes to more code and not data. In reality
this requirement usually isn't particularly onerous as you only
ever want to branch to a particular routine that performs the
required task, not to some random code.

There are, however, one or two fringe cases where data can be code
or vice versa. The first useful case is self modifying code as
has already been mentioned, although nowadays that is usually
regarded as a Bad Thing everywhere except possibly the embedded
world, and even here you have to be careful if the processor has
separate instruction and data caches.

The second useful case, and somewhat more common, is initial program
load on a disk-based system. When the program is read off disk,
it is initially regarded as data. After setting up the program's
memory map, linking in any dynamic libraries and anything else that
needs doing, that data is then regarded as code, control is passed
to it and your program starts running.

Less desirable is the vulnerability caused by this ambiguity to
running user-supplied code/data - this is a powerful mechanism for
crackers. Here, the general idea is to stuff a data buffer with
code that will cause the desired effect, and then fooling the
program into passing control to that data. This is why it is a
Good Thing if your MMU can mark pages non-executable, so that an
error is caused if this kind of thing is attempted.

--
Andrew Smallshaw
and...@sdf.lonestar.org

Steve

unread,
Oct 21, 2007, 7:54:58 PM10/21/07
to
"karthikbalaguru" <karthikb...@gmail.com> wrote in message
news:1192956657.3...@t8g2000prg.googlegroups.com...
> Hi,
>
> How is a processor able to differentiate the numbers as either data or
> instructions ?

For the most popular computers today... it doesn't.

Computers store numbers in addressed locations in memory. When the "program
counter" is set to an address and the processor executes the number at the
address, it is an instruction. When a program loads a value from the same
address into a processor register, it is data.

But generally speaking if you look at a number somewhere in memory you can't
tell whether it is data or an instruction. It is how the number is used
that defines it as data or instruction.

Regards,
Steve

Del Cecchi

unread,
Oct 21, 2007, 11:15:30 PM10/21/07
to

"karthikbalaguru" <karthikb...@gmail.com> wrote in message
news:1192956657.3...@t8g2000prg.googlegroups.com...
That is why von neuman is famous and you aren't. Don't feel bad, I'm not
either.


Tom

unread,
Oct 22, 2007, 12:08:46 AM10/22/07
to
In article <1192956657.3...@t8g2000prg.googlegroups.com>, karthikbalaguru <karthikb...@gmail.com> wrote:
>Hi,
>
>How is a processor able to differentiate the numbers as either data or
>instructions ?

It isn't. It's the program that's running on the processor has to make the
differentiation. However there are also cases where it doesn't. Search for
these terms: microsoft buffer overflow remote code execution

John Ahlstrom

unread,
Oct 22, 2007, 1:51:44 AM10/22/07
to Andrew Smallshaw
Andrew Smallshaw wrote:
> On 2007-10-21, karthikbalaguru <karthikb...@gmail.com> wrote:
>> How is a processor able to differentiate the numbers as either data or
>> instructions ?
>
> In a word, context. In a Von Neumann architechure, there is no
> fundamental difference between the two.
-- snip snip

The irony here is delicious. The original VN architecture
had no address calculation capability - in particular no
index registers. Treating an instruction as data - adding or
subtracting a value to from its address field was the only
way - other than having a distinct instruction with the
appropriate address in it - to access multiple elements
of an array or other data structure.

As soon as our cousins across the sea invented
address modification registers - b lines - that
was no longer necessary.

To be an effective computer the original VN arch
had to interpret the contents of (some) memory
locations as both instructions and data.

JKA


--
How do you tighten a screw? Turn it until the thread strips
and then back it off a quarter of a turn?

Tim McCaffrey

unread,
Nov 2, 2007, 5:12:09 PM11/2/07
to
In article <L8FSi.34498$c_1....@text.news.blueyonder.co.uk>,
noe...@address.com says...

>
>"karthikbalaguru" <karthikb...@gmail.com> wrote in message
>news:1192956657.3...@t8g2000prg.googlegroups.com...
>> Hi,
>>
>> How is a processor able to differentiate the numbers as either data or
>> instructions ?
>>
>> Thx in advans,
>> Karthik Balaguru
>
>
>Some processors have separate data and instruction buses, and some
>protection mechanisms to generate exceptions, but other than that, it cant
>differentiate between the two. It just does with the 'numbers' what your
>software tells it to do. If you set the program counter to an address that
>was within data it would attempt to execute the data.
>--
>Regards,
>Richard.


Y'all are forgetting about tagged architectures, which check the tag of the
memory word before using what was read, or writing to it. e.g. Unisys Libra
series.

- Tim


0 new messages