8085 Micro-Processor Programs


Multiplication of two 8-bit numbers using 8085


Ø   An Assembly Language Program to perform multiplication of two 8-bit numbers using 8085?

Algorithm

1)      Start the program by loading HL register pair with address of memory location.
2)      Copy the data to the accumulator.
3)      Get the second data and load into a register.
4)      Add the two register contents.
5)      Check for carry.
6)      Increment the value of carry.
7)      Check whether repeated addition is over and store the value of product and carry in           memory location.
8)      Terminate the program.

Program

MEMORY
LABEL
MNEMONIC
HEX CODE
COMMENT
4200

LXI H, 4500
21
Load address of 1st number to    H-L pair
4201


00
4202


45
4203

MOV A, M
7E
Copy 1st number to Accumulator
4204

INX H
23
Increment memory
4205

MOV B,M
46
Copy 2nd number to register B
4206

MVI D,00
16
Initialize D as 0
4207


00
4208

MOV C,A
4F
Copy Accumulator content to register C
4209

MOV A,D
7A
Copy content of register C to Accumulator
420A
GO
ADD B
80
Add register B to Accumulator content
420B

JNC AHEAD
D2
Jump on no carry to label AHEAD
420C


0F
420D


42
420E

INR D
14
Increment D by 1
420F
AHEAD
DCR C
OD
Decrement C by 1
4210

JNZ GO
C2

Jump on no carry to label GO
4211


OA
4212


42
4213

STA 4100
32
Store Accumulator content to 4100
4214


00
4215


41
4216

MOV A,D
7A
Copy content of register D to Accumulator
4217

STA 4101
32
Store Accumulator content to 4100
4218


01
4219


41
421A

HLT
76
Halt the program

Observation

Input at           4500    :           05H
4501    :           03H

Output at         4100    :           0FH
                        4101    :           00H

------------------------------------------------------------------------------------------------


Division of two 8-bit numbers using 8085

Ø   An Assembly Language Program to perform division of two 8-bit numbers using 8085?

Algorithm

1)      Start the program by loading HL register pair with address of memory location.
2)      Copy the data to the accumulator.
3)      Get the second data and load into a register.
4)      Compare the two numbers to check for carry.
5)      Subtract the two numbers.
6)      Increment the value of carry.
7)      Check whether repeated subtraction is over and store the value of product and carry in memory location.
8)      Terminate the program.

Program

MEMORY
LABEL
MNEMONIC
HEX CODE
COMMENT
4200

LXI H, 4500
21
Load address of 1st number to    H-L pair
4201


00
4202


45
4203

MOV A, M
7E
Copy 1st number to Accumulator
4204

MVI C,00
0E
Initialize C as 0
4205


00
4206

INX H
23
Increment address
4207

MOV B,M
46
Copy 2nd number address to register B
4208
LOOP
CMP B
B8
Compare Accumulator and register B
4209

JC GO
DA

Jump on carry to label GO
420A


11
420B


42
420C

INR C
0C
Increment register C by 1
420D

SUB B
90
Subtract register B’s content from Accumulator
420E

JNZ LOOP
C2

Jump on non-zero to label LOOP
420F


08
4210


42
4211
GO
STA 4100
32

Store accumulator content to 4100
4212


00
4213


41
4214

MOV A,C
79
Copy content of register C to Accumulator
4215

STA 4101
32
Store Accumulator content to 4101
4216


01
4217


41
4218

HLT
76
Program ends

Observation

Input at           4500    :           09H
4501    :           02H

Output at         4100    :           01H
                        4101    :           04H
-----------------------------------------------------------------------------------------------

No comments:

Post a Comment