The C language was used to write Unix to achieve portability—the same C language program compiled using different compilers produces different machine instructions. How come the Windows OS is able to run on both Intel and AMD processors?
-
2does anybody remember AMD's K5 series :) – Nick Dandoulakis Jul 10 '09 at 13:54
-
Now that AMD is working on ARM64, this question is ambiguous :-) – Jeff Hammond Dec 23 '14 at 01:29
-
1AMD has always made CPUs that are compatible with Intel... – Yousha Aleayoub Aug 15 '17 at 22:33
-
More technical versions of this question: [What EXACTLY is the difference between intel's and amd's ISA, if any?](https://stackoverflow.com/q/38516823) / [What is the compatible subset of Intel's and AMD's x86-64 implementations?](https://stackoverflow.com/q/29833938) / [X64 instructions that behave differently on different CPUs](https://stackoverflow.com/q/40621827) – Peter Cordes Oct 06 '22 at 13:12
6 Answers
AMD and Intel processors(*) have a large set of instructions in common, so it is possible for a compiler or assembler to write binary code which runs "the same" on both.
However, different processor families even from one manufacturer have their own sets of instructions, usually referred to as "extensions" or whatever. Ignoring the x87 coprocessor, the first time I remember this being a marketing point was when everything suddenly went "with MMX technology". Binary code expected to run on any processor either needs to avoid extensions, or to detect the CPU type before using them.
Intel's Itanium 64-bit architecture was completely different from AMD's x86-64 architecture, so for a while their 64-bit offerings were non-compatible (and Itanium was nothing like x86, whereas x86-64 extended the instruction set by adding 64bit instructions). Intel blinked first and adopted x86-64, although there are still a few differences: Differences between AMD64 and Intel 64
Windows probably uses the common x86 or x86-64 instruction set for almost all code. I wouldn't be surprised if various drivers and codecs are shipped in multiple versions, and the correct one selected once the CPU has been interrogated.
(*) Actually, Intel makes or has made various kinds of processors, including ARM (Intel's ARM processors were called XScale, but I think they've sold that business). And AMD makes other processors too. But we know which Intel/AMD processors you mean :-)

- 30,738
- 21
- 105
- 131

- 273,490
- 39
- 460
- 699
-
9+1. Internally, AMD and Intel generally handle these common instructions quite differently: some instructions may execute much slower on one architecture than on the other. – Eric Bainville Jul 10 '09 at 14:07
-
Exactly right and such is the case with Linux. I'm a Linux kernel hacker and if you've ever recompiled your own Linux kernel, you'll notice you can target a plethora of CPU types and, of course, picking the wrong type and installing it amounts in a core dump or hung system. Nice write up by onebyone on this one!!! – Eric Jul 10 '09 at 14:32
-
Intel also made the RISC i860 roughly simultaneously with the rise of the x86 series... obviously we know which one survived and which didn't :) – ephemient Jul 10 '09 at 15:03
-
Intel and AMD CPUs may have different behaviors even on common instructions. As a specific example, in real-mode, running EIP past 0xffffffff will generate an exception on Intel, but will silently wrap to 0x00000000 on AMD -- at least as far as my memory serves. – ephemient Jul 10 '09 at 15:12
-
1That might qualify as a "well don't do that, then" situation. I'm not an assembly programmer, so I can't imagine why you might want to :-) – Steve Jessop Jul 10 '09 at 15:36
-
-
All x86-64 instructions are essentially standardized enough to be implemented by any CPU manufacturer. This answer leaves out the fact that most of the less-used instructions are meant for speed, accuracy, or larger than average sized registry values and are not necessary to use. Since Windows does not require any instructions outside what Intel and AMD support in common to run, the differences are effectively irrelevant. Their relevance is in support for "extensions". – Micah W May 01 '19 at 00:00
AMD are Intel-compatible. Otherwise, they would never have gained a foothold in the marketplace.
They are effectively clone compatible.

- 30,738
- 21
- 105
- 131

- 5,410
- 4
- 46
- 69
As you suspect, the mainstream Intel and AMD processors have the same instruction set.
Windows does not run on ARM or PowerPC chips, for example, because it is somewhat dependent on the underlying instruction set.
However, most of Windows is written in C++ (as far as I know), which should be portable to other architectures. Windows NT even ran on PowerPC and other architectures.

- 30,738
- 21
- 105
- 131

- 21,529
- 9
- 63
- 82
-
3And look at the Linux kernel for an operating system that runs on many architectures, even with different instruction sets. While the C code is portable, a lot of assembler has to be changed for each target. – Nick Meyer Jul 10 '09 at 13:45
-
4The XBox 360 uses a modified Windows 2000 kernel, running on a PPC architecture. I am pretty sure that Windows is probably as portable as other operating systems out there, there is just not a strong incentive for Microsoft to actually provide other versions to the public (for, like, two customers, or so). – Joey Jul 10 '09 at 13:46
-
This answer is mostly true, except in the case of SIMD instruction sets. Things start diverging when you once you mix in 3DNow!, SSE1/2/3, etc. but this is also why x86 compilers generally don't support these instruction sets. – hythlodayr Jul 10 '09 at 13:57
-
4In the mid nineties there was a version of Windows that ran on PowerPC, MIPS and Alpha processors as well as x86. They gradually went away between NT3.1 and Win2000. There may still be a version that runs on the Itanium. NT was written with portability in mind -- there's a nice book called Show Stopper about the development -- but I suspect that you couldn't just rebuild Win7 for, say, PPC now. – Stephen Darlington Jul 10 '09 at 14:33
-
Look at the FreeBSD or NetBSD kernels (and userlands) for operating system that run well on many different architectures. They handle portability and documentation quite well – Good Person Feb 24 '13 at 18:45
-
`Windows does not run on ARM` is not true, Windows CE supported ARM long ago, and later since Windows Phone 8 Windows NT also supports ARM – phuclv Oct 08 '22 at 09:57
Intel's 80x86 CPUs and AMD's 80x86 are "mostly the same sort of", but some things are completely different (e.g. virtual machine extensions - SVM vs. VT-x) and some things (extensions) may or may not be supported. However, some things are different on different CPUs from the same manufacturer too (e.g. some Intel chips support AVX2 and some don't).
There are multiple ways to deal with the differences:
only use the common subset so the same code runs on all 80x86 CPUs (e.g. treat it like an 8086 chip).
use a subset of features that is common to a range of CPUs so the same code runs on all 80x86 CPUs in that range. This is very common (e.g. "this software requires an 80x86 CPU (and OS) that supports 64-bit extensions").
use install-time tests. For example, there might be 4 different copies of software (compiled for 4 different ranges of CPUs) where the installer decides which copy makes sense for the computer the software is being installed on.
use run-time tests. For example, code can use the
CPUID
instruction to doif( AVX2_is_supported() ) { set_function_pointers_so_AVX2_is_used(); } else {set_function_pointers_so_AVX2_is_not_used(); }
. Note: Some compilers (Intel's ICC) can automatically generate code that does run-time tests.
These aren't mutually exclusive options. For example, the installer might decide to install a 64-bit version (and not a 32-bit version), and then the 64-bit version might check which features are supported at run-time and have different code to use different features.
Also note that different parts of an OS can be treated separately. For example, an OS could have 6 different boot loaders, 4 different "HALs", 4 different kernels, and 3 different "kernel modules" to support virtualisation; where some of these things might do run-time tests and some might not.
Do Intel and AMD processor have the same assembler?
Almost all assemblers for 80x86 support almost all extensions (from all CPU manufacturers - e.g. Intel, AMD, VIA, Cyrix, SiS, ...). In general; it's up to the programmer (or compiler) to make sure they only use things that they know exist. Some assemblers provide features to make this easier (e.g. NASM provides a CPU ...
directive so that the programmer can tell the assembler to generate errors if it sees instructions that aren't supported on the specified CPU).

- 35,656
- 2
- 39
- 66
-
With the 3rd option (installing for a particular architecture), does that mean if you swapped a hard drive into a new computer with a different architecture, some installed programs might malfunction, but the 4th option is more resilient? Does that make runtime checks more popular? I know the CPU predictor probably gets the branch right 100% of the time, but the efficiency me hates unneeded `if` statements (mostly joking). – user904963 Sep 18 '22 at 16:30
AMD and Intel use the same instruction set.
When you install Windows on an AMD processor or an Intel processor, it doesn't "compile" code on the machine.
I remember many people being confused on this subject back during college. They believe that a "setup" means that it is compiling code on your machine. It isn't. Most, if not all, Windows applications outside of the free realms, are given to you as a binary.
As for portability, that isn't necessarily 100% true. While C is highly portable, in many cases writing for a specific OS or system will result in the code only being able to compile/executed on that box. For example, certain Unix machines handle files and directories differently, so it might not be 100% portable.

- 30,738
- 21
- 105
- 131

- 374
- 2
- 5
Do Intel and AMD processor have the same assembler? An assembler assembles a program to be run on a processor, so your question is flawed. Processors do not use assemblers.
If you mean can Intel and AMD processor run the same assembler? Then the answer is yes!!!
All assemblers are programs that assemble other programs from structured text files. Visual Basic is an example of an assembler.

- 30,738
- 21
- 105
- 131

- 3
- 1
-
3An assembler technically is a certain kind of translation program. It translates assembly language to machine code. Assembly language is primarily made up of mnemonic instructions which correspond closely to machine code instructions. Visual Basic is not an assembler. – ecm Aug 13 '20 at 18:01
-
Re *"Visual Basic is an example of an assembler."*: That is not what is usually meant by an assembler. The name is normally reserved for a program that can turn symbolic machine code (assembly language) into machine code (one-to-one, except for macros) – Peter Mortensen Jun 27 '23 at 13:56