PhysicsTeacher.in

High School Physics + more

Addition of two 16-bit numbers: 8085 programming

In this post, we will write programs in 8085 Assembly language for the addition of two 16-bit numbers.

In program 1, eight bit addition instructions are used (ADD and ADC) and addition is performed in two steps. First lower byte addition using ADD instruction and then higher byte addition using ADC instruction.

In program 2, 16-bit addition instruction (DAD) is used.

Problem statement 1: Add two 16-bit numbers (using ADD and ADC instructions)

8085 Assembly language program code (with ADD and ADC instructions)

Memory Address(H)Machine Code(H)LabelMnemonics(Instruction)Comments
C000
C001
C002
2A
00
C1

LHLD C100HGet first I6 bit number in HL
C003EB
XCHGSave first I6 bit number in DE
C004
C005
C006
2A
02
C1

LHLD C102HGet second I6 bit number in HL
C0077B
MOV A, EGet lower byte of the first number
C00885
ADD LAdd lower byte of the second number
C0096F
MOV L, AStore result in L register
C00A7A
MOV A, DGet higher byte of the first number
C00B8C
ADC HAdd higher byte of the second number with CARRY
C00C67
MOV H, AStore result in H register
C00D
C00E
C00F
22
04
C1

SHLD C104HStore I6bit result in memory locations C104H and C105H.
C01076
HLTTerminate program execution
program 1 code: using ADD and ADC

Input Data

Memory Address(H)Data(H)
C10015
C1011C
C102B7
C1035A

Result

1C15 + 5AB7H = 76CCH

Memory Address(H)Data(H)
C104CC
C10576

Problem statement 2: Add two 16-bit numbers using DAD instruction.

8085 Assembly language program code (with DAD instruction)

Memory Address(H)Machine Code(H)LabelMnemonics(Instruction)Comments
C000 C001 C0022A 00 C1
LHLD C100HGet first I6 bit number
C003EB
XCHGSave first I6 bit number in DE
C004 C005 C0062A 02 C1
LHLD C102HGet second I6 bit number in HL
C00719
DAD DAdd DE and HL

C008 C009 C00A22 04 C1
SHLD C104HStore I6 bit result in memory locations C104H and C105H.
C00B76
HLT

Terminate program execution

Program 2 code: using DAD instruction

Input Data

Memory Address(H)Data(H)
C10015
C1011C
C102B7
C1035A

Result

1C15 + 5AB7H = 76CCH

Memory Address(H)Data(H)
C104CC
C10576
See also  Multiplication of Two 8 bit Numbers using 8085 microprocessor
Scroll to top
error: physicsTeacher.in