Digital Microntrollers
And Microprocessors
Electrical Power Engineering Techniques Department
By
Dr. Ahmed Aftan
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
8085 MICROPROCESSOR
PROGRAMS
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
1
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
ADDITION OF TWO 8 BIT NUMBERS
AIM:
To perform addition of two 8 bit numbers using 8085.
ALGORITHM:
1) Start the program by loading the first data into Accumulator.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
4) Add the two register contents.
5) Check for carry.
6) Store the value of sum and carry in memory location.
7) Terminate the program.
PROGRAM:
MVI C, 00 Initialize C register to 00
LDA 4150 Load the value to Accumulator.
MOV B, A Move the content of Accumulator to B register.
LDA 4151 Load the value to Accumulator.
ADD B Add the value of register B to A
JNC LOOP Jump on no carry.
INR C Increment value of register C
LOOP: STA 4152 Store the value of Accumulator (SUM).
MOV A, C Move content of register C to Acc.
STA 4153 Store the value of Accumulator (CARRY)
HLT Halt the program.
OBSERVATION:
Input: 80 (4150)
80 (4251)
Output: 00 (4152)
01 (4153)
RESULT:
Thus the program to add two 8-bit numbers was executed.
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
2
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
SUBTRACTION OF TWO 8 BIT NUMBERS
AIM:
To perform the subtraction of two 8 bit numbers using 8085.
ALGORITHM:
1. Start the program by loading the first data into Accumulator.
2. Move the data to a register (B register).
3. Get the second data and load into Accumulator.
4. Subtract the two register contents.
5. Check for carry.
6. If carry is present take 2’s complement of Accumulator.
7. Store the value of borrow in memory location.
8. Store the difference value (present in Accumulator) to a memory
9. location and terminate the program.
PROGRAM:
MVI C, 00 Initialize C to 00
LDA 4150 Load the value to Acc.
MOV B, A Move the content of Acc to B register.
LDA 4151 Load the value to Acc.
SUB B
JNC LOOP Jump on no carry.
CMA Complement Accumulator contents.
INR A Increment value in Accumulator.
INR C Increment value in register C
LOOP: STA 4152 Store the value of A-reg to memory address.
MOV A, C Move contents of register C to Accumulator.
STA 4153 Store the value of Accumulator memory address.
HLT Terminate the program.
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
3
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
OBSERVATION:
Input: 06 (4150)
02 (4251)
Output: 04 (4152)
01 (4153)
RESULT:
Thus the program to subtract two 8-bit numbers was executed.
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
4
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
MULTIPLICATION OF TWO 8 BIT NUMBERS
AIM:
To perform the multiplication of two 8 bit numbers using 8085.
ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
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:
MVI D, 00 Initialize register D to 00
MVI A, 00 Initialize Accumulator content to 00
LXI H, 4150
MOV B, M Get the first number in B - reg
INX H
MOV C, M Get the second number in C- reg.
LOOP: ADD B Add content of A - reg to register B.
JNC NEXT Jump on no carry to NEXT.
INR D Increment content of register D
NEXT: DCR C Decrement content of register C.
JNZ LOOP Jump on no zero to address
STA 4152 Store the result in Memory
MOV A, D
STA 4153 Store the MSB of result in Memory
HLT Terminate the program.
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
5
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
OBSERVATION:
Input: FF (4150)
FF (4151)
Output: 01 (4152)
FE (4153)
RESULT:
Thus the program to multiply two 8-bit numbers was executed.
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
6
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
DIVISION OF TWO 8 BIT NUMBERS
AIM:
To perform the division of two 8 bit numbers using 8085.
ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register(B register).
3) Get the second data and load into Accumulator.
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:
LXI H, 4150
MOV B, M Get the dividend in B – reg.
MVI C, 00 Clear C – reg for qoutient
INX H
MOV A, M Get the divisor in A – reg.
NEXT: CMP B Compare A - reg with register B.
JC LOOP Jump on carry to LOOP
SUB B Subtract A – reg from B- reg.
INR C Increment content of register C.
JMP NEXT Jump to NEXT
LOOP: STA 4152 Store the remainder in Memory
MOV A, C
STA 4153 Store the quotient in memory
HLT Terminate the program.
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
7
MICROPROCESSOR & MICROCONTROLLER LAB MANUAL
OBSERVATION:
Input: FF (4150)
FF (4251)
Output: 01 (4152) ---- Remainder
FE (4153) ---- Quotient
RESULT:
Thus the program to divide two 8-bit numbers was executed.
C.SARAVANAKUMAR. M.E.,
LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
8
Question Bank 8085 Microprocessor
POINTS TO REMEMBER
• Instruction It is a binary pattern design inside a microprocessor to perform a specific function
• Instruction basically consists of two parts The first part is called as op code and the second is called as
operand
• 1 Byte instruction includes the op code and the operand in the 8 bit only
• 2 Byte instruction use 1St byte to specify the operation i e op code and second byte to specify the
operand
• 3 byte instruction uses first byte to specify the operation i e op code, second and third bytes are used to
specify the operand
• The different methods to select the operands are called the addressing modes For 8085 they are ,
Immediate addressing Register addressing, Direct addressing Indirect addressing, Implied addressing
• The instructions are generally classified into the functional categories as follows
(i) Data transfer group
(ii) Arithematic group
(iii) Logical group
(iv) Branching group
(v) Stack and machine control group
Stack is a reserved area of the memory This area is usually defined in RAM only It is used to store information
(data) temporarily It is program by the user
The stack related instructions are
(i) PUSH R
(ii) POPR
(iii) SPHL
(iv) XTHL
Q 1. List categories of 8085 instructions that manipulate data.
Ans. 8085 instruction, are:
1. Data transfer instructions :
(a) MOV
(b) MVI
(c) LDA
(d) STA
2. Arithematic Instructions
(a) ADD
(b) AD)
(c)SUB
(ci) SBI
(f) DCR
3. Logical Instructions
(a) ANA
(b) ORI
(c)CMP
(d) RLC
(e) RRC
4. Branch Instructions
(a) JMP
(b) CALL
5. Stack and machine control instructions
(a) PUSH
(b) POP.
Q 2. Explain the function of assembler, compiler and interpreter.
Ans. Assembler: It is a software which translates an assembly language program into a machine language
program. Each microprocessor has its own assembler and each assembler has its own rules and directives.
The program written in English like words is called mnemonics and machine language is called object code.
Compiler: It is software the converts high level language program into machine level program (object code).
Compiler occupies more space and takes longer time to produce results. A compiler is more powerful than
assembler. It checks all kinds of limits, error etc. It is of two types : Self compiler and cross compiler.
For examples, SDCC complier, Turbo C complier, KEIL etc.
Interpreter : Interpreter is also a software that converts high level language program into object codes. But this
translation is done statement wise. It takes up one statement of high level language program at a time, translates
it and executes it. It occupies less memory space. But it is slower as compared to compiler.
Q 3. Explain the difference between machine language and assembly language.
Ans.
Q 4. The memory location 2500 H holds the data byte FFH Transfer this data byte to the accumulator
using instructions LDA, LDA X and MOV.
Ans. LDA:
LXI 0, 2500 H
LDAXD
LXI H, 2500
MOVA,M
Q 5. What is difference between CALL, RET and PUSH, POP’ instructions?.
Ans.
Q 6. Write a program in assembly language program to sort the numbers in ascending order?