You are on page 1of 9

Lab 1

Introduction to 8085 Kit


Pinaki Ranjan Sarkar
(SC13B110)
19 Jan 2015
Sub: Microprocessor and Micro-controllers
Date of Submission: February 2, 2015

Department: B Tech (Avionics)

Question 1:
Write an assembly language program (ALP) in 8085 to add two sixteen bit numbers.

Algorithm:
For FFFF + FFFF, carry will be generated.
Initialise registers C and D to 00.
Access the lower eight bytes of the two numbers and add them. Store carry (if any) in C.
Store this sum.
Add the higher eight bytes. Store carry (if any) in D.
Add the carry stored in C. If there is a carry , store in D. Carry will be generated in this step or
in the above step. NOT in both.
Store the sum and the carry

Program Code:

Label

Address
8000
8001
8002

L1

L2

L3

8003
8004
8005
8006
8007
8008
8009
800A
800B
800C
800D
800E
800F
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
801A
801B
801C
801D
801E
801F
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
802A
802B

Table 1: Addition of two 16 bit numbers


Opcode
Mnemonics
Operands
Comments
Move Immediate value to Accu16
MVI
D,00
mulator
00
Move Immediate value to Regis0E
MVI
C,00
ter B
00
3A
LDA
8500
Load data to accumulator
00
85
47
MOV
B,A
Copy data from A to B
3A
LDA
8502
Load data to accumulator
02
85
80
ADD
B
Add contents of B to that of A
D2
JNC
L1
Jump if no carry to L1
10
80
0C
INR
C
Increment C by 1
32
STA
8504
Store value to memory location
04
85
3A
LDA
8501
Load data to accumulator
01
85
47
MOV
B,A
Copy data from A to B
3A
LDA
8503
Load data to accumulator
03
85
80
ADD
B
Add contents of B to that of A
D2
JNC
L2
Jump if no carry to L2
1F
80
14
INR
D
Increment D by 1
81
ADD
C
Add contents of C to that of A
D2
JNC
L3
Jump if no carry to L3
24
80
14
INR
D
Increment D by 1
32
STA
8505
Store value to memory location
05
85
7A
MOV
A,D
Copy data from D to A
32
STA
8506
Store value to memory location
06
85
DF
RST3
Return control to monitor

Result
Contents of utilised memory locations and the registers after execution of the program are as follows:
Table 2: Memory contents
Memory Locations Content Memory Locations
8500
FF
8501
8502
FF
8503
8504
FE
8505
8506
01

Content
FF
FF
FF

Table 3: Register contents


Register Content Register Content
A
01
B
FF
C
01
D
01
E
00
H
00
L
00

Discussion
The program adds two sixteen bit numbers and stores the result to specified memory location.

Question 2:
Make a copy of your program

Algorithm:
Load the 16 bit memory addresses as data in the D,E register, H,L register pair.
Compare the memory content of the register H,L pair with HLT (DF)
If comparison is found then zero flag will be set and finish the program.
Else exchange the memory contents in the registers.
Then again go to the first program

Program Code:

Label

L1

L2

Address
8200
8201
8202
8203

Opcode
3A
00
82
4F

8204

11

8205
8206

00
89

8207

21

8208
8209

00
80

820A

Table 4: Copying of Code


Mnemonics
Operands
LDA
8600

MOV

C,A

LXI

D,8900

LXI

H,8000

7E

MOV

A,M

820B

B9

CMP

820C
820D
820E

CA
17
80

JMP

L2

820F

EB

XCHG

8210
8211

77
EB

MOV
XCHG

8212

13

INXD

8213

23

INXH

8214
8215
8216
8217

CA
0A
80
76

JMP

M,A

L1

HLT

Comments
Load data to Accumulator

Copy contents of A to C
Load data from address to register pair D,E

Load data from address to register pair H,L

Copy data from address to accumulator


The contents of the C register
are compared with the contents
of the accumulator
Jump to L2

The contents of the register H are


changed with the contents of register L, and the contents of register L are exchanged with the contents of register E
Copy data from A to address
same as above
The contents of the register pair
D,E are incremented by 1
The contents of the register pair
H,L are incremented by 1
Jump to L1

Return control to monitor

Result
Contents of utilised memory locations and the registers after execution of the program are as follows:
Table 5: Memory contents
Memory Locations Content Memory Locations
8900
16
8901
8902
0E
8903
8904
3A
8905
8906
85
8907
8908
3A
8909
890A
85
890B
890C
D2
890D
890E
80
890F
8910
32
8911
8912
85
8913
8914
01
8915
8916
47
8917
8918
03
8919
891A
80
891B
891C
1F
891D
891E
14
891F
8920
D2
8921
8923
80
8924
8925
05
8926
8927
7A
8928
8929
06
892A
892B
DF

Table 6: Register contents


Register Content Register Content
A
DF
B
FF
C
FF
D
01
E
00
H
00
L
00

Content
00
00
00
47
02
80
10
OC
04
3A
85
3A
85
D2
80
81
24
32
85
32
85

Question 3:
Write an assembly language program (ALP) in 8085 to subtract two sixteen bit numbers.

Algorithm:
First subtract the lower bits of the 16 bit digit.
Get the lower bit in the accumulator and in a resister(B) from two memory locations.
Subtract contents of the B from A
If no carry is generated after subtraction take 2s complement.
Else save the data in some memory location
Now get the higher bits of data in accumulator and in resister(B) from the next two memory
location.
Subtract the contents of B and borrow from the accumulator.
Again check for carry.
If no carry is generated after subtraction take 2s compliment and save the data to a memory
address.
Else save the answer to a memory address.
By help of another resister(D) show that the result is negative.

Program Code:

Label

Address
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
900A
900B
900C
900D
900E
900F
9010
9011
9012

L1

9013
9014
8015
9016
9017
9018
9019
901A
901B
901C
901D
901E
901F
9020
9021
9022
9023
9024

L2

9025
9026
9027
9028
9029
902A
902B
902C

Table 7: Subtraction two 16 bit numbers


Opcode
Mnemonics
Operands
Comments
16
MVI
D,00
Move Immediate value to resister
00
D
Move Immediate value to regis0E
MVI
C,00
ter
00
C
3A
LDA
8502
Load data to accumulator from
02
the memory address
85
47
MOV
B,A
Copy data from A to B
3A
LDA
8500
Load data to accumulator from
00
the address
85
80
SUB
B
Subtract contents of B from A
D2
JNC
L1
Jump if no carry, to L1
13
90
The contents of the accumulator
2F
CMA
are complemented
Add immediate to the accumulaC6
ADI
01
tor
01
Increment contents of register C
0C
INR
C
by 1
32
STA
8504
Load the accumulator contents
04
in the memory address
85
3A
LDA
8503
Load data to accumulator
03
85
47
MOV
B,A
Copy the data of A to B
3A
LDA
8501
Load data to accumulator
01
85
Subtract contents of the B and
98
SBB
B
the borrow flag from the accumulator
D2
JNC
L2
Jump if no carry
25
90
2F
CMA
Complement accumulator
C6
ADI
01
Increment D by 1
01
Increment the contents of resister
14
INR
D
D
32
STA
8505
Load the accumulator contents
05
in the memory address
85
Copy data of D to the accumula7A
MOV
A,D
tor
32
STA
8506
Load the accumulator contents
06
in the memory address
80
DF
RST3
Return control to the monitor

Result
Contents of utilised memory locations and the registers after execution of the program are as follows:
Table 8: Memory contents
Memory Locations Content Memory Locations
8500
FF
8501
8502
FF
8503
8504
FE
8505
8506
01

Content
FF
FF
FF

Table 9: Register contents


Register Content Register Content
A
01
B
FF
C
01
D
01
E
00
H
00
L
00

Discussion
The program subtracts two sixteen bit numbers using 2s compliment method and stores the result to
specified memory location.

You might also like