Tom's Hardware > Forum > CPU & Components > CPUs > How programs work inside a computer?

How programs work inside a computer?

Forum CPU & Components : CPUs - How programs work inside a computer?

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

These are my doubts about the internal working of programs. If somebody can clear it please do that.

When we are building an executable file actually we are converting the code to the instructions to the microprocessor. This binary conversion is the duty of the compiler and it will convert the code to instructions for a specific microprocessor. Now how can it work in other microprocessors? I will tell you an example. Consider if the compiler converted the code for Pentium 4, and suppose there are some SSE2 instructions. Now how can I run this executable file in an Athlon XP which is not supporting SSE2?One explanation is usage of an emulator which is inside the processor which is emulating the Pentium 4 instructions. Is there such kind of thing in all processors? But how an executable build with a modern compiler (the code contains SSE2 instructions) is working even the oldest X86 processor which is not even supporting SSE? Does the compiler have to build various branches for various processors?

Sponsored Links
Register or log in to remove.
- 0 +

Well just a guess, but if the program detects SSE2 in the processor, then it'll run SSE2 instructions.

*shrugs*

-----
<A HREF="http://www.khmercity.com/city_music//Kerpal Comedy@@ kick my dog~ :-)/Jerky Boys - Kerpal - Airport Pakistani And Hindi Fight.mp3" target="_new">I'm going to get you, you bastard guy</A>.

Reply to Woodman

Optimized code often has processor-specific logic branches so that SSE2 can be run on SSE2 enabled CPUs but isn't a requirement for non-SSE2 CPUs. Sometimes it's a matter of the code using specific DLLS. Other times it's branching in the primary binary itself. But almost always any time you have code for a specific feature like that you also have code to run without that feature.

<pre><A HREF="http://ars.userfriendly.org/cartoons/?id=20030905" target="_new"><font color=black>People don't understand how hard being a dark god can be. - Hastur</font color=black></A></pre><p>

Reply to slvr_phoenix

Post deleted by varghesejim

Reply to varghesejim

So if my program uses the MMX,SSE, and SSE2 instructions the compiler have to write code in four ways(branches).One for the newest P4,One for the P3 with SSE one for the pentium with MMX and one for the processor prior to it.So that much of space is needed if you want to optimise code for all the generation of processors.I understand your point.
Now one doubt.I heard that some processors ,specifically RISC ones which have small instruction sets are using emulators onboard to ensure compatability.Do you know which processors are using this technology(any desktop processors?).What are the occations "branching software" and "emulators" are used and what is the criteria for selecting one of the technology for a processor?branching have space complexity high and emulators will make the time complexity high.Right?

Reply to varghesejim

Quote :

So if my program uses the MMX,SSE, and SSE2 instructions the compiler have to write code in four ways(branches).One for the newest P4,One for the P3 with SSE one for the pentium with MMX and one for the processor prior to it.


The compiler or the programmer, depending on the situation. Some software out there however just ignores older processors. This is why there are things called 'minimum requirements'.

Quote :

I heard that some processors ,specifically RISC ones which have small instruction sets are using emulators onboard to ensure compatability.Do you know which processors are using this technology(any desktop processors?).


I've no idea which RISC, CISC, etc. would be doing such, if any. I'd hazard a guess at procs for Macs at the very least.

Quote :

What are the occations "branching software" and "emulators" are used and what is the criteria for selecting one of the technology for a processor?


Branching is pretty much used exclusively in any x86 that wants processor-specific optimizations. I've no idea about the emulators. And the criteria is pretty much if you want to optimize for it. Otherwise just stick to plain old x86/x87 or whatever.

Quote :

branching have space complexity high and emulators will make the time complexity high.Right?


Branching makes the binaries larger, yes, though not always by much. It depends on how much code is repeated in each branch. And emulators would likely cause a performance loss. Although in theory a hardware emulation layer should run without a noticable performance loss if designed well.

<pre><A HREF="http://ars.userfriendly.org/cartoons/?id=20030905" target="_new"><font color=black>People don't understand how hard being a dark god can be. - Hastur</font color=black></A></pre><p>

Reply to slvr_phoenix

I didnt understand what u mean

Reply to varghesejim
Tom's Hardware > Forum > CPU & Components > CPUs > How programs work inside a computer?
Go to:

There are 512 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them
  • 01:00 gpfear won the Freshman badge
  • 01:00 Conrad925 won the Freshman badge
  • 01:00 skythra won the Freshman badge
  • 01:00 Ckaz won the Freshman badge
  • 01:00 james59 won the Uniformed badge
  • 01:00 snarl won the Uniformed badge
  • 01:00 patlabor44 won the Uniformed badge
  • 01:00 Kiren won the Uniformed badge
  • 01:00 WookinPaNub won the Uniformed badge
  • 01:00 kwadams won the Uniformed badge