On this page
Multiplication and Division
This program demonstrates the multiplication and division operations available in the 8051 instruction set.
Description
The program performs both multiplication and division on two 8-bit numbers and stores the results in internal RAM.
Memory Locations
- 33H: First operand (A)
- 34H: Second operand (B)
- 35H: Multiplication result (higher byte)
- 36H: Multiplication result (lower byte)
- 37H: Division remainder
- 38H: Division quotient
Code
| |
Explanation
Multiplication (MUL AB)
- MOV A, 33H: Load first number into A
- MOV B, 34H: Load second number into B
- MUL AB: Multiply A × B
- Result: 16-bit product
- A: Lower 8 bits
- B: Higher 8 bits
- Store results in memory (35H and 36H)
Division (DIV AB)
- MOV A, 33H: Load dividend into A
- MOV B, 34H: Load divisor into B
- DIV AB: Divide A ÷ B
- A: Quotient
- B: Remainder
- Store results in memory (37H and 38H)
Example
If 33H = 25 (decimal) and 34H = 4 (decimal):
- Multiplication: 25 × 4 = 100 (0064H)
- 35H = 00H (higher byte)
- 36H = 64H (lower byte)
- Division: 25 ÷ 4 = 6 remainder 1
- 37H = 01H (remainder)
- 38H = 06H (quotient)
Both operations automatically set the OV (overflow) flag if needed.