Home »
Embedded Systems
Subtraction of Two 8 bits number with consideration of Borrow in 8085 Microprocessor
Here, we are going to learn how to subtract two 8 bits numbers with consideration of borrow in 8085 Microprocessor?
Submitted by Samiksha Yadav, on October 19, 2018
Problem statement:
To subtract two 8bit numbers with consideration of borrow using 8085 microprocessor.
Algorithm:
- Load the H-L pair with the address of first memory location.
- Move the content of H-L to accumulator.
- Increment H-L pair to next memory location.
- Load the register B with the memory location of second data.
- Initialize register C with 00H. this will store the borrow (if any).
- Subtract the content of accumulator with the content of register B and the result will be stored in accumulator automatically.
- If carry flag is set then increment register C.
- Increment H-L pair.
- Move result from accumulator to memory location 3002H.
- Increment H-L pair.
- Move borrow from register C to memory location 3003H.
Program:
Address Mnemonics Operands
2000 LXI H,3000H
2003 MOV A, M
2004 INX H
2005 MOV B, M
2006 MVI C, 00H
2008 SUB B
2009 JNC 200D
200C INR c
200D INX H
200E MOV M, A
200F INX H
2010 MOV M, C
2011 HLT
Observation:
INPUT:
3000H: 05H
3001H: 02H
OUTPUT:
3002H: 03H
3003H: 00H
Hence successfully subtracted two 8 bits numbers with consideration of borrow.
Help this article has answered all your questions. Like and comment below if satisfied.