0% found this document useful (0 votes)
50 views36 pages

MI Practical

Uploaded by

aklavya pathak
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)
50 views36 pages

MI Practical

Uploaded by

aklavya pathak
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/ 36

Department of Computer Engineering

Government Engineering College,Daman


Gujarat Technological University,Ahmedabad

MICROPROCESSOR AND INTERFACING


Subject Code: 3160712

LAB MANUAL
FOR

6th Semester

Academic Year: 2023-2024

Submitted To: Submitted By:

Prof. Mrs. Hemali Damania Aklavya Pathak

Assistant Professor B.E.(6th Semester)

Department of Computer Engineering Enroll No.:221423107005


Practical - 1

AIM: To Study Different Addressing Modes of 8085 Microprocessors

8085 Microprocessor:

8085 is pronounced as an "eighty-eighty-five" microprocessor. It is an 8-bit microprocessor designed by


Intel in 1977 using NMOS technology.

It has the following configuration:

● 8-bit data bus


● 16-bit address bus, which can address upto 64KB.
● A 16-bit program counter.
● A 16-bit stack pointer.
● Six 8-bit registers arranged in pairs: BC, DE, HL.
● Requires +5V supply to operate at 3.2 MHZ single phase clock.

Addressing modes in 8085 Microprocessor:

The 8085 microprocessor has several addressing modes that are used to access memory locations.
Some of the most commonly used addressing modes in the 8085 microprocessor are: The way of
specifying data to be operated by an instruction is called addressing mode.

Types of addressing modes:

In 8085 microprocessor there are 5 types of addressing modes:

1. Immediate Addressing Mode:

In immediate addressing mode the source operand is always data. If the data is 8-bit, then the
instruction will be of 2 bytes, if the data is of 16-bit then the instruction will be of 3 bytes.

Example:

MVI B, 45 (move the data 45H immediately to register B).

LXI H 3050 (load the H-L pair with the operand 3050H immediately).

JMP address (jump to the operand address immediately).

2. Register Addressing Mode:

In register addressing mode, the data to operate is available inside the register(s) and register(s) is
(are) operands.

Therefore the operation is performed within various registers of the microprocessor.

Examples:

MOV A, B (move the contents of register B to register A).

GEC,Daman 1 221423107005
Practical - 1

ADD B (add contents of registers A and B and store the result in register A).

INR A (increment the contents of register A by one).

3. Direct Addressing Mode:

In direct addressing mode, the data to be operated is available inside a memory location and that
memory location is

directly specified as an operand. The operand is directly available in the instruction itself.

Examples:

LDA 2050 (load the contents of memory location into accumulator A)

LHLD address (load contents of 16-bit memory location into H-L register pair)

IN 35 (read the data from port whose address is 35)

4. Indirect Addressing Mode:

In register indirect addressing mode, the data to be operated is available inside a memory location and
that memory

location is indirectly specified by a register pair.

Examples:

MOV A, M (move the contents of the memory location pointed by the H-L pair to the accumulator)

LDAX B (move contents of B-C register to the accumulator)

STAX B (store accumulator contents in memory pointed by register pair B-C)

5. Implied/implicit Addressing Mode:

In implied/implicit addressing mode the operand is hidden and the data to be operated is available in
the instruction itself.

Examples:

CMA (finds and stores the 1's complement of the contents of accumulator A in A)

RRC (rotate accumulator A right by one bit)

RLC (rotate accumulator A left by one bit)

Advantages of Addressing Modes in 8085 Microprocessor:

● Versatility: The 8085 microprocessor supports several addressing modes, which allows for a
wide range of memory access and manipulation options.

GEC,Daman 2 221423107005
Practical - 1

● Efficient memory usage: Different addressing modes allow for efficient use of memory,
reducing the memory footprint of programs and making the best use of available memory.
● Easy to use: The addressing modes are easy to use, making it simple for programmers to
write and execute complex programs.
● Improved performance: The use of different addressing modes can improve the performance of
programs, as the correct addressing

mode can be chosen to match the specific requirement of the program.

Disadvantages of Addressing Modes in 8085 Microprocessor:

● Complexity: The various addressing modes can be complex, making it difficult for programmers
to choose the correct mode for a given task.
● Overhead:The use of different addressing modes can result in additional overhead, as the
microprocessor must perform additional operations to access memory.
● Debugging difficulties:Debugging programs that use multiple addressing modes can be difficult,
as the programmer must keep track of the different modes used in each memory access.
● Limitations:The addressing modes are limited by the size of the program counter and the
memory address space, which can impact the performance of large programs.

GEC,Daman 3 221423107005
Practical-2

AIM:To study all instructions of the 8085 Microprocessor.


Data Transfer Instructions:
Data transfer instructions are the instructions that transfer data in the microprocessor. They are also
called copy instructions.

OPCODE OPERAND EXPLANATION Example No. of Bytes


MOV Rd Rs Rd ← Rs MOV A, B 1 byte
MOV Rd., M Rd ← M[c] MOV A, 2050 1 byte
MOV M. Rs M[c] ← Rs MOV 2050, A 1 byte
MVI Rd, 8-bit data Rd ← data MVI A, 34H 2 byte
MVI M. 8-bit data M[c] ← data MVI 2050, 34H 2 byte
LDA 16-bit A ← M[address] LDA 2051 3 byte
address
STA 16-bit M[address] ← A STA 2051 3 byte
address
LHLD 16-bit H ← M[address + 1], L ← M[address] LHLD 2020 3 byte
address
SHLD 16-bit M[address + 1] ← H, M[address] ← L SHLD 2050 3 byte
address
LXI RP. 16-bit Load the specific register pair with data LXI D, 3050 3 byte
LDAX RP A ← M[RP] LDAX H 1 byte
STAX 16-bit M[address] ← M[RP] STAX 2050 1 byte
address
XCHG none Exchange H with D and L with E XCHG 1 byte
XTHL none Exchange the content of top of the XTHL 1 byte
stack with the content of H & L register
PUSH R Push RP to the Stack PUSH H 1 byte
POP RP Pop the Stack to RP POP H 1 byte
IN 8-bit port Input the content of specified port to A IN 15 2 byte
OUT 8-bit port Output content of A to the specified port OUT 16 2 byte

GEC,Daman 4 221423107005
Practical-2

Arithmetic Instruction:
Arithmetic Instruction is the instruction which performs basic arithmetic operations such as addition,
subtraction and a few more. In an 8085 microprocessor, the destination operand is generally the
accumulator.

OPCODE OPERAND EXPLANATION Example No. of Bytes


ADD R A=A+R ADD B 1 byte
ADD M A=A+Mc ADD 2050 1 byte
ADI 8-bit data A=A+8-bit data ADI 34H 2 byte
ADC R A=A+R+carry ADC B 1 byte
ADC M A=A+Mc+carry ADC 2050 1 byte
ACI 8-bit data A=A+ 8-bit data + prev. ACI 34H 2 byte
carry
SUB R A=A-R SUB B 1 byte
SUB M A=A-Mc SUB 2050 1 byte
SUI 8-bit data A-A-8-bit data SUI 34H 2 byte
SBB R A=A-R-prev. carry SBB B 1 byte
SBB M A=A-Mc-prev, carry SBB 2050 1 byte
SBI 8-bit data A-A-8-bit data - prev. carry SBI 34H 2 byte
INR R R=R+1 INR B 1 byte
INR M M=Mc+1 INR 2050 1 byte
INX RP RP=RP+1 INX H 1 byte
DCR R R=R-1 DCR B 1 byte
DCR M M=Mc-1 DCR 2050 1 byte
DCX RP RP=RP-1 DCX H 1 byte
DAD RP HL=HL+RP DAD H 1 byte

Logical Instruction:

Logical instructions are the instructions that perform basic logical operations such as AND, OR, etc. in the
8085 microprocessor, the destination operand is always the accumulator. Here logical operation works on a
bitwise level.

OPCODE OPERAND DESTINATION EXAMPLE NO. OF BYTES


ANA R A = A AND R ANA B 1 byte
ANA M A = A AND Mc ANA 2050 3 byte
ANI 8-bit data A = A AND 8-bit data ANI 50 2 byte
ORA R A = A OR R ORA B I byte

GEC,Daman 5 221423107005
Practical-2

ORA M A = A OR Mc ORA 2051 3 byte


ORI 8-bit data A = A OR 8-bit data ORI 51 2 byte
XRA R A = A XOR R XRA B 1 byte
XRA M A - A XOR Mc XRA 2050 3 byte
XRI 8-bit data A = A XOR 8-bit data XRI 50 2 byte
CMA none A = 1's complement of A CMA 1 byte
CMP R Compares R with A and triggers CMP B 1 byte
the flag register
CMP M Compares Mc with A and triggers CMP 2050 3 byte
the flag register
CPI 8-bit data Compares 8-bit data with A and CPI 50 2 byte
triggers the flag register
RRC none Rotate accumulator right without RRC 1 byte
carry
RLC none Rotate accumulator left without RLC 1 byte
carry
RAR none Rotate accumulator right with RAR 1 byte
carry
RAL none Rotate accumulator left with carry RAL 1 byte
CMC none Compliments the carry flag CMC 1 byte
STC none Sets the carry flag STC 1 byte

Branching Instruction:
Branching instructions refer to the act of switching execution to a different instruction sequence as a
result of executing a branch instruction.

The three types of branching instructions are:

1. Jump (unconditional and conditional)

2. Call (unconditional and conditional)

3. Return (unconditional and conditional)

1. Jump Instructions:

OPCODE OPERAND EXPLANATION EXAMPLE


Unconditional Jump
JMP 16-bit address Jumps to the address JMP 2050
Conditional Jump
JC Jumps to the address if carry flag is 1 JC 2050
JNC Jumps to the address if carry flag is 0 JNZ 2050
JZ Jumps to the address if zero flag is 1 JZ 2050
JNZ Jumps to the address if zero flag is 0 JNZ 2050

GEC,Daman 6 221423107005
Practical-2

JPE 16-bit address Jumps to the address if parity flag is 1 JPE 2050
JPO Jumps to the address if sign flag is 0 JPO 2050
JM Jumps to the address if sign flag is 1 JM 2050
JP Jumps to the address if sign flag 0 JP 2050

2. Call Instructions:

OPCODE OPERAND EXPLANATION EXAMPLE


Unconditional Call
CALL address Unconditionally calls CALL 2050
Conditional Call
CC Call if carry flag is 1 CC 2050
CNC Call if carry flag is 0 CNC 2050
CZ Calls if zero flag is 1 CZ 2050
CNZ address Calls if zero flag is 0 CNZ 2050
CPE Calls if parity flag is 1 CPE 2050
CPO Calls if parity flag is 0 CPO 2050
CM Calls if sign flag is 1 CM 2050
CP Calls if sign flag is 0 CP 2050

3. RETURN

OPCODE OPERAND EXPLANATION EXAMPLE


Unconditional return
RET None Return from the subroutine unconditionally RET
Conditional return
RC Return from the subroutine if carry flag is 1 RC
RNC Return from the subroutine if carry flag is 0 RNC
RZ Return from the subroutine if zero flag is 1 RZ
RNZ None Return from the subroutine if zero flag is 0 RNZ
RPE Return from the subroutine if parity flag is 1 RPE
RPO Return from the subroutine if parity flag is 0 RPO
RM Return from the subroutine if sign flag is 1 RM
RP Return from the subroutine if sign flag is 0 RP

GEC,Daman 7 221423107005
Practical-2

DAA Instruction:

The full form of DAA is Decimal Adjust Accumulator and it is used in BCD addition. This instruction can be
used only after addition and it cannot be used stand alone.

All rules are listed below:

✓ If the LS hex digit in A is <= 9 and AC flag is 0, the LS hex digit value will not be altered.
✓ If the LS hex digit is > 9, or if AC flag is set to 1, it adds 6 to the LS hex digit of A. if carry result,
then it increments the MS hex digit if this addition resulted in a carry to the MS digit position. In this
process, the Cy flag will be set to 1 if the MS hex digit was incremented from F to 0.
✔ If the MS hex digit is <= 9 and Cy flag is 0, the MS hex digit will not be altered, and
Cy flag is reset to 0.
✓If the MS hex digit is > 9, or if Cy flag is set to 1, it adds 6 to the MS hex digit of A and
sets Cy flag to 1.

Machine Control Instructions:


These types of instructions control machine functions such as Halt, Interrupt, or do nothing. This type of
instructions alters the different types of operations executed in the processor.
Following are the type of Machine control instructions:

OPCODE OPERAND MEANING EXPLANATION


NOP None No operation
No operation is performed, i.e., the instruction is
fetched and decoded
HLT None Halt and enter wait The CPU finishes executing the current
state instruction and stops further execution. An
interrupt of reset is necessary to exit from the
halt state.
DI None Disable interrupts The interrupt enable flip-flop is reset and all
the interrupts are disabled except TRAP.
EI None Enable interrupts The interrupt enable flip-flop is set and all the
interrupts are enabled.
RIM None Read interrupt This instruction is used to read the status of
mask interrupts 7.5, 6.5, 5.5, and read serial data
input bit.
SIM None Set interrupt mask This instruction is used to implement the
interrupts 7.5, 6.5, 5.5, and serial data output.

GEC,Daman 8 221423107005
Practical-3

AIM: Add two numbers stored at 2000H and 2001H, Store the sum at 2002H
and carry at 2003H.

: Add 2 numbers

MVI C, 00H ; Assume C register is Storing carry


LDA 2000H ; (1st) num in A

MOV B, A ; (1st) num in B

LDA 2001H ; (2nd)num in A

ADD B ;[A=A+B]
JNC SKIP ; jump if no carry
INR C ; make (C=1) if carry found

SKIP: STA 2002 ; store content of A at location 2002H


MOV A, C ;[C=A]

STA 2003H ; store content of A at location 2003H


HLT

Output:

AIM:Adding Two number using memory pointer

MVIC, 00H ;Assume C storing carry

GEC,Daman 9 221423107005
Practical-3

LXI H, 2000H ;M point to 2000H

MOV B, M ;(B=1st) Number

INX H ;M point to next memory location 2001H

MOV A, M ;(A=2nd) Number

ADD B ;[A=A+B]

JNC SKIP ;jump if no carry to SKIP

INR C ;Increase C if carry exist

SKIP: INXH ;Point to next memory location 2002H

MOV M, A ;storing content of A to 2002H location

INX H ;point to next memory location 2003H

MOV M, C ;moving content of C to location 2003H

HLT

Output:

GEC,Daman 10 221423107005
Practical-3

GEC,Daman 11 221423107005
Practical-4

AIM:Write a program to move blocks of bits from source location starting at


2000 to destination location starting from 3000 where size of blocks is 10
bytes.

LXI B, 2000H ; BC pair point to 2000h location

LXI D, 3000H ; DE pair point to 3000h location

MVI L, 0AH ; store 0A in L register

BACK: LDAX B ; load the accumulator with the content of BC pair

STAX D ; store the content of accumulator to DE pair

INX B ; increment the BC pair

INX D ; increment the DE pair

DCR L ; decrement L register by 1

JNZ BACK ; jump to Back if content of L is not zero


HLT

Output:

GEC,Daman 12 221423107005
Practical-4

AIM: Write a program to move blocks of bits from source location starting at
2000 to 2009 to destination location starting from 3009 to 3000 where size of
blocks is 10 bytes.

LXI B, 2000H ; BC pair point to 2000h location

LXI D, 3009H ; DE pair point to 3009h location

MVI L, OAH ; store 0A in L register

BACK: LDAX B ; load the accumulator with the content of BC pair

STAX D ; store the content of accumulator to DE pair

INX B ; increment the BC pair

DCX D ; decrement the DE pair

DCR L ; decrement L register by 1

GEC,Daman 13 221423107005
Practical-4

JNZ BACK ; jump to Back if content of L is not zero

HLT

Output:

GEC,Daman 14 221423107005
Practical-4

GEC,Daman 15 221423107005
Practical-5

Write Assembly Language Program to add two 8-bit numbers at location


5000H and 5001H also store the result at 5002H.

LDA 5000H ; Load the first number (at 5000H) into the accumulator

MOV B, A ; Move the accumulator value (first number) to a register (e.g., B)

LDA 5001H ; Load the second number (at 5001H) into the accumulator

ADD B ; Add the contents of accumulator (second number) and register B (first number)

STA 5002H ; Store the result (in accumulator) to the desired location (5002H)

HLT

Output:

GEC,Daman 16 221423107005
Practical-5

AIM:Write Assembly Language Program to add two BCD number by using


8-bit Operation.

MVI C, 00H ; C = 00h

LDA 2000H ; load content of 2000h in A

MOV B, A ; move content of A to B

LDA 2002H ; load content of 2002h in A

ADD B ;A=A+B

DAA ; Decimal adjust Accumulator

STA 2004 ; store content of A to memory location 2004

LDA 2001H ; load content of 2001h in A

MOV B, A ; move content of A to B

LDA 2003H ; load content of 2003h in A

ADC B ; A = A + B + CF

DAA ; Decimal adjust Accumulator

STA 2005H ; store content of A to 2005h location

JNC SKIP ; jump if no carry to skip label

INR C ; increment C

SKIP: MOV A, C ; move content C to A

STA 2006H ; store content of A to 2006h

HLT

GEC,Daman 17 221423107005
Practical-5

OUTPUT:

GEC,Daman 18 221423107005
Practical-6

AIM:Write Assembly Language Program to exchange blocks of 10 byte


sorting from 2000H to 3000H.

MVI C, 10H

LXI H, 2000H

LXI D, 3000H

Loop: MOV A, M

STAX D

INX H

INX D

DCR C

JNZ Loop

HLT

OUTPUT:

GEC,Daman 19 221423107005
Practical-6

GEC,Daman 20 221423107005
Practical-7

AIM:Write an Assembly Language Programming to find the largest number


from a block of 10 bytes.

LXI H, 2000H ; load content of 2000h in HL pair

MVI C, 09H ; move 09h to C register directly

MOV A, M ; move content of HL pair in A

BACK: CMP M ;A=A-M

JNC SKIP ; if no carry then jump to skip label

MOV A, M ; move content of M to A

SKIP: INX H ; increment HL pair

DCR C ; decrement C

JNZ BACK ; jump if no zero to back label

INX H ; increment HL pair

MOV M, A ; move content of A to memory location

HLT

OUTPUT:

GEC,Daman 21 221423107005
Practical-7

AIM:Write an Assembly Language Programming to find the smallest number


from a block of 10 bytes.

LXI H,2000H

MVI C,0AH

MOV A,M

BACK:CMP M

JC SKIP

MOV A,M

SKIP:INX H

DCR C

JNZ BACK

MOV M,A

HLT

GEC,Daman 22 221423107005
Practical-7

OUTPUT:

GEC,Daman 23 221423107005
Practical-8

AIM: Write an assembly program to add 10 8-bit numbers stored from


2000H to 2009H, store the result at 200AH and carry at 200BH.
LXI H, 2000H

MVI C, 0AH

MVI A, 00H

MVI B, 00H
BACK: ADD M
JNC SKIP
INR B
SKIP: INX H
DCR C
JNZ BACK
MOV M, A
INX H
MOV M, B
HLT

OUTPUT:

GEC,Daman 24 221423107005
Practical-8

AIM: Write an assembly language program to arrange two numbers in


descending order stored at location 2000H and 2001H.

LXI H, 2000H
MOV A, M INX
H
CMP M JNC
SKIP MOV
C, M MOV
M, A DCX H
MOV M, C
SKIP: HLT

OUTPUT:

GEC,Daman 25 221423107005
Practical-8

AIM: Write an assembly language program to find 2’s complement of a


number stored in memory location 4000H and store the result at 4001H.
LDA 4000H
CMA
INR A
STA 4001H
HLT

OUTPUT:

GEC,Daman 26 221423107005
Practical-8

AIM: Write an assembly language program to find 2’s complement of 5


numbers stored in memory location 2000H and store the result in 200AH

LXI H, 2000H

LXI D, 200AH

MVI C, 05H

BACK: MOV A,M

CMA

INR A

STAX D

INX H

INX D

DCR C

JNZ BACK

HLT

GEC,Daman 27 221423107005
Practical-8

OUTPUT:

GEC,Daman 28 221423107005
Practical-9

AIM: Write an assembly language program to sort numbers stored at


memory location 2000H to memory location 2004H.

MVI B, 04H
BACK2: MVI C, 04H
LXI H, 2000
BACK1: MOV A, M
INX H
CMP M
JC SKIP
JZ SKIP
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H
SKIP: DCR C
JNZ BACK1
DCR B
JNZ BACK2
HLT
OUTPUT:

GEC,Daman 29 221423107005
Practical-10

AIM: Write an assembly language program to check the number of 1’s in the
location 2000H.

MVI B, 00H
MVI C, 08H
LDA 2000H
BACK:RLC
JNC SKIP
INR B
SKIP: DCR C
JNZ BACK
MOV A, B
STA 2001H
HLT
OUTPUT:

GEC,Daman 30 221423107005
Practical-11

AIM: write an assembly language program for 8085 interfacing with 8255 PPI
for traffic control.

LXI SP, FFFFH SP=FFFF

MVI A, 80H A=80

OUT 63H CWR=A

UP: MVIA, 21H A=21

OUT 60H PORT A = A

MVI A, 0CH A=0C

OUT 61H PORT B=A

CALL DELAY 1 WAIT FOR 55 SEC

MVI A, 12H A=12

OUT 60H PORT A=A

MVI A, 0CH A=0C

OUT 61H PORT B=A

CALL DELAY 2 WAIT FOR 5 SEC

MVI A, 0CH A=0C

OUT 60H PORT B=A

MVI A, 21H A=21

OUT 61H PORT B=A

CALL DELAY 1 WAIT FOR 55 SEC

MVI A, 0CH A=0C

OUT 60H PORT A=A

MVIA, 12H A=12

OUT 61H PORT B=12

CALL DELAY2 WAIT FOR 5 SEC

JUMP UP

GEC,Daman 31 221423107005
Practical-12

AIM: write a subroutine for 8085 to generate a delay of 100 microsecond.

DELAY 100US: MVI B, 16H ; set the loop counter to 16

DELAY_LOOP: DCR B ; Decrement B register

JNZ DELAY_LOOP ; jump back to DELAY_LOOP if not zero

RET ; return from the subroutine

The above subroutine will generate an approximately 100 micro sec.

AIM: write a subroutine for 8085 to generate delay of 10 millisecond.

DELAY 10MS: MVI B, 27H ; Load B register with the value 27

DELAY LOOP: MOV C, B ; Move the value from B to C register

DELAY_LOOP2: DCR C ; decrement the value in c register

JNZ DELAY_LOOP2 ;jump back to DELAY_LOOP2 if C is not zero

DCR B ; decrement the value in B register

JNZ DELAY_LOOP ; jump back to DELAY_LOOP if B is no Zero

RET ; return from the subroutine

The above subroutine will generate an approximately 10 millisecond.

GEC,Daman 32 221423107005
Practical-13

AIM: Write an Assembly Language program to divide two 8-bit numbers


stored at 2000h and 2001h and store the quotient at 2002h and remainder at
2003h.

LDA 2001H ; Load A with content of 2001h

ADI 00H ; Add 00 with content of A

JZ EXIT ; Jump if flag register is zero

MOV C, A ; Move content of A to C (C=divisor)

MVI E, 00H ; E = 00h

LDA 2000H ; Load A with content of 2000h (A=dividend)

BACK: CMP C ; Perform A - C

JC NEXT ; Jump if carry flag is set

SUB C ;A=A-C

INR E ; Increment E by 1

JMP BACK ; Jump to Back label

NEXT: STA 2003H ; Store content of A to 2003h location

MOV A, E ; Move content of E to A

STA 2002H ; Store content of A to 2002h location

EXIT: HLT ; Halt the program

OUTPUT:

GEC,Daman 33 221423107005
Practical-13

GEC,Daman 34 221423107005
Practical-14

AIM: Write an assembly language program to multiply two 8-bit numbers


stored at 2000H and 2001H, store result at 2002H.

LXI H, 0000H
LXI D, 0000H
LDA 2000H
MOV E, A
LDA 2001H
MOV C, A
BACK: DAD D
DCR C
JNZ BACK
SHLD 2002H
HLT
OUTPUT:

GEC,Daman 35 221423107005

You might also like