ROOT BLOG CONTACT

x86 vs x64

If you've ever worked with low-level code or even just compiled code you might have noticed the option to compile for x86 or x64 architecture. Most know that x86 is 32-bit and x64 is 64-bit. But what does that even mean? What is x86-64? Welcome to the rabbit hole of instruction set architectures.

1. What is an instruction set architecture?

An instruction set architecture (ISA) basically defines how software talks with hardware.

Its kinda like this: if I want to talk to my friend in Japan and he doesn't speak English, I have to use Japanese. But if I want to talk to my friend in Great Britain, I have to use English. The same goes for software (me) and processors (my friends).

If the software wants to communicate with an Intel i5-12400, then it must use the x86-64 ISA. However, if the software wants to talk with an Apple M1 chip, then it must use the ARM ISA. The Intel i5 does not understand the ARM ISA and the Apple M1 does not understand the x86-64 ISA.

There are two main types of ISAs:

1.CISC (Complex Instruction Set Computing) e.g. x86

2.RISC (Reduced Instruction Set Computing) e.g. ARM

A little warning, I use the terms "ISA", "architecture", "sets" and "instruction set" interchangeably, just know that they all refer to the same thing. Having cleared that up

2. What is the difference between 32-bit and 64-bit ISAs?

To understand the difference between x86 and x64 ISAs, its important to first understand the difference between 32-bit and 64-bit instruction sets. 32-bit instruction sets can process data in 32-bit chunks, which limits how much memory (e.g. RAM) it can access, usually only up to 4GB. In contrast 64-bit systems, because they process data in 64-bit chunks, can theoretically access up to 16 exabytes (16.000.000.000GB) of memory, although practical limits are much lower (think 128GB - 18.4 mil TB on most windows systems).

Now that we know that

3. A little bit of history

Its important to understand what the names x86 and x64 actually refer to, before moving on to the differences.

3.1 Where does x86 come from?

It all started with the 8086, which was a processor using the 8086 ISA (a 16-bit instruction set with the same name as the chip) made by intel in 1978. This was later known as x86-16. The name really only emerged with the successors of the 8086, which had the naming convention 80x86. There was the 80186, 80286, 80386 and the 80486. This only lasted until the emergence of its successors, the 80x86 chips, the 80186, 80286, 80386 and the 80486. Although the 80386 was the first chip from intel using the IA-32 ISA or more commonly known the i386 ISA, a 32-bit architecture.

At this point x86 refers to both the 8086 (a 16-bit set) ISA and the IA-32 ISA.

3.2 Where does x64 come from?

Intel created the IA-64 ISA (Intel Itanium architecture), a 64-bit set. After that AMD created its own 64-bit set called the AMD64, which was backwards compatible with the IA-32 set and also basically only an extension of the x86 architecture called x86-64. That's where the name x64 came from, which doesn't refer to Intel's IA-64 ISA but rather also refers to Intel's later introduced Intel 64 architecture.

So x86 is simply an ambiguous term referring to all 32-bit instruction system architectures. In turn x64 is used to refer to almost all 64-bit architectures.

4. What is the difference between x86 and x64?

Having looked at the history and what x86 and x64 actually refer to, what is the difference between those two?

4.1 Backward compatibility

The x64 architecture is backwards compatible with the x86 architecture, because x86 dominated the processor market for quite a long time after x64 was introduced. This means that all 64-bit processors can run 32-bit applications.

4.2 Memory

64-bit systems can handle more memory than 32-bit systems. As previously discussed a 32-bit system can handle up to 4GB of memory and a 64-bit system can practically handle up to 18.4 mil TB of memory.

4.3 Performance

Also because 64-bit CPUs can process 64-bits of data in a single cycle they are faster than 32-bit CPUs that can only handle 32-bits of data in a single cycle.

5. How does that effect developers?

Generally this doesn't effect you at all.
Unless of course you need to write architecture specific code, as a `long` in cpp has a different length on linux as on windows. But normally the average dev doesn't need to worry about that, and why? because compilers today are some of the most complex software ever written and handle a lot of stuff so we don't have to worry about it.

END