0% found this document useful (0 votes)
348 views

Microprocessors Lab Manual Original

Lab Manual for the Academic Year 2009-2010 III B. Tech I Semester DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Microprocessors and Interfacing Lab Ist Computer Science and Engineering.

Uploaded by

Chaitanya Ymr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
348 views

Microprocessors Lab Manual Original

Lab Manual for the Academic Year 2009-2010 III B. Tech I Semester DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Microprocessors and Interfacing Lab Ist Computer Science and Engineering.

Uploaded by

Chaitanya Ymr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 81

SRI VASAVI ENGINEERING COLLEGE

Pedatadepalli, Tadepalligudem (A. P.)

Lab Manual for the Academic Year 2009-2010

III B. Tech I Semester

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Microprocessors and Interfacing Lab

Microprocessors and Interfacing Lab

Sri Vasavi Engineering College


Pedatadepalli, Tadepalligudem (A. P.)

Department of Computer Science & Engineering


Lab Manual for the Academic Year 2009-10 (In accordance with JNTU syllabus)

SUBJECT SEMESTER BRANCH INSTRUCTOR

: : : :

Microprocessors and Interfacing Lab Ist Computer Science & Engineering. ________________________________ ________________________________

PROGRAMMERS

________________________________ ________________________________

Microprocessors and Interfacing Lab

Head CSE

Microprocessors and Interfacing Lab

S.No 1 2 3 Lab Objective

Contents

Page No I II III

Introduction About Lab Guidelines to Students

List of Lab Exercises

Solutions for Programs

Microprocessors and Interfacing Lab

INDEX
SI.NO EXPERIME NT NO. NAME OF THE EXPERIMENT (CYCLE-1)
1. 1

PAGE NO

MICRO PROCESSOR PROGRAMS Introduction to TASM 8- Bit Arithmetic Operations


a) Addition Numbers 2 2 b) Numbers of Two 8-bit

Subtraction of Two 8-bit

c) Multiplication of Two 8-bit Numbers d) Division of Two 8-bit Numbers

16- Bit Arithmetic Operations


a) Addition Numbers 3 3 of Two 16-bit

b) Subtraction of Two 16-bit Numbers c) Multiplication of Two 16-bit Numbers d) Division of Two 16-bit Numbers

Multi bit Operations


a) Addition Numbers 4 4 of Two 32-bit

b) Subtraction of Two 32-bit Numbers c) Multi Byte Addition d) Average of N Numbers

Microprocessors and Interfacing Lab

Arithmetic Operations of Decimal Numbers


5 5 a) Addition of Two Decimal Numbers b) Subtraction of Two Decimal Numbers

Arithmetic Operations of ASCII Numbers


6 6 a) Addition Numbers b) Subtraction Numbers of of Two Two ASCII ASCII

Signed operations
7 7 a) Multiplication of Signed Numbers b) Division of Signed numbers

Logical operations
8 8 a) Conversion of packed BCD to unpacked BCD b) Conversion of packed BCD to ASCII sorting operations

Sorting Of Numbers
9 9 a) order b) order 10 10 a) b) To sort array in Ascending To sort array in Descending

String Operations
To Copy given String To Compare Two Strings

c) To Find the length of the String d) To reverse of the String

e) To insert new string into the given String f) To delete String from the given 6

Microprocessors and Interfacing Lab


String

Using DOS-BIOS Interrupts 11 11 a) b) To read aString from DOS Prompt To display String on the DOS Prompt

INTERFACING PROGRAMS
(CYCLE-2) 12 13 14 12 13 14 Interfacing with 8259 PIC Interfacing with 8255 PPI Interfacing with 8251 USART

MICRO CONTROLLER PROGRAMS


(CYCLE-3) 15 16 17 18 19 20 15 16 17 18 19 20 To Understand First Memory Area From (00-1F) To Understand Second Memory Area From (20-2F) To Understand Third Memory Area From (30-7F) To Understand the Memory Area of 80-FF SWAP Operation SET-RESET

Microprocessors and Interfacing Lab


LAB OBJECTIVE The objective of the course is to make students aware of the functioning of a multi-user operating system. This course will serve as a foundation course for the higher level course in UNIX. The students are expected to learn the commands while doing practical and emphasis should be given to those switches/options and flags, which are most frequently used in real life. Topics: Course Outlined by topical areas like, Operating System Concepts, Linux Ideas and History, Linux Usage Basics, Running commands and Getting help, Browsing the file system, The X-Window System, Users, Groups and Permissions, Advanced Topics in Users, Groups and Permissions, The Linux file system indepth, vi : An advanced text editor , Standard I/O and Pipes, Using the bash shell , Configuring the Bash Shell,Text Processing Tools , Shell Programming, Investigating and managing process, Finding and Processing Files, Basic System Configuration Tools Contribution to outcomes: The course used assigned readings, lectures, and homework to enable students to understand the role of Operating System concepts. Use System calls and memory management. Use Unix commands and editors. Carry out Unix File management and shell programming in Unix. Do Network configuration and security management in Unix

Microprocessors and Interfacing Lab


INTRODUCTION ABOUT LAB There are 66 systems ( Compaq Presario ) installed in this Lab. Their configurations are as follows : Processor : AMD Athelon 1.67 GHz RAM : 256 MB Hard Disk : 40 GB Mouse : Optical Mouse Network Interface card : Present Software 1 All systems are configured in DUAL BOOT mode i.e, Students can boot from Windows XP or Linux as per their lab requirement. This is very useful for students because they are familiar with different Operating Systems so that they can execute their programs in different programming environments. 2 Each student has a separate login for database access Oracle 9i client version is installed in all systems. On the server, account for each student has been created. This is very useful because students can save their work ( scenarios, pl/sql programs, data related projects ,etc) in their own accounts. Each student work is safe and secure from other students. 3 Latest Technologies like DOT NET and J2EE are installed in some systems. Before submitting their final project, they can start doing mini project from 2nd year onwards. 4 MASM ( Macro Assembler ) is installed in all the systems

Students can execute their assembly language programs using MASM. MASM is very useful students because when they execute their programs they can see contents of Processor Registers and how each instruction is being executed in the CPU. 1 Rational Rose Software is installed in some systems Using this software, students can depict UML diagrams of their projects. 2 Software installed : C, C++, JDK1.5, MASM, OFFICE-XP, J2EE and DOT NET, Rational Rose. 3 Systems are provided for students in the 1:1 ratio. 4 Systems are assigned numbers and same system is allotted for students when they do the lab.

Microprocessors and Interfacing Lab


GUIDELINES TO STUDENTS: 1 Equipment in the lab for the use of student community. Students need to maintain a proper decorum in the computer lab. Students must use the equipment with care. Any damage caused is punishable. 2 Students are required to carry their observation / programs book with completed exercises while entering the lab. 3 Students are supposed to occupy the machines allotted to them and are not supposed to talk or make noise in the lab. The allocation is put up on the lab notice board. 4 Lab can be used in free time / lunch hours by the students who need to use the systems should take prior permission from the lab in-charge. 5 6 Lab records need to be submitted on or before date of submission. Students are not supposed to use floppy disks & pendrives

10

Microprocessors and Interfacing Lab


VISION To confer upon the society and environment that fosters the intellectual growth of students and serve humanity through promulgation of technological applications MISSION

To create and sustain an agile community which is highly professional with due consideration
for ethical, ecological and economical issues.

To impart quality education that serves the needs of present and to energize the technological
world. To forge mutually beneficial commitments with government, industry society and alumni. Commitment to learn, adopt and change as a means to perpetual development. To purse research and disseminate innovations to the society.

11

Microprocessors and Interfacing Lab Experiment:1

Introduction To Tasm
Steps for entering and proceed by using 8086 in TASM simulator 1: switch on your system 2: go for command prompt Check start menu in your desk top and select run then type command or cmd to go to the command prompt 3: type cd<space>TASM 4:c:\TASM >will be appeared on your screen 5: now type edit <space > filename.asm Eg:edit addition.asm 6:edit window will be appearing on the screen and type the whole program in that editior 7:save the program in the tasm directory or in any directory created by you ( file name should not be more than 8 characters) 8: press alt+f and x to exit from the editor 9: c:\tasm >will be appeared on screen .now type tasm<space>filename.asm(if there are any errors check the program correct then errors and then switch to the next command) C:\tasm>tlink<space>filename.obj C:\tasm>td<space>filename 10: finally output object file will be observed 11: now press f8 to compile the program and note down the required data

12

Microprocessors and Interfacing Lab Experiment:2(a)

8-Bit Addition
Aim: To perform the addition of two 8 bit numbers Apparatus: Tasm software, pc Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4: add the contents of al and bl Step5: store the result in d3 variable Step6: stop

Source code
data segment d1 db 15h d2 db 82h d3 db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 add al,bl mov d3,al mov ah,4ch int 21h code ends end start

Result
The addition of two 8 bit numbers is completed successfully

13

Microprocessors and Interfacing Lab Experiment:2(b)

8 Bit Subtraction
Aim: To perform the subtraction of two 8 bit numbers Apparatus: Tasm software, pc Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4: subtract the contents of bl and al Step5: store the result in d3 variable Step6: stop

Source code
data segment d1 db 02h d2 db 05h d3 db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 sub al,bl mov d3,al mov ah,4ch int 21h code ends end start

Result
The subtraction of two 8 bit numbers is completed successfully

14

Microprocessors and Interfacing Lab Experiment:2(c)

8 Bit Multiplication
Aim: To perform the multiplication of two 8 bit numbers
Apparatus: Tasm software, pc

Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4: multiply the contents of al and bl Step5: store the result in d3 variable Step6: stop

Source code
data segment d1 db 02h d2 db 03h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 mul bl mov d3,ax mov ah,4ch int 21h code ends end start

Result
Multiplication of two 8 bit numbers is completed successfully

15

Microprocessors and Interfacing Lab Experiment:2(d)

8 Bit Division
Aim: To perform the division of two 8 bit numbers Apparatus: Tasm software, pc Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into al and move one variable data into bl Step4:divide the contents of al by bl Step5: store the qutioent in d3 variable Step6: store the remainder in fourth variable Step7: stop

Source code
data segment d1 db 09h d2 db 02h quotient db ? remainder db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 mov ah,00h div bl mov quotient,al mov remainder,ah mov ah,4ch int 21h code ends end start

Result
The division of two 8 bit numbers is completed successfully

16

Microprocessors and Interfacing Lab Experiment:3(a)

16-Bit Addition
Aim: To perform the addition of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: add the contents of ax and bx Step5: store the result in d3 variable step6:stop

Source code
datasegment d1 dw 8000h d2 dw 8000h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 add ax,bx mov d3,ax adc ah,00h mov byte ptr d3+2,ah mov ah,4ch int 21h code ends end start

Result
The addition of two 16 bit numbers is completed successfully

17

Microprocessors and Interfacing Lab Experiment:3(b)

16-Bit Subtraction
Aim: To perform the subtraction of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: subtract the contents of bx from ax Step5: store the result in d3 variable step6:stop

Source code
data segment d1 dw 7000h d2 dw 8000h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 sub ax,bx mov d3,ax sbb ah,00h mov byte ptr d3+2,ah mov ah,4ch int 21h code ends end start

Result
The subtraction of two 16 bit numbers is completed successfully

18

Microprocessors and Interfacing Lab Experiment:3(c)

16-Bit Multiplication
Aim : To perform the multiplication of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: multiply the contents of ax and bx Step5: store the result in d3 and d3+2 locations step6:stop

Source code
data segment d1 dw 4000h d2 dw 2000h d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 mul bx mov d3,ax mov d3+2,dx mov ah,4ch int 21h code ends end start

Result
The multiplication of two 16 bit numbers is completed successfully

19

Microprocessors and Interfacing Lab Experiment:3(d)

16-Bit Division
Aim: To perform the division of two 16 bit numbers Apparatus: Tasm software Algorithm
Step1 : start Step2: initialize data segment Step3: move one variable data into ax and move one variable data into bx Step4: divide the contents of ax by bx Step5: store the qutioent in d3 variable step6:store the remainder in d4 variable step7: stop

Source code
data segment d1 dw 4000h d2 dw 2500h quotient dw ? remainder dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,d2 div bx mov quotient,ax mov remainder,dx mov ah,4ch int 21h code ends end start

Result
The division of two 16 bit numbers is completed successfully

20

Microprocessors and Interfacing Lab Experiment:4(a)

32-Bit Addition
AIM: To find the addition of two 32-bit numbers. APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address of d1 into si register and load the effective address of d2 at di register. Step4: Move the contents in si register to ax register and the contents of di register to bx register. Step5: Add the contents of ax and bx. Step6: Increment the contents of si register and di register two times. Step7: Move the contents in si register to cx register and move the contents in di register to dx register. Step8: Add the contents of cx and dx with carry. Step9: Load the effective address of d3 into si. Step10: move the contents of ax and cx register into si. Step11: Stop.

Source code
Data segment d1 dd 23416708h d2 dd 78912345h d3 dd ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,d1 lea di,d2 mov ax,[si] mov bx,[di] add ax,bx inc si inc si inc di inc di mov cx,[si] mov dx,[di] adc cx,dx lea si,d3 mov [si],ax inc si inc si
21

Microprocessors and Interfacing Lab mov [si],cx mov ah,4ch int 21h code ends end start

RESULT:
The addition of two 32-bit numbers is completed successfully.

22

Microprocessors and Interfacing Lab Experiment:4(b)

32-Bit Subtraction
AIM: To find the SUBTRACTION of two 32-bit numbers. APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address of d1 into si register and load the effective address of d2 at di register. Step4: Move the contents in si register to ax register and the contents of di register to bx register. Step5: Subtract the contents of bx from ax. Step6: Increment the contents of si register and di register two times. Step7: Move the contents in si register to cx register and move the contents in di register to dx register. Step8: Subtract the contents of bx from ax with barrow. Step9: Load the effective address of d3 into si. Step10: move the contents of ax and cx register into si. Step11: Stop.

SOURCE CODE:
Data segment d1 dd 12344321h d2 dd 56788765h d3 dd ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,d1 lea di,d2 mov ax,[si] mov bx,[di] sub ax,bx inc si inc si inc di inc di mov cx,[si] mov dx,[di] sbb cx,dx lea si,d3 mov [si],ax inc si inc si
23

Microprocessors and Interfacing Lab mov [si],cx mov ah,4ch int 21h code ends end start

RESULT:
The subtraction of two 32-bit numbers is completed successfully.

24

Microprocessors and Interfacing Lab Experiment:4(c)

Multibyte Addition
AIM: To perform multibyte addition operation APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address for the input variables and output variables with the help of si, di and bp respectively. Step4: clear the count. Step5: Assign a lable go Step6: Move contents of si into al step7: Increment si. Step8: Move the contents of di into bl. Step9: Increment di. Step10: add the contents al,bl along with carry. Step11: Move the result into bp. Step12: Increment bp Step13: Decrement count Step14: The loop will repeat until count=0. Step15: Stop.

SOURCE CODE:
Data segment d1 dq 2341670823416708h d2 dq 7891234578912345h d3 dq ? count equ 08h data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov cl,count lea si,d1 lea di,d2 lea bp,d3 clc go: mov al,[si] inc si mov bl,[di] inc di adc al,bl mov [bp],al inc bp
25

Microprocessors and Interfacing Lab dec cl jnz go mov ah,4ch int 21h code ends end start

RESULT:
The multibyte addition is completed successfully.

26

Microprocessors and Interfacing Lab Experiment:4(d)

Average Fo N Numbers
AIM: To find the average of n numbers. APPARATUS: Tasm software ALGORITHM:
Step1: start Step2: Initialize the data segment Step3: load the effective address of si to array Step4: Assign a lable l. Step5: Add the contents of al and si register. Step6: jump to label l2 if carry is not generated. Step7: Increment ah and assign a lable l2. Step8: Increment the si and decrement the cl register. Step9: repeat from step4 until cl not equal to zero. Step10: divide the components of dx by a. Step11: Store the result in allocated memory location. Step12: Stop.

SOURCE CODE:
data segment array db 01h,11h,12h,99h,96h,02h,02h,02h count equ 08h avg dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,array mov cl,count mov bl,count xor ax,ax l1: add al,[si] jnc l2 inc ah l2: inc si dec cl jnz l1 div bl mov avg,ax mov ah,4ch int 21h code ends end start
27

Microprocessors and Interfacing Lab

RESULT:
The average of n numbers is completed successfully.

28

Microprocessors and Interfacing Lab Experiment:5(a)

Decimal Addition Operation


AIM: To perform arithmetic addition operation of two decimal numbers. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of two input variables into registers al,bl respectively Step-4: Add the contents of al and bl registers Step-5: Perform the Decimal Adjust After Addition operation Step-6: Store the result in an output variable as output data Step-7: Stop SOURCE CODE: data segment d1 db 99h d2 db 99h d3 db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 add al,bl daa mov d3,al mov ah,4ch int 21h code ends end start RESULT: The Arithmetic addition of two decimal numbers is successfully completed.

29

Microprocessors and Interfacing Lab Experiment No:5(b)

Decimal Subtraction Operation


AIM: To perform arithmetic subtraction operation of two decimal numbers. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of two input variables into registers al,bl respectively Step-4: Add the contents of al and bl registers Step-5: Perform the Decimal Adjust After Subtraction operation Step-6: Store the result in an output variable as output data Step-7: Stop SOURCE CODE: data segment d1 db 14h d2 db 84h d3 db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 sub al,bl das mov d3,al mov ah,4ch int 21h code ends end start RESULT: The Arithmetic addition of two decimal numbers is successfully completed.

30

Microprocessors and Interfacing Lab Experiment No:6(a)

ASCII Addition Operation


AIM: To perform arithmetic addition operation of two ASCII numbers. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of two input variables into registers al,bl respectively Step-4: Add the contents of al and bl registers Step-5: Perform the ASCII Adjust After Addition operation Step-6: Add 3030h to register ax Step-7: Store the result in an output variable as output data Step-8: Stop SOURCE CODE: data segment d1 db 29 d2 db 10 d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ah,00h mov al,d1 mov bl,d2 add al,bl aaa add ax,3030h mov d3,ax mov ah,4ch int 21h code ends end start RESULT: The Arithmetic addition of two ASCII numbers is successfully completed.

31

Microprocessors and Interfacing Lab Experiment No:6(b)

ASCII Subtraction Operation


AIM: To perform arithmetic subtraction operation of two ASCII numbers. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of two input variables into registers al,bl respectively Step-4: Subtract the contents of al and bl registers Step-5: Perform the ASCII Adjust After Subtraction operation Step-6: Add 3030h to register ax Step-7: Store the result in an output variable as output data Step-8: Stop SOURCE CODE: data segment d1 db 9 d2 db 4 d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ah,00h mov al,d1 mov bl,d2 sub al,bl aas add ax,3030h mov d3,ax mov ah,4ch int 21h code ends end start RESULT: The Arithmetic subtraction of two ASCII numbers is successfully completed.

32

Microprocessors and Interfacing Lab Experiment No:7(a)

Signed Multiplication Operation


AIM: To perform signed multiplication operation of two 8-bit numbers. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of two input variables into registers al,bl respectively Step-4: Perform the Integer Multiplication of the contents of registers al and bl Step-5: Store the result in an output variable as output data Step-6: Stop SOURCE CODE: data segment d1 db 10h d2 db 0FCh d3 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 imul bl mov d3,ax mov ah,4ch int 21h code ends end start RESULT: The signed multiplication operation of two 8-bit numbers is successfully completed.

33

Microprocessors and Interfacing Lab Experiment No:7(b)

Signed Division Operation


AIM: To perform signed division operation of two 8-bit numbers. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of two input variables into registers al,bl respectively Step-4: Change the byte to word Step-5: Perform the Integer Division of the contents of registers al and bl l Step-6: Store the result in an output variable as output data Step-7: Stop SOURCE CODE: data segment d1 db 20h d2 db 0FCh d3 dw ? d4 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,d1 mov bl,d2 cbw idiv bl mov d3,al mov d4,ah mov ah,4ch int 21h code ends end start RESULT: The signed division operation of two 8-bit numbers is successfully completed.

34

Microprocessors and Interfacing Lab Experiment No:8(a)

Conversion Of Packed Bcd To Unpacked Bcd


AIM: To perform conversion of BCD numbers from packed to unpacked form. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of input data into registers ax Step-4: Move the contents of register ax into bx Step-5: Perform the AND operation between register ax and 000Fh & store it in ax Step-6: Perform the AND operation between register bx and 00F0h & store it in bx Step-7: Perform ROTATE-LEFT operation for register bx 4 times Step-8: Perform the OR operation between registers ax and bx Step-9: Store the result of unpacked BCD as output data Step-10: Stop SOURCE CODE: data segment d1 dw 0054h d2 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,ax and ax,000Fh and bx,00F0h rol bx,04h or ax,bx mov d2,ax mov ah,4ch int 21h code ends end start RESULT: The conversion of BCD numbers from packed to unpacked form is successfully completed.

35

Microprocessors and Interfacing Lab Experiment No:8(b)

Conversion Of Packed Bcd To ASCII


AIM: To perform conversion of BCD numbers from packed to ASCII form. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of input data into registers ax Step-4: Move the contents of register ax into bx Step-5: Perform the AND operation between register ax and 000Fh & store it in ax Step-6: Perform the AND operation between register bx and 00F0h & store it in bx Step-7: Perform ROTATE-LEFT operation for register bx 4 times Step-8: Perform the OR operation between registers ax and bx Step-9: Perform the AND operation between register ax and 3030h Step-10: Store the result of ASCII form as output data Step-11: Stop SOURCE CODE: data segment d1 dw 0059h d2 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,d1 mov bx,ax and ax,000Fh and bx,00F0h rol bx,04h or ax,bx and ax,3030h mov d2,ax mov ah,4ch int 21h code ends end start RESULT: The conversion of BCD numbers from packed to ASCII form is successfully completed.

36

Microprocessors and Interfacing Lab Experiment No:9(a)

Sorting Array in Ascending order


AIM: To perform sorting operation of an array in ascending order. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of count value into dx registers Step-4: Move the contents of register dx into cx Step-5: Load the effective address of array into si Step-6: Move the contents of address location pointed by si to register al Step-7: Compare the contents of al & [si+1] location Step-8: Go to step 10 if CF=1 Step-9: Exchange the contents of [si] & [si+1] location Step-10: Increment the si register Step-11: Repeat from step6 Step-12: Decrement the register dx Step-13: Go to step4 if zf0 Step-14: Stop SOURCE CODE: data segment array db 53h,24h,35h,03h,22h count equ 04h data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov dx,count b: mov cx,dx lea si,array back: mov al,[si] cmp al,[si+1] jc noswap xchg al,[si+1] xchg [si],al noswap: inc si loop back dec dx jnz b mov ah,4ch int 21h code ends end start

37

Microprocessors and Interfacing Lab RESULT: My output is same as the object file output. Therefore sorting of array in ascending order is successfully completed.

38

Microprocessors and Interfacing Lab Experiment No:9(b)

Sorting Array in Descending order


AIM: To perform sorting operation of an array in descending order. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the contents of count value into dx registers Step-4: Move the contents of register dx into cx Step-5: Load the effective address of array into si Step-6: Move the contents of address location pointed by si to register al Step-7: Compare the contents of al & [si+1] location Step-8: If CF=1, exchange the contents of [si] & [si+1] locations otherwise goto step1 Step-9: Increment the si register Step-10: Repeat from step6 Step-11: Decrement the register dx Step-12: Go to step4 if zf0 Step-13: Stop SOURCE CODE: data segment array db 42h,54h,36h,74h,82h count equ 04h data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov dx,count b: mov cx,dx lea si,array back: mov al,[si] cmp al,[si+1] jnc noswap xchg al,[si+1] xchg [si],al noswap: inc si loop back dec dx jnz b mov ah,4ch int 21h code ends end start

39

Microprocessors and Interfacing Lab RESULT: My output is same as the object file output. Therefore sorting of array in descending order is successfully completed.

40

Microprocessors and Interfacing Lab Experiment No:10(a)

Moving Block of Data


AIM: To perform the copy of two strings. APPARATUS: TASM Software,PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variable in data segment Step-4:Create duplicate locations into which the data should moved. Step-5: Load the effective address of variables to SI,DI Step-6: Perform Clear Direction operation and take length of string as count. Step-7: Repeatedly move string byte-by-byte until count reaches zero. Step-8: Store the result in specified memory locations declared in data segment. Step-9: Stop SOURCE CODE: data segment str1 db MPI$ str2 db 5dup(0) count equ ($-str1) data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,str1 lea di,str2 mov cl,count cld rep movsb mov ah,4ch int 21h code ends end start RESULT: Thus block of data is moved to specified memory location.

41

Microprocessors and Interfacing Lab Experiment No:10(b)

Comparison Of Strings
AIM: To perform the comparison of two strings. APPARATUS: TASM Software,PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize two string variables in data segment Step-4:Calculate the length of the two strings. Step-5: Load the effective address of variables to SI,DI Step-6: Compare the lengths of two strings (a)if equal goto step-7. (b)if not equal goto step-7(b). Step-7: Repeatedly compare strings byte-by-byte until count reaches zero. (a) if equal store the result as 1111H (b) if not equal store result as 0FFFFH Step-8: Stop SOURCE CODE: data segment str1 db MPI$ strlen1 equ ($-str1) str2 db MPI$ strlen2 equ ($-str2) data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,str1 lea di,str2 mov cx,strlen1 mov dx,strlen2 cmp cx,dx jne NOTEQUAL cld rep cmpsb jne NOTEQUAL mov res,1111H jmp QUIT NOTEQUAL: mov res,0FFFFH QUIT: mov ah,4ch int 21h code ends end start RESULT: Thus two strings are compared .
42

Microprocessors and Interfacing Lab Experiment No:10(c)

Length Of String
AIM: To calculate the length of string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variable in data segment whose length is to be calculated. Step-4: Load the effective address of variables to SI,DI Step-5:Clear AX and BX registers. Step-6:Load the string to AX and checks for $. (a) If finds goto step-7 (b) If not increment BL register and take it as required length of string Step-7: Stop SOURCE CODE: data segment str1 db MPI$ length db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,str1 xor ax,ax xor bx,bx BACK: lods str1 cmp al,$ je GO inc bl jmp BACK GO: mov length,bl mov ah,4ch int 21H code ends end start RESULT: Thus length of string is calculated .

43

Microprocessors and Interfacing Lab Experiment No:10(d)

Reverse Of String
AIM: To reverse the string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variable in data segment whose calculate its length. Step-4: Load the effective address of variable to SI. Step-5: Add string length to DI. Step-5:Clear AX register and move contents to AL. Step-6:Exchange the values of SI and DI and increment SI and decrement DI. Step-7: Repeat Step-6 until DI value should above or equal to SI. Step-8:Stop SOURCE CODE: data segment str1 db MPI$ strlen1 equ ($-str1) data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax xor ax,ax lea si,str1 add di,(strlen1-1) L1: mov al,[si] Xchg [di],al mov [si],al inc si dec di cmp di,si jae L1 mov ah,4ch int 21H code ends end start RESULT: Thus the given string is reversed.

44

Microprocessors and Interfacing Lab Experiment No:10(e)

String Insertion
AIM: To insert a sub string into the main string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variable str1 in data segment and calculate its length. Step-4: Initialize another string variable str2 Step-6: Load effective address of strt1 to SI and str2 to DI. Step-7:Move the length of string in str1 to CX until from where the insertion starts . Step-8:Move length of sub string which is to be inserted to DX Step-9:Read the sub string from DOS by using DOS-BIOS Interrupts. Step-10:Store the string in str2. Step-11:Move the remaining string from str1 to str2 Step-12:Stop SOURCE CODE: data segment str1 db MICROPROCESSORS$ strlen1 equ ($-str1) str2 db str1+20 data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov ds,ax mov es,ax lea si,str1 lea di,str2 mov cx,15 rep movsb mov dx,20 L1: mov ah,01h int 21H stos str2 dec dx jnz L1 mov cx,01h rep movsb mov ah,4ch int 21H code ends end start RESULT: Thus the string is inserted.
45

Microprocessors and Interfacing Lab Experiment No:10(f)

String Deletion
AIM: To delete a sub string into the main string. APPARATUS: TASM Software , PC ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Initialize a string variables str1 and str2 in data segment and calculate its length. Step-4: Load effective address of strt1 to SI and str2 to DI. Step-5:Move the some length of string in str1 to CX . Step-6:Take count value to DX (which is the deleted string count) Step-7: Increment SI until DX becomes zero. Step-8: Move the remaining string from str1 to str2 Step-9:Stop SOURCE CODE: data segment str1 db MICROPROCESSORS AND INTERFACING $ strlen1 equ ($-str1) str2 db 35 dup(0) data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov ds,ax mov es,ax lea si,str1 lea di,str2 mov cx,15 rep movsb mov dx,04 L1: inc si dec dx jnz L1 mov cx,13 rep movsb mov ah,4ch int 21H code ends end start RESULT: Thus the string is deleted

46

Microprocessors and Interfacing Lab Experiment No:11(a)

Reading Characters from Dos Prompt


AIM: To read a string in dos prompt. APPARATUS: TASM Software ALGORITHM: Step-1: Start Step-2: Initialize the data segment Step-3: Move the count value of the word into dl registers Step-4: Load the effective address of dl to diregister Step-5: Move the contents value 06h to dl register Step-6: Read the character from keyboard Step-7: Decrement dl Step-8: Store the character in dl Step-9: If zf=0 goto step6 Step-10: Stop SOURCE CODE: data segment d1 db 7 dup(0) data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov ds,ax mov es,ax mov dl,06h lea di,d1 l1: mov ab,01h int 21h dec d1 jnz l1 mov ah,4ch int 21h code ends end start RESULT: Therefore reading a string in dos prompt is successfully completed.

47

Microprocessors and Interfacing Lab Experiment No:11(b)

Displaying Characters on the Dos Prompt


AIM: To display a string on the ````dos prompt. APPARATUS: TASM Software ALGORITHM: For macro Step-1: macro definition Step-2: move 09h to ah register Step-3: Move the offset of displayed string to dx register Step-4: end of macro For program Step-1: Start Step-2: Initialize data segment Step-3: Call the macro with d1 as argument Step-4: Call the macro with d2 as argument Step-5: Stop SOURCE CODE: Display1 macro strg mov ah,09h mov dx,offset strg int 21h endm data segment str1 db 'Microprocessors$' str2 db 'Interfacing$' str3 db 'lab$' data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax display1 str1 display1 str2 display1 str3 mov ah,4ch int 21h code ends end start RESULT: Therefore the display of a string on the dos prompt is successfully completed.

48

Microprocessors and Interfacing Lab

Interfacing Programs
(CYCLE NO-2)

Experiment No:12
49

Microprocessors and Interfacing Lab

PROGRAMMABLE INTERRUPT CONTROLLER 8259 INTERFACING


AIM: To test the programmable interrupt controller 8259 with the 8086 KIT. Jumper connections: J6,j7 short 1&2 J9,j4,j5 short 2&3 EPROM address: F000:1587 PROCEDURE: Connect 26 pin connector to 8086 kit , and observe the interrupts on other terminals of 26 pin connector keeping one should be ground. In the 26 pin connector 1&2 is to be noted as ground, red mark in cable connector is chosen as pin 1of IC .Finally observe the interrupts (in0-in6). PROGRAM 3000 48 45 4C 4C 4F 20 3006 2E 2E 2E 2E 2E 2E 300C 2E 2E 2E 2E 00 3011 20 20 49 20 47 4F 3017 54 20 49 4E 54 52 301D 20 30 20 20 00 3022 20 20 49 20 47 4F 3028 54 20 49 4E 54 52 302E 20 31 20 20 00 3033 20 20 49 20 47 4F 3039 54 20 49 4E 54 52 303F 20 32 20 20 00 3044 20 20 49 20 47 4F 304A 54 20 49 4E 54 52 3050 20 33 20 20 00 3055 20 20 49 20 47 4F 305B 54 20 49 4E 54 52 3061 20 34 20 20 00 3066 20 20 49 20 47 4F 306C 54 20 49 4E 54 52 3072 20 35 20 20 00 3077 20 20 49 20 47 4F 307D 54 20 49 4E 54 52 3083 20 36 20 20 00 msg DB 'HELLO ..........',0H

msg1

DB

' I GOT INTR 0 ',0H

msg2

DB

' I GOT INTR 1 ',0H

msg3

DB

' I GOT INTR 2 ',0H

msg4

DB

' I GOT INTR 3 ',0H

msg5

DB

' I GOT INTR 4 ',0H

msg6

DB

' I GOT INTR 5 ',0H

msg7

DB

' I GOT INTR 6 ',0H

50

3088 20 20 49 20 47 4F 308E 54 20 49 4E 54 52 3094 20 37 20 20 00 4000 4000 4001 4002 4007 400A 400C 400F 4012 4016 4019 401B 401E 401F 4023 4025 4028 4029 402D 402F 4032 4033 4037 4039 403C 403D 4041 4043 4046 4047 404B 404D 4050 4051 4055 4057 405A 405B 405F 4061 4064 4065 4069 406B 406E 4071 4073 4074

msg8

DB

Microprocessors and Interfacing Lab ' I GOT INTR 7 ',0H

START: 0E 07 9A B1 4B 00 F8 B8 00 00 8E D8 BB 02 02 B9 08 00 C7 07 00 00 83 C3 04 E2 F7 BB 00 02 2E 8D 06 00 60 89 07 83 C3 04 2E 8D 06 08 60 89 07 83 C3 04 2E 8D 06 10 60 89 07 83 C3 04 2E 8D 06 18 60 89 07 83 C3 04 2E 8D 06 20 60 89 07 83 C3 04 2E 8D 06 28 60 89 07 83 C3 04 2E 8D 06 30 60 89 07 83 C3 04 2E CS 8D 06 38 60 89 07 83 C3 04 BA 00 30 B0 13 EF BA 02 30

PUSH CS POP ES CALLS 4BB1, F800 ; MOV AX,0000 MOV DS,AX MOV BX, 0202 MOV CX, 08 MOV WPTR [BX], 00H ADD BX,4 LOOP 4012 MOV BX,0200 CS LEA AX,6000 MOV [BX],AX ADD BX,4 CS LEA AX,6008 MOV [BX],AX ADD BX,4 CS LEA AX,6010 MOV [BX],AX ADD BX,4 CS LEA AX, 6018 MOV [BX], AX ADD BX,4 CS LEA AX, 6020 MOV [BX], AX ADD BX,4 CS LEA AX, 6028 MOV [BX], AX ADD BX, 4 CS LEA AX,6030 MOV [BX], AX ADD BX, 4 LEA AX, 6038 MOV [BX],AX ADD BX,4 MOV DX,03000 MOV AL, 13 OUT DX MOV DX,03002
51

Microprocessors and Interfacing Lab 4077 4079 407A 407C 407D 407F 4080 4083 4086 408B 408C 6000 6003 6006 600B 600C 6008 600B 600E 6013 6014 6010 6013 6016 601B 601C 6018 601B 601E 6023 6024 6020 6023 6026 602B 602C 6028 602B 602E 6033 6034 6030 6033 6036 603B 603C B0 60 EF B0 0F EF B0 00 EF BF 80 00 BE 00 30 9A 00 10 00 F0 FB E9 FD FF BF C0 00 BE 11 30 9A 00 10 00 F0 FB CF BF C0 00 BE 22 30 9A 00 10 00 F0 FB CF BF C0 00 BE 33 30 9A 00 10 00 F0 FB CF BF C0 00 BE 44 30 9A 00 10 00 F0 FB CF BF C0 00 BE 55 30 9A 00 10 00 F0 FB CF BF C0 00 BE 66 30 9A 00 10 00 F0 FB CF BF C0 00 BE 77 30 9A 00 10 00 F0 FB CF MOV AL, 60 OUT DX MOV AL, 0F OUT DX MOV AL,00 OUT DX MOV DI,80 MOV SI, 3000 CALLS 1000, 0F000 STI BCK: JMP BCK SERV1: MOV DI,0C0H MOV SI, 3011 CALLS 1000, 0F000 STI IRET SERV2: MOV DI,0C0H MOV SI, OFFSET MSG2 CALLS 1000, 0F000 STI IRET SERV3: MOV DI,0C0H MOV SI, OFFSET MSG3 CALLS 1000, 0F000 STI IRET SERV4: MOV DI,0C0H MOV SI, OFFSET MSG4 CALLS 1000, 0F000 STI IRET SERV5: MOV DI,0C0H MOV SI, OFFSET MSG5 CALLS 1000, 0F000 STI IRET SERV6: MOV DI,0C0H MOV SI, OFFSET MSG6 CALLS 1000, 0F000 STI IRET SERV7: MOV DI,0C0H MOV SI, OFFSET MSG7 CALLS 1000, 0F000 STI IRET
52

Microprocessors and Interfacing Lab 6038 603B 603E 6043 6044 BF C0 00 BE 88 30 9A 00 10 00 F0 FB CF SERV8: MOV DI,0C0H MOV SI, OFFSET MSG8 CALLS 1000, 0F000 STI IRET

Result: Hence we observe the interrupts (IN 0-IN 06) by using 8259 kit.

Experiment No:13
53

Microprocessors and Interfacing Lab

8255 INTERFACING
AIM: To test 8255 in different modes (mode0, mode1, mode2) by using the interfacing kit Apparatus: personnel computer 8255 kit--1nos Power supply connections: no power is needed Procedure: connect the bus from interface kit (nifc 15) to 8086 ALS trainer of 8255 connector (CN1). Care should be taken such that pin1 of cn1 coincides with pin1 of the cable 1. Mode0: 1. EPROM address: GO (PRESS ENTER) E000 (enter SHIFT button):19b0 Mode 0: any read or write For read operation 1&3 short by using jumpers For write operation 3&5 short Jumper connections: Jp1---2&3 Jp2---2&3 Jp7---1&2 Jp8---1&2 For PORT A the given data is complimentary data in PORT B. that is the concept of mode 0. 2. Mode 1(strobed i/p &o/p) Strobed i/p:-RD mode: Jp1---2&3; jp22&3; jp71&2; jp8: 1&2; jp51&2; jp6: 1&2 EPROM address E000:1700 3. Mode 2: When the data is given in the port a ,as the press the strobe pulse then the same data reads on port b. Strobed o/p:-Modewrite mode Jp1---2&3; jp22&3; jp71&2; jp8: 1&2; jp52&3; jp6: 3&4. EPROM address: E000:1640 It takes data from keyboard i.e. Enter aa then port b displayed that value. Mode2: strobed bidirectional i/p & o/p:-Mode: read mode Jp1---2&3; jp22&3; jp71&2; jp8: 1&2; jp51&2; jp6: 1&2, jp6:5&6.

54

Microprocessors and Interfacing Lab Program:


1 .OUTPUT 2500AD 2 3 4 ****************************************** 5 ;PROGRAM TO TEST 8255 IN MODE 0 (BASIC I/O) 6 ***************************************** 7 ; PORT A bits are connected to DIP switch (used as i/p port) 8 ; PORT B bits are connected to LEDs (used as output port) 9 ; PORT C bits PC1, PC5 & PC7 are connected to LEDs 10 ;( used as o/p port) 11 12 3000 PORTA EQU 3000H ; 8255 PORT A address 13 3002 PORTB EQU 3002H ; 8255 PORT B address 14 3004 PORTC EQU 3004H ; 8255 PORT C address 15 3006 CTLP_55 EQU 3006H ; 8255 control port address 16 17 0000:0000 DSEG SEGMENT 18 0000:3000 ORG 0000:3000H 19 0000:3000 20 38 32 35 35 20 MSG DB ' 8255 in mode-0 ',0h 0000:3006 69 6E 20 6D 6F 64 0000:300C 65 2D 30 20 00 20 0000:3011 20 20 20 42 61 73 MSG1 DB ' Basic I/O ',0h 0000:3017 69 63 20 49 2F 4F 0000:301D 20 20 20 20 00 21 DSEG ENDS 22 23 0000:0000 CSEG SEGMENT 24 25 0000:4000 ORG 0000:4000H 26 27 ASSUME CS: CSEG, DS:DSEG 28 29 ; displaying message on LCD 30 ; -----------------------------------------31 0000:4000 9A B1 4B 00 F8 CALL far f800:4bb1h ; clear display 32 0000:4005 BF 80 00 MOV di, 80h ; display in upper line 33 0000:4008 BE 00 30 MOV SI, offset MSG ; 34 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h; display output routine 35 0000:4010 BF C0 00 MOV DI, C0H ; display in lower line 36 0000:4013 BE 11 30 MOV SI, OFFSET MSG1 37 0000:4016 9A C0 4F 00 F8 CALL FAR F800:4FC0H; display o/p routine 38 39 40 0000:401B START: 41 0000:401B B0 90 MOV AL,90H ;control word to initialise 8255 42 0000:401D BA 06 30 MOV DX,CTLP_55;portA as i/p, portB and portC as o/p 43 0000:4020 EE OUT DX,AL 44 0000:4021 55

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 96

; ; ; ; ; 0000:4021 0000:4021 0000:4021 0000:4024 0000:4025 0000:4027 0000:402A 0000:402B 0000:402B 0000:402D 0000:4030 0000:4031 0000:4034 0000:4036 0000:4039 0000:403A 0000:403D 0000:403F 0000:4042 0000:4043 0000:4046 0000:4048 0000:404B 0000:404C 0000:404F 0000:4051 0000:4054 0000:4055 0000:4058 0000:405A 0000:405D 0000:405E 0000:4061 0000:4064 0000:4064 0000:4067 0000:4069 0000:0000 0000:0000 BA 00 30 EC F6 D0 BA 02 30 EE B0 02 BA 06 30 EE E8 30 00 B0 03 BA 06 30 EE E8 27 00 B0 0A BA 06 30 EE E8 1E 00 B0 0B BA 06 30 EE E8 15 00 B0 0E BA 06 30 EE E8 0C 00 B0 0F BA 06 30 EE E8 03 00 E9 BD FF B9 FF 7F E2 FE C3

Read data from portA, this data depends on input switch settings. Complement the data and output it portB. PortC port can be operated in bit set reset mode. Observe portC bits on LED (PC1,PC5 & PC7) portC bits must be outputted to control port of 8255. LOOP1: MOV DX, PORTA IN AL, DX NOT AL MOV DX, PORTB OUT DX, AL MOV AL, 02H ;reset pc1 bit MOV DX, CTLP_55 OUT DX, AL CALL DELAY MOV AL,03H ;set pc1 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0AH ;reset pc5 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0BH ;set pc5 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0EH ;reset pc7 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY MOV AL,0FH ;set pc7 bit MOV DX,CTLP_55 OUT DX,AL CALL DELAY

Microprocessors and Interfacing Lab

;This program can be executed for JMP LOOP1 ;different switch settings DELAY:MOV CX,7FFFH NEXT:LOOP NEXT ;loop for delay RET CSEG ENDS END END

56

Microprocessors and Interfacing Lab


1 .OUTPUT 2500AD 2 3 4 ********************************************************* 5 PROGRAM TO TEST 8255 IN MODE 1 (STROBED I/O MODE) 6 ********************************************************* 7 ;8255 operating in strobed input mode 8 ;MODE 1 makes use of interrupt for transferring i/o data to 9 ;or from a specified port.Priority interrupt controller 10 ;8259 used as a interrupt to CPU 11 12 ; In mode1, portC is used as control/status for portA & portB. 13 ;I/P is controlled by 3 control bits STBA(PC4),IBFA(PC5) & 14 ; INTRA(PC3).By controlling these signals,data can be 15 ; read/write from specified ports. 16 ; Interface is designed by taking portA as i/p port. 17 18 3000 PORTA EQU 3000H 19 3002 PORTB EQU 3002H 20 3004 PORTC EQU 3004H 21 3006 CTLP_55 EQU 3006H 22 23 0000:0000 DSEG SEGMENT 24 0000:3000 ORG 0000:3000H 25 0000:3000 20 38 32 35 35 20 MSG DB ' 8255 in mode-1 ', 0h 0000:3006 69 6E 20 6D 6F 64 0000:300C 65 2D 31 20 00 26 0000:3011 53 74 72 6F 62 65 MSG1 DB 'Strobed I/O mode', 0h 0000:3017 64 20 49 2F 4F 20 0000:301D 6D 6F 64 65 00 27 DSEG ENDS 28 29 0000:0000 CSEG SEGMENT 30 31 0000:4000 ORG 0000:4000H 32 33 ASSUME CS: CSEG, DS: DSEG 34 35 ; displaying message on LCD 36 ; -----------------------------------------37 0000:4000 9A B1 4B 00 F8 CALL far f800:4bb1h ; clear display 38 0000:4005 BF 80 00 MOV di, 80h ; display in upper line 39 0000:4008 BE 00 30 MOV SI, offset MSG ; 40 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h; display output routine 41 0000:4010 BF C0 00 MOV DI, C0H ; display in lower line 42 0000:4013 BE 11 30 MOV SI, OFFSET MSG1 43 0000:4016 9A C0 4F 00 F8 CALL FAR F800:4FC0H; display o/p routine 44 45 0000:401B START: 57

46 0000:401B pointer 47 0000:401E 48 0000:4020 49 0000:4023 50 0000:4023 51 0000:4024 52 0000:4025 53 0000:4025 initialisation 54 0000:4028 55 56 0000:402A vector 57 0000:402D 58 0000:402E 59 0000:402F 60 0000:4031 61 0000:4034 62 0000:4039 63 64 0000:403B 65 0000:403E 66 0000:4040 67 68 0000:4041 address) 69 0000:4044 70 0000:4046 71 72 0000:4047 73 0000:4049 74 75 0000:404A 76 0000:404C 77 0000:404D 78 0000:404D mode1 79 0000:404F 80 0000:4052 81 82 0000:4053 which is 83 0000:4055 pc4 84 85 0000:4056 86 0000:4058 87 88 0000:4059 89 0000:405B 90 91 0000:405C 92 0000:405E 93 94 95 0000:405F

B8 00 00 8E D0 BC 00 20 FA FC B8 00 00 8E D8 BB 02 02 CLI CLD

MOV AX, 00H

Microprocessors and Interfacing Lab


; initialisation of stack

MOV SS,AX MOV SP,2000H

MOV AX,00H MOV DS,AX MOV BX,202H

;data segment

;initalisation of interrupt

0E PUSH CS 58 POP AX 89 07 MOV [BX],AX BB 00 02 MOV BX,200H 2E 8D 06 63 40 LEA AX,CS:SERVICE 89 07 MOV [BX],AX BA D8 FF B0 13 EE BA DA FF B0 80 EE B0 0F EE B0 FE EE B0 B4 BA 06 30 EE B0 09 EE B0 03 EE B0 0A EE B0 0F EE FB MOV DX,0FFD8H MOV AL,13H OUT DX,AL ;ICW1

MOV DX,0FFDAH ;ICW2(interrupt vector MOV AL,80H OUT DX,AL MOV AL,0FH OUT DX,AL ;ICW4 MOV AL,0FEH OUT DX,AL ;OCW1(IR0 mask reset) MOV AL,0B4H ;initialisation of 8255 for

MOV DX,CTLP_55 ;input operation OUT DX,AL MOV AL,09H OUT DX,AL ;to enable INTE flip flop

;controlled by bit set/reset of ;OBF1(PC1) is set ;IBF(PC5) is reset ;OBF2(PC7) is set

MOV AL,03H OUT DX,AL MOV AL,0AH OUT DX,AL MOV AL,0FH OUT DX,AL STI 58

;enable interrupt bit

96 97 0000:4060 E9 FD FF BACK: JMP BACK 98 99 ;INTR1 bit will be set when strobe pulse is given, 100 ;pulse can be given by user by pressing push button. 101 ;As soon as user presses the switch STB* line goes low, ;When the STB* line goes low,IBF goes high to indicate that 103 ;the data has been loaded in to input latch.This sets INTR & 104 ;controls transforms to service subroutine. 105 ;In service routine data is read from port A and the result 106 ;is displayed on portB 107 0000:4063 108 0000:4063 SERVICE: 109 0000:4063 110 0000:4063 BA 00 30 MOV DX,PORTA 111 0000:4066 EC IN AL,DX 112 0000:4067 BA 02 30 MOV DX,PORTB 113 0000:406A EE OUT DX,AL 114 115 0000:406B FB STI 116 0000:406C CF IRET 117 118 CSEG ENDS 118 CSEG ENDS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 .OUTPUT 2500AD ********************************************* 8255 OPERATING IN STROBED OUTPUT MODE (MODE 1) ********************************************** ;Output mode is controlled by bits ACK*(PC2),OBF*(PC1) ;and INTR(PC0).In this mode accept data from keyboard ;display it on portB 0000:0000 3000 PORTA EQU 3000H 3002 PORTB EQU 3002H 3004 PORTC EQU 3004H 3006 CTLP_55 EQU 3006H 4ECC KBDT EQU 0F800:4ECCH

Microprocessors and Interfacing Lab

0000:0000 DSEG SEGMENT 0000:3000 ORG 0000:3000H 0000:3000 20 38 32 35 35 20 MSG DB ' 8255 in md1 O/P',0h 0000:3006 69 6E 20 6D 64 31 0000:300C 20 4F 2F 50 00 20 DSEG ENDS 21 22 0000:0000 CSEG SEGMENT 23 0000:4000 ORG 0000:4000H 24 59

25 26 27 0000:4000 28 29 30 0000:4000 display 31 0000:4005 line 32 0000:4008 33 0000:400B 34 0000:4010 35 0000:4013 initialisation 36 0000:4015 37 38 0000:4018 39 0000:4019 40 0000:401A 41 0000:401A initialisation 42 0000:401D 43 44 0000:401F 45 0000:4022 46 0000:4023 47 0000:4024 48 0000:4026 49 0000:4029 50 0000:402E 51 52 0000:4030 53 0000:4033 54 0000:4035 55 0000:4036 56 0000:4039 8259A 57 0000:403B 58 0000:403C 59 0000:403E 60 0000:403F 61 0000:4041 62 0000:4042 63 0000:4042 mode1. 64 0000:4045 65 0000:4047 66 67 0000:4048 which is 68 0000:404A 69 0000:404D 70 71 0000:404E 72 0000:4050 73 0000:4051 74 0000:4053

ASSUME CS:CSEG,DS:DSEG

Microprocessors and Interfacing Lab

START: ;displaying message on LCD ;-----------------------------------------9A B1 4B 00 F8 CALL far f800:4bb1h BF 80 00 BE 00 30 9A C0 4F 00 F8 B8 00 00 8E D0 BC 00 20 FA FC B8 00 00 8E D8 CLI CLD MOV AX,00H MOV DS,AX MOV di,80h

;clear

;display in upper

MOV SI,offset MSG ; CALL FAR f800:4FC0h;display o/p routine MOV AX,00H MOV SS,AX ;Stack segment MOV SP,2000H

;data segment

BB 02 02 MOV BX,202H 0E PUSH CS 58 POP AX ;initialisation of interrupt vector 89 07 MOV [BX],AX BB 00 02 MOV BX,200H 2E 8D 06 67 40 LEA AX,CS:SERVICE 89 07 MOV [BX],AX BA D8 FF B0 13 EE BA DA FF B0 80 EE B0 0F EE B0 FE EE BA 06 30 B0 B4 EE B0 05 BA 06 30 EE B0 0A EE B0 0F EE MOV MOV OUT DX,AL MOV MOV DX,FFD8H AL,13H DX,FFDAH AL,80H ;initialisation of PIC

OUT DX,AL MOV AL,0FH OUT DX,AL MOV AL,FEH OUT DX,AL MOV DX,CTLP_55 MOV AL,B4H OUT DX,AL MOV AL, 05H ;initialise 8255 in ;portA i/p and portB o/p ;enable INTE flip flop

MOV DX,CTLP_55 ;controlled by bit PC2 OUT DX,AL MOV AL,0AH OUT DX,AL ;IBF(PC5) taken low MOV AL,0FH OUT DX,AL ;OBF2*(PC7) taken high 60

75 0000:4054 76 0000:4054 data 77 0000:4059 in AL 78 0000:405B 79 80 0000:405D portB 81 0000:4060 82 0000:4062 83 84 0000:4063 85 86 0000:4064 87 88 when user 89 data 90 91 92 complemented 93 ACK* 94 95 96 0000:4067 97 0000:4067 input. 98 0000:4069 and 99 0000:406B 100 0000:406D 101 0000:4070 102 0000:4071 103 0000:4072 104 105 105

Microprocessors and Interfacing Lab


9A CC 4E 00 F8 8B C6 8A C8 BA 02 30 8A C1 EE FB E9 FD FF CALL FAR KBDT ;monitor routine to accept MOV AX,SI MOV CL,AL MOV DX,PORTB MOV AL,CL OUT DX,AL STI BACK: JMP BACK ;output data on ;from keyboard,data is

;When the user presses the key,OBF* line goes low & ;presses push button,ACK* line goes low indicating that is received by peripheral.This sets INTR(PC0) to cause an ;interrupt to the CPU & interrupt jumps to interrupt service ;routine, where the data written to portB & then ;& displayed on portB,next interrupt occurs only when ;is given. 8A C1 F6 D0 8A C8 BA 02 30 EE FB CF SERVICE: MOV AL,CL NOT AL ;CL contains keyboard ;Complement the value

MOV CL,AL ;output it to portB MOV DX,PORTB OUT DX,AL RETURN:STI IRET CSEG ENDS CSEG ENDS

1 .OUTPUT 2500AD 2 3 4 ********************************************************************* 5 PROGRAM TO TEST 8255 IN MODE 2 (BIDIRECTIONAL INPUT MODE). ********************************************************************* 7 ;In mode2, PORTA is used for both transmitting and 8 ;receiving data and has 5 bit control port(PORTC) for control 9 ;and status for the 8-bit,bidirectional bus port(PORTA) 10 ;The input is controlled by three bits STB*(PC4) & IBF*(PC5) 11 ;and INTR.INTR pin is common for both input and output. 61

12 ;NOTE :Make sure that DPDT switch is on RD side. 13 0000:0000 14 3000 PORTA EQU 3000H ;8255 PORTA address 15 3002 PORTB EQU 3002H ;8255 PORTB address 16 3004 PORTC EQU 3004H ;8255 PORTC address 17 3006 CTLP_55 EQU 3006H ;8255 CONTROL PORT address 18 4F1F DBDT EQU 0F800:4F1FH ;routine to display 19 20 0000:0000 DSEG SEGMENT 21 0000:3000 ORG 0000:3000H 22 0000:3000 38 32 35 35 20 69 MSG DB '8255 in md2 I/P ',0h 0000:3006 6E 20 6D 64 32 20 0000:300C 49 2F 50 20 00 23 DSEG ENDS 24 25 0000:0000 CSEG SEGMENT 26 0000:4000 ORG 0000:4000H 27 ASSUME CS:CSEG,DS:DSEG 28 29 0000:4000 START: 30 ;displaying message on LCD 31 ;-----------------------------------------32 0000:4000 9A B1 4B 00 F8 CALL far f800:4bb1h ;clear display 33 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 34 0000:4008 BE 00 30 MOV SI,offset MSG ; 35 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h ;display output routine 36 0000:4010 B8 00 00 MOV AX,00H 37 0000:4013 8E D0 MOV SS,AX ;stack segment initialisation 38 0000:4015 BC 00 20 MOV SP,2000H 39 40 0000:4018 41 0000:4018 FA CLI 42 0000:4019 FC CLD 43 0000:401A 44 0000:401A B8 00 00 MOV AX,00H ;data segment initialisation 45 0000:401D 8E D8 MOV DS,AX 46 0000:401F BB 02 02 MOV BX,202H 48 0000:4022 0E PUSH CS 49 0000:4023 58 POP AX 50 0000:4024 89 07 MOV [BX],AX ;interrupt vector initialisation 51 0000:4026 BB 00 02 MOV BX,200H 52 0000:4029 2E 8D 06 52 40 LEA AX,CS:SERVICE 53 0000:402E 89 07 MOV [BX],AX 54 55 0000:4030 BA D8 FF MOV DX,FFD8H 56 0000:4033 B0 13 MOV AL,13H 57 0000:4035 EE OUT DX,AL 58 0000:4036 BA DA FF MOV DX,FFDAH 59 0000:4039 B0 80 MOV AL,80H ;initialisation of PIC 8259A 60 0000:403B EE OUT DX,AL 62

Microprocessors and Interfacing Lab

61 0000:403C B0 0F MOV AL,0FH 62 0000:403E EE OUT DX,AL 63 0000:403F B0 FE MOV AL,FEH 64 0000:4041 EE OUT DX,AL 65 0000:4042 66 0000:4042 B0 C1 MOV AL,C1H ;initialise 8255 in mode 2 67 0000:4044 BA 06 30 MOV DX,CTLP_55 ;portA i/p & o/p,portC lower i/p. 68 0000:4047 EE OUT DX,AL 69 0000:4048 70 0000:4048 B0 09 MOV AL,09H ;enable INTE2 flip flop which is 71 0000:404A BA 06 30 MOV DX,CTLP_55 ;controlled by bit set/reset of pc4 72 0000:404D EE OUT DX,AL 73 74 0000:404E FB STI ;enable interrupt 75 76 0000:404F E9 FD FF BACK: JMP BACK 77 78 ;When STB* pulse is given by pressing the switch,STB* line 79 ;goes low & IBF goes high & INTR line goes high and data is 80 ;read by 8255.Then control jumps to interrupt service routine 81 ;to perform read operation.O/P the same on portB and display. 82 83 0000:4052 SERVICE: 84 0000:4052 BA 00 30 MOV DX,PORTA 85 0000:4055 EC IN AL,DX 86 0000:4056 8A C8 MOV CL,AL 87 0000:4058 BA 02 30 MOV DX,PORTB 88 0000:405B EE OUT DX,AL 89 90 0000:405C B5 00 MOV CH,00H 91 0000:405E 8B F1 MOV SI,CX 92 0000:4060 9A 1F 4F 00 F8 CALL FAR DBDT 93 0000:4065 94 0000:4065 FB STI 95 0000:4066 CF IRET 96 97 CSEG ENDS 97 CSEG ENDS 1 2 3 4 5 6 7 8 9 .OUTPUT 2500AD ********************************************************** PROGRAM TO TEST 8255 IN MODE 2 (BIDIRECTIONAL O/P MODE). ********************************************************** ;Output is controlled by bits ACK*(PC6) & OBF*(PC7). ;NOTE:Make sure that the DPDT switch is on the WR side 63

Microprocessors and Interfacing Lab

10 3000 PORTA EQU 3000H 11 3002 PORTB EQU 3002H 12 3004 PORTC EQU 3004H 13 3006 CTLP_55 EQU 3006H 14 4ECC KBDT EQU 0F800:4ECCH 15 16 0000:0000 DSEG SEGMENT 17 0000:3000 ORG 0000:3000H 18 0000:3000 38 32 35 35 20 69 MSG DB '8255 in md2 O/P ',0h 0000:3006 6E 20 6D 64 32 20 0000:300C 4F 2F 50 20 00 19 DSEG ENDS 20 21 0000:0000 CSEG SEGMENT 22 0000:4000 ORG 0000:4000H 23 ASSUME CS:CSEG,DS:DSEG 24 25 0000:4000 START: 26 ;displaying message on LCD 27 ;-----------------------------------------28 0000:4000 9A B1 4B 00 F8 CALL FAR F800:4bb1h ;clear display 29 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 30 0000:4008 BE 00 30 MOV SI,offset MSG ; 31 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h;display output routine 32 0000:4010 B8 00 00 MOV AX,00H 33 0000:4013 8E D0 MOV SS,AX ;stack segment initialisation 34 0000:4015 BC 00 20 MOV SP,2000H 35 36 0000:4018 37 0000:4018 FA CLI 38 0000:4019 FC CLD 39 0000:401A 40 0000:401A B8 00 00 MOV AX,00H ;data segment initialisation 41 0000:401D 8E D8 MOV DS,AX 43 0000:401F BB 02 02 MOV BX,202H 44 0000:4022 0E PUSH CS 45 0000:4023 58 POP AX 46 0000:4024 89 07 MOV [BX],AX ;interrupt vector initialisation 47 0000:4026 BB 00 02 MOV BX,200H 48 0000:4029 2E 8D 06 55 40 LEA AX,CS:SERVICE 49 0000:402E 89 07 MOV [BX],AX 50 51 0000:4030 BA D8 FF MOV DX,FFD8H 52 0000:4033 B0 13 MOV AL,13H 53 0000:4035 EE OUT DX,AL 54 0000:4036 BA DA FF MOV DX,FFDAH 55 0000:4039 B0 80 MOV AL,80H ;initialisation of PIC 8259A 56 0000:403B EE OUT DX,AL 57 0000:403C B0 0F MOV AL,0FH 58 0000:403E EE OUT DX,AL 64

Microprocessors and Interfacing Lab

59 60 61 62 2

0000:403F B0 FE 0000:4041 EE 0000:4042 0000:4042 B0 C1 BA 06 30 EE B0 0D BA 06 30 EE B0 03 EE FB E9 FD FF

MOV AL,FEH OUT DX,AL

Microprocessors and Interfacing Lab

MOV AL,C1H MOV DX,CTLP_55 OUT DX,AL

;initialise 8255 in mode ;port A i/p & o/p,port

63 0000:4044 C lower i/p 64 0000:4047 65 66 0000:4048 67 0000:404A 68 0000:404D 69 70 0000:404E 71 0000:4050 72 73 0000:4051 74 75 0000:4052 76 77 78 goes high 79 latched 80 received. 81 PORTA 82 83 0000:4055 84 0000:4055 85 0000:4055 86 0000:405A 87 0000:405C 88 0000:405F 89 0000:4060 90 0000:4061 91 0000:4062 92 92

MOV AL,0DH ;enable INTE flip flop MOV DX,CTLP_55 OUT DX,AL MOV AL,03H OUT DX,AL STI ;OBF1* taken high

;enable interrupt

BACK: JMP BACK

;When CPU writes data on output latch OBF* line goes low. ;As soon as user presses switch,ACK* goes low & INTR ;and control jumps to service routine and the data is ;on PORTA and OBF* line gets cleared when ACK* is ;This data can also be observed on LED connected to

SERVICE: 9A CC 4E 00 F8 CALL FAR KBDT 8B C6 MOV AX,SI BA 00 30 MOV DX,PORTA EE OUT DX,AL FB STI CF IRET CSEG ENDS CSEG ENDS

Result : Thus different modes of 8255 are observed.

Experiment No:14

8251 INTERFACING (TRANSMITTING&RECEIVING PART)


AIM: To test 8251 in transmitting and receiving parts by using the interfacing kit Apparatus: personnel computer Transmitting &receving kit(nifc 21)1nos Power supply connections : +5 v------BLUE GND---BLACK 65

+12--- RED _12---GREEN

Microprocessors and Interfacing Lab

Jumper connections: Jp 6: 1&2; Jp 7: 1&2; Jp17: 1&2; Jp 18: 1&2; Jp 1: 3&2; Jp 2: 3&2; Jp 4,jp5,jp13: 1&2: Jp 9 :5&6;jp 10 :5&6;jp 16:3&2; Eprom address : E000:34D0 Procedure for transmitting part: Connect the cable of RS 232 One end to kit (nifc 21) to other end is connected to personnel computer parallel port. And then run the communication package for 86drv.exe for 8086kit, b30drv.exe for 51lcd kit. execute the program in keyboard mode using go command Then the message TESTING 8251 TRANSMITTING PART will be displayed in the Kit. Suppose we may enter the data from the key board the data will see in the memory location of 0:ff00. Procedure for receving part: Jp 6: 1&2; Jp 7: 1&2; Jp17: 1&2; Jp 18: 1&2; Jp 1: 3&2; Jp 2: 3&2; Jp 4,jp5,jp13: 1&2: Jp 9 :1&2;jp 10 :5&6;jp 16:3&2; Eprom address : E000:35C0 And then run the communication package for 86drv.exe for 8086kit, b30drv.exe for 51lcd kit. execute the program in keyboard mode using go command Then the message 8251-RECEVING MODEwill be displayed on the lcd kit Then enter the characters from keyboard ,when user does not want to enter the characters any more then press the enter key. when it is pressed the char OD appears on the data The user can see the characters transmiited to the 8251A in RAM location 0:ff00 for 86 series kit AIM:To test 8251 in transmitting and receiving parts by using the interfacing kit Apparatus: personnel computer Transmitting &receving kit1nos Program: 1 2 3 4 5 frequency 6 address 7 address 8 9 address 10 11 data field 12 13 14 15 16 .OUTPUT 2500AD ;PROGRAM TO TEST 8251 7000 3402 3400 3002 3006 FF00 4F1F 000A 0140 0028 0014 CLOCK_FREQ EQU 1536000 CTL_8251 EQU 3402H DATA_8251 EQU 3400H TMR1_8253 EQU 3002H CTL_8253 EQU 3006H ;8253 clock ;8251 control port ;8251 data port ;8253 timer1 address ;8253 control port

EXT_RAM_LC EQU 0:FF00H ;RAM location DBDT EQU F800:4F1FH ;routine for display on CNT_BAUD_9600_MODE16 CNT_BAUD_4000_MODE01 CNT_BAUD_2400_MODE16 CNT_BAUD_1200_MODE64 66 EQU EQU EQU EQU 000AH 0140H 0028H 0014H

17 18 19 20 21 22 23 is

0050 00CE 00CD 00CF

CNT_BAUD_0300_MODE64 EQU 0050H MODE_WORD16 EQU CEH MODE_WORD1 EQU CDH MODE_WORD64 EQU CFH

Microprocessors and Interfacing Lab

;With the count calculated for various baud rates program

24 ;written to test receiver part of 8251 using RS_232 standard. 25 ;Data characters can be received from keyboard & sent to 8251 26 ;on an interrupt basis.RxRDY pin of the 8251 is connected to 27 ;an interrupt input through PIC 8259. 28 29 ;************************************ 30 ;PROGRAM TO TEST 8251 RECEIVING PART. 31 ;************************************ 32 33 0000:0000 DSEG SEGMENT 34 0000:3000 ORG 0000:3000H 35 0000:3000 38 32 35 31 2D 52 MSG2 DB '8251-Receiv mode',0H 0000:3006 65 63 65 69 76 20 0000:300C 6D 6F 64 65 00 36 DSEG ENDS 37 38 0000:0000 CSEG SEGMENT 39 0000:4000 ORG 0000:4000H 40 ASSUME CS:CSEG,DS:DSEG 41 42 0000:4000 START: 43 44 ;displaying message on LCD 45 ;-----------------------------------------46 0000:4000 9A B1 4B 00 F8 CALL FAR F800:4BB1H ;clear display 47 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 48 0000:4008 BE 00 30 MOV SI,offset MSG2 ; 49 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h;display output routine 50 51 52 0000:4010 B8 00 00 MOV AX,00H ;initialisation of stack pointer 53 0000:4013 8E D0 MOV SS,AX 54 0000:4015 BC 00 20 MOV SP,2000H 55 56 0000:4018 8E D8 MOV DS,AX 57 0000:401A 58 0000:401A FA CLI 59 0000:401B FC CLD 60 0000:401C 61 0000:401C BB 02 02 MOV BX,0202H ;initalisation of interrupt vector 62 0000:401F 0E PUSH CS 63 0000:4020 58 POP AX 64 0000:4021 89 07 MOV [BX],AX 67

65 0000:4023 BB 00 02 MOV BX,200H 66 0000:4026 2E 8D 06 80 40 LEA AX,CS:SRVC2 67 0000:402B 89 07 MOV [BX],AX 68 69 0000:402D BA D8 FF MOV DX,0FFD8H ;ICW1 70 0000:4030 B0 13 MOV AL,13H 71 0000:4032 EE OUT DX,AL 72 73 0000:4033 BA DA FF MOV DX,0FFDAH ;ICW2(intrrpt vector address) 74 0000:4036 B0 80 MOV AL,80H 75 0000:4038 EE OUT DX,AL 76 77 0000:4039 B0 0F MOV AL,0FH 78 0000:403B EE OUT DX,AL ;ICW4 79 80 0000:403C B0 FE MOV AL,0FEH 81 0000:403E EE OUT DX,AL ;OCW1(IR0 mask reset) 82 83 0000:403F BB 00 FF MOV BX,EXT_RAM_LC ;BX points to RAM location where the 84 ;character read from 8251 are stored 85 86 0000:4042 BA 06 30 MOV DX,CTL_8253 ;initialise timer1 in mode2 87 0000:4045 B0 76 MOV AL,76H 88 0000:4047 EE OUT DX,AL 89 90 0000:4048 BA 02 30 MOV DX,TMR1_8253 91 0000:404B B0 0A MOV AL,<CNT_BAUD_9600_MODE16 ;load LSB in count reg 92 0000:404D EE OUT DX,AL 93 0000:404E B0 00 MOV AL,>CNT_BAUD_9600_MODE16 ;load MSB in count reg 94 0000:4050 EE OUT DX,AL 95 96 0000:4051 FB STI ;enable interrupt 97 98 0000:4052 BA 02 34 MOV DX,CTL_8251 ;send 0's to guarantee,device is in 99 0000:4055 B0 00 MOV AL,00H ;command instruction format before 100 0000:4057 EE OUT DX,AL ;the RESET command is issued. 101 102 0000:4058 90 NOP 103 0000:4059 90 NOP 104 0000:405A 90 NOP 105 0000:405B 90 NOP 106 0000:405C EE OUT DX,AL 107 108 0000:405D 90 NOP 109 0000:405E 90 NOP 110 0000:405F 90 NOP 111 0000:4060 90 NOP 112 0000:4061 EE OUT DX,AL 113 68

Microprocessors and Interfacing Lab

114 0000:4062 command to 115 0000:4065 state 116 0000:4067 117 0000:4068 118 0000:4069 119 0000:406A 120 0000:406B 121 0000:406C 122 0000:406C word 123 0000:406F 124 0000:4071 125 0000:4072 126 0000:4073 127 0000:4074 128 0000:4075 129 130 0000:4076 word 131 0000:4079 132 0000:407B 133 8251,and the 134 read,RxRDY pin 135 is set 136 routine 137 138 139 140 0000:407C 141 0000:407D 142 143 144 0000:4080 145 0000:4080 146 0000:4083 data is 147 0000:4084 whether typed 148 0000:4085 indicates 149 0000:4086 displayed 150 0000:4087 display and 151 0000:4088 starting 152 0000:4089 location. 153 0000:408B 154 155 0000:408D

BA 02 34 B0 40 EE 90 90 90 90 BA 02 34 B0 CE EE 90 90 90 90 BA 02 34 B0 36 EE

MOV DX,CTL_8251 ;send internal RESET MOV AL,40H OUT DX,AL NOP NOP NOP NOP MOV DX,CTL_8251 ;load mode control ;return device to idle

Microprocessors and Interfacing Lab

MOV AL,MODE_WORD16 OUT DX,AL NOP NOP NOP NOP MOV DX,CTL_8251 ;load command

MOV AL,36H OUT DX,AL ;when the character typed has been shifted into ;character is in receiver buffer ready to be ;is connected to the interrupt pin,as soon as RxRDY ;interrupt is enabled & process jumps to service

90 E9 FC FF

BACK1: NOP JMP BACK1 SRVC2:

BA 00 34 EC EC 90 90 90 90 3C 0D 75 0F B4 00

MOV DX,DATA_8251 IN AL,DX ;In the service routine IN AL,DX NOP NOP NOP NOP CMP AL,0DH JNZ AHEAD2 MOV AH,00 69 ;read from 8251,check ;character is 0DH.If yes it ;it is the last char and is ;in the data field of the ;reinitialise pointer to the ;address of RAM

156 0000:408F 157 0000:4091 158 0000:4096 159 0000:4099 160 0000:409C other than 0DH 162 0000:409E RAM loc. 163 0000:409F 164 0000:40A0 165 to reset 166 service 167 be read. 168 169 170 0000:0000 170 0000:0000 1 2 3 4 5 frequency 6 address 7 address 8 9 address 10 11 data field 12 13 14 15 16 17 18 19 20 21 22 23 is 24 standard 25 basis.So 26 27

8B F0 9A 1F 4F 00 F8 BB 00 FF E9 03 00 88 07 43 FB CF

MOV SI,AX CALL FAR DBDT MOV BX,EXT_RAM_LC JMP TERM AHEAD2:MOV [BX],AL ;If typed char is INC BX ;then store the char in

Microprocessors and Interfacing Lab

TERM: STI IRET ;Reading a data char from 8251 data port causes it ;the RxRDY output signal.The process returns from ;routine & waits until another character is ready to CSEG ENDS END END .OUTPUT 2500AD PROGRAM TO TEST 8251

7000 3402 3400 3002 3006 FF00 4F1F 000A 0140 0028 0014 0050 00CE 00CD 00CF

CLOCK_FREQ EQU 1536000 CTL_8251 EQU 3402H DATA_8251 EQU 3400H TMR1_8253 EQU 3002H CTL_8253 EQU 3006H

;8253 clock ;8251 control port ;8251 data port ;8253 timer1 address ;8253 control port

EXT_RAM_LC EQU 0000:FF00H ;RAM location DBDT EQU F800:4F1FH ;routine for display on CNT_BAUD_9600_MODE16 CNT_BAUD_4000_MODE01 CNT_BAUD_2400_MODE16 CNT_BAUD_1200_MODE64 CNT_BAUD_0300_MODE64 MODE_WORD16 EQU CEH MODE_WORD1 EQU CDH MODE_WORD64 EQU CFH ;With the count calculated for various baud rates program ;written to test transmission part of 8251 using RS_232 ;Data characters can be sent to 8251 on an interrupt ;to send characters on interrupt basis the TxRDY pin of the ;8251 is connected to an interrupt input through PIC 8259. 70 EQU EQU EQU EQU EQU 000AH 0140H 0028H 0014H 0050H

28 29

Microprocessors and Interfacing Lab

30 ;*************************************** 31 ;PROGRAM TO TEST 8251 TRANSMITTING PART. 32 ;*************************************** 33 34 0000:0000 DSEG SEGMENT 35 0000:3000 ORG 0000:3000H 36 0000:3000 20 20 54 65 73 74 MSG2 DB ' Testing 8251 ',0h 0000:3006 69 6E 67 20 38 32 0000:300C 35 31 20 20 00 37 0000:3011 54 72 61 6E 73 6D MSG1 DB 'Transmiting part',0h 0000:3017 69 74 69 6E 67 20 0000:301D 70 61 72 74 00 38 0000:3022 54 45 53 54 49 4E MSG DB 'TESTING 8251 IN ASYNCHRONOUS MODE',0DH,0AH,1BH 0000:3028 47 20 38 32 35 31 0000:302E 20 49 4E 20 41 53 0000:3034 59 4E 43 48 52 4F 0000:303A 4E 4F 55 53 20 4D 0000:3040 4F 44 45 0D 0A 1B 39 DSEG ENDS 40 41 0000:0000 CSEG SEGMENT 42 0000:4000 ORG 0000:4000H 43 ASSUME CS:CSEG,DS:DSEG 44 ;displaying message on LCD 45 ;-----------------------------------------46 0000:4000 9A B1 4B 00 F8 CALL FAR F800:4BB1H ;clear display 47 0000:4005 BF 80 00 MOV DI,80H ;display in upper line 48 0000:4008 BE 00 30 MOV SI,offset MSG2 ; 49 0000:400B 9A C0 4F 00 F8 CALL FAR f800:4FC0h ;display output routine 50 0000:4010 BF C0 00 MOV DI,C0H ;display in lower line 51 0000:4013 BE 11 30 MOV SI,OFFSET MSG1 52 0000:4016 9A C0 4F 00 F8 CALL FAR F800:4FC0H ;display output routine 53 54 0000:401B START: 55 56 0000:401B B8 00 00 MOV AX,00H ;initialisation of stack pointer 57 0000:401E 8E D0 MOV SS,AX 58 0000:4020 BC 00 20 MOV SP,2000H 59 60 0000:4023 B8 00 00 MOV AX,00H 61 0000:4026 8E D8 MOV DS,AX 62 63 0000:4028 FA CLI 64 0000:4029 FC CLD 65 0000:402A 66 0000:402A BB 02 02 MOV BX,0202H ;initalisation of interrupt vector 71

67 0000:402D 0E PUSH CS 68 0000:402E 58 POP AX 69 0000:402F 89 07 MOV [BX],AX 70 0000:4031 BB 00 02 MOV BX,0200H 71 0000:4034 2E 8D 06 91 40 LEA AX,CS:SRVC1 72 0000:4039 89 07 MOV [BX],AX 73 74 0000:403B BA D8 50 MOV DX,050D8H ;ICW1 75 0000:403E B0 13 MOV AL,13H 76 0000:4040 EE OUT DX,AL 77 78 0000:4041 BA DA 50 MOV DX,050DAH ;ICW2(interrupt vector address) 79 0000:4044 B0 80 MOV AL,80H 80 0000:4046 EE OUT DX,AL 81 82 0000:4047 B0 0F MOV AL,0FH 83 0000:4049 EE OUT DX,AL ;ICW4 84 85 0000:404A B0 FE MOV AL,0FEH 86 0000:404C EE OUT DX,AL ;OCW1(IR0 mask reset) 87 88 89 0000:404D BB 22 30 MOV BX,OFFSET MSG ;BX points to message 90 0000:4050 BE 00 FF MOV SI,EXT_RAM_LC ;SI points to RAM Locations 91 ;where the characters written to 8251 are stored 92 93 0000:4053 BA 06 30 MOV DX,CTL_8253 ;initialise timer1 in mode2 94 0000:4056 B0 76 MOV AL,76H 95 0000:4058 EE OUT DX,AL 97 0000:4059 BA 02 30 MOV DX,TMR1_8253 98 0000:405C B0 0A MOV AL,<CNT_BAUD_9600_MODE16 ;load the LSB count in 99 0000:405E EE OUT DX,AL ;timer1 count reg 100 0000:405F B0 00 MOV AL,>CNT_BAUD_9600_MODE16 ;load the MSB count in 101 0000:4061 EE OUT DX,AL ;timer1 count reg 102 103 0000:4062 FB STI ;enable interrupt 104 105 0000:4063 BA 02 34 MOV DX,CTL_8251 ;8251 control port address.Send 106 0000:4066 B0 00 MOV AL,00H ;0's to guarantee,device is in 107 0000:4068 EE OUT DX,AL ;the command instruction format. 108 ;Repeat the same four times 109 0000:4069 90 NOP 110 0000:406A 90 NOP 111 0000:406B 90 NOP 112 0000:406C 90 NOP 113 0000:406D EE OUT DX,AL 114 0000:406E 90 NOP 115 0000:406F 90 NOP 72

Microprocessors and Interfacing Lab

116 0000:4070 117 0000:4071 118 0000:4072 119 120 0000:4073 command 121 0000:4076 idle state 122 0000:4078 123 0000:4079 124 0000:407A 125 0000:407B 126 0000:407C 127 0000:407D 128 0000:407D control word 129 0000:4080 130 0000:4082 131 0000:4083 132 0000:4084

90 90 EE BA 02 34 B0 40 EE 90 90 90 90 BA 02 34 B0 CE EE 90 90

NOP NOP OUT DX,AL

Microprocessors and Interfacing Lab

MOV DX,CTL_8251 ;send internal reset MOV AL,40H OUT DX,AL NOP NOP NOP NOP MOV DX,CTL_8251 ;load the mode ;to return device to

MOV AL,MODE_WORD16 OUT DX,AL NOP NOP

134 0000:4085 BA 02 34 MOV DX,CTL_8251 ;load the command word 135 0000:4088 B0 33 MOV AL,33H ;when CTS* input of 8251 is 136 0000:408A EE OUT DX,AL ;asserted low and the 8251 buffer 137 0000:408B 90 NOP ;is ready for a character,the TxRDY 138 0000:408C 90 NOP ;pin will go high.Since TxRDY pin 139 ;is connected to the interrupt pin,as soon as TxRDY is set INTR 140 ;is enabled and the process jumps to service routine. 141 0000:408D 142 0000:408D 90 BACK: NOP 143 0000:408E E9 FC FF JMP BACK 146 0000:4091 SRVC1: 147 0000:4091 B8 00 00 MOV AX,0000H 148 0000:4094 8E D8 MOV DS,AX 149 0000:4096 8A 07 MOV AL,[BX] message address stored in reg BX 150 0000:4098 83 C3 01 ADD BX,01H ;read the message byte by byte 151 0000:409B 3C 1B CMP AL,1BH ;check if the byte is a last byte 152 0000:409D 75 09 JNZ AHEAD 153 0000:409F 154 0000:409F 155 0000:409F BB 22 30 MOV BX,OFFSET MSG ;if yes reinitialise the pointer 156 0000:40A2 BE 00 FF MOV SI,EXT_RAM_LC ;to message and RAM location 157 0000:40A5 E9 E9 FF JMP SRVC1 73

158 0000:40A8 BA 00 34 the char to data port 159 0000:40AB EE location 160 0000:40AC 8A C8 161 0000:40AE B8 00 00 162 0000:40B1 8E D8 163 0000:40B3 8A C1 164 0000:40B5 88 04 165 0000:40B7 83 C6 01 166 0000:40BA FB 167 0000:40BB CF 168 port the 8251 169 to receive 170 routine after 171 ready in 172 174 175 0000:0000 176 0000:0000

AHEAD: MOV DX,DATA_8251

Microprocessors and Interfacing Lab


;if not send

OUT DX,AL;of 8251 & also save in ram MOV CL,AL MOV AX,00H MOV DS,AX MOV AL,CL MOV [SI],AL ADD SI,01H STI IRET ;When the data character is written to 8251 data ;resets its TxRDY o/p until the buffer is again ready ;a character.The process returns from interrupt ;writing data to 8251 and waits until 8251 buffer is ;in the main loop. CSEG ENDS END

Result: Hence we observed the transmitting &receiving part of the kit of 8251.

74

Microprocessors and Interfacing Lab

Micro Controller Programs


(CYCLE NO-3)

Experiment No:15
75

Microprocessors and Interfacing Lab

TO UNDERSTAND FIRST MEMORY AREA FROM (00-1F)


Aim: To understand the 1st memory area of 8051 micro controller. Apparatus: ALS-SDA-51-STA KIT Key board Power supply +5v Source code: SET D4 SET D3 MOV R1, #50 MOV R2, #40 ADD A1,R1 ADD A,R2 LCALL 0003H Result: Thus we understand the 1st memory area 00-1F of 8051 micro controller.

Experiment No:16

TO UNDERSTAND SECOND MEMORY AREA FROM (20-2F)


Aim: To understand the 2nd memory area of 8051 micro controller (Bit addressable) 76

Microprocessors and Interfacing Lab


Apparatus: ALS-SDA-51-STA KIT Key board Power supply +5v Source code: MOV C,27 MOV 2E, C LCALL 0003H Result: Thus we understand the 2nd memory area 20-2F (bit-addressable) of 8051 micro controller.

Experiment No:17

TO UNDERSTAND THIRD MEMORY AREA FROM (30-7F)


Aim: To understand the 3rd memory area of 8051 micro controller (30-7F). Apparatus: ALS-SDA-51-STA KIT Key board 77

Power supply +5v Source code: MOV A, 6F ADD A,6B MOV BE, A LCALL 0003H

Microprocessors and Interfacing Lab

Result: Thus we understand the 3rd memory area of 8051 micro controller (30-7F).

Experiment No:18

TO UNDERSTAND THE MEMORY AREA of 80-FF


Aim: To understand the memory area of 80-FF in 8051 micro controller. Apparatus: ALS-SDA-51-STA KIT Key board Power supply +5v Source code: 78

MOV d0, #75 MOV E0, #25 ADD A, D0 MOV F0, A LCALL 0003H

Microprocessors and Interfacing Lab

Result: Thus we understand the memory area of 80-FF in 8051 micro controller.

Experiment No:19

SWAP OPERATION
Aim: To perform swap operation in 8051 micro controller. Apparatus: ALS-SDA-51-STA KIT Key board Power supply Source code: 79

Microprocessors and Interfacing Lab


MOV A1,#64 SWAP A MOV R4,A LCALL 0003h Result: Thus the swap operation in 8051 micro controller performed.

Experiment No:20

SET-RESET
Aim: To perform the set reset operation of 8051 micro controller Apparatus: ALS-SDA-51-STA KIT Key board Power supply +5v Source code: SET B, D4 CLR D3 80

Microprocessors and Interfacing Lab


MOV RO, D0 MOV A,@R0 LCALL 0003H

Result: Thus the set-reset operation in 8051 micro controller is performed.

81

You might also like