What Is x86
Published: 2020-08-23 07:10:16

## Introduction
I hear x86, x86-64, AMD64 and ARM often but I don't know what they mean in detail. We need to know "ISA" to dive into them. Let's start with it.

## What Is ISA
ISA is the definition of operations, addressing mode and storage locations. It also describes how to invoke and access them. It works as an interface between software and hardware. Why do we need it?
In the beginning of computer era, each machine had its own instruction set. It means one software runs on one type of machine and we cannot use it in other machines. It was so inconvenient. So IBM started to integrate instruction set and define ISA. Every software can run on every machine if they are according to the same ISA. This reinforced the versatility of software.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jkwxksksg5u98js37dk7.png)

There are three type of ISAs in term of storage locations.
・Stack
The number of operands is zero. When the operations require data, it will be manged on the stack.
・Accumulator
This uses memory address as operands.
・General Purpose Register (GPR)
Data is stored in the register and the operations take it as the operands.

Let's think about A+B=C on each architecture. The simple assemblies are as below.

This history and the changes of name confuse us a lot :(

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rrqzjmq1nqfk2w0sar6s.png)

## Famous ISAs
x86, x86-64, AMD64 and ARM are the names of ISA. Here is a brief table to know the difference at the glance.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d7b3nhlyfmqf21f0doba.png)

### History of ISAs for PC
Actually, x86-64 and AMD64 are the same things. The simple history of ISA in PC is as below
・Intel developed 80386 which was a first 32 bits CPU. Other series were released and they came to be called "x86" generically
・Intel developed 64 bits CPU IA-64 architecture but it didn't spread because it was not compatible with x86.
・AMD developed 64 bits CPU x86-64 architecture and it became popular. It changed the name to AMD64 after a few years.
・Intel developed 64 bits CPU IA-32e architecture and changed the name to EM64T and to Intel64. It is compatible with AMD64.

This history and the changes of name have confused us a lot :(

### The type of architecture
・CISC(Complex Instruction Set Computing)
The task on the desktop PC tends to be complicated. CISC architecture is suitable for it. The instruction set consists of complex commands which can be divided into smaller sub commands and whose size is different. When the processor uses commands, they are sent to the decode unit and translated as a microcode. Nano processor(like a processor in a processor) processes it. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fq21vky8og84i96874fh.png)

・RISC
The task on the mobile tends to be simpler than PC. RISC is suitable for this case. The instruction set consists of simple commands whose size is same. There is no overhead to divide the commands into pieces so that they are only needed to be decoded to micro codes. This architecture enables it to read commands and process it faster.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m2w7cumbxkx7in67l6x6.png)

### Register
The big difference is an available memory size. When programs need to access to the memory, the required address loads into the register. So, the limitation of the size program can handle depends on the size of the register. For example, 32 bit CPU can handle about 40 billion addressed, which means 4GB and 64 bit CPU can handle 16EiB.

P.S. What else should I know to understand deeply of computer architecture or CPU??
Enjoy hacking!!