按位元指令(bitwise instruction), 包括AND, OR, XOR, NOT及TEST等邏輯運算元, 執行時來源參數中的每個位元與目的參數中相同位置的位元做運算.
CMP指令將目的運算元和來源運算元作比較, 換句話說, 由目的參數減來源參數而不保留相減的結果, CMP會依這個隱含的減法指令結果來修改CPU狀態的旗標值(flag value). CMP的後面通常緊接著條件跳耀指令(conditional jump instruction), 來將程式控制權移到某個程式碼標籤處, 常見的跳耀指令類型有:
- 根據特定指標值(Jumps based on Specific flags), 例如: JC(jump carry), JZ(jump zero)..等.
- 根據是否相等(Jumps based on Equality), 例如: JE(jump equal), JNE(jump not equal)...等.
- 根據有號整數比較結果(Jumps based on Signed Comparisons), 例如:JL(jump if less), JG(jump if greater)...等.
- 根據無號整數比較結果(Jumps based on Signed Comparisons), 例如:JA(jump if above), JB(jump if below)...等.
學習目標:
1. Boolean and Comparison Instructions
- CPU Status Flags
- AND, OR, XOR, NOT and TEST instructions
2. Conditional jumps
- Jumps Based on (Specific flags, equality, unsigned comparisons...)
3. Conditional Structures
- Block-Structured IF statements
- Compound Expression with AND
- Compound Expression with OR
- WHILE Loops
- TABLE-Driven Selection
沒有留言:
張貼留言