The x86 architecture first appeared inside the Intel 8086 CPU in 1978. It was adopted (in the simpler 8088 version) three years later as the standard CPU of the IBM PC. The PC's enormous success during the last 20 years has guaranteed that the x86 architecture that became the most popular CPU architecture ever. See also Intel.
It can be generalized that the x86 architecture is CISC with variable instruction length. Memory is aligned by byte boundaries. Information is stored in the little-endian order. Backwards compatibility was a driving force behind the development of the x86 architecture, that caused numerous sub-optimal and otherwise unjustifiable design decisions.
Note that the names for instructions and registers (mnemonics) that appear in this brief review are the ones specified in Intel documentation and used by some of the assemblers, however they are still arbitrary. An instruction that is specified in TASM syntax by mov al, 30h is equivalent to AT&T-syntax movb $0x30, %al, and both translate to the two bytes of machine code B0 30 (hexadecimal). You can see that there is no trace left in this code of either "mov" or "al", which are the original Intel mnemonics. If we wanted, we could write an assembler that would produce the same machine code from the command "move immediate byte hexadecimally encoded 30 into low half of the first register". However, the convention is to stick to Intel's original mnemonics.
Intel 8086 and 8088 had 14 16-bit registers. Four of them (AX, BX, CX, DX) were general purpose (although each had also an additional purpose; for example only CX can be used as a counter with the loop instruction). Each could be accessed as two separate bytes (thus BX's high byte can be accessed as BH and low byte as BL). In addition to them, there are 4 segment registers (CS, DS, SS and ES). They are used to form a memory address. There are 2 pointer registers (SP which points to the bottom of the stack, and BP which can be used to point at some other place in the stack or the memory). There are two index registers (SI and DI) which can be used to point inside an array. Finally, there are the flag register (containing flags such as carry, overflow, zero and so on), and the instruction pointer (IP) which points at the current instruction. Both can't be changed directly.
In real mode, memory access is segmented. This is done by shifting the segment address left by 4 bits and adding an offset in order to receive a final 20-bit address. Thus the total address space in real mode is 220 bits, or 1 MB, quite an impressive figure for 1978. There are two addressing modes: near and far. In far mode, both the segment and the offset are specified. In near mode, only the offset is specified, and the segment is taken from the appropriate register. For data the register is DS, for code is CS, and for stack it is SS. For example, if DS is A000h and SI is 5677h, DS:SI will point at the absolute address DS × 16 + SI = A5677h.
In this scheme, two different segment/offset pairs can point at a single absolute location. Thus, if DS is A111h and SI is 4567h, DS:SI will point at the same A5677h as above. In addition to duplicacy, this scheme also makes it impossible to have more than 4 segments at once. Moreover, CS, DS and SS are vital for the correct functioning of the program, so that only ES can be used to point somewhere else. This scheme, which was intended as a compatibility measure with the Intel 8085 has caused no end of grief to programmers.
In addition to the above-said, the 8086 also had 64K of 8-bit (or alternatively 32K of 16-bit) I/O space, and support for up to 256 interrupts. A 64K (one segment) stack in memory is supported by hardware. Only words (2 bytes) can be pushed to the stack. The stack grows downwards, its bottom being pointed by SS:SP. There are 256 interrupts, which can be created by both the hardware and the software. The interrupts can cascade, using the stack to store the return address.
Protected and Enhanced Modes
The Intel 80286 could support 8086 Real Mode 16-bit software without any changes, however it also supported another mode of work called the Protected Mode, which expanded adresable memory to 16MB. This was done by using the segment registers only for storing an index to a segment table. The segment table provided a 24-bit base address, which could then be added to the desired offset to create an absolute address. In addition, each segment could be given one of four privelige levels (called the rings). Overall, the introductions were an improvements; however they were not used widely per se because using Protected Mode made software incompatible with the Real Mode of 8086.
The Intel 80386 introduced, perhaps, the greatest leap so far in the x86 architecture. It was 32-bit - all the registers, instructions, I/O space and memory. To work with the latter, it used Enhanced Mode, a 32-bit extension of Protected Mode. As it was in the 286, segment registers were used to index inside a segment table that described the division of memory. Unlike the 286, however, inside each segment one could use 32-bit offsets, which allowed every application to access up to 4GB of memory. In addition, Enhanced Mode supported paging, a mechanism which made it possible to use virtual memory.
No new general-purpose registers were added. All 16-bit registers except the segment ones were expanded to 32 bits. Intel represented this by adding "E" to the register mnemonics (thus the expanded AX became EAX, SI became ESI and so on). Since there was a greater number of registers, instructions and operands, the machine code format was expanded as well. In order to provide backwards compatibility, the segments which contain executable code can be marked as containing either 16 or 32 bit instructions. In addition, a special byte prefix can be used to include 32-bit instructions in a 16-bit segment and vice versa.
Paging and segmented memory access were both required in order to support a modern multitasking operating system. Linux, 386BSD, Windows NT and Windows 95 were all initially developed for the 386, because it was the first CPU that made it possible to reliably support the separation of programs' memory space (each into its own address space) and the preemption of them in the case of necesity (using rings). The basic architecture of the 386 (which is also called IA32) became the basis of all further development in the x86 series, and no significant changes have been made to it since, thus exemplifying the elegance and scalability of the 386's design.
The Intel 80387 math co-processor was integrated into the next CPU in the series, the Intel 80486. The new FPU could be used to make floating point calculations, important for scientific calculation and graphic design.
MMX and beyond
1996 saw the appearance of the MMX (Multimedia Extensions) technology by Intel. While the new technology has been advertised widely and vaguely, its essence is very simple: MMX added 8 64-bit registers to the Intel Pentium CPU design. Instructions were added to the CPU so that it could support moving the registers' contents from and to the memory, and perform arithmetic operations upon them more quickly and with more convenience than before.
While MMX itself was not a ground-breaking success, it overcame to an extent the x86 architecture's greatest defficiency: the lack of general-purpose registers (only 4 to 6, depending on the task, when some architectures offer up to 128!). The additional registers could be used to store extra variables, perform vector transformations and do all sorts of useful calculations with registers, that would otherwise have to be much slower due to the need to continuously access the variables in memory. Thus, while a very-well optimised assembly code could run almost as fast as MMX, its presence made generic programming (without spending much time on optimisations) much easier.
x86 and compatibles are manufactured by: