0% found this document useful (0 votes)
24 views9 pages

Experiment 3

Uploaded by

Khin Myat Thu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views9 pages

Experiment 3

Uploaded by

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

EXPERIMENT 3

Name Roll No:

AIM

 To study the arithmetic/logic operation of 8085 Microprocessor


 To perform addition of two 8-bit numbers using 8085

THEORY
Arithmetic Instruction:
ADD; ADD Add the contents of a register
ADI; ADD Immediate Add 8-bit data.
The arithmetic instructions (except INR and DCR)
1. Assume implicitly that the accumulator is one of the operands
2. Modify all the flags according to the data conditions of the result
3. Place the result in the accumulator
4. Do not affect the contents of the operand register
The instruction INR and DCR
1. Affect the contents of the specified register
2. Affect all flag except the CY flag.

Opcode Operand Description


ADD R Add
This is a 1-byte instruction
Adds the contents of register R to the contents of the accumulator
ADD 8-bits Add Immediate
This is a 2-byte instruction
Adds the second byte to the contents of the accumulator
SUB R Subtract
This is a 1-byte instruction
Subtracts the contents of register R to the contents from A
SUI 8-bits Subtract Immediate
This is a 2-byte instruction
Subtracts the second byte from the contents of the accumulator

1
INR R Increment
This is a 1-byte instruction
Increases the contents of register R by 1
Caution: All flags except The CY are affected
DCR R Decrement
This is a 1-byte instruction
Decreases the contents of register R by 1
Caution: All flags except The CY are affected

Logical Instruction:
ANA; AND Logically AND the contents of a register
ANI; AND Immediate Logically AND 8-bit data
The logic instructions
1. Implicitly assume that the accumulator is one of the operands
2. Reset (clear) CY flag. The instruction CMA is an exception; it does not affect any flags.
3. Modify the Z, P, and S flag according to the data conditions of the result.
4. Place the result in the accumulator.
5. Do not affect the contents of the operand register.

Opcode Operand Description


ANA R Logical AND with Accumulator (A)
This is a 1-byte instruction
Logically ANDs the contents of the register R with the contents of A
8085: CY is reset and AC is set
ANI 8-bit AND Immediate with Accumulator (A)
This is a 2-byte instruction
Logically ANDs the second byte with the contents of A
8085: CY is reset and AC is set
ORA R Logical OR with Accumulator (A)
This is a 1-byte instruction
Logically ORs the contents of the register R with the contents of A

2
ORI 8-bit OR Immediate with Accumulator (A)
This is a 2-byte instruction
Logically ORs the second byte with the contents of A
XRA R Logically Exclusive-OR with Accumulator (A)
This is a 1-byte instruction
Logically XORs the contents of the register R with the contents of A
XRI 8-bit Exclusive-OR Immediate with Accumulator (A)
This is a 2-byte instruction
Logically XORs the second byte with the contents of A
CMA Complement Accumulator
This is a 1-byte instruction that complement the contents of A
No flags are affected

Writing a Assembly Language Program


Steps to write a program
 Analyze the problem
 Develop program Logic
 Write an Algorithm
 Make a Flowchart
 Write program Instructions using Assembly language of 8085
Program 8085 in Assembly language to add two 8-bit numbers and store 8-bit result in register C
1. Analyze the problem
 Addition of two 8-bit numbers to be done
2. Program Logic
 Add two numbers
 Store result in register C
Example
10011001 (99H) A
+00111001 (39H) D
11010010 (D2H) C

3
3. Algorithm
 Get two numbers
st
A. Load 1 no. in register D
nd
B. Load 2 no. in register E
 Add them
A. Copy register E to A
B. Add register D to A
 Store result
A. Copy A to register C

 Stop
A. Stop processing

4. Making Flow Chart

Start

st
A. Load 1 no. in register D
Load Registers D, E nd
B. Load 2 no. in register E

Copy E to A
A. Copy register E to A
B. Add register D to A
Add A and D

Copy A to C A. Copy A to register C

A. Stop processing
Stop

5. Assembly Language Program


MVI D, 3FH
MVI E, 43H

4
MOV A,E
ADD D
MOV C,A
HLT

Problem Statement 1: Add the contents of memory location 4001H and the contents of memory
location 2000H and place the result in memory location 4002H.
LXI H 4000H : HL points 4000H
MOV A, M : Get first operand
INX H : HL points 4001H
ADD M : Add second operand
INX H : HL points 4002H
MOV M, A : Store result at 4002H
HLT : Terminate program execution
Making Flow Chart

Observation : Data in memory


(4000H) = 14H

5
(4001H) = 89H
Result = 14H + 89H = _______H
Flag =

D7 D6 D5 D4 D3 D2 D1 D0

Problem Statement 2: Write a program to perform the following functions, and verify the
output.
1. Load the number 8BH in register D.
2. Load the number 6FH in register C.
3. Increment the contents of register C by one.
4. Add the contents of registers C and D and display the sum at the output PORT1.

Verification

6
QUESTION

A. Write a program to perform the following functions, and verify the output.
1. Load the number 8BH in register D.
2. Load the number 6FH in register C.
3. Increment the contents of register C by one.
4. Add the contents of registers C and D and display the sum at the output PORT 1.

5. Specify the Flag Status.


D7 D6 D5 D4 D3 D2 D1 D0

B. What operation can be performed by using the instruction ADD A?

7
C. Write a program using the ADI instruction to add the two hexadecimal numbers 3AH and
48 H and to display the answer at an output port.

D. Write instruction to
1. Load 00H in the accumulator
2. Decrement the accumulator
3. Display the answer

Specify the answer you would expect at the output.

E. Write a program to
1. Clear the accumulator
2. Add 47H

8
3. Subtract 92H
4. Add 64 H
5. Display the results after subtracting 92H and after adding 64H.

You might also like