Subtract two 8-bit numbers in 8085

In this program, we are going to write an assembly language program to subtract two 8-bit numbers in the 8085 microprocessor with a program flow chart and explanation of the program.

Subtract two 8-bit numbers in 8085

Program Statement

Subtract the content of memory location D001H from memory location D000H and place the result in memory location D002H.

Explanation of Program

  • We have two numbers at memory locations D000H and D001H. Let these numbers be 50H and 20H. We have to subtract these numbers.
  • using the SUB instruction, we will subtract the two numbers.
  • Store the result at the memory location D002H.
    • E.g. : D000H = 50 H and D001H = 20 H
    • Result: D002H = 50H – 20H = 30H

Assembly Language Program

InstructionCommentOperation
LXI H, D000Hset HL as memory pointer at memory location D000HH=D0H, L=00H
MOV A, MLoad the first operand in the accumulatorA=50H
INX HIncrement HL to point to the next memory location i.e. D001HH=D0H, L=01H
D001H : 20H
SUB MIncrement HL to point to the next memory location i.e. D002HA= A-M
A=50-20=30H
INX HIncrement HL to point to next memory location i.e. D002HH=D0H, L=02H
MOV M, AStore the resultD002H= 30H result
HLTterminate program executionStop

Flow Chart of Program

flow chart subtract two 8 bit numbers in 8085
Sr. No.Name of the 8085 Programs
1.Write a program to load the data into the accumulator and any register.
2.Write a program to exchange the contents of memory locations.
3.Add two 8-bit numbers.
4.Subtract two 8-bit numbers.
5.Add two 16-bit numbers.
6.Subtract two 16-bit numbers
7.Find the 1’s complement of a Number
8.Find the 2’s complement of a Number
9.8085 Program To Mask The Lower Nibble
10.8085 Program To Mask The Upper Nibble
11.8085 program to pack the two unpacked BCD numbers
12.8085 program to Unpack the two packed BCD numbers
13.8085 program to find the sum of a series of 8-bit numbers
14.8085 Program to sort the numbers in ascending order
15.8085 Program to sort the numbers in Descending order
16.8085 Program to Multiply Two 8-bit Numbers
17.8085 Program to Divide 16-bit number by 8-bit number
18.8085 Program to Find the Number of Negative Numbers in Array
19.8085 Program to Find Maximum Number in Array
20.8085 Program to count the number of 1’s in a register
21.8085 Program to Calculate the sum of a series of even numbers
22.8085 Program to find the square of numbers
23.8085 Program to find the smallest number in the array

Hello friends, my name is Trupal Bhavsar, I am the Writer and Founder of this blog. I am Electronics Engineer(2014 pass out), Currently working as Junior Telecom Officer(B.S.N.L.) also I do Project Development, PCB designing and Teaching of Electronics Subjects.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

telegram logo Join Our Telegram Group!