Microprocessor 8085 program to find the Subtraction of two 8-bit numbers

TANSCHE third year of the B.Sc. Physics Microprocessor 8085 programming - subtraction of two 8-bit numbers





In the third year of the B.Sc. Physics program under TANSCHE, it's really important to learn how microprocessors work. One of the main experiments is with the Microprocessor 8085, which is a popular 8-bit processor. In this experiment, students get to practice basic math operations.

In this blog post, we will talk about the experiment called "Subtraction of Two 8-bit Numbers with the Microprocessor 8085." This hands-on activity helps students understand how the 8085 microprocessor works, including programming and memory tasks. By the end of this experiment, you'll have a good grasp of how the 8085 processes data and performs math operations, giving you a strong base in microprocessor systems.

Microprocessor 8085 program to find the Subtraction of two 8-bit numbers

Aim:

Write an assembly language program to subtract two 8-bit numbers (with and without borrow) using microprocessor 8085.

Apparatus required:

Microprocessor 8085 kit, power supply etc

Program:

Subtraction of two 8-bit numbers; sum 8-bit (without borrow)

Memory address

Machine code

Mnemonics

Operands

Comments

8000

21

LXI

H, 8501H

Address of the LSB of the number

8001

01

8002

85

8003

7E

MOV

A, M

Move the number to the accumulator

8004

23

INX

H

Increment the H-L pair

8005

96

SUB

M

Add the number in the memory with the accumulator

8006

32

STA

8503H

Store the result in the accumulator in the location 8503H

8007

03

8008

85

8009

76

HLT

Stop the program

Example:

Subtraction of two 8-bit numbers; sum 8-bit (without borrow)

First input location 8501H - 23H (In binary form 0001 0010)

Second input location 8502H - 12H (In binary form 0010 0011)

Result location 8503H - 11H (In binary form (0001 0001)

Subtraction of two 8-bit numbers; sum 16-bit (with borrow)

Memory address

Machine code

Labels

Mnemonics

Operands

Comments

8000

21

LXI

H, 8501H

Address of the LSB of the number

8001

01

8002

85

8003

0E

MVI

C, 00H

Store 00H to C register

8004

00

8005

7E

MOV

A, M

Move the number to the accumulator

8006

23

INX

H

Increment the H-L pair

8007

96

SUB

M

Add the number in the memory with the accumulator

8008

D2

JNC

AHEAD

Jump on no carry to AHEAD (800C)

8009

0C

800A

80

800B

0C

INR

C

Increment C register

800C

32

AHEAD

STA

8503H

Store the result in the accumulator in the location 8503H

800D

03

800E

85

800F

79

MOV

A, C

Move the content of C register to accumulator

8010

32

STA

8504H

Store the result in the accumulator in the location 8504H

8011

04

8012

85

8013

76

HLT

Stop the program

Example:

Subtraction of two 8-bit numbers; sum 16-bit (with borrow)

First input location 8501H - 03H (In binary form 0000 0011)

Second input location 8502H - 04H (In binary form 0000 0100)

By adding these two binary numbers the result is, 1 0000 0001

Result location 8503H - 01H (Sum)

Result location 8504H - 01H (borrow)

Procedure:

Result: 

The assembly programmes for microprocessor 8085 for subtraction of two 8-bit numbers were written and executed using the microprocessor 8085 kit.

Click here for Addition
For further reading:
External site

Post a Comment

0 Comments