×

Embedded Systems Tutorial

AVR Microcontroller

8051 Microcontroller

8085 Microprocessor

8086 Microprocessor

8255 Microprocessor

Embedded Systems Practice

Subtract Two 8-bit numbers with Borrow in 8085 Microprocessor

In this tutorial, we will learn how to subtract two 8-bit numbers with borrow in 8085 Microprocessor? By Samiksha Yadav Last updated : May 13, 2023

Subtraction of Two 8-bit numbers with Consideration of Borrow in 8085 Microprocessor

Given two 8-bit numbers, we have to subtract them in 8085 Microprocessor.

Algorithm

  1. Load the H-L pair with the address of first memory location.
  2. Move the content of H-L to accumulator.
  3. Increment H-L pair to next memory location.
  4. Load the register B with the memory location of second data.
  5. Initialize register C with 00H. this will store the borrow (if any).
  6. Subtract the content of accumulator with the content of register B and the result will be stored in accumulator automatically.
  7. If carry flag is set then increment register C.
  8. Increment H-L pair.
  9. Move result from accumulator to memory location 3002H.
  10. Increment H-L pair.
  11. 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.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.