Note sorting comes from Wangdao postgraduate entrance examination
Instruction format
-
Also known as machine instruction, it refers to the command for the computer to perform a certain operation, which is the smallest functional unit of the computer operation
-
The set of all instructions of a computer constitutes the instruction set
-
A computer can only execute the instructions of its own instruction system, but cannot execute the instructions of other systems
Instruction format-address code
-
Fixed length instruction word structure: fixed instruction length
-
Variable length instruction word structure: instruction length is not equal
Instruction format-opcode
The opcode is the OP above
- Fixed length opcode: n bits -> 2^n instructions
- Variable length opcode -> extended opcode
Extended opcode
- Short opcodes are not allowed to be prefixes of long codes
- The opcode of each instruction must not be repeated
In the upper-level instruction format, we leave one or more operands in the instruction number of the opcode as the next-level instruction extension. For example, in the three-address instruction format, we leave all 1s (1111 ) To extend the next level two address instruction format, because the 4-bit opcode and 8-bit opcode may cause recognition problems when reading, so set aside 1111 as the next level extension, which means reading the first 4 bits At 1111, it means that the next read is the opcode, not the address code, which is the format of the second instruction.
- Under normal circumstances, for instructions with higher frequency of use, shorter opcodes are allocated, and for instructions with lower frequency of use, longer opcodes are allocated to reduce instruction decoding and analysis time
example
Operation type of the instruction
- data transmission
- Arithmetic logic
- Shift operations (arithmetic, logic, loop)
- Transfer operation
- Input and output operations
Instruction addressing
Data storage
- Byte storage, word storage
- Machine word length, instruction word length, storage word length
Boundary aligned and unaligned storage
Boundary alignment: the starting address is an integer multiple of the word length (in bytes)
Addressing mode (two types)-given by the program counter PC
- Sequential addressing
- Skip addressing
Data addressing
Operand type
address | digital | character | Logical number |
---|---|---|---|
Unsigned number | Fixed-point, floating-point, decimal | ASCII code | logic operation |
Addressing mode
Use different addressing methods to process the formal address to find the effective address
Address immediately
Direct addressing
Indirect addressing
Register addressing
Registers are some small storage areas used to store data inside the CPU, which are used to temporarily store the data involved in operations and the results of operations
Register indirect addressing
Implicit addressing
Addressing mode | Effective address | Memory fetches |
---|---|---|
Implicit addressing | Program designation | 0 |
Address immediately | A is the operand | 0 |
Direct addressing | EA = A | 1 |
Indirect addressing | EA = (A) | 2 |
Register addressing | EA = Ri | 0 |
Register Clip One Address | EA = (Ri) | 1 |
Offset addressing
-
Base addressing
-
Indexed addressing
-
Relative addressing
example
Addressing mode | Effective address | Fetch address |
---|---|---|
Relative addressing | EA = (PC) + A | 1 |
Base addressing | EA = (BR) + A | 1 |
Indexed addressing | EA = (IX) + A | 1 |
Stack addressing
Hardware that implements the stack
- Hard stack
- Use main memory to call soft stack
CISC and RISC
CISC | RISK |
---|---|
Complex instruction set | Reduced instruction set |
One instruction completes a complex basic function | One instruction completes a basic "action", and a combination of multiple instructions completes a complex basic function |
X86 architecture, notebook, desktop | ARM architecture, mobile phones, tablets |