8085 Micro-Processor Programs


Square root of a number using 8085


Ø   An Assembly Language Program to find the square root of a number using 8085?

Algorithm

1)      Load the HL pair with the address of the number whose square root is to be found.
2)      Copy the number to accumulator.
3)      Initialize E with 0.
4)      Subtract content of E from accumulator.
5)      Increment register E by 2.
6)      Increment content C register by 1.
7)      Compare accumulator content with 0.
8)      If accumulator content is not zero then go to step 4 else go to step 9.
9)      Store the square root in to the memory.
10)  Terminate the program.

Program

MEMORY
LABEL
MNEMONIC
HEX CODE
COMMENT
4200

MVI C,00
0E
Initialize C as 0
4201


00
4202

LXI H,4100
21
Load HL pair with the address of the data whose occurrence is to be found
4203


00
4204


41
4205

MOV A,M
7E
Copy the data to the Accumulator
4206

MVI E,01
1E
Initialize E with 0
4207


01
4208
LOOP
SUB E
93
[A] ß [A] + [E]
4209

INR E
1C
Increment register E
420A

INR E
1C
Increment register E
420B

INR C
0C
Increment register C
420C

CPI ,00
FE
Compare accumulator content with 0
420D


00
420E

JNZ LOOP
C2
Jump on non-zero to the label LOOP
420F


07
4210


42
4211

MOV A,C
79
Copy content of register C to accumulator
4212

STA 4500
32

Store the square root in 4500
4213


00
4214


45
4215

HLT
76
Program ends

Observation

Input at           4100    :           31H
Output at         4500    :           07H        ------------ Square root

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

ASCII to HEX conversion using 8085


Ø   An Assembly Language Program to perform ASCII to HEX conversion using 8085?

Algorithm

1)      Load the ASCII number in to the accumulator.
2)      Subtract 30H from the number.
3)      Compare the number with 0A.
4)      If number < 0A then store result and exit else go to step 5.
5)      Subtract 07H from the number and store result.
6)      Terminate the program.

Program

MEMORY
LABEL
MNEMONIC
HEX CODE
COMMENT
4200

LDA 4500
3A
Load the ASCII number to the accumulator
4201


00
4202


45
4203

SBI 30
DE
Subtract 30 from the number
4204


30
4205

CPI OA
FE
Compare accumulator with 0A
4206


OA
4207

JC AHEAD
DA
Jump on carry to the label AHEAD
4208


OC
4209


42
420A

SBI 07
DE
Subtract 07H from the number
420B


07
420C
AHEAD
STA 4501
32

Store the HEX value in 4501
420D


01
420E


45
420F

HLT
76
Program ends

Observation

Input at           4500    :           42        ------- ASCII value
Output at         4501    :           0B       ------- HEX value

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

No comments:

Post a Comment