Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Why do programs work on any PC?

  1. Jul 5, 2015 #1
    Last year I took introductory computer architecture. The course focused mainly on microcontrollers rather than PCs (I'm taking that one next year), and we learned about things like instruction sets. But the discussion was mainly limited to microcontrollers and very simple architecture. I also know nothing about compilers, so that might be a cause for my lack of understanding.

    So what I'm wondering is, how does a program run both on a PC with one kind of CPU (say, an Intel i5) and a PC with another kind of CPU (say, an AMD FX processor)? Is the instruction set standardized across the industry, and compilers use the standard instructions?
  2. jcsd
  3. Jul 5, 2015 #2
    Intel and AMD instructions sets are largely compatible.
    There are some instructions which are unique, however applications designed to run under popular PC operating systems would usually be compiled using only the common instructions.
    The developer can have a choice for the target architecture when compiling, but the default choice would be to use just the common instructions set.
    Last edited: Jul 5, 2015
  4. Jul 7, 2015 #3
    It's history time.

    A long time ago, there were a handful of manufacturing giants, but the only ones that really mattered for personal computers were Motorola and Intel. IBM was the computer king, they chose to use Intel chips for all of their computers. Apple rose as their competition, who used Motorola chips, so for a long time you had either an "IBM Compatible" or an "Apple" computer. There were no PC/Macs yet.

    Because Apple and IBM became so huge, other manufacturers wanted to remain compatible to one of them. IBM became way more popular to clone because Apple wrote their own software and OS, where IBM licensed DOS. Microsoft's license allowed them to sell to other manufacturers as well, so it was actually DOS that became the standard and the Intel chipset became a secondary cause of that. Software needs to interact with the computer too, so they're very reliant on a standard operating system. That's why PCs will forever be Intel instruction sets and why Apple was able to switch from Motorola, to PowerPC, to Intel chips without much difficultly.

    AMD came on the scenes and they wanted to penetrate the pre-existing market. So they had to conform to what was already in place, that's why their chipset is just like Intel's.

    Now in a word of just in time compilers and virtual machines, those lines are getting blurred. I have a Macbook, I'm constantly opening Linux machines in virtual computers, and even opening Windows programs directly in OSX with an emulation layer. Everything works everywhere now (to an extent) because of this.
  5. Jul 7, 2015 #4
    Awesome, thanks guys! I'm not really as knowledgeable about computer science as I'd like to be, so thanks for the help, this has been a question on my mind for ages.
  6. Jul 7, 2015 #5


    User Avatar
    Homework Helper

    The IBM PC was released in August 1981, wiki article:


    The Macintosh was released in Jan 1984, wiki article:


    The earliest (1974) popular home computer was an Altair 8800 kit system, but some companies built the kits and sold ready to run systems, wiki article:


    Between 1974 and 1981, there were home computer's like Apple II, Atari 8 bit series (400, 800, 65XE, 130XE), Commodore Pet, ... , and for office and office like personal computers, CP/M systems, some based on the S100 bus, wiki article:


    The 1981 IBM PC didn't sell that well, but the next versions IBM PC XT, and IBM PC AT, became very popular. Compaq had the first popular PC clone, that was portable as it came in a luggable suitcase like enclosure. By the time the 286 was released, there were many clone makers. When the 386 was released, IBM chose to use it's own micro channel bus (with the PS/2), while the clone makers went with an extended version of the original iSA bus called EISA, and those became the most popular. The transition to PCI bus versions occurred around 1994 (starting in 1991), some for 486's, but mostly with the Pentium and later Intel X86 type processors.

    Getting back to the original question, programs don't work on any PC, since most programs also target a specific operating system, dos/windows, unix type systems, or one of the Mac operating systems. As posted before, there's a common part of the instruction set for X86 compatible processors, and programs written to run on any PC with a particular operating system will only use the common instruction set.
    Last edited: Jul 7, 2015
  7. Jul 8, 2015 #6
    This is not correct. Before the IBM PC (and long before the Mac), the microprocessor market was split between the MOS Technology 6502 (e.g. Apple II, Commodore PET) and Zilog Z80 (e.g. generic CP/M machines, ZX Spectrum, Tandy TRS-80) - the latter was based on and backwards compatible with but faster and more powerful than the Intel 8080 which fell by the wayside, whilst Motorola's 6800 never found its way into a successful consumer product.

    It was only when IBM chose Intel's 8088 for its PC that Intel began to push aside both the Apple II and Z80/CP/M machines that dominated business microcomputer use, and it was 3 years later when Apple chose Motorola's 68000 for the Macintosh.
  8. Jul 8, 2015 #7


    Staff: Mentor

    Also IBM championed the PowerPC chip designed by IBM, built by Motorola and used in Apple products and IBM RISC 6000 machines. The chip evolved into the Cell processor used in MS Xbox and Sony Playstation machines.

    Basically chip history much more complex than 6800 vs 8080 chip architectures and you can read more about PowerPC history here:


    and here for Cell:

  9. Jul 11, 2015 #8
    Just to add to the thread, no one has yet mentioned the language a program is written in. You do not see many releases of source code like in the old days, but most professional programs are written in some variation of C. From the source code, you compile it on the hardware you want to use it on. With a few exceptions of debugging for hardware dependencies, something written in C can be compiled on any machine, Windows, MAC, Linux, UNIX, ect. The compiler does all the changes needed at the assembly language level.
  10. Jul 11, 2015 #9
    So the OS contains a compiler that tells the computer how to run the code? But how would it know how to compile it for the hardware it's running on?
  11. Jul 11, 2015 #10


    Staff: Mentor

    A human configured the compiler to tell it what OS to code for usually via command line flags. Gnu compilers are designed for cross compiling that is working on one machine and compiling code for another machine.
  12. Jul 11, 2015 #11


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    The software you buy and install on your PC is already compiled to machine code when you get it. Same with the operating system, be it Windows or something else, which is a special program that runs all the time and allows the computer operator to make, store and retrieve files, run programs, control the video display, etc.

    A software developer writes a set of instructions for a program in a programming language like C or Fortran or whatever and uses the compiler to turn those human-readable instructions into code which the computer can execute. Once the compiled code is generated, it can be used over and over again, until the program is changed or re-written, without the need to compile every time before running the program.

    A similar process is done to write software for microcontrollers. Once the microcontroller code is finished and compiled, it can be stored in a ROM chip and then run constantly so that the microcontroller knows what to do.
  13. Jul 11, 2015 #12


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    According to this article, the IBM PC reportedly racked up 100,000 sales in its first year, which wasn't bad for a business machine:


    The PC XT was not introduced until March 1983, and the sales of the PC by the end of that year totaled some 750,000 units, which was more units than Apple had sold. IBM was shipping 40,000 units a month and demand was not even close to being satisfied.
  14. Jul 11, 2015 #13


    User Avatar
    Homework Helper

    It was just the first year of the original PC, with less that 100,000 sold, but it's still a good number. In 1983, about 750,000 units were sold. It seemed the big jump in sales occurred with 286 and later 386 "AT" clones (IBM chose to use it's micro channel PS/2's for 386). Some articles claim that Mac's outsold PC's in 1984, but the trend reversed over time, with Mac having about 20% of the personal computer market, most of which was clones by the early 1990's, in the 386 / Wintel (Windows 3.0 / 3.1) era. This was also a time when clones dominated the market place. During one year in the early Wintel era, the top 20 PC makers only accounted for 50% of PC sales, the rest were clones made of common components (motherboards, video cards, ... ) sold by small PC shops. Also during this era, with Mac's increase in prices (1989) and release of Windows 3.0 and later 3.1, Mac sales went from 20% market share to about 5% market share, although much of this was due to a big increase in total sales of personal computers, again a lot of no-name clones.
    Last edited: Jul 11, 2015
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook