MindMap Gallery Chapter 4 Command System
This is a mind map about Chapter 4 Instruction System, including the instruction system, the addressing mode of instructions, the machine-level code representation of the program, etc.
Edited at 2024-01-16 15:52:47El cáncer de pulmón es un tumor maligno que se origina en la mucosa bronquial o las glándulas de los pulmones. Es uno de los tumores malignos con mayor morbilidad y mortalidad y mayor amenaza para la salud y la vida humana.
La diabetes es una enfermedad crónica con hiperglucemia como signo principal. Es causada principalmente por una disminución en la secreción de insulina causada por una disfunción de las células de los islotes pancreáticos, o porque el cuerpo es insensible a la acción de la insulina (es decir, resistencia a la insulina), o ambas cosas. la glucosa en la sangre es ineficaz para ser utilizada y almacenada.
El sistema digestivo es uno de los nueve sistemas principales del cuerpo humano y es el principal responsable de la ingesta, digestión, absorción y excreción de los alimentos. Consta de dos partes principales: el tracto digestivo y las glándulas digestivas.
El cáncer de pulmón es un tumor maligno que se origina en la mucosa bronquial o las glándulas de los pulmones. Es uno de los tumores malignos con mayor morbilidad y mortalidad y mayor amenaza para la salud y la vida humana.
La diabetes es una enfermedad crónica con hiperglucemia como signo principal. Es causada principalmente por una disminución en la secreción de insulina causada por una disfunción de las células de los islotes pancreáticos, o porque el cuerpo es insensible a la acción de la insulina (es decir, resistencia a la insulina), o ambas cosas. la glucosa en la sangre es ineficaz para ser utilizada y almacenada.
El sistema digestivo es uno de los nueve sistemas principales del cuerpo humano y es el principal responsable de la ingesta, digestión, absorción y excreción de los alimentos. Consta de dos partes principales: el tracto digestivo y las glándulas digestivas.
Chapter 4 Command System
command system
command system
The instruction system is the core part of the instruction set architecture (ISA). ISA completely defines the interface between software and hardware.
Basic format of instructions
zero address instruction
one address command
Two address instructions
Three address instructions
Four address instructions
Fixed-length opcode instruction format
Fixed-length opcodes are very beneficial for simplifying computer hardware design and improving instruction decoding and recognition speed.
Extended opcode instruction format
The operation type of the instruction
data transmission
Transfer between registers (MOV)
The memory unit reads data into the CPU register (LOAD)
CPU register writes data to memory unit (STORE)
Arithmetic and logical operations
Add (ADD), subtract (SUB), compare (CMP), multiply (MUL), divide (DIV), add 1 (INC), subtract 1 (DEC), AND (AND), or (OR), negate ( NOT), exclusive OR (XOR)
shift operation
Arithmetic shift, logical shift, circular shift
program control instructions
Loop control instructions
LOOP L1. Each time this instruction is executed, the number of loops in the loop counter ECX is decremented by 1, and then it is judged whether ECX is 0. If it is not 0, the program will go to L1 to continue execution; otherwise, the loop will end and the next instruction of the LOOP instruction will be executed.
transfer instruction
unconditional transfer
conditional transfer
Use JZ and JNZ to represent branching when = and ≠, and use JGE/JAE, JG/JA, JLE/JBE, and JL/JB to represent branching when ≥, >, ≤, and < of signed/unsigned numbers respectively.
Subroutine call and return instructions
subroutine call instructions
The address of the next instruction of the rotor instruction in the main program is called a breakpoint, and the breakpoint is the return address when the subprogram returns to the main program.
call instruction in x86, jal instruction in MIPS
Return command
ret instruction in x86, jr $ra instruction in MIPS.
The difference between call instructions and transfer instructions
Transfer instructions transfer within the same program, while rotor instructions transfer between different programs.
The transfer instruction does not need to return to the original position, while the rotor instruction does not need to return to the original position.
Rotor instructions and return instructions are usually unconditional, while conditional transfer instructions require conditions.
Input and output operations
When the external device and the main memory adopt a unified addressing mode, there is no need to set up dedicated I/O instructions, and the memory access instructions can be used to directly access the external device.
stack manipulation instructions
String processing instructions
Instruction addressing mode
Instruction addressing and data addressing
Instruction addressing (finding the address of the next instruction to be executed is called instruction addressing)
sequential addressing
The address of the next instruction is formed by adding one to PC, that is, EA=(PC) “1” of the address of the next instruction. Among them, "1" is the number of storage units occupied by the current instruction.
skip addressing
Absolute address (obtained directly from the marker)
Relative address (offset relative to the current instruction address)
Data addressing (finding the data address of this instruction is called data addressing)
Common data addressing methods
implicit addressing
Immediate (number) addressing
MOV EAX,2008H
Direct addressing
MOV EAX,[2008H]
Indirect addressing
MOV EAX,@2008H; @ is the indirect addressing flag
Register addressing
MOV EAX,ECX
register indirect addressing
MOV AL,[EBX]
relative addressing
EA=PC 1D
base addressing
Use special registers: The base address register uses implicit addressing method and does not need to be explicitly pointed out in the instruction. The formal address field in the instruction gives the offset value involved in base addressing. Using general registers: You need to add a register number field to indicate the number of the base address register used.
indexed addressing
MOV EAX,32[ESI] #Add the offset 32 to the value of the index register ESI to form an address to access the main memory, and send the result to EAX.
stack addressing
memory stack
register stack
machine-level code representation of a program
Assembly instruction format
Comparison of AT&T format commands and Intel format commands
Common instructions (Intel format)
The labels used for the operands represent registers, memory, and constants respectively.
<reg>: represents any register. If there is a number after it, specify its number of digits.
<mem>: represents the memory address
<con>: represents an 8-bit, 16-bit or 32-bit constant
data transfer instructions
mov instruction
push instruction
pop command
Arithmetic and logical operation instructions
jmp command
Pay attention to distinguishing between jmp (unconditional jump) and jcondition (conditional jump instructions)
jcondition instruction
cmp/test command
cmp and test instructions are usually used in conjunction with the jcondition instruction
call/ret instruction
Common arithmetic operation instructions
Common logical operation instructions
Machine-level representation of procedure calls
Assume that process P (caller) calls process Q (callee). The execution steps of the procedure call are as follows
1) P places the entry parameters (actual parameters) where Q can access them.
2) P stores the return address in a specific place, and then transfers control to Q. CALL instruction
3) Q saves the location of P (the contents of the general register) and allocates space for its own non-static local variables.
4) Execute process Q.
5) Q restores the scene of P, puts the returned result somewhere that P can access, and releases the space occupied by local variables.
6) O takes out the return address and transfers control to P. RET instruction
Function call instruction: call <function name>
①Push the old IP value onto the stack (save it at the top of the stack frame of the function) ② Set the new value of IP and unconditionally transfer to the first instruction of the called function
Function return instruction: ret
Find the old IP value (i.e. return address) from the top of the stack frame of the function, pop it off the stack and restore the IP register
Mark stack frame range: EBP, ESP register
ebp: Points to the "bottom" of the current stack frame
esp: points to the "top" of the current stack frame
Access to data within the stack frame is based on ebp and esp.
How to access stack frame?
How to switch stack frames when a function is called?
"Routine processing" at the beginning of each function
push ebp #Save the stack frame base address of the previous layer function (old value of ebp)
mov ebp,esp #Set the stack frame base address of the current function (ebp new value)
How to switch stack frames when a function returns?
"Routine processing" before each function ret
Note: The bottom of each stack frame is used to save the base address of the previous stack frame.
mov esp, ebp #Let esp point to the bottom of the current stack frame
pop ebp #Pop the element pointed to by esp from the stack and write it to the register ebp
What content may be contained in a stack frame
Machine-level representation of select statements
unconditional transfer instruction
jmp<address> #PC unconditionally transferred to <address> jmp 128 #<address> can be given as a constant jmp eax #<address> can come from a register jmp[999] #<address> can come from main memory jmp NEXT #<address> can be anchored with "label"
The underlying principle of the cmp instruction
Essentially, it performs a-b subtraction operation and generates flag bits OF, ZF, CF, SF
je<address> #If a==b, jump, ZF==1?
jne<address> #If a!=b, jump, ZF==0?
jg<address> #If a>b, jump, 2F==0 && SF==OF?
jge<address> #If a>=b, jump, SF==OF?
jl<address> #If a<b, jump, SF!=OF?
jle<address> #If a<=b, jump, SF!=OF||ZF==1?
Machine-level representation of loop statements
Implementing loops using conditional transfer instructions
Use loop instruction to implement loop
Basic concepts of CISC and RISC
Complex Instruction System Computer (CISC)
main feature
The command system is complex and huge
The length of the instruction is not fixed, there are many instruction formats, and there are many addressing modes.
There are no restrictions on the instructions that can be accessed from memory
The frequency of use of various instructions varies greatly.
The execution time of various instructions varies greatly, and most instructions require multiple clock cycles to complete.
Most controllers use microprogram control
It is difficult to generate efficient object code programs with optimized compilation
Most of them can achieve software compatibility, that is, high-end machines contain all the instructions of low-end machines and can be expanded.
Reduced Instruction System Computer (RISC)
main feature
Select some of the most frequently used simple instructions. The functions of complex instructions are realized by a combination of simple instructions.
The instruction length is fixed, there are few types of instruction formats, and there are few types of addressing modes.
Only Load/Store (fetch/store) instructions access memory, and the operations of other instructions are performed between registers.
The number of general-purpose registers in the CPU is quite large
RISC must use instruction pipeline technology, and most instructions are completed within one clock cycle.
Mainly based on hard wiring control, no or less use of micro-program control
Pay special attention to compilation optimization work to reduce program execution time
Most RISC machines are not compatible with older machines
Comparison of CISC and RISC