
1. Overview of Single-Byte Instructions
1.1 Basic Concepts
A single-byte instruction refers to an instruction that contains only the opcode field and has no explicit operands. These instructions typically have the following characteristics:
- The operand is implicit in the instruction
- The instruction length is fixed at 1 byte
- High execution efficiency
1.2 Common Examples of Single-Byte Instructions
| Instruction | Opcode (Hexadecimal) | Function Description |
|---|---|---|
| AAA | 37 | ASCII Addition Adjustment |
| AAS | 3F | ASCII Subtraction Adjustment |
| CBW | 98 | Convert Byte to Word |
| LODSB | AC | Load Byte into AL |
| XLAT | D7 | Table Lookup Conversion |
2. Principles of Immediate Operand Encoding
2.1 Little-Endian Storage
Immediate operands are stored in Little-Endian format:
- Low byte stored at low address
- High byte stored at high address
2.2 Register Encoding Rules
| Register | Number | Register | Number |
|---|---|---|---|
| AX/AL | 0 | SP/AH | 4 |
| CX/CL | 1 | BP/CH | 5 |
| DX/DL | 2 | SI/DH | 6 |
| BX/BL | 3 | DI/BH | 7 |
3. Instruction Encoding Example Analysis
3.1 Single-Byte Instruction Encoding
Example 1: PUSH CX
Machine Instruction: 51
Encoding Process:
1. PUSH 16-bit Register Base Opcode: 50
2. CX Register Number: 1
3. Final Opcode: 50 + 1 = 51
3.2 Immediate Number Instruction Encoding
Example 2: MOV AX, 1
Machine Instruction: B8 01 00
Encoding Process:
1. Immediate Number to 16-bit Register Base Opcode: B8
2. AX Register Number: 0 → B8 + 0 = B8
3. Immediate Number 0001 stored in Little-Endian: 01 00
Example 3: MOV BX, 1234h
Machine Instruction: BB 34 12
Encoding Process:
1. Immediate Number to 16-bit Register Base Opcode: B8
2. BX Register Number: 3 → B8 + 3 = BB
3. Immediate Number 1234h stored in Little-Endian: 34 12
4. Detailed Explanation of Encoding Modes
4.1 Register Mode Instruction Format
MOV reg, immediate Instruction Format:
[Opcode B8+rw] [Immediate Low Byte] [Immediate High Byte]
4.2 Special Optimization Design
The reason instruction set designers provide unique opcodes for commonly used instructions is:
- Code Size Optimization: Reducing instruction length
- Execution Speed Optimization: Improving instruction decoding and execution efficiency
- Hardware Implementation Simplification: Reducing processor complexity
5. Practical Application Recommendations
5.1 Learning Recommendations
- Manual Assembly Practice: Try manually encoding common instructions
- Verification by Comparison: Use MASM to generate code for comparison
- Understanding Principles: Deeply grasp encoding rules rather than rote memorization
5.2 Encoding Techniques
- Remember the Register Number Table
- Master Little-Endian Storage Rules
- Understand the relationship between Opcode Base Value and Register Offset
6. Conclusion
The encoding of single-byte instructions and immediate operands reflects the design philosophy of the x86 architecture:
- Simplifying instruction encoding through register numbering
- Using Little-Endian to optimize memory access
- Providing dedicated opcodes for common operations to improve efficiency
This encoding design achieves a good balance between code density and execution efficiency while maintaining backward compatibility, serving as an important foundation for modern processor architecture design.