100% found this document useful (1 vote)
659 views3 pages

Practical:7: A. Write A Program To Find GCD of Two Numbers Using 8085. Program

The document contains programs written in 8085 assembly language to: 1. Find the greatest common divisor of two numbers. 2. Add multiple two-digit BCD numbers stored in memory locations. 3. Calculate the length of a string stored in memory and ending with 0DH, storing the length in the accumulator.

Uploaded by

Nandani Thumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
659 views3 pages

Practical:7: A. Write A Program To Find GCD of Two Numbers Using 8085. Program

The document contains programs written in 8085 assembly language to: 1. Find the greatest common divisor of two numbers. 2. Add multiple two-digit BCD numbers stored in memory locations. 3. Calculate the length of a string stored in memory and ending with 0DH, storing the length in the accumulator.

Uploaded by

Nandani Thumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

190170107144 PRACTICAL:7

a. Write a Program to Find GCD Of Two Numbers Using 8085.

Program:

# ORG 2000H
MVI A,09 // Load first no. in reg.A
MVI B,07 // Load second No. in reg.B
CMP B // Compare B to A
JZ down // True if A=B
JNC shift // True if A>B
MOV C,A // A → C
MOV A,B // A ← B
MOV B,C // C← B
shift:SUB B // A-B → A
CMP B // Compare B to A
JZ move // True if A=B
JNC shift // True if A>B
MOV C,A // A ← C
MOV A,B // A ← B
MOV B,C // C → A
JMP shift // Unconditional Jump
move:MOV A,B // B → A
down:STA F200 // A → [address]
RST 1 // Terminate

Input:

A-09 H, B-07 H

Output:

A- 01 H, F200-01 H

VGEC(CE) 1 MPI
190170107144 PRACTICAL:7

b. Write a Program to Add ‘N’ Two Digit BCD Numbers Using 8085.

Program:

# ORG 2000H
LXI H,F100 // HL &8592; F100
MOV C,M // C &8592;[HL]
MVI D,00 // Clear reg.D
INX H // HL+1 &8594; HL
DCR C // C-1 &8594; C
MOV A,M // M &8594; A
up:INX H // HL+1 &8594; HL
ADD M // M+A &8594;A
DAA // Decimal Adjust After Addition
JNC down // Jump if no carry
INR D // D+1 &8594;D
down:DCR C // C-1 &8594;C
JNZ up // Jump if ZF=0
STA F200 // A &8592;[F200]
RST 1 // Terminate

# ORG F100H // Store inputs at the address


# DB 04,43,77,55,55 // Store bytes in successive locations

Input:

F100-04 H, F101-43 H, F102- 77 H, F103- 55 H, F104- 55 H

Output:

D-02 H, A-30 H

VGEC(CE) 2 MPI
190170107144 PRACTICAL:7

c. Write a program to calculate the length of a string stored at starting location 3050H.
A string is ended with 0DH. Store the length of the string in the accumulator

Program:

LXI A,ODH
MVI H,3050H
INR B:LOOP
CMP M
INX H
JNZ LOOP
MOV A,B
STA 5000H
HLT

Input:

3050H:11H, 3051H:34H ;3052H:0DH

Output:

5000H:03H

VGEC(CE) 3 MPI

You might also like