0% found this document useful (0 votes)
2 views3 pages

Exp4 - With Program

The document outlines an algorithm and an assembly language program for the 8051 microcontroller to multiply two 16-bit numbers stored in specific memory locations. The result is a 32-bit value stored across four memory locations. The algorithm includes detailed steps for loading values, performing multiplications, handling carries, and storing results.

Uploaded by

ebinkbbirikkulam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Exp4 - With Program

The document outlines an algorithm and an assembly language program for the 8051 microcontroller to multiply two 16-bit numbers stored in specific memory locations. The result is a 32-bit value stored across four memory locations. The algorithm includes detailed steps for loading values, performing multiplications, handling carries, and storing results.

Uploaded by

ebinkbbirikkulam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Exp4:

Multiplication of two 16-bit numbers

AIM:

Write an algorithm and an 8051 microcontroller assembly language program to


multiply two 16-bit numbers. The first 16-bit number is stored at memory
locations 4500H (lower byte) and 4501H (higher byte). The second 16-bit
number is stored at memory locations 4502H (lower byte) and 4503H (higher
byte). Store the 32-bit result in memory locations 4504H, 4505H, 4506H, and
4507H, with the least significant byte at 4504H and the most significant byte at
4507H.

ALGORITHMS:
1. Start.
2. Load the lower byte of the first 16-bit number from memory location
4500H into register R0, the higher byte of the first 16-bit number from
memory location 4501H into register R1, the lower byte of the second
16-bit number from memory location 4502H into register R2, and the
higher byte of the second 16-bit number from memory location 4503H
into register R3.
3. Multiply the lower byte of the first number with the lower byte of the
second number using the MUL AB instruction.
4. Store the lower byte of the result at memory location 4504H.
5. Store the higher byte of the result temporarily in register R4.
6. Multiply the lower byte of the first number with the higher byte of the
second number using the MUL AB instruction.
7. Store the higher byte of the result temporarily in register R5.
8. Add the lower byte of this product to the previously stored higher byte
(content of R4) and store the sum result temporarily in R4.
9. Increment R5 if a carry occurs.
[Link] the higher byte of the first number with the lower byte of the
second number using the MUL AB instruction.
[Link] the higher byte of the result temporarily in register R6.
[Link] the lower byte of this product to the previously stored data in R4
and store the sum at memory location 4505H.
[Link] R6 if a carry occurs.
[Link] the higher byte of the first number with the higher byte of the
second number using the MUL AB instruction.
[Link] the lower byte of this product to the previously stored data in R5
and increment the B register if a carry occurs.
[Link] the sum result to the previously stored data in R6 and increment the
B register if a carry occurs.
[Link] the sum result at memory location 4506H.
[Link] the contents of the B register at memory location 4507H.
[Link]

PROGRAM:
Memory Label Assembly language Comments
address
MOV DPTR, #4500H
MOVX A, @DPTR
MOV R0, A
INC DPTR
MOVX A, @DPTR
MOV R1, A
INC DPTR
MOVX A, @DPTR
MOV R2, A
INC DPTR
MOVX A, @DPTR
MOV R3, A
MOV A,R0
MOV B,R2
MUL AB
INC DPTR
MOVX @DPTR, A
MOV R4, B
MOV A, R0
MOV B, R3
MUL AB
MOV R5, B
ADD A,R4
MOV R4, A
JNC SKIP1
INC R5
SKIP1: MOV A, R1
MOV B, R2
MUL AB
MOV R6, B
ADD A,R4
INC DPTR
MOVX @DPTR, A
JNC SKIP2
INC R6
SKIP2: MOV A, R1
MOV B, R3
MUL AB
ADD A,R5
JNC SKIP3
INC B
SKIP3: ADD A,R6
JNC SKIP4
INC B
SKIP4: INC DPTR
MOVX @DPTR, A
INC DPTR
MOV A,B
MOVX @DPTR, A
STOP: SJMP STOP

You might also like