Difference between x86, x32, and x64 architectures?
Asked Answered
S

4

67

Please explain the difference between x86, x32 and x64? Its a bit confusing when it comes to x86 and x32 because most of the time 32-bit programs run on x86...


Related/possible duplicate which also covers terms like IA-32 used in official docs:

Saltire answered 3/10, 2011 at 12:32 Comment(6)
x32 is a new ABI being actively worked on. It is basically 32-bit code running in x86_64 (x64) mode on the CPU so that it has access to the additional 8 registers to boost program speed while remaining memory efficient via the use of 32-bit pointers. See sites.google.com/site/x32abi and lwn.net/Articles/456731.Beaux
The x32 ABI is part of Linux 3.4, released on the 20th May 2012Etiology
@jww I don't have a hammer. Also, I didn't say that this wasn't a real question, just that it's off-topic. It's a little bit broad, and probably would have been better asked on Super User. Still, Hans' answer can be improved without reopening the question.Ancestress
@jww Ah, I see. I added a reopen vote. I guess there's no harm in SO hosting a borderline SO/SU question.Ancestress
x86 refers to the architectures compatible with intel 386, 486, etc. x32 and x64 are misnomers often used just to mean "32-bit" or "64-bit"Paigepaik
Related: The most correct way to refer to 32-bit and 64-bit versions of programsMichelinemichell
P
43

x86 refers to the Intel processor architecture that was used in PCs. Model numbers were 8086, 8088 (8-bit bus version of 8086 and used in the first IBM PC), 286, 386, 486. After which they switched to names instead of numbers to stop AMD from copying the processor names. Pentium etc, never a Hexium :).

x64 is the architecture name for the extensions to the x86 instruction set that enable 64-bit code. Invented by AMD and later copied by Intel when they couldn't get their own 64-bit arch to be competitive, Itanium didn't fare well. Other names for it are x86_64, AMD's original name and commonly used in open source tools. And amd64, AMD's next name and commonly used in Microsoft tools. Intel's own names for it (EM64T and "Intel 64") never caught on.

x32 is a fuzzy term that's not associated with hardware. It tends to be used to mean "32-bit" or "32-bit pointer architecture", Linux has an ABI by that name.

Pneumatology answered 3/10, 2011 at 12:32 Comment(2)
8 bit version of 8086 is a bit misleading. The 8088 is a 16-bit processor which means its registers are 16 bit wide. However, the external data bus is only 8 bits wide.Enrollee
8086 is a 16-bit internal and external data bus , 8088 is 16-bit internal data bus and 8-bit external data busOstrowski
S
53

Hans and DarkDust answer covered i386/i686 and amd64/x86_64, so there's no sense in revisiting them. This answer will focus on X32, and provide some info learned after a X32 port.

x32 is an ABI for amd64/x86_64 CPUs using 32-bit integers, longs and pointers. The idea is to combine the smaller memory and cache footprint from 32-bit data types with the larger register set of x86_64. (Reference: Debian X32 Port page).

x32 can provide up to about 30% reduction in memory usage and up to about 40% increase in speed. The use cases for the architecture are:

  • vserver hosting (memory bound)
  • netbooks/tablets (low memory, performance)
  • scientific tasks (performance)

x32 is a somewhat recent addition. It requires kernel support (3.4 and above), distro support (see below), libc support (2.11 or above), and GCC 4.8 and above (improved address size prefix support).

For distros, it was made available in Ubuntu 13.04 or Fedora 17. Kernel support only required pointer to be in the range from 0x00000000 to 0xffffffff. From the System V Application Binary Interface, AMD64 (With LP64 and ILP32 Programming Models), Section 10.4, p. 132 (its the only sentence):

10.4 Kernel Support
Kernel should limit stack and addresses returned from system calls between 0x00000000 to 0xffffffff.

When booting a kernel with the support, you must use syscall.x32=y option. When building a kernel, you must include the CONFIG_X86_X32=y option. (Reference: Debian X32 Port page and X32 System V Application Binary Interface).


Here is some of what I have learned through a recent port after the Debian folks reported a few bugs on us after testing:

  • the system is a lot like X86
  • the preprocessor defines __x86_64__ (and friends) and __ILP32__, but not __i386__/__i686__ (and friends)
  • you cannot use __ILP32__ alone because it shows up unexpectedly under Clang and Sun Studio
  • when interacting with the stack, you must use the 64-bit instructions pushq and popq
  • once a register is populated/configured from 32-bit data types, you can perform the 64-bit operations on them, like adcq
  • be careful of the 0-extension that occurs on the upper 32-bits.

If you are looking for a test platform, then you can use Debian 8 or above. Their wiki page at Debian X32 Port has all the information. The 3-second tour: (1) enable X32 in the kernel at boot; (2) use debootstrap to install the X32 chroot environment, and (3) chroot debian-x32 to enter into the environment and test your software.

Smith answered 19/9, 2015 at 1:37 Comment(1)
"once a register is populated/configured from 32-bit data types, you can perform the 64-bit operations on them, like adcq". Ok, but that's exactly the same as x86-64. The speed gains are mostly for code with pointer-heavy data structures. Only some kinds of HPC are like that. Other scientific computing tasks want giant amounts of memory and lots of FP on giant arrays, where x32 makes little difference. Code-size is probably similar or worse than x86-64, since it tends to need address-size prefixes. Although pointer manipulation can sometimes avoid REX prefixes.Michelinemichell
P
43

x86 refers to the Intel processor architecture that was used in PCs. Model numbers were 8086, 8088 (8-bit bus version of 8086 and used in the first IBM PC), 286, 386, 486. After which they switched to names instead of numbers to stop AMD from copying the processor names. Pentium etc, never a Hexium :).

x64 is the architecture name for the extensions to the x86 instruction set that enable 64-bit code. Invented by AMD and later copied by Intel when they couldn't get their own 64-bit arch to be competitive, Itanium didn't fare well. Other names for it are x86_64, AMD's original name and commonly used in open source tools. And amd64, AMD's next name and commonly used in Microsoft tools. Intel's own names for it (EM64T and "Intel 64") never caught on.

x32 is a fuzzy term that's not associated with hardware. It tends to be used to mean "32-bit" or "32-bit pointer architecture", Linux has an ABI by that name.

Pneumatology answered 3/10, 2011 at 12:32 Comment(2)
8 bit version of 8086 is a bit misleading. The 8088 is a 16-bit processor which means its registers are 16 bit wide. However, the external data bus is only 8 bits wide.Enrollee
8086 is a 16-bit internal and external data bus , 8088 is 16-bit internal data bus and 8-bit external data busOstrowski
E
12

x86 means Intel 80x86 compatible. This used to include the 8086, a 16-bit only processor. Nowadays it roughly means any CPU with a 32-bit Intel compatible instruction set (usually anything from Pentium onwards). Never read x32 being used.

x64 means a CPU that is x86 compatible but has a 64-bit mode as well (most often the 64-bit instruction set as introduced by AMD is meant; Intel's idea of a 64-bit mode was totally stupid and luckily Intel admitted that and is now using AMDs variant).

So most of the time you can simplify it this way: x86 is Intel compatible in 32-bit mode, x64 is Intel compatible in 64-bit mode.

Enrollee answered 3/10, 2011 at 12:42 Comment(3)
I think it is useful to add that x64 is also known as x86-64 and AMD64.Advance
"x64" is only used in the Windows world. In Linux terminology, i386 is the 32bit ISA, and amd64 is the 64bit ISA, also called x86-64. x86 is the superset, so x86-32 (i386) and x86-64 (amd64) are the two flavours of x86. x32 should not be used as a synonym for 32bit x86, because that term refers to something specific and very different (see the other answers/comments).Michelinemichell
@PeterCordes took several seconds to understand that ISA is Instruction Set Architecture, not Industry Standard Architecture (the bus, since you were talking about i386 at first).Hatpin
M
0

As the 64bit version is an x86 architecture and was accordingly first called x86-64, that would be the most appropriate name, IMO. Also, x32 is a thing (as mentioned before)—‘x64’, however, is not a continuation of that, so is (theoretically) missleading (even though many people will know what you are talking about) and should thus only be recognised as a marketing thing, not an ‘official’ architecture (again, IMO–obviously, others disagree).

Mackenzie answered 5/10, 2020 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.