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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
; A -> 33H
; B -> 34H

ORG 0000H
	
	MOV A,33H
	MOV B,34H
	
	MUL AB ; A-> Lower Byte B-> Higher Byte
	MOV 35H , B
	MOV 36H , A

	MOV A,33H
	MOV B,34H
	DIV AB ; A-> Quotient B->Remainder
	MOV 37H , B ; Remainder
	MOV 38H , A ; Quotient
	
END

Explanation

Multiplication (MUL AB)

  1. MOV A, 33H: Load first number into A
  2. MOV B, 34H: Load second number into B
  3. MUL AB: Multiply A × B
    • Result: 16-bit product
    • A: Lower 8 bits
    • B: Higher 8 bits
  4. Store results in memory (35H and 36H)

Division (DIV AB)

  1. MOV A, 33H: Load dividend into A
  2. MOV B, 34H: Load divisor into B
  3. DIV AB: Divide A ÷ B
    • A: Quotient
    • B: Remainder
  4. 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.