You are currently viewing [PRACTICAL] Implement a program to perform arithmetic operations on two 8 bit numbers
Microprocessor 8085 programming

[PRACTICAL] Implement a program to perform arithmetic operations on two 8 bit numbers

[PRACTICAL] IMPLEMENT A PROGRAM TO PERFORM ARITHMETIC OPERATIONS(ADD, SUBTRACT, MULTIPLY, AND DIVIDE) ON TWO 8 BIT NUMBERS

Are you looking for a step-by-step guide to Implement a program to perform arithmetic operations (add, subtract, multiply, and divide) on two 8 bit numbers? here are the steps to implement a program to perform arithmetic operations (add, subtract, multiply, and divide) on two 8 bit numbers.

ADDITION

Program:

//Addition of two 8bit numbers
//Manually strore 1st no in the memory location C050
//Manually store 2nd no in the memory location C051
//Result is stored in C053

LXI H,C050
MOV A,M
INX H
ADD M
STA C052
HLT

Input:

Content of Memory Location C050: 05h

Content of Memory Location C051: 04h

Output:

Content of Memory Location C052: 09h

SUBSTRACT

Program:

//Substraction of two 8bit numbers
//Manually strore 1st no in the memory location C050
//Manually store 2nd no in the memory location C051
//Result is stored in C053

LXI H,C050
MOV A,M
INX H
SUB M
INX H
MOV M,A
HLT

Input:

Content of Memory Location C050: 45h

Content of Memory Location C051: 12h

Output:

Content of Memory Location C052: 33h

MULTIPLY

Program:

//Multiply 5 by 4
//Result is stored in A Register.

MVI C,05H
MVI A,00H
MVI B,04H
NEXT: ADD B
DCR C
JNZ NEXT
HLT

Output:

5×4= 20 in decimal

Accumulator: 14h

OR

//Multiple 4 by 2
//Result is stored in A Register.

MVI A,04H
RAL
HLT

Output:

4×2= 08 in decimal

Accumulator: 08h

DIVISION

Program:

//Divide 15 decimal by 5 decimal
//Store result in c registers

MVI A,0FH
MVI B,05H
MVI C,00H
NEXT: INR C
SUB B
JNZ NEXT
HLT

Output:

15/5= 15 in decimal

C register: 03h

OR

//Divide 8 by 2
//Result is stored in A Register.

MVI A,08H
RAR
HLT

Output:

8/2= 04 in decimal

Accumulator: 04h