58
Microprocessor and Interfacing Laboratory Manual Enrollment No. _______________ Name of the student:_________________________________ Government Engineering College, Rajkot

Microprocessor Lab Manual SEM IV 2013

Embed Size (px)

DESCRIPTION

j

Citation preview

Page 1: Microprocessor Lab Manual SEM IV 2013

Microprocessor and Interfacing

Laboratory Manual

Enrollment No. _______________

Name of the student:_________________________________

Government Engineering College, Rajkot

Page 2: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 2

GOVERNMENT ENGINEERING COLLEGE, RAJKOT

CERTIFICATE

This is to certify that Mr/Miss

____________________________________Enrollment No. _____________

of B.E. (E.C.) SEM-V has satisfactorily completed the term work

of the subject 140701 Microprocessor and interfacing

prescribed by Gujarat Technological University during the

academic term January-2013 to April-2013.

Date: Signature of the faculty

Page 3: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 3

INDEX Sr. No.

Name of Experiment Page No.

1. To become familiar with 8085 microprocessor training kit and execute following programs on microprocessor kit

Add two 8 bit numbers stored in register B & C store result in register D

Subtract 8 bit data stored at memory location 4021h from data stored at memory location 4020h. Store result at memory location 4022h

To perform OR operation between accumulator and register B. Store result in register C

2. To become familiar with 8085 microprocessor simulator and simulate following programs using simulator

Write a program to interchange content of register B and C

Subtract content of register E from register B. Complement content of accumulator and display result on output port PORT2.

Perform logical OR operation between register B and C, logical AND operation between accumulator and register B.

3. Write a program to transfer set of data from memory location 2050-205Fh to 2060-206Fh

4. Write a program to find smallest number from given set of data stored at location 2040h to 205Fh

5. Write a program to find negative numbers in given set of data stored at the location 2050h to 205Fh

6. Write program to arrange an array of data in ascending order

7. Write a program to multiply two 8 bit numbers stored at the location 2100 and 2101. Store result at memory location 2102h

8. Write program to divide 16 bit number stored at memory location 2100h and 2101h by 8 bit number stored at memory location 2102h. Store quotient in memory locations 2110h and 2111h, remainder at memory location 2112h

9. Write a program to separate out (unpack) two digit BCD number and pack (combine) two digit BCD number into one

Page 4: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 4

10. Write a program to convert hexadecimal number into equivalent BCD number

11. Write a program to check parity of data stored at memory location 2100. Move content EEh to register B, if parity is even and 00h if parity is Odd.

12. Write and execute program to display count value 0 to 9 on the seven segment display using standard subroutine for display output

13. Write program to use vector interrupt (VI) RST 7.5 to switch from up counter to down counter

14. Write program to flash message “EC LAB” on address and data field of display

15. To interface Programmable peripheral interface (PPI) IC-8255 with 8085 Microprocessor in Mode 0

16. To generate square wave on port pin PC7 of 8255 in BSR mode

Instructions to the students:

Solve exercise given at end of each practical, write answers and execute it

Test your all programs with 8085 microprocessor kit or simulator

Get signature of staff regularly after completion of practical and exercise regularly

Prepare separate notebook for the assignments given in the classroom by faculty

Separate interfacing card to interface with the Microprocessor kit which will be useful in experiment number 15 and 16. At least one circuit per one batch. Connector detail is given in experiment 15.

Get circuit diagram of interfacing card from faculty

Use simulator GNU8085 or 8085 Simulator IDE which comes in CD along with Book by Ramesh Gaonkar

Page 5: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 5

EXPERIMENT NO. 1

AIM: To become familiar with 8085 microprocessor training kit and execute following programs on microprocessor kit

Add two 8 bit numbers stored in register B & C store result in register D

Subtract 8 bit data stored at memory location 4021h from data stored at memory location 4020h. Store result at memory location 4022h

To perform OR operation between accumulator and register B. Store result in register C

Introduction of 8085 Kit:

8085 Kit allows you to enter hex code of the program and run the program. You can observe content of registers and memory locations after and before execution of assembly language program.

8085 Kit has 8Kbyte CMOS RAM chip 6264 and 8Kbyte EPROM. 8085 Kit has various input-output devices such as 8279 (Keyboard-

display interface), 8255 (Programmable peripheral interface), 8155 (Programmable I/O port and timer), 8253 (Programmable interval timer)

8085 has following keys to enter, execute and observe result of the program. RESET: To reset the system VI: To provide hardware interrupt SHIFT: To give second level command (Alternate function) GO: To execute program SI: To execute program in single step mode EXMEM: Examine or modify memory locations EXREG: Examine or modify CPU registers PRE: Used with EXMEM to decrement content of PC

(Intermediate terminator) NEXT: Increment PC value. Used while examining memory

locations and contents of registers . (DOT): It is terminator to terminate command and write data in

the data field at the location displayed in address field DEL: Delete part of the program or data INS: Inserts the part of the program or data with relocation by

one or more bytes BM: Allows user to move block of memory to any other RAM

area FILL: Allows user to fill RAM area with a constant

Page 6: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 6

REL: Relocates a program written for some memory area and transfer to other memory area

INSDATA: Inserts one or more data bytes in user program data area

DELDATA: Deletes one or more data bytes from the user program/data

MEMC: Compares two blocks of memory 0-F: Hexadecimal keys to enter program and data

8085 kit has six digit seven segment display. First four digits are called “address field” and last two digits are called “data field”. Memory map for the kit is as follow:

EPROM: 0000 to 1FFF (Used to store in built monitor program)

RAM: 2000 to 3FFF (Used to enter program code in the kit) Scratch Pad RAM used by monitor program: 2770 to 27FF

(Students should not use this area to store their program) Steps for entering and executing assembly language program in the Kit Let us understand how to enter and execute following program in the kit Memory Address

Label Mnemonics Hex Codes Comment

2000 MVI A,55 3E,55 Transfer data 55 to accumulator

2002 RST 5 EF End of program

Steps to enter program in the kit: Above program transfers data value 55 into accumulator. Use following steps to enter program in the kit.

Switch ON 8085 Kit. Message “SCb 85” will be displayed on the seven segment display

To enter HEX code of the program press “EXMEM” key Dot “.” will be displayed on the screen. Enter start memory address

for example 2000 Press “NEXT” key Enter HEX code. In our program, first hex code is 3E. It will be

displayed on data field. Press “NEXT” key Enter next HEX code i.e. 55 Press “NEXT” key Enter next HEX code i.e. EF Press NEXT key

Page 7: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 7

Steps to execute the program: After entering program, now let us understand how to execute this program.

Press “RESET” key. Message “SCb 85” will be displayed on the seven segment display

Press “GO” key Enter start memory address of the program i.e. 2000 Press “.” Key. Program will execute

Steps to examine result after execution of the program: After entering and executing program, we wish to examine result of the program. In our program, we want to examine content of Accumulator. Use following steps to observe content of accumulator.

Press “SHIFT” Key Press “EXREG” Key, Dot “.” Will be displayed on seven segment

display. Press “A” to examine content of accumulator

Note: To observe content of other registers like B,C,D,E,H,L,PCL,PCH,SPL, SPH etc. press “NEXT” key. Or to observe content of any register press corresponding key from the keyboard after displaying “.” with above steps. To observe data at memory location use following steps:

Press “RESET” key Press “EXMEM” key Enter address (for example 2010), press “NEXT” key, data at location

2010 will be displayed on data field. Assembly language programs:

Program 1: Add two 8 bit numbers stored in register B & C store result in register D

Memory Address

Label Mnemonics Hex Codes Comment

2000 MVI B,44 06,44 Store data 44 in register B

2002 MVI C,55 0E,55 Store data 55 in register C

2004 MOV A,B 78 Transfer content of register B in A

2005 ADD C 81 Add data stored in register C in Accumulator

Page 8: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 8

2006 MOV D,A 57 Store result in register D

2007 RST 5 EF Software interrupt (End of program)

Enter hex codes of the program in the kit. Observe result stored in register D.

Program 2: Subtract 8 bit data stored at memory location 2100h from data stored at memory location 2101h. Store result at memory location 2102h Memory Address

Label Mnemonics Hex Codes Comment

2000 LXI H,2100 21,00,21 Set HL register pair as a memory pointer

2003 MOV A,M 7E Get data from memory location 2100

2004 INX H 23 Increment memory location

2005 SUB M 96 Subtract from accumulator

2006 INX H 23 Increment memory location

2007 MOV M,A 77 Store result at 2102

2008 RST 5 EF Software interrupt (End of program)

Store some values at memory location 2100 and 2101. Execute above program and observe result at memory location 2102.

Example data:

[1] 2100: 45 2101: 33 Note down result at 2102: _____

[2] 2100: 54 2101: 53 Note down result at 2102: _______

Write your comment for the second result:

____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 9: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 9

Program 3: To perform OR operation between accumulator and register B. Store result in register C Memory Address

Label Mnemonics Hex Codes Comment

2000 MVI A,55 3E,55 Transfer data 55 to A

2002 MVI B,33 06,33 Transfer data 33 to B

ORA B B0 Perform logical OR operation between accumulator and register B

2001 MOV C,A 4F Store result in register C

2002 RST 5 EF SWI (End of program)

Initially store some data in register A (accumulator) and B. Execute above program and verify result. Example data: [1] A: 55 B: 33 C: _______ [2] A: 55 B: 22 C: ________ [3] A: 25 B: 55 C: ________

:: WORKSHEET ::

Write and execute following programs in microprocessor kit

[a] Write a program to add two 8 bit numbers stored at memory locations 2100h and 2101h. Store result at memory location 2102h. _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 10: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 10

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________[b] Write a program to subtract 8 bit data stored in register B from the data stored in register C. Store result in register D. ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ [c] To perform AND operation between register B and C. Store result in register D. ___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 11: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 11

EXPERIMENT NO. 2

AIM: To become familiar with 8085 microprocessor simulator and simulate following programs using simulator

Write a program to interchange content of register B and C Subtract content of register E from register B. Complement content of

accumulator and display result on output port PORT2. Perform logical OR operation between register B and C, logical AND

operation between accumulator and register B. There are so many simulators available to write, assemble and execute assembly language program. Advantage of using assemblers is that we need not worry about writing hex codes of the program. Assembler will generate hex code from the mnemonics written in the program. We will use two types of simulator for 8085 [1] Linux based GNU8085 simulator and [2] 8085 Simulator IDE which comes in CD along with book on “Microprocessor Architecture, Programming and Applications with the 8085 by Ramesh Gaonkar”. We will write, run and simulate assembly language program. [1] GNU8085 Simulator: GNU8085 provides IDE (Integrated Development Environment) to write, assemble and execute assembly language program. Screen shot of GNU8085 simulator is shown in the following figure.

GNU8085 Microprocessor simulator allows you to write assembly language program in the editor space. You don’t need to write or enter hex codes. Hex

Page 12: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 12

codes will be generated automatically when you assemble your program. You can save your program, get print out of the program.

Steps to use GNU8085 Simulator:

Click on File-->New to open new file and write assembly language program

Click on Assembler-->assemble (Short cut F8) to assemble your program

Click on Assembler-->Execute (Short cut F9) to execute your program

You can also execute your program step by step (one by one instruction) by using Debug-->step in (Short cut key F5) to see execution of instructions one by one. It is good practice for debugging your program. This assembler is user friendly.

It allows you to examine content of CPU registers A,B,C,D,E,H,L,PC,SP, Program status word (PSW) , I/O ports, memory.

It is having keypad to insert mnemonics while writing the program. It is having decimal to hex and hex to decimal conversion facility.

[2]8085 Simulator IDE(Comes in CD with Book written by Ramesh Gaonkar)

8085 Microprocessor simulator IDE (Integrated Development Environment) allows to write, assemble and execute assembly language program. Screen shot of this simulator is given in following figure.

Page 13: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 13

This simulator allows us to write and execute programs. It also allows to simulate peripherals, input-output devices. It also allows interrupt execution. It has memory editor to display hex codes, peripheral devices window to display status of I/O port. Steps to use 8085 Simulator IDE

Start 8085 Simulator IDE. Click on Tools\Assembler. Click on File\New. Write program by giving TAB (First column is for LABEL) After writing program, Save it giving file name let us say test.asm Click on Tools\Assemble. Assembler will generate two files: test.lst (assembler listing with assembled

opcodes) and test.obj (binary image of assembled routine ready to be loaded into memory). The output listing file test.lst will be displayed.

Click on Tools\Load. That will load the program file test.obj into 8085 Simulator IDE memory.

Close assembler window. Select the option Options\Enable logging. Click on Tools\Memory Editor. That will open the Memory Editor Reposition the windows on the screen to get better view, if necessary Check that Options\HLT Stops Simulation option is selected. Check that Rate\Fast simulation rate is selected. You can change the

simulation rate even when the simulation is running. Click on Simulation\Start. The simulation will start immediately.

Execute following programs on the simulator and note down results after execution of the program:

Program 1: Write a program to interchange content of register B and C MVI B,75h ;Load initial content 45h in register B

MVI C,89h ;Load initial content 56h in register C

MOV A,B ; Copy value of register B in accumulator

MOV B,C ; Copy content of register C in register B

MOV C,A ; Copy accumulator into register C

HLT ; Halt program

Write result after execution of the program:

B=

C=

A=

Page 14: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 14

Program 2: Write and execute program to add two hexadecimal numbers stored in register B and C. Add numbers, complement result and display it on LEDs connected at output port PORT0 (Consider PORT0 address 00h)

MVI B,33h

MVI C,22h

MOV A,B

ADD C

OUT 00h

CMA

OUT 00h

HLT

Write result after execution of the program:

B=

C=

A=

PORT0 =

Get Results on LEDs of peripheral windows in Microprocessor 8085 IDE

Program 3: Write and execute program in single step mode for logical OR operation between register B and C, logical AND operation between accumulator and register B.

MVI B,91h

MVI C,0A8h

MOV A,B

ORA C

ANA B

HLT

Write result after execution of the program:

B=

C=

After ORA instruction, content of A=

After ANA instruction, content of A=

Page 15: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 15

:: WORKSHEET :: [1] Write and simulate program to subtract content of register E from register B. Complement content of accumulator and display result on output port PORT2. Assume PORT2 address 02h. Write results after execution of the program.

_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ Result: _______________________________________________________________________________________________________________________________________________________________________________________________________________

[2] Write and simulate program to logical EX-OR operation between register H and L. Store result in register D. Use single stepping mode to execute program.

____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ Result: _______________________________________________________________________________________________________________________________________________________________________________________________________________

Page 16: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 16

[3] Write program to increment content of register B from value 00h to 10h and decrement register C from 10h to 00h. Use single stepping mode to observe content of register B and C after every increment and decrement.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ Result: __________________________________________________________________________________________________________________________________________

[4] Write a program to load value 21h to register H, 00h to register L. Transfer data 55h to memory location 2100h using instruction MVI M,55h. Check content of location 2100h. Transfer content of memory location 2100h to port address 00h.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ Result: __________________________________________________________________________________________________________________________________________

Page 17: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 17

EXPERIMENT NO. 3

AIM: Write a program to transfer set of data from memory location 2050-205Fh to 2060-206Fh Program: LXI H,2050h ;Set HL as memory pointer for source location LXI D,2060h ;Set DE as a pointer for destination location MVI C,10h ;Set register C as counter for sixteen data NEXT: MOV A,M ;Get data byte from source memory STAX D ;Store accumulator at the address pointed by ;DE register pair i.e. destination location INX H ;Increment memory pointer INX D ;Increment destination location DCR C ;Decrement counter value JNZ NEXT ;Next data if counter in not zero HLT

Execute this program on simulator and test. Execute same program in microprocessor kit and check result.

For microprocessor kit use following hex codes Memory Address

Label Mnemonics Hex Codes Comment

2000 LXI H,2050h 21,50,20 Set HL as memory pointer for source location

2003 LXI D,2060h 11,60,20 Set DE as a pointer for destination location

2006 MVI C,10h 0E,10 Set register C as counter for sixteen data

2007 NEXT: MOV A,M 7E Get data byte from source memory

2008 STAX D 12 Store accumulator at destination location

2009 INX H 23 Increment memory pointer

200A INX D 13 Increment destination location

200B DCR C 0D Decrement counter value

200C JNZ NEXT C2,07,20 Next data if counter in not zero (Zero flag not set) 200F RST 5 EF Software interrupt (Halt)

Page 18: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 18

:: WORKSHEET :: [1] Write a program to transfer set of data from memory location 2050-205Fh to 2060-206Fh in reverse order i.e. content at location 2050h should be copied into 206F, 2051h should be copied into 206E and so on content of 205Fh into 2060h.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ _______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 19: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 19

[2] Draw flow chart of the program given in this experiment.

Page 20: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 20

EXPERIMENT NO. 4

AIM: Write a program to find smallest number from given set of data stored at location 2040h to 205Fh. Store smallest number in accumulator Program: LXI H,2040h ;Set HL register as memory pointer MVI C,20h ;Set counter for 32 data MOV A,M ;Transfer first data stored at location 2040h to A NEXT: INX H ;Increase memory pointer for next data CMP M ;Compare with accumulator JC SKIP ;Skip if accumulator is already small MOV A,M ;Transfer small data to accumulator SKIP: DCR C ;Decrement counter value JNZ NEXT ;Get next data for comparison HLT

Execute this program on GNU8085 simulator and test. Execute same program in microprocessor kit and check result. Write HEX codes for above program

Memory Address

Label Mnemonics Hex Codes Comment

Page 21: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 21

:: WORKSHEET :: [1] Draw flow chart and write a program to find largest number from given set of data stored at location 2050h to 205Fh. Store largest number at the memory location 2060h

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 22: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 22

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 23: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 23

EXPERIMENT NO. 5

AIM: Write a program to find negative numbers in given set of data stored at the location 2050h to 205Fh. Store all negative numbers starting from memory location 2060h Program: LXI H,2050h ;Set HL register as memory pointer LXI D,2060h ;Set DE register as memory location for destination MVI C,10h ;Counter for sixteen data NEXT: MOV A,M ;Get data from memory to accumulator RAL ;Transfer sign bit into carry flag to check sign bit JNC SKIP ;If number is positive skip next instructions STAX D ;If number is negative, store it at destination location INX D ; Increment destination memory location SKIP: INX H ; Increment HL pair for next memory location DCR C ; Decrement counter register C JNZ NEXT ; Repeat process if counter is not ZERO. HLT

Execute this program on GNU8085 simulator and test. Execute same program in microprocessor kit and check result. Write HEX codes for above program

Memory Address

Label Mnemonics Hex Codes Comment

Page 24: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 24

:: WORKSHEET :: [1] Draw flow chart and write a program to find positive number from given set of data stored at location 2050h to 206Fh. Store positive numbers at the memory location starting from 2070h

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 25: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 25

____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________________________________________________________________________________________________________________________

Page 26: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 26

EXPERIMENT NO. 6

AIM: Write program to arrange an array of data stored in memory location 2100h to 210Fh in ascending order Algorithm 1:

1. Initialize memory pointer at location 2100h by HL register pair 2. Initialize register C as a counter for number of data 3. Reset register D to use as a indicator 4. Get first value in accumulator 5. Compare value of accumulator with content of next memory location 6. If A>content of next memory location, exchange contents, set indicator 7. Decrements register C and repeat steps 5 and 6 until register C

becomes zero. 8. If indicator (Register D) is set in step 6, repeat step 1 to 7 else stop

Program (method 1):

START: LXI H, 2100h MVI D,00h MVI C,10h

NEXT: MOV A,M INX H CMP M JC SKIP MOV B,M MOV M,A DCX H MOV M,B INX H MVI D,01h

SKIP: DCR C JNZ NEXT MOV A,D RRC JC START HLT

Check program for following data: 2100: 33 2101: 55 2102: 77 2103: 99 2103: 76 2104: 12 2105: 02 2106: 44 2107: 66 2108: 88 2109: 08 210A: 09 210B: 82 210C: 25 210D: 75 210E: 86 210F: 91 Result:

Page 27: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 27

Algorithm 2: 1. Initialize memory pointer at location 2100h by HL register pair 2. Initialize register C as a counter for number of data first loop 3. Initialize register D for second loop 4. Get first value in accumulator 5. Compare value of accumulator with content of next memory location 6. If A>content of next memory location, exchange contents, 7. Decrements register D and repeat steps 5 and 6 until register D

becomes zero. 8. Decrement register C (loop2) repeat steps 3 to 7 until C becomes 0

Program (method 2):

MVI C,10h

DCR C

REPEAT: MOV D,C

LXI H,2100h

LOOP: MOV A,M

INX H

CMP M

JC SKIP

MOV B,M

MOV M,A

DCX H

MOV M,B

INX H

SKIP: DCR D

JNZ LOOP

DCR C

JNZ REPEAT

HLT

Exercise: Which method executes fast?

Page 28: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 28

:: WORKSHEET :: [1] Write program to arrange an array of data stored in memory location 2100h to 210Fh in descending order _______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ _______________________________________________________________________________________________________________________________________________________________________________________________________________

Page 29: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 29

EXPERIMENT NO. 7

AIM: Write a program to multiply two 8 bit numbers stored at the location 2100h and 2101h. Store result at memory location 2102h Algorithm: There is no multiplication instruction available in 8085 instruction set. Multiplication can be done by repetitive addition. Steps:

Load first 8 bit number (n1) from memory location 2100h in accumulator

Copy it in some register (let us say register E) Load second 8 bit number (n2) from memory location 2101h Copy second number n2 in register C We will perform addition of first number n1 which is stored in register

E, n2 times to get multiplication of numbers n1 and n2. Result is stored in HL register pair. Store HL pair at memory location 2102-03h

Flow chart:

Start

Get first number n1

Initialize second number n2 as counter in register C

HL=0

HL = HL + n1

Decrement Counter C

C=0 ?

End

No

Yes

Page 30: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 30

Programs: LDA 2100h ;Load accumulator from 2100h MOV E,A ;Copy accumulator to register E MVI D,00 ;Clear register D LDA 2201h ; Load accumulator from 2101h MOV C,A ;Initialize counter LXI H,0000h ;Clear HL to store Result NEXT: DAD D ;Add content of HL and DE DCR C ;Decrement counter JNZ NEXT ;Check whether counter is 0 or not? SHLD 2102h ;Store result at memory location 2102h and 2103h HLT Write Result of execution for following data: Data: 2100h30h 210105h Result: HL: ___________ 2102h: _______ 2103h: ________ Data: 2100h55h 21010Ah Result: HL: ___________ 2102h: _______ 2103h: ________

:: WORKSHEET :: [1] Write program to add series of numbers stored at memory location 2100h to 2105h. Store the result in HL pair

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 31: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 31

[2] Write program to add series of numbers stored at memory location 2100h to 2105h. Store the result in HL pair

_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ Check your program with following data: 2100: 11h 2101: 12h 2102: 22h 2103: 21h 2104: 33h 2105: 34h

Result: ________

Page 32: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 32

EXPERIMENT NO. 8

AIM: Write program to divide 16 bit number stored at memory location 2100h and 2101h by 8 bit number stored at memory location 2102h. Store quotient in memory locations 2110h and 2111h, remainder at memory location 2112h Program: LHLD 2100h ;Get 16 bit number in HL pair LDA 2102h ;Get 8 bit divisor in accumulator MOV C,A ;Set counter equal to divisor number LXI D,0000h ;Clear DE pair to store quotient NEXT: MOV A,L ;Get lower byte of 16 bit number in A SUB C ;Subtract 8 bit number MOV L,A ;Store result of subtraction in L JNC SKIP ; SKIP next instruction of carry does not ; occur DCR H ;Decrement higher byte if borrow occurs in ; subtraction operation SKIP: INX D ; Get total number of subtraction in register ; pair DE MOV A,H ; Copy content of H in accumulator CPI 00h ; Compare value of A (hence H) with 0 JNZ NEXT ; Perform subtraction again if dividend >divisor MOV A,L CMP C JNC NEXT SHLD 2112h ;Store remainder at 2112h and 2113h XCHG ; Exchange HL pair with DE pair SHLD 2110h ; Store result at 2110h and 2111h HLT Check your program with following data: 16 bit number: 0108h Divisor: 08h 2100: 01h 2101: 08h 2102: 08h

Result: ____________________________________________________________

Page 33: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 33

:: WORKSHEET :: [1] Write program to divide one 8 bit number stored at memory location 2100h by other 8 bit number stored at memory location 2101h. Store quotient at memory location 2102h and remainder at memory location 2103h

____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ Check your program with following data: 16 bit number: 0108h Divisor: 08h 2100: 01h 2101: 08h 2102: 08h

Result: ____________________________________________________________

Page 34: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 34

EXPERIMENT NO. 9

AIM: Write a program to separate out (unpack) two digit BCD number stored at memory location 2100h. Store tow digits at memory locations 2101h and 2102h. Program: LXI H,2100h ;Memory pointer for location 2100h MOV A,M ; Get two digit BCD number in A MOV B,A ;Copy number in register B ANI 0Fh ;Mask upper four bits (higher nibble) INX H ;Increment memory pointer MOV M,A ;Store digit at memory location 2101h MOV A,B ;Get original two digit BCD number in A ANI F0h ;Mask lower nibble RRC ;Rotate four times to get LSB from MSB RRC RRC RRC INX H ;Increment memory pointer MOV M,A ;Store second digit at 2102h HLT

Check with following data: 2100: 85h 2101: _____ 2102: _____ Write a program to combine (pack) two BCD digits and form one two digit BCD number. Consider that two BCD digits are stored at location 2110h and 2111h. Store packed BCD number at location 2112h. Program: LDA 2110h ;Get first digit

ANI FOh ; Mask lower nibble RLC ; Rotate left four times to make it MSB RLC RLC RLC MOV C,A ; Copy in register C LDA 2111h ; Get second digit ADD C ; Combine both digits STA 2112h ; Store result at location 2112h HLT

Page 35: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 35

Check with following data: 2110: 06h 2111: 07h 2112: _____

:: WORKSHEET :: [1] Write a program to find 1’s complement of 16 bit number stored at memory locations 2100h and 2101h. Store result at 2110h and 2111h

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________________________________________________________________________________________________________________________ [2] Write a program to find 2’s complement of 16 bit number stored at memory locations 2100h and 2101h. Store result at 2110h and 2111h

_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 36: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 36

EXPERIMENT NO. 10

AIM: Write a program to convert hexadecimal number into equivalent BCD number Algorithm 1:

Set HL pair as a memory pointer Clear register D and accumulator to get BCD number Get hexadecimal data in register C Increment content of accumulator and adjust for decimal in a loop

until register C becomes zero If accumulator exceeds 99, increment register D by one Store accumulator and register D at memory location 2101h and

2102h Program 1:

LXI H,2100h MVI D,00H XRA A MOV C,M LOOP2: ADI 01 DAA JNC LOOP1 INR D LOOP1: DCR C JNZ LOOP2 STA 2101h MOV A,D STA 2102h HLT Check with following data: 2100: 55h 2101: _____ 2102: _____

2100: FFh 2101: _____ 2102: _____

Page 37: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 37

Algorithm 2: Prepare subroutine BINBCD and BCD Set HL pair as a memory pointer Call BINBCD function Algorithm for BINBCD subroutine: Subtract 100 from Hex number until carry occurs

Count number of times 100 subtracted in some register and store it

Subtract 10 from remainder until carry occurs Count number of times 10 is subtracted in some register and store it

Call function BCD subroutine within BINBCD subroutine for subtraction operation by 10 and 100.

Program 2:

LXI H,2100h MOV A,M ;transfer hex data from memory to A

INX H ;Increment memory pointer to save result CALL BINBCD HLT BINBCD: MVI B,64h ;load 100 into register B CALL BCD ;call conversion for BCD3 MVI B,0Ah ;load 10 into register B CALL BCD ;call conversion for BCD2 MOV M,A ;store BCD1 RET BCD: MVI M,0FFH ;load buffer with -1 STORE: INR M ;clear buffer first and increment for each subtraction SUB B ;subtract power of ten from binary number JNC STORE ;if number is larger than power of ten, go back and ; add 1 to buffer ADD B ;if no, add power of ten to get back remainder INX H ;go to next buffer location RET Check with following data: 2100: 64h 2101: _____ 2102: _____ 2100: e0h 2101: _____ 2102: _____

Page 38: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 38

:: WORKSHEET :: [1] Write program to convert ASCII code stored in register B to hex number and store result in register C

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________________________________________________________________________________________________________________________ [2] Explain and execute following program:

MVI B,55h MOV A,B ANI 0Fh CALL ASCII STA 2100h MOV A,B ANI 0F0h RLC RLC RLC RLC CALL ASCII STA 2101h HLT ASCII: CPI 0Ah JC SKIP ADI 07h SKIP: ADI 30h RET

Page 39: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 39

Explanation: _______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ _____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ _____________________________________________________________________ [3] Write program to multiply value of accumulator by 16 using rotate instruction.

_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________________________________________________________________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

Page 40: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 40

EXPERIMENT NO. 11 AIM: Write a program to check parity of data stored at memory location 2100. Move content EEh to register B, if parity is even and 00h if parity is Odd. Program: LXI H,2100h MOV A,M ORA A JPO ODD MVI B,EEh JMP STOP ODD: MVI B,00h STOP: HLT

:: WORKSHEET :: [1] Write explanation of above program: __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ [2] Write a program to calculate number of 1’s in given data stored in register D. Calculate number of 1’s and store count value in register C _____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 41: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 41

EXPERIMENT NO. 12

AIM: Write program to flash message “EC LAB” on address and data field of display In this practical, we will use standard subroutines for various functions. These standard subroutines are stored in EPROM of the kit. Addresses of subroutines are fixed. We will call these routine in our program. Details of standard subroutine used in this program are given below: [1] CALL OUTPUT (To call output subroutine)

This routine (OUTPUT) is stored at memory location 05D0 This routine display characters on data and address field

If A=0, it display characters on address field A=1, it display characters on data field

This routine displays characters which are stored at memory location defined by HL pair. Memory location of characters should be transferred to HL pair before calling this routine. Before calling this routine, if B=0: Dot will not display and if B=1, dot will display.

[2] CALL CLEAR (To call clear subroutine) This routine is stored at memory location 0347 This routine clears seven segment display in data and address field

[3] CALL DELAY (To call delay subroutine)

This routine is stored at memory location 03BC This routine provides delay depending on value stored in DE register Value stored in the DE register pair is decremented until it becomes

zero. Once it becomes zero, RET is executed Total delay provided by the routine is (24N+17)*T Crystal frequency used in the kit is 6.14 MHZ, it is internally divided

by two, so clock frequency is 3.07 MHZ. T=0.33µS If we load 0000h in DE pair, we will get highest delay, N=65536 Delay =(24*65536+17)*0.33 µS 0.5 Second

Program: Memory Address

Label Mnemonics Hex Codes Comment

2000 Start: CALL CLEAR CD,47,03 Call standard subroutine to clear the display

2003 LXI H,2050 21,50,20 Load memory pointer, from where data will be displayed

2006 XRA A AF Ex-OR accumulator with itself to clear it

Page 42: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 42

2007 CALL OUTPUT CD,D0,05 Call standard subroutine to display in address field

200A MVI A,01 3E,01 A=01, output subroutine display in data field

200C LXI H,2054 21,54,20 Memory pointer for data to display it in data field

200F CALL OUTPUT CD,D0,05 Call standard subroutine to display in address field

2012 LXI D,0000 11,00,00 Counter for 0.5 second delay

2015 CALL DELAY CD,BC,03 Call standard delay subroutine

2018 CALL CLEAR CD,47,03 Call standard subroutine to clear the display

201B LXI D,0000 11,00,00 Counter for 0.5 second delay

201E CALL DELAY CD,BC,03 Call standard delay subroutine for 0.5 sec. blank

2021 JMP Start C3,00,20 Display message again (Flashing of message)

Store following data from memory location 2050h and execute the program 2050h: 0Eh 2051h: 0Ch 2052h: 16 (code for Blank) 2053h: 11h 2054h: 0Ah 2055h: 0Bh

:: WORKSHEET :: [1] Instead of calling standard DELAY routine, write your own delay routine using register pair DE and write above program again. Execute program to display “HELLO” on the display. (Hint: Code for H: 10 E:0E L:11 0:00)

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 43: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 43

___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

_________________________________________________________________

Page 44: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 44

EXPERIMENT NO. 13

AIM: Write and execute program to display count value 0 to 9 on the seven segment display using standard subroutine for display output

Algorithm:

1. Load initial count value 0 in accumulator

2. Display count value at output

3. Increment count value

4. Call delay routine

5. Compare count value with 0A, if it is less than 0Ak repeat steps 2 to 4 else repeat steps 1 to 4.

Program:

START: MVI A,00h ; Load count value in accumulator NEXT: OUT 00h ; Considering output address 00h CALL DELAY ; Call delay between two counts INR A ; Increment count value CPI 0Ah ;Compare with 0Ah JC NEXT ;Display incremented count value JMP START : Continue We will use standard subroutine for display count value and delay in our program, so Execute following program in the kit:

Algorithm:

1. Use standard subroutine OUTPUT to display count value on data field

2. Clear register B for no dot to be displayed

3. Load initial count value in memory

4. Display count value

5. Move 01h to accumulator to display count value in data field

6. Call output subroutine

7. Call delay subroutine

8. Clear display using clear display subroutine

9. Increment count value

10. Compare count value with 9. If it is less than or equal to 9, repeat steps 4 to 9 else repeat steps 3 to 9.

Page 45: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 45

Program:

Memory Address

Label Mnemonics Hex Codes Comment

2000 MVI B,00h 06,00 Do not display dot

2002 LXI H,2100h 21,00,21 HL as Memory pointer for count value

2005 START MVI M,00h 36,00 Count value=0

2007 NEXT PUSH H E5 Store HL pair (Memory pointer) in stack

2008 MVI A,01h 3E,01 Use data field

200A CALL OUTPUT CD,D0,05 Call output subroutine

200D LXI D,0000h 11,00,00 Delay count

2010 CALL DELAY CD,BC,03 Call Delay subroutine

2013 CALL CLEAR CD,47,03 Clear the display

2016 POP H E1 Get back memory pointer from stack

2017 INR M 34 Increment count value

2018 MOV A,M 7E Get count value in accumulator for comparison

2019 CPI OAh FE,0A Compare with 0Ah

201B JC NEXT DA,07,20 Display next count if A<0Ah

201E JMP START C3,05,20 Start again from count 0

:: WORKSHEET :: [1] Modify program for down counter (count value from 9 to 0). (Hint: Load initial count value 09h in memory, Use DCR M instead of INR M, use JNZ instead of JC). Write program again and execute in the kit.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 46: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 46

___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 47: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 47

EXPERIMENT NO. 14

Aim: Write program to use vector interrupt (VI) RST 7.5 to switch from up-counter to down counter

Introduction:

When interrupt occurs, microprocessor completes current instruction, save current program counter value in stack, and executes program stored at interrupt vector location.

8085 has five interrupts:

INTR : Receives address of subroutine from external device

TRAP : Vector location: 0024h

RST7.5 : Vector location: 003Ch

RST6.5 : Vector location: 0034h

RST5.5 : Vector location: 002Ch

We will use RST7.5 interrupt in our program. In microprocessor kit, key VI generates RST7.5 interrupt.

We will use instruction SIM to enable the interrupt

SIM is multipurpose instruction used for serial communication and interrupts. Bit D7 is serial output data, SDE is serial data enable,

RST7.5: If this bit is 1, RST7.5 flip-flop is reset

MSE: Mask set enable. If this bit is set, it enables use of M5.5 to M7.5 It is master control for bits M7.5, M6.5 and M5.5

M7.5: If this bit=0, RST7.5 enabled and if it is 1 (set) RST7.5 disabled

M6.5: If this bit=0, RST6.5 enabled and if it is 1 (set) RST6.5 disabled

M5.5: If this bit=0, RST5.5 enabled and if it is 1 (set) RST5.5 disabled

We want to use RST 7.5, so bit configurations will be as under:

SOD SDE XXX RST7.5 MSE M7.5 M6.5 M5.5

0 0 0 0 1 0 1 1 =0Bh

Page 48: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 48

To add use of VI (vector interrupt) in counter program add following instructions in program of experiment 13.

MVI A, 0Bh ;Code to enable RST7.5 interrupt

SIM ;Set interrupt mask

EI ;Set Enable interrupts flip-flop

Once you add these instructions at the beginning of program, program will recognize press of VI key. When you press VI key program will jump to vector location 002Ch. In microprocessor kit, it is EPROM location where you can not write any instruction but there is already jump instruction written at this location which takes jump to another memory location 27BDh. You can take further jump from that location.

If you write down counter program from the location 2050h. You can simply write following instruction at location 27BDh to take a jump for down counter program.

27BD JMP 2050 C3,50,20

:: WORKSHEET :: [1] Write up-counter and down-counter programs of experiment no. 13 at memory location 2004h and 2050h respectively. Add following three instructions from memory location 2000h.

2000 MVI A, 0Bh 3E, 0B ;Code to enable RST7.5 interrupt

2002 SIM 30 ;Set interrupt mask

2003 EI FB ;Set Enable interrupts flip-flop

2004 to 2025 …… Up counter program

2050 ……. Down counter program

27BD JMP 2050 C3,50,20

Execute program, up-counting will start, press VI to start down-counting.

Note: Most of the code is same for up-counter and down-counter, you can use block move facility to copy entire code of up-counter to down-counter locations and do minor modifications.

For block move, use BM key on microprocessor kit. Press BM, enter source start location, next, source end location, next, destination start location,”.”.

Page 49: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 49

___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 50: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 50

EXPERIMENT NO. 15

AIM: To interface Programmable peripheral interface (PPI) IC-8255 with 8085 Microprocessor in Mode 0 Objectives: Interface IC-8255 with microprocessor 8085 in mode 0 Interface LEDs to the ports of IC-8255 Display data on LED and read input from the switches Introduction: The programmable peripheral interface (PPI) IC-8255 is widely used parallel input output device. It can be programmed to transfer data under various conditions. It has three 8 bit ports named as Port A, Port B & Port C. Pin diagram of IC-8255 is as shown in the Fig. 1 and block diagram is as shown in the Fig. 2

+ Fig. 1 Pin diagram of 8255A Pins available on connector CN4 of 8085 Kit: PC5 PC3 PC1 PB7 PB5 PB3 PB1 PA7 PA5 PA3 PA1 PC7 Vcc

2 4 6 8 10 12 14 16 18 20 22 24 26 1 3 5 7 9 11 13 15 17 19 21 23 25

PC4 PC2 PC0 PB6 PB4 PB2 PB0 PA6 PA4 PA2 PA0 PC6 GND

Page 51: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 51

Fig. 2 Block diagram of 8255A In this experiment, we will understand mode 0 that is simple input output mode Control word format is shown in the Fig. 3 In simple I/O mode, Outputs are latched Inputs are not latched Ports do not have handshaking or interrupt facility Port A,B & C can be used as an input or output port Depending upon required operation, control word is decided from the specified format & written into control register. Port A, Port B, Port C & control register (CR) can be selected with chip select signal and Address lines A0, A1.

Page 52: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 52

Fig. 3 Control word format

Control word for Mode 0, Port A, B & C output port: D7 D6 D5 D4 D3 D2 D1 D0

1 0 0 0 0 0 0 0 80H

Addresses of 8255 for Microprocessor Kit: PORT A: 00h PORT B: 01h PORT C: 02h Control Word: 03h Procedure: Connect your LED/seven segment card with 8085 kit connector CN4 Connect power supply with the microprocessor kit & switch on the unit Enter software code and execute program Observe Flashing of LEDs If you have not prepared card, measure voltage carefully Change the delay and execute program again

Page 53: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 53

Program to flash LEDs connected at Port A alternately: Memory Address

LABEL Mnemonics Machine Code Remarks

2000 MVI A, 80H 3E,80 Send control word 80h to control register 2002 OUT 03H D3,03

2004 LOOP MVI A, 55H 3E,55 Send data 55h to Port A. 2006 OUT 00H D3,00

2008 LXI D,0000h 11,00,00 Call standard delay routine for 0.5 second 200B CALL DELAY CD,BC,03

200E MVI A, AAH 3E,AA Send data AAh to Port A 2010 OUT 00H D3,00

2012 LXI D,0000h 11,00,00 Call delay 0.5 second 2015 CALL DELAY CD,BC,03 2018 JMP LOOP C3,04,20 Program to read data from port C and display it on Port B: Control word for Mode 0, Port C input & Port B output: D7 D6 D5 D4 D3 D2 D1 D0

1 0 0 X 1 0 0 1 89H

Memory Address

Mnemonics Machine Code

Remarks

C000 MVI A, 80H 3E,89 Send control word 80h to control register C002 OUT 03H D3,03

C004 IN 02H DB,02 Read data from port C and Display it on port B. C00E OUT 01H D3,01

C010 HLT 76 End of the Program

:: WORKSHEET :: [1] Find out control word for following configuration

Port A as output port Port B & C as in input port

_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 54: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 54

_____________________________________________________________________ [2] Write assembly language program to read status of the switches connected to port A and display status on Port B. ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ [3] Write assembly language program to flash 8 LEDs connected to port A on & off continuously at the interval of 0.5 second. _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

[4] Why Ic-8255 is known as programmable device? ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 55: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 55

EXPERIMENT NO. 16

AIM: To generate square wave on port pin PC7 of 8255 in BSR mode The bit set reset (BSR) mode is used to set or reset eight bit of port C. Individual bits of port C can be made 1 (set) or 0 (reset) to control devices connected with port pins. The control word bit D7 is 0 for BSR mode. It does not affect any previously transmitted control word of I/O mode (i.e. mode with bit D7=1)

Control word for Bit Set Reset (BSR) mode:

Some examples of control words:

D7 D6 D5 D4 D3 D2 D1 D0

To set bit PC0 0 0 0 0 0 0 0 1 01H

To set bit PC6 0 0 0 0 1 1 0 1 0DH

To reset bit PC7 0 0 0 0 1 1 1 0 0EH

Procedure:

Connect Logic Interface Card with 8085 Kit Connect power supply with the microprocessor kit & switch on the

unit Enter software code and execute program Connect CRO between port pin PC7 & ground terminal Observe waveform on the C.R.O. Measure ON-OFF time of the square wave. Calculate theoretical delay and compare it with practical measured

value. Draw your own conclusion.

Page 56: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 56

Memory

Address

LABEL Mnemonics Machine Code

Remarks

2000 Start: MVI A, 0F H 3E,FF Send control word to Set bit PC7

2002 OUT 03 H D3,03

2003 NOP 00

2004 NOP 00

2005 NOP 00

2006 NOP 00

2007 NOP 00

2008 MVI A, 0EH 3E,0E Send control word to Reset bit PC7

200A OUT 03 H D3,03

200C NOP 00

200D NOP 00

200E NOP 00

200F NOP 00

2010 NOP 00

2011 JMP start C3,00,20

:: WORKSHEET ::

[1] Draw waveform and note down on-off time.

Page 57: Microprocessor Lab Manual SEM IV 2013

E.C. Department, Government Engineering College, Rajkot Page 57

[2] Calculate theoretical on-off time & compare it with practical value __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

[3] Modify program to generate square wave on pin PC4 & PC2.

__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Page 58: Microprocessor Lab Manual SEM IV 2013

Lab Manual of Microprocessor and Interfacing Page 58

[4] Draw an interfacing circuit so that 100 W Lamp can made ON & OFF using port pin PC7. Write program to make Lamp ON and OFF continuously at the interval of 1 second

[5] Draw an interfacing circuit to control electrical appliance (AC load) using port pin PC0. Interfacing circuit should provide optical isolation.