Instruction Set Architecture
Four Types of ISAs.
- Stack Architrectures. All operation refer to operands in stack
and implicitly operate on the top stack operands.
- Accumulator Architectures. They can be thought of as a single
register architecture. All operations implicitly name the accumulator
as one operand. The other operand if it exists is explicitly names
and is found in memory.
- General Register Architectures. The architecture supports
general purpose registers. Operands for operations can be found
either in registers or in memory.
- Load-Store Architectures. The architecture supports general
purpose registers. All operands for operations are found in
registers. The only operations that access operations are load and
store instructions. This is the RISC approach.
Why are Registers Good?
There are three reasons for prefering register operands to memory
operands. Registers are faster than memory, they reduce memory and
interconnect traffic, and they are more compact when naming them. A
32-register architecture only requires 5 bits to name a register,
while it requires between 30-40 bits to name a memory location.
Addressing Modes
The addressing modes specifies how a particular instruction operand
should be interpreted. There is a large number of addressing modes
but the important ones are:
- Register: Add R4,R3 ---- R4 = R4+R3
- Immediate: Add R4,#3 ---- R4 = R4+3
- Displacement: Add R4,100(R1) ---- R4 = R4+Mem[100+R1]
Most RISC processor only support these three addressing modes. All
other addressing modes can be constructed from these. For Immediate
and Displacement modes it is important to know how big the Immediate
and Displacement numbers can be. Most processors use 16 bits. If you
want larger immediate number you have the use the LUI instrustion
which loads a 16-bit immediate number on the top 16 bits of a 32-bit
register.
Types Of Instructions
- Data Movement (load, store, etc.)
- Arithmetic (add, subtract, multiply, divide, etc.)
- Logical (or, and, not, etc)
- Control Flow (branch, jump, call subroutine, etc.)
- Miscellaneous (synchronization, trap, etc.)
Frequency of Instruction on an 80x86
- Load ---- 22%
- Conditional Branch ---- 20%
- Compare ---- 16%
- Store ---- 12%
- Add ---- 8%
- And ---- 6%
- Sub ---- 5%
- Move register-register ---- 4%
- Call ---- 1%
- Return ---- 1%
- Other ---- 4%