07-28-2014, 01:25 PM
(This post was last modified: 07-28-2014, 01:26 PM by Cutlassw30.)
X86 IS NOT BAD BECAUSE X86 IS CISC. X86 IS BAD BECAUSE ITS X86
After a recent argument It seems that many people have no clue as to why x86 is a shitty architecture and blame it on it being CISC. The CISC features of x86 however is not what makes it bad but its all in the memory management. You see even back in the 16 bit i8086 days (original x86) and to the 64 bit super scalar out of order gigahertz beasts of today x86 has always had terrible memory accessing schemes. I will first start off with the 8086 (no virtual memory aka "real mode"):
On the 8086 or on modern x86 processors in real mode accessing memory is a pain in the ass. Why is that? well because of all the bullshit that needs to happen for it. You see real mode x86 has 13 registers in 16 bit mode, these are: AX, BX, CX, DX, SI, DI, BP, SP, CS, DS, ES, SS, IP, FL
AX, BX, CX, DX, SI, and DI: Are for sake of argument general purpose registers (They all have special uses but are used generally in programs)
BP and SP: Are for manipulating the stack
IP: Is the instruction pointer (or program counter)
FL: Is the flags register which holds what state the processor is currently in.
CS, DS, ES, SS: Are 20 bit segment registers... yes thats right 20 bit registers on a 16 bit CPU. These are used in, you guessed it memory access. CS stands for code segment, DS stands for data segment, ES stands for extra segment, SS stands for stack segment. When you are loading an instruction the code segment is used, when you are using data from RAM data,extra,and stack segments can be used. So what do these do? well for example in the instruction:
ADD AX,[BX+12]
On a normal processor this would take the value of BX add 12 to it and access memory at that location (BX+12) and then use that to add with AX. This is how most processors of that time worked (and thats what separates RISC processors from CISC is that RISC works off internal registers and CISC can do operations directly on main memory aka RAM).
But in x86 they thought they where all fancy and the instruction:
ADD AX,[BX+12]
Actually means
ADD AX,[DS<<4+(BX+12)]
Thats right in x86 you first add BX+12 then add that to the data segment shifted left 4 times to get your memory address then do the final addition. Not only is it a pain in the ass to program but it also takes 4 different operations just to add two numbers together! You have to:
ADD BX+12
SHIFT DS<<4
ADD result of DS<<4 + result of BX+12
ADD the two numbers the programmer wanted to.
As you can see this is really fucking slow and frankly a pain to program. The reason x86 did this was to allow 1 megabyte of RAM instead of 64k which really wasn't worth it because to access that upper 640k of RAM you had to use some werid shifted 20 bit register which made it a bitch to program.
But wait there's more! Some overpaid engineer had the bright idea to figure out that sometimes the 3rd add would have a carry out. And guess what they made it so that the carry out could be used as another address line getting around 2 megs of RAM that was even harder to access! Now an entire 1 meg of RAM would only be used during a COUT of the 3rd addition, great.
But wait even more! Guess where they decided to put the AND gate to enable this "feature". Nope not in the CPU, Not in the RAM controller, THEY PUT IT IN THE FUCKING KEYBOARD CONTROLLER. Yes to access more RAM you must interact with the PC keyboard PS/2 controller first. No lie this is called the "A20 gate" which is a reference to the AND gate on address 20 line.
http://en.wikipedia.org/wiki/A20_line
"It was originally a hack put on the IBM PC keyboard controller"
*FACEDESK*
This my dear is why x86 "real mode" is a big lump of shit.
Why is x86-64 a lump of shit? Well to access memory with the virtual memory scheme (which implements segmentation bounds and 2 level paging) can best be summed up with this diagram. Each of the tables is a place in RAM that must be accessed before the data from RAM can be accessed (Note this is outside of the instruction!)
So for example:
ADD AX,[BX+12]
The operations we must do are:
ADD BX+12
Load this shit from RAM using the above addition as the "logical address":
ADD the two numbers
/thread
After a recent argument It seems that many people have no clue as to why x86 is a shitty architecture and blame it on it being CISC. The CISC features of x86 however is not what makes it bad but its all in the memory management. You see even back in the 16 bit i8086 days (original x86) and to the 64 bit super scalar out of order gigahertz beasts of today x86 has always had terrible memory accessing schemes. I will first start off with the 8086 (no virtual memory aka "real mode"):
On the 8086 or on modern x86 processors in real mode accessing memory is a pain in the ass. Why is that? well because of all the bullshit that needs to happen for it. You see real mode x86 has 13 registers in 16 bit mode, these are: AX, BX, CX, DX, SI, DI, BP, SP, CS, DS, ES, SS, IP, FL
AX, BX, CX, DX, SI, and DI: Are for sake of argument general purpose registers (They all have special uses but are used generally in programs)
BP and SP: Are for manipulating the stack
IP: Is the instruction pointer (or program counter)
FL: Is the flags register which holds what state the processor is currently in.
CS, DS, ES, SS: Are 20 bit segment registers... yes thats right 20 bit registers on a 16 bit CPU. These are used in, you guessed it memory access. CS stands for code segment, DS stands for data segment, ES stands for extra segment, SS stands for stack segment. When you are loading an instruction the code segment is used, when you are using data from RAM data,extra,and stack segments can be used. So what do these do? well for example in the instruction:
ADD AX,[BX+12]
On a normal processor this would take the value of BX add 12 to it and access memory at that location (BX+12) and then use that to add with AX. This is how most processors of that time worked (and thats what separates RISC processors from CISC is that RISC works off internal registers and CISC can do operations directly on main memory aka RAM).
But in x86 they thought they where all fancy and the instruction:
ADD AX,[BX+12]
Actually means
ADD AX,[DS<<4+(BX+12)]
Thats right in x86 you first add BX+12 then add that to the data segment shifted left 4 times to get your memory address then do the final addition. Not only is it a pain in the ass to program but it also takes 4 different operations just to add two numbers together! You have to:
ADD BX+12
SHIFT DS<<4
ADD result of DS<<4 + result of BX+12
ADD the two numbers the programmer wanted to.
As you can see this is really fucking slow and frankly a pain to program. The reason x86 did this was to allow 1 megabyte of RAM instead of 64k which really wasn't worth it because to access that upper 640k of RAM you had to use some werid shifted 20 bit register which made it a bitch to program.
But wait there's more! Some overpaid engineer had the bright idea to figure out that sometimes the 3rd add would have a carry out. And guess what they made it so that the carry out could be used as another address line getting around 2 megs of RAM that was even harder to access! Now an entire 1 meg of RAM would only be used during a COUT of the 3rd addition, great.
But wait even more! Guess where they decided to put the AND gate to enable this "feature". Nope not in the CPU, Not in the RAM controller, THEY PUT IT IN THE FUCKING KEYBOARD CONTROLLER. Yes to access more RAM you must interact with the PC keyboard PS/2 controller first. No lie this is called the "A20 gate" which is a reference to the AND gate on address 20 line.
http://en.wikipedia.org/wiki/A20_line
"It was originally a hack put on the IBM PC keyboard controller"
*FACEDESK*
This my dear is why x86 "real mode" is a big lump of shit.
Why is x86-64 a lump of shit? Well to access memory with the virtual memory scheme (which implements segmentation bounds and 2 level paging) can best be summed up with this diagram. Each of the tables is a place in RAM that must be accessed before the data from RAM can be accessed (Note this is outside of the instruction!)
So for example:
ADD AX,[BX+12]
The operations we must do are:
ADD BX+12
Load this shit from RAM using the above addition as the "logical address":
ADD the two numbers
/thread