Behind the scenes of CPU | How a CPU works | 0x03 | Bin exp#4
Hi friends, in the last blog I write about the C compilation process in this blog we are going to see the behind of the process of CPU and How a Cpu works. So let’s get started.
Content :
- What is a CPU?
- The CPU registers
- How a CPU works?
What is a CPU?
→It stands for Central Processing Unit.
→Simply, it follows some simple arithmetic operations to solve complex tasks.
→Inside Cpu, many processors are placed.
→And each processor within a CPU has its own ALU(Arithmetic Logic Unit), FPU(Floating point unit ), registers, and cache memory.
→The cache is the fastest Memory of the CPU.
→cache in a processor is aimed to store some frequently used instructions so that the next time in the time of execution the CPU can take it from the cache memory.
The CPU registers
→Registers are the fastest volatile memory unit that is placed within a processor of the CPU.
→Generally, registers are many types but for us knowing GPR’s(General Purpose Registers) is enough.
→Commonly registers are of two modes that are 32-bit and 64-bit
→In 32-bit the registers are named like EIP, EBP, etc.. but, In 64-bit the registers are named like RIP, RBP, etc.
→General-purpose registers are of 4 types that are ,
- Data registers
- Index pointers
- Pointer registers
- Special registers
Data registers:
- RAX/EAX → Extended Accumulator
- RBX/EBX → Extended Base register
- RCX/ECX → Extended Control register
- RDX/EDX → Extended Data Register
Simply the above registers are to do some Arithmetic Process.
Index Registers:
- RSI/ESI → Extended Source index
- RDI/EDI → Extended Destination index
The above registers are used when a process like COPY PASTE has occurred. Because the process COPY PASTE need both source address and destination address
Pointer Registers:
- RSP/ESP → Extended Stack pointer
- RBP/RSP → Extended Base pointer
These registers are used to do stuff with STACK and for now, The RSP registers are used to trace the top of the STACK and the RBP is used to trace the Boundaries of the function. For now, it may be looks weird but in the next blog, it gets clear to you.
Special Registers:
RIP/EIP → Extended Instruction pointer or Program Counter.
It’s is one of the Important register, which holds the memory address of the currently running process.
How a CPU works?
Now it is a storytime,
At the time when you executed the binary, the Operating System creates a place on Main Memory(RAM) for the binary to load on it. Now the instructions(x86-code) are load to the RAM by having a unique memory address for each line of instruction. Now the register named RIP fetches the loaded instruction’s on the RAM and Process that and Executed that binary. And other registers also play certain roles at the time of execution.
This is a simple overview of how the CPU works.
Hope you guys enjoy this blog.
And if you have any doubt’s DM me on Twitter: https://twitter.com/0xCyber_Zombie
And don’t forget to Subscribe to my YouTube Channel.
And Happy Hacking…!!!