Hardware Foundations for Software Performance
ISA Interface
The Software-Hardware Contract
Software doesn't directly command the transistors in a processor. Instead, it speaks a specific language that the hardware is built to understand. This language, a set of fundamental commands the processor can execute, is called the Instruction Set Architecture, or ISA. It's the critical interface that decouples the fast-moving world of software from the more methodical pace of hardware design.
ISA is the contract between software and hardware.
Think of an ISA as the menu at a restaurant. The menu lists all the dishes the kitchen knows how to make (the instructions). A programmer, like a customer, can only order what's on the menu. They can combine these dishes in infinite ways to create a full meal (a program), but they can't ask the kitchen to make something it doesn't have the recipe for. This contract allows different chefs (hardware engineers) to build kitchens (processors) in various ways, as long as they can all produce the dishes on that same menu.
Encoding Instructions
Every instruction a processor can execute is represented by a unique pattern of bits. This binary representation is broken into two main parts: the opcode and the operands.
- Opcode (Operation Code): This is the verb of the instruction. It tells the CPU what to do, like
ADD,STORE, orJUMP. - Operands: These are the nouns. They specify the data or memory locations the opcode will act upon. For example, in an
ADD R1, R2instruction,ADDis the opcode, and the registersR1andR2are the operands.
This structure must be rigidly defined. The CPU needs to know exactly how many bits make up the opcode and where to find the data for the operands. This encoding scheme is a core part of the ISA's specification.
The way these opcodes and operands are designed leads to two major philosophical camps in processor design: CISC and RISC.
Design Philosophies CISC vs RISC
Not all processor
