mp lab manual

51
MICROPROCESSORS LABORATORY Department of CSE Subject Code: 10CSL48 I.A. Marks: 25 Hours/Week: 03 Exam Hours: 03 Total Hours: 42 Exam Marks: 50 Faculty: Mr. Mahesh Notes: Develop and execute the following programs using 8086 Assembly Language. Any suitable assembler like MASM, TASM etc may be used. Program should have suitable comments. The board layout and the circuit diagram of the interface are to be provided to the student during the examination. Session 1: Introduction to 8086 Microprocessor programming. P1. Search a key element in a list of ‘n’ 16-bit numbers using the Binary search algorithm. P2. Sort a given set of ‘n’ numbers in ascending order using the Bubble Sort algorithm. Session 2: P3. Read the current time from the system and display it in the standard format on the screen. P4. Compute nCr using recursive procedure. Assume that ‘n’ and ‘r’ are non-negative integers. Session 3: P5. Write a program to create a file (input file) and to delete an existing file. P6. Write two ALP modules stored in two different files; one module is to read a character from the keyboard and the other one is to display a character. Use the above two modules to read a string of characters from the keyboard terminated by the carriage return and print the string on the display in the next line. Session 4: P7. Reverse a given string and check whether it is a palindrome or not. P8. Read two strings, store them in locations STR1 and STR2. Check whether they are equal or not and display appropriate messages. Also display the length of the stored strings. Session 5: P9. Read your name from the keyboard and display it at a specified location on the screen after the message “What is your name?” You must clear the entire screen before display. P10. Read an alphanumeric character and display its equivalent ASCII code at the center of the screen. Session 6: P11. Read a pair of input co-ordinates in BCD and move the cursor to the specified location on the screen. P12. Write a program to simulate a Decimal Up-counter to display 00-99. Session 7: P13. Read the status of eight input bits from the Logic Controller Interface and display ‘FF’ if it is the parity of the input read is even; otherwise display 00.

Upload: devirpasad

Post on 02-Feb-2016

14 views

Category:

Documents


0 download

DESCRIPTION

microprocessor 5th sem vtu lab

TRANSCRIPT

Page 1: Mp Lab Manual

MICROPROCESSORS LABORATORY

Department of CSE

Subject Code: 10CSL48 I.A. Marks: 25 Hours/Week: 03 Exam Hours: 03 Total Hours: 42 Exam Marks: 50 Faculty: Mr. Mahesh Notes: Develop and execute the following programs using 8086 Assembly

Language. Any suitable assembler like MASM, TASM etc may be used. Program should have suitable comments. The board layout and the circuit diagram of the interface are to be

provided to the student during the examination. Session 1: Introduction to 8086 Microprocessor programming. P1. Search a key element in a list of ‘n’ 16-bit numbers using the Binary search algorithm. P2. Sort a given set of ‘n’ numbers in ascending order using the Bubble Sort algorithm. Session 2: P3. Read the current time from the system and display it in the standard format on the screen. P4. Compute nCr using recursive procedure. Assume that ‘n’ and ‘r’ are non-negative integers. Session 3: P5. Write a program to create a file (input file) and to delete an existing file. P6. Write two ALP modules stored in two different files; one module is to read a character from the keyboard and the other one is to display a character. Use the above two modules to read a string of characters from the keyboard terminated by the carriage return and print the string on the display in the next line. Session 4: P7. Reverse a given string and check whether it is a palindrome or not. P8. Read two strings, store them in locations STR1 and STR2. Check whether they are equal or not and display appropriate messages. Also display the length of the stored strings. Session 5: P9. Read your name from the keyboard and display it at a specified location on the screen after the message “What is your name?” You must clear the entire screen before display. P10. Read an alphanumeric character and display its equivalent ASCII code at the center of the screen. Session 6: P11. Read a pair of input co-ordinates in BCD and move the cursor to the specified location on the screen. P12. Write a program to simulate a Decimal Up-counter to display 00-99. Session 7: P13. Read the status of eight input bits from the Logic Controller Interface and

display ‘FF’ if it is the parity of the input read is even; otherwise display 00.

Page 2: Mp Lab Manual

PESIT - Bangalore South Campus

P14. Implement a BCD Up-Down Counter on the Logic Controller Interface. Session 8: P15. Read the status of two 8-bit inputs (X & Y) from the Logic Controller Interface and display X*Y. P16. Drive a Stepper Motor interface to rotate the motor in specified direction (clockwise or counter-clockwise) by N steps (Direction and N are specified by the examiner). Introduce suitable delay between successive steps. (Any arbitrary value for the delay may be assumed by the student). Session 9: P17. Display messages FIRE and HELP alternately with flickering effects on a 7-segment display interface for a suitable period of time. Ensure a flashing rate that makes it easy to read both the messages (Examiner does not specify these delay values nor is it necessary for the student to compute these values). P18. Assume any suitable message of 12 characters length and display it in the rolling fashion on

a 7-segment display interface for a suitable period of time. Ensure a flashing rate that makes it

easy to read both the messages. (Examiner does not specify these delay values nor is it

necessary for the student to compute these values). Session 10: P19. Convert a 16-bit binary value (assumed to be an unsigned integer) to BCD and display it from left to right and right to left for specified number of times on a 7-segment display interface. P20. Scan a 8 x 3 keypad for key closure and to store the code of the key pressed in a memory location or display on screen. Also display row and column numbers of the key pressed. Session 11: P21. Generate the Sine Wave using DAC interface (The output of the DAC is to be displayed on the CRO). P22. Generate a Half Rectified Sine wave form using the DAC interface. (The output of the DAC is to be displayed on the CRO). Session 12: P23. Generate a Fully Rectified Sine waveform using the DAC interface. (The output of the DAC is to be displayed on the CRO). P24. Drive an elevator interface in the following way: i. Initially the elevator should be in the ground floor, with all requests in OFF state. ii. When a request is made from a floor, the elevator should move to that floor, wait there for a

couple of seconds (approximately), and then come down to ground floor and stop. If some

requests occur during going up or coming down they should be ignored. Note: In the examination each student picks one question from the lot of all

12 questions. MICROPROCESSOR LAB (10CSL48) 2 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 3: Mp Lab Manual

PESIT - Bangalore South Campus

CONTENTS 1. A) BINARY SEARCH

B) PARITY CHECK 2. A) ALP MACROS

B) BCD UP-DOWN & RING COUNTER 3. A) BUBBLE SORT

B) DISPLAY X*Y 4. A) DISPLAY ASCII CODE AT THE CENTER

B) DISPLAY MESSAGES ALTERNATIVELY 5. A) PALINDROME

B) DISPLAY MESSAGE IN ROLLING FASHION 6. A) COMPARISON OF TWO STRINGS

B) CONVERSION OF 16- BIT BINARY VALUE TO BCD 7. A) READ FROM KEY BOARD & DISPLAY ON SCREEN

B) DISPLAY OF ROW & COLUMN NO. OF KEY PRESSED 8. A) COMPUTING NCR

B) STEPPER MOTOR IN BOTH DIRECTIONS 9. A) DISPLAY SYSTEM TIME

B) GENERATE SINE-WAVE 10. A) DECIMAL UP-COUNTER

B) HALF RECTIFIED SINE WAVE 11. A) MOVE CURSOR TO SPECIFIED LOCATION

B) FULLY RECTIFIED SINE WAVE 12. A) FILE CREATION & DELETION

B) ELEVATOR INTERFACE

MICROPROCESSOR LAB (10CSL48) 3 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 4: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 1(a) BINARY SEARCH AIM: Search a key element in a list of ‘n’ 16-bit numbers using the Binary search algorithm. .model small .data

.code a db 3h,5h,7h,10h,20h

n dw $-a key db 5h

m1 db 10,13,"KEY FOUND$" m2 db 10,13,"KEY NOT FOUND$"

.code start:mov ax,@data

mov ds,ax mov

cx,key mov

dx,n dec dx

mov al,key again:cmp cx,dx

ja over1 mov

bx,cx add

bx,dx shr

bx,01h mov

si,bx cmp

al,a[si] je

over2 cmp

al,a[si] jae

big dec si

mov dx,si

jmp again big: inc si

mov cx,si

jmp again over1:lea dx,m2

mov ah,09

int 21h jmp exit

over2:lea dx,m1 mov ah,09h

int 21h exit: mov ah,4ch

int 21h end start MICROPROCESSOR LAB (10CSL48) 4 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 5: Mp Lab Manual

PESIT - Bangalore South Campus

PARITY CHECK USING LOGIC CONTROLLER

INTERFACE DIAGRAM:

X86

MICRO- PROCESSOR

OR

PERSONAL COMPUTER

8255 PPI

INTERFACING PORT

CARD A

(PCI CARD) PORT

B

PORT

C

DC POWER SUPPLY

LOGIC

CONTROLLER BOARD

PORT A OUTPUT

(RED LED’S)

(GREEN LED’S)

8 PORT B

B INPUT

I

T

S

W

I

T

C

H

PORT C

(LOWER)

OUTPUT

4 PORT C

B

I (UPPER

T )

S INPUT

W

I

T

C

H

MICROPROCESSOR LAB (10CSL48) 5 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 6: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 1(b) PARITY CHECK AIM: Read the status of eight input bits from the Logic Controller Interface and

display ‘FF’ if it is even parity bits otherwise display ‘00’. Also display number

of 1’s in the input data. .MODEL SMALL .DATA

MSG DB "THE NUMBER OF 1’S IS : ",13,10,"$" .CODE

MOV AX,@DATA MOV DS,AX LEA DX,MSG MOV AH,09H INT 21H

MOV AL,82H MOV DX,9803H OUT DX,AL MOV DX,9801H IN AL,DX MOV CX,08H MOV BL,00H AGAIN : SHR AL,01H JNC SKIP INC BL SKIP : LOOP AGAIN MOV CL,BL SHR CL,01H JC ODD_P MOV AL,0FFH JMP HERE ODD_P :XOR AL,AL HERE : MOV DX,9800H OUT DX,AL ADD BL,30H MOV DL,BL MOV AH,02H INT 21H MOV AH,4CH INT 21H

END

MICROPROCESSOR LAB (10CSL48) 6 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 7: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 2(a) ALP MACROS AIM: Write ALP macros:

i. To read a character from the keyboard in the module (1) (in a different file) ii. To display a character in module (2) (from different file) iii. Use the above two modules to read a string of characters from the

keyboard terminated by the carriage return and print the string on the

display in the next line. .MODEL SMALL

.STACK 100H

.DATA

STR DB 20 DUP(0) .CODE

INCLUDE F1.MAC INCLUDE F2.MAC

PROG: MOV AX,@DATA

MOV DS,AX MOV ES,AX CLD LEA DI,STR MOV CX,0000H

UP1: RDKEY

CMP AL,13 JZ EXT STOSB INC CX JMP UP1

EXT: MOV AL,0AH

ECHO MOV AL,0DH ECHO LEA SI,STR

UP2: LODSB

ECHO LOOP UP2 MOV AH,4CH INT 21H END PROG

FILE NAME F1.MAC

RDKEY MACRO MOV AH,01H INT 21H

MICROPROCESSOR LAB (10CSL48) 7 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 8: Mp Lab Manual

PESIT - Bangalore South Campus

ENDM

FILE NAME F2.MAC

ECHO MACRO MOV DL,AL MOV AH,02H INT 21H ENDM

MICROPROCESSOR LAB (10CSL48) 8 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 9: Mp Lab Manual

PESIT - Bangalore South Campus

BCD UP-DOWN & RING COUNTER USING LOGIC CONTROLLER

INTERFACE DIAGRAM:

X86

MICRO-

8255 PPI

PROCESSOR

OR INTERFACING

CARD

PERSONAL (PCI CARD)

COMPUTER

DC

POWER SUPPLY

LOGIC

CONTROLLER BOARD

PORT A OUTPUT

(RED LED’S) PORT

A PORT

B PORT

C

MICROPROCESSOR LAB (10CSL48) 9 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 10: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 2(b) BCD UP-DOWN & RING COUNTER AIM: Perform the following functions using the Logic Controller

Interface. i. BCD up-down Counter ii. Ring Counter .MODEL SMALL .DATA

MSG DB 'PRESS ANY KEY FOR RETURNING TO DOS',13,10,'$' PORTA DW 9800H PORTB DW 9801H PORTC DW 9802H CTLW DW 9803H

.CODE MOV AX,@DATA MOV DS,AX MOV DX,OFFSET MSG MOV AH,09H INT 21H MOV AL,82H MOV DX,CTLW OUT DX,AL MOV DX,PORTB IN AL,DX CMP AL,0FFH JE UP4

UP : MOV AL,00 UP3 : PUSH AX

MOV AX,00H MOV AH,06H MOV DL,0FFH INT 21H JNZ QUIT MOV DX,PORTA POP AX OUT DX,AL CALL DELAYP INC AL CMP AL,0AH JE UP JMP UP3

UP4 : MOVAL,09H UP5 : PUSH AX

MOV AX,00H MOV AH,06H MOV DL,0FFH INT 21H JNZ QUIT MOV DX,PORTA POP AX OUT DX,AL CALL DELAYP DEC AL

MICROPROCESSOR LAB (10CSL48) 10 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 11: Mp Lab Manual

PESIT - Bangalore South Campus

CMP AL,0FFH JE UP4 JMP UP5

QUIT : MOV AH,4CH INT 21H DELAY PROC PUSH CX PUSH BX MOV CX,05FFFH

UP2 : MOV BX,0FFFFH UP1 : DEC BX

JNZ UP1 LOOP UP2 POP BX POP CX RET

DELAY ENDP END MICROPROCESSOR LAB (10CSL48) 11 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 12: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 3(a) BUBBLE SORT AIM: Sort a given set of ‘n’ numbers in ascending and descending orders using the Bubble Sort algorithm. .Model Small .data

a dw 20h,70h,40h,10h,50h

cnt equ ($-a)

.code start:mov ax,@data

mov ds,ax mov

dx,cnt-1 again0:mov

cx,dx lea si,a

again1:mov ax,[si]

cmp ax,[si+2] jl pr1 xchg [si+2],ax

xchg [si],ax pr1: add si,02

loop again1

dec dx jnz again0

mov ah,4ch

int 21h

end start

MICROPROCESSOR LAB (10CSL48) 12 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 13: Mp Lab Manual

PESIT - Bangalore South Campus

DISPLAY X*Y USING LOGIC CONTROLLER

INTERFACE DIAGRAM:

X86

MICRO-

8255 PPI

PROCESSOR

OR INTERFACING

CARD

PERSONAL (PCI CARD)

COMPUTER

DC

POWER

SUPPLY

LOGIC

CONTROLLER

BOARD

PORT A

OUTPUT

(RED LED’S)

(GREEN LED’S)

8 PORT B

B INPUT

I

PORT T

S

A W

PORT T

I

B C

PORT H

C

PORT C

(LOWER)

OUTPUT

4 PORT C

B

I (UPPER)

T INPUT

S

W

I

T

C

H

MICROPROCESSOR LAB (10CSL48) 13 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 14: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 3(b) DISPLAY X*Y AIM: Read the status of two 8-bit inputs (X & Y) from the Logic Controller Interface and display X*Y. .MODEL SMALL .CODE

MOV DX,9803H MOV AL,82H OUT DX,AL MOV DX,9801H IN AL,DX MOV BL,AL IN AL,DX MUL BL

MOV DX,9800H OUT DX,AL MOV AL,AH OUT DX,AL MOV AH,4CH INT 21H

END

MICROPROCESSOR LAB (10CSL48) 14 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 15: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 4(a) DISPLAY ASCII CODE AT THE CENTER AIM: Read an alphanumeric character and display its equivalent ASCII code at the center of the screen. .model small .data

msg db "ENTER A KEY",10,13,"$" .code start: mov ax,@data

mov ds,ax mov ah,00h mov

al,03h

int 10h mov dx,offset msg mov ah,09h int 21h mov

ah,01h int

21h mov

bl,al mov

ah,02 mov

bh,00 mov

dh,12 mov

dl,40 int

10h mov

al,bl and

al,0f0h mov

cl,04 shr

al,cl call

disp mov

al,bl and

al,0fh call

disp mov

ah,4ch int

21h disp proc

cmp al,0ah

jb skip add

al,7h skip: add al,30h

mov dl,al

mov ah,02h

int 21h ret

disp endp

end start MICROPROCESSOR LAB (10CSL48) 15 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 16: Mp Lab Manual

PESIT - Bangalore South Campus

7-SEGMENT DISPLAY EXPERIMENTS INTERFACE DIAGRAM:

DC POWER SUPPLY

X86 8255 PPI

MICRO-

PROCESSOR INTERFACING

PORT A

OR CARD

PERSONAL (PCI CARD) PORT C

COMPUTER

7-SEGMENT DISPLAY BOARD

7-SEGMENT DISPLAY BOARD INTERNAL CONNECTIONS:

PORT A = PA6 TO PA0

D5 D4 D3 D2 D1 D0

5

3 TO 8

4

PC2

D

3

PORT C PC1 E

C

2

PC0

O

D 1

E

0

R

To display a word on a Display Unit Di ( i=0 to 5), the seven segment code of the character to be displayed on the unit is to be output through Port A, while the display unit is selected by the combination on PC2-PC0 bits of port C.

MICROPROCESSOR LAB (10CSL48) 16 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 17: Mp Lab Manual

PESIT - Bangalore South Campus 7-SEGMENT LED DISPLAY: 7-SEGMENT CODES

a Character h g f e d c b a In Hex

f

b

g F 0 1 1 1 0 0 0 1 71H

c

I 0 0 0 0 0 1 1 0 06H

e R 0 1 1 1 0 1 1 1 77H

E 0

1 1 1 1 0

0 1 79H

h H 0

1 1 1 0 1

1 0 76H

d

E 0 1 1 1 1 0 0 1 79H

L 0 0 1 1 1 0 0 0 38H

P 0 1 1 1 0 0 1 1 73H

CONTROL WORD:

D7 D6 D5 D4 D3 D2 D1 D0 1 GA GA PA PCU GB PB PCL 1 0 0 0 0 0 0 0 = 80H All ports are configured as I/O ports in Mode-0. Port A & Port C are output ports. MICROPROCESSOR LAB (10CSL48) 17 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 18: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 4(b) DISPLAY MESSAGES ALTERNATIVELY AIM: Display messages FIRE and HELP alternately with flickering effects on a 7-

segment display interface for a suitable period of time. Ensure a flashing rate that

makes it easy to read both the messages (Examiner does not specify these delay

values nor it is necessary for the student to compute these values). .MODEL SMALL .DATA

FIRSTCODE DB 86H,88H,0F9H,8EH

SECCODE DB 8CH,0C7H,86H,89H .CODE

START : MOV AX,@DATA MOV DS,AX MOV DX,9803H MOV AL,80H OUT DX,AL MOV BH,0AH

AGAIN : MOV SI,OFFEST FIRSTCODE CALL DISPLAY1 CALL DELAY MOV SI,OFFSET SECCODE

CALL DISPLAY1 CALL DELAY DEC BH CMP BH,00H JE TERMINATE JMP AGAIN

DISPLAY1 PROC MOV CX,04H LOOP2 : MOV BL,08H MOV AL,[SI]

NEXT : ROR AL,01H MOV DX,9801H OUT DX,AL PUSH AX MOV AL,0FFH INC DX OUT DX,AL MOV AL,00H OUT DX,AL DEC BL POP AX JZ NEXT1 JMP NEXT

NEXT1 : INC SI LOOP LOOP2 RET DISPLAY1 ENDP

DELAY PROC PUSH AX PUSH CX

MICROPROCESSOR LAB (10CSL48) 18 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 19: Mp Lab Manual

PESIT - Bangalore South Campus

MOV CX,0FFFFH LOOP1 : MOV AX,0FFFH LOOP3 : DEC AX

JNZ LOOP3 LOOP LOOP1

POP CX POP AX RET

DELAY ENDP TERMINATE : MOV

AH,4CH INT 21H END START MICROPROCESSOR LAB (10CSL48) 19 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 20: Mp Lab Manual

PESIT - Bangalore South Campus EXPERIMENT NO.:- 5(a) PALINDROME AIM: Reverse a given string and check whether it is a palindrome or not.

.model small

.data str db "MADAM$" len equ 5 rstr db 10 dup(?) msg1 db 10,13,"PALINDROME$" msg2 db 10,13,"NOT A PALINDROME$"

.code mov ax,@data

mov ds,ax

mov es,ax

lea si,str

lea di,rstr

add di,len

dec di

mov cl,len again: mov al,[si]

mov [di],al dec di inc si

dec cl

jnz again

cld mov ch,0h

mov cl,len

lea si,str lea

di,rstr repe

cmpsb je

palin lea dx,msg2

mov ah,09h

int 21h

exit: mov ah,4ch

int 21h palin: lea dx,msg1

mov ah,09h

int 21h jmp

exit END MICROPROCESSOR LAB (10CSL48) 20 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 21: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 5(b) DISPLAY MESSAGE IN ROLLING FASHION AIM: Assume any suitable message of 12 characters length and display it in the rolling

fashion on a 7-segment display interface for a suitable period of time. Ensure a flashing

rate that makes it easy to read both the messages. (Examiner does not specify these

delay values nor it is necessary for the student to compute these values). .MODEL SMALL .DATA

STRING DB 0C0H, 0F9H, 0A4H, 0B0H, 099H, 092H, 082H, 0F8H, 080H, 098H, 88H, 83H, 0C6H

LEN DW ($-STRING) .CODE

MOV AX,@DATA MOV DS,AX MOV AL,080H MOV DX,9803H OUT DX,AL

L1 : MOV CX,LEN LEA SI,STRING

L2 : MOV AL,[SI] CALL DISPLAY1 CALL DELAY INC SI LOOP L2 JMP TERMINATE DISPLAY1 PROC PUSH CX MOV CX,08

L3 : MOV DX,9801H ROL AL,01 OUT DX,AL PUSH AX MOV DX,9802H MOV AL,0FFH OUT DX,AL MOV AL,00H OUT DX,AL POP AX LOOP L3 POP CX

RET DISPLAY1 ENDP

TERMINATE : MOV AH,4CH INT 21H

DELAY PROC PUSH CX PUSH BX MOV CX,03FFFH

L4 : MOV BX,0FFFFH L5 : DEC BX

JNZ L5 MICROPROCESSOR LAB (10CSL48) 21 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 22: Mp Lab Manual

PESIT - Bangalore South Campus

LOOP L4 POP BX POP CX RET DELAY ENDP

END MICROPROCESSOR LAB (10CSL48) 22 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 23: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 6(a) COMPARISON OF TWO STRINGS AIM: Read two strings, store them in locations STR1 and STR2. Check whether

they are equal or not and display appropriated messages. Also display the

length of the stored strings. DISP MACRO MSG

LEA DX,MSG MOV AH,09h INT 21H

ENDM .MODEL SMALL .STACK .DATA

M1 DB 'ENTER STRING1: $' M2 DB 13,10,'ENTER STRING2: $' M3 DB 13,10,'LENGTH1:$' M4 DB 13,10,'LENGTH2:$' M5 DB 13,10,'STR1=STR2$' M6 DB 13,10,'STR1!=STR2$' STR1 DB 80,?,80 DUP(' ') STR2 DB 80,?,80 DUP(' ') L1 DB ? L2 DB ?

.CODE

MOV AX,@DATA MOV DS,AX MOV ES,AX

DISP M1 LEA DX,STR1 CALL READ

DISP M2 LEA DX,STR2 CALL READ

MOV AL,[STR1+1] MOV L1,AL MOV AL,[STR2+1] MOV L2,AL CMP AL,L1 JNE STRNODE MOV CH,0 MOV CL,L1 LEA SI,STR1+2 LEA DI,STR2+2 CLD REPE CMPSB JNE STRNODE

MICROPROCESSOR LAB (10CSL48) 23 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 24: Mp Lab Manual

PESIT - Bangalore South Campus

DISP M5 JMP NEXT

STRNODE :DISP M6 NEXT :DISP M3

MOV AL,L1 CALL DISPL DISP M4 MOV AL,L2 CALL DISPL MOV AH,4CH INT 21H

READ PROC

MOV AH,0AH INT 21H RET

READ ENDP DISPL PROC

AAM MOV BX,AX ADD BX,3030H MOV AH,2 MOV DL,BH INT 21H MOV DL,BL INT 21H RET

DISPL ENDP END MICROPROCESSOR LAB (10CSL48) 24 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 25: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 6(b) CONVERSION OF 16- BIT BINARY VALUE TO BCD AIM: Convert a 16-bit binary value (assumed to be an unsigned integer) to BCD

and display it from left to right and right to left for specified number of times

on a 7-segment display interface. .MODEL SMALL .STACK 100H .DATA

BIN DW 04D2H BCD DW DUP(0) DISPTBL DB 03H,09FH,25H,0DH,99H,49H,41H,1FH,01H,09H PA

EQU 9800H PB EQU 9801H PC EQU 9802H CW EQU 9803H

.CODE MOV AX,@DATA MOV DS,AX MOV AL,90H MOV DX,CW OUT DX,AL MOV CX,BIN MOV AX,00H

AGN : ADD AL,1 DAA JNC NOINCAH ADD AH,1 MOV AL,AH DAA MOV AH,AL MOV AL,00

NOINCAH : LOOP AGN MOV DX,AX MOV BL,10H MOV AH,00 MOV AL,DH DIV BL MOV BCD,AL MOV BCD+1,AH MOV AH,00 MOV AL,DL DIV BL MOV BCD+2,AL MOV BCD+3,AH MOV CL,0AH

REPEAT : CALL BCDLDISP CALL DELAY1 CALL BCDRDISP CALL DELAY1 LOOP REPEAT MOV AH,4CH

MICROPROCESSOR LAB (10CSL48) 25 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 26: Mp Lab Manual

PESIT - Bangalore South Campus

INT 21 BCDLDISP

PROC PUSH CX MOV SI,3

NEXTCHAR : MOV AH,08H MOV AL,BCD[SI] LEA BX,DISPTBL XLAT

NEXTSEG : MOV DX,PB OUT DX,AL MOV CH,AL MOV AL,00H MOV DX,PC OUT DX,AL MOV AL,0FFH OUT DX,AL DEC AH JZ OVERCHK MOV AL,CH ROR AL,01 JMP

NEXTSEG OVERCHK : DEC SI

CMP SI,-1H JNE NEXTCHAR POP CX RET BCDLDISP ENDP BCDRDISP PROC PUSH CX MOV SI,0

NEXTCHAR1 : MOV AH,08H MOV AL,BCD[SI] LEA BX,DISPTBL XLAT

NEXTSEG1 : MOV DX,PB OUT DX,AL MOV CH,AL MOV AL,00H MOV DX,PC OUT DX,AL MOV AL,0FFH OUT DX,AL DEC AH JZ OVERCHK1

MOV AL,CH ROR

AL,01 JMP

NEXTSEG1 OVERCHK1 : INC SI

CMP SI,04 JNE NEXTCHAR1

POP CX MICROPROCESSOR LAB (10CSL48) 26 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 27: Mp Lab Manual

PESIT - Bangalore South Campus

RET BCDRDISP ENDP DELAY1 PROC PUSH CX PUSH BX MOV CX,0FAAH

L4 : MOV BX,0FFFFH L3 : DEC BX

JNZ L3 LOOP L4 POP BX POP CX RET DELAY1 ENDP

END MICROPROCESSOR LAB (10CSL48) 27 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 28: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 7(a) READ FROM KEY BOARD & DISPLAY ON SCREEN AIM: Read your name from the keyboard and display it at a specified location

on the screen in front of the message What is your name? You must clear the

entire screen before display. strread macro

loc mov ah,01h int 21h mov loc,al endm

.model small

.data m1 db "WHAT IS UR NAME ?$

" arr db 20h dup(?) .code start: mov ax,@data

mov ds,ax mov

si,0h loop1: strread

arr[si] inc si cmp al,13

jnz loop1 mov arr[si],"$"

mov ah,00h

mov al,03h

int 10h

mov ah,02h

mov bh,00h

mov dh,12h

mov dl,20h

int 10h

lea dx,m1

mov ah,09h

int 21h

mov si,0h

lea dx,arr[si]

mov ah,09h

int 21h

mov ah,4ch

int 21h end start MICROPROCESSOR LAB (10CSL48) 28 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 29: Mp Lab Manual

PESIT - Bangalore South Campus

KEYBOARD INTERFACE EXPERIMENTS

INTERFACE DIAGRAM: 7%6÷5×4— K

3+2.19CE08C E

Y

B

O

X86 A

8255 PPI

R

MICRO-

D

PROCESSOR

INTERFACING PORT A

I

OR CARD PORT C

N

(PCI CARD)

PERSONAL T

E

COMPUTER

R

F

A

C

E

KEYBOARD INTERFACE INTERNAL CONNECTIONS:

PC0 0 1 2

PORT C PC1

8

9

.

3 4 5 6 7

+ — × ÷ %

PC2 C CE

PA0

PA1

PA2

PORT A PA3

PA4

PA5

PA6

PA7

Keyboard scan includes activation of a scan line by outputting a logic-1 on scan line (PC2-PC0), while expecting a “1” on return line (PA7-PA0) in the column corresponding to the key pressed. MICROPROCESSOR LAB (10CSL48) 29 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 30: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 7(b) DISPLAY OF ROW & COLUMN NO. OF KEY PRESSED AIM: Scan an 8 x 3 keypad for key closure and to store the code of the key

pressed in a memory location or display on screen. Also display row and

column numbers of the key pressed. .MODEL SMALL .DATA

DISP DB ‘0123456789.+-X/%ACH=WXYZ$’ MSG DB 10,13,’KEY PRESSED IS ‘,’$’ MSG1 DB 10,13,’THE ROW NUMBER IS = ‘ ROW DB ?,10,13,’$’ MSG2 DB 10,13,’THE COLUMN NUMBER IS = ‘ COL DB ?,10,13,’$’

.CODE MOV AX,@DATA MOV DS,AX MOV AL,90H MOV DX,9803H OUT DX,AL

REPEAT : MOV DX,9802H MOV AL,01H OUT DX,AL MOV DX,9800H IN AL,DX CMP AL,00 JNZ F_C MOV DX,9802H MOV AL,02H OUT DX,AL MOV DX,9800H IN AL,DX CMP AL,00 JNZ S _C MOV AL,04H MOV DX,9802H OUT DX,AL MOV DX,9800H IN AL,DX CMP AL,00

JNZ T_C JMP

REPEAT F_C : MOV SI,OFFSET

DISP MOV ROW,31H MOV CL,30H

NEXT1 : INC CL SHR AL,01 JC DISP1

INC SI JMP NEXT1

S_C : MOV SI,OFFSET

DISP ADD SI,08H MICROPROCESSOR LAB (10CSL48) 30 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 31: Mp Lab Manual

PESIT - Bangalore South Campus

MOV ROW,32H MOV CL,30H

NEXT2 : INC CL SHR AL,01 JC DISP1 INC SI JMP NEXT2

T_C : MOV SI,OFFSET DISP ADD SI,10H MOV ROW,33H MOV CL,30H

NEXT3 : INC CL SHR AL,01 JC DISP1 INC SI JMP NEXT3

DISP1 : LEA DX,MSG MOV AH,09H INT 21H MOV DL,[SI] MOV AH,02H INT 21H MOV DL,0DH MOV AH,02H INT 21H MOV COL,CL MOV DX,OFFSET MSG1 MOV AH,09H INT 21H MOV DX,OFFSET MSG2 MOV AH,09H INT 21H MOV AH,4CH INT 21H

END MICROPROCESSOR LAB (10CSL48) 31 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 32: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 8(a) COMPUTING NCR

AIM: Compute nCr (nCr) using recursive procedure. Assume that ‘n’ and ‘r’ are

non-negative integers. .model small .data

n dw 3h

r dw 2h ncr dw 01h dup(0)

.code mov ax,@data

mov ds,ax

mov ax,n mov

bx,r call ncrproc

mov dx,ncr

add dx,30h

mov ah,02h

int 21h mov

ah,4ch int

21h ncrproc proc

cmp ax,bx

je res1

cmp bx,0

je res1

cmp bx,1

je resn

dec ax

cmp ax,bx

je resn

push ax

push bx call ncrproc pop bx pop

ax dec bx

push ax

push bx

call ncrproc pop bx pop

ax

ret res1: inc ncr

ret resn: add

ncr,ax ret

MICROPROCESSOR LAB (10CSL48) 32 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 33: Mp Lab Manual

PESIT - Bangalore South Campus

ncrproc

endp end MICROPROCESSOR LAB (10CSL48) 33 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 34: Mp Lab Manual

PESIT - Bangalore South Campus

STEPPER MOTOR EXPERIMENTS

INTERFACE DIAGRAM: DC

POWER

SUPPLY

X86

8255 PPI

MICRO-

PROCESSOR INTERFACING

OR CARD

PERSONAL (PCI CARD) STEPPER

MOTOR

COMPUTER PORT C INTERFACING

MODULE

STEPPER MOTOR-1

STEPPER MOTOR INTERFACING MODULE INTERNAL CONNECTIONS:

PC3-PC0

STEP SEQUENCE

PC3PC2_PC1PC0ORPC

STEPPER

7PC6PC5_PC4__1110110

110110111

PORT C MOTOR

STEPPER MOTOR-1

INTERFACING

(PC7-

MODULE

PC0)

PC7-PC4

ANTI- CLOCK

CLOCK

STEPPER MOTOR-2

(OPTIONAL)

To rotate a Stepper Motors in clock-wise or anticlockwise direction, the sequence should be output in the nibble of Port C as shown above. Sequence is output on PC3-PC0 for Stepper Motor –1 and on PC7-PC4 for Stepper Motor–2. CONTROL WORD:

D7 D6 D5 D4 D3 D2 D1 D0 1 GA GA PA PCU GB PB PCL

1 0 0 0 0 0 0 0 = 80H All ports are configured as I/O ports in Mode-0.

MICROPROCESSOR LAB (10CSL48) 34 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 35: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 8(b) STEPPER MOTOR IN BOTH DIRECTION AIM: Drive a stepper motor interface to rotate the motor by N steps left direction and N

steps right direction (N is specified by the examiner). Introduce suitable delay between

successive steps. (Any arbitrary value for the delay may be assumed by the student). CLOCKWISE PROGRAM: .MODEL SMALL .DATA

N DW 200 .CODE

MOV AX,@DATA MOV DS,AX MOV DX,09803H MOV AL,80H OUT DX,AL MOV DX,09800H MOV AL,88H MOV CX,N

AGAIN : OUT DX,AL CALL DELAY ROR AL,01 LOOP AGAIN MOV AH,4CH INT 21H

DELAY PROC PUSH BX PUSH CX MOV CX,0FFFH

REPEAT : MOV BX,0FFFFH HERE1 : DEC BX

JNZ HERE1 REPEAT POP CX POP BX

RET DELAY

ENDP END ANTICLOCKWISE PROGRAM: .MODEL SMALL .DATA

N DW 200 .CODE

MOV AX,@DATA MOV DS,AX MOV DX,09803H MOV AL,80H OUT DX,AL MOV DX,09800H MOV AL,88H MOV CX,N

MICROPROCESSOR LAB (10CSL48) 35 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 36: Mp Lab Manual

PESIT - Bangalore South Campus

AGAIN : OUT DX,AL CALL DELAY ROL AL,01 LOOP AGAIN MOV AH,4CH INT 21H

DELAY PROC PUSH BX PUSH CX MOV CX,0FFFH

REPEAT : MOV BX,0FFFFH HERE1 : DEC BX

JNZ HERE1

LOOP REPEAT

POP CX POP BX

RET DELAY

ENDP END MICROPROCESSOR LAB (10CSL48) 36 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 37: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 9(a) DISPLAY SYSTEM TIME AIM: Read the current time from the system and display it in the standard format on the screen. .model small .code

mov ah,2ch

int 21h

mov al,ch

aam mov bx,ax

call disp

mov dl,':'

mov ah,02h

int 21h

mov al,cl

aam mov bx,ax

call disp

mov ah,4ch

int 21h disp proc

mov dl,bh

add dl,30h

mov ah,02h

int 21h mov

dl,bl add

dl,30h mov

ah,02h int

21h ret

disp endp

end

MICROPROCESSOR LAB (10CSL48) 37 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 38: Mp Lab Manual

PESIT - Bangalore South Campus

DUAL DAC INTERFACE EXPERIMENTS

INTERFACE DIAGRAM: DC

POWER

SUPPLY

X86

8255 PPI

MICRO-

PROCESSOR INTERFACING

OR CARD

(PCI CARD)

DUAL DAC

PERSONAL

CRO

PORT A INTERFACE

COMPUTER MODULE

OR

PORT B

DAC INTERFACE INTERNAL CONNECTIONS:

PORT A

OUT1

(PA0-PA7)

CRO

DAC 1

GND

(OPTIONAL)

PORT B

OUT2

(PB0-PB7) DAC 2

CRO

GND

Analog output corresponding to Digital data input in Port A is available in

OUT-1, while the one corresponding to data input in Port B is available in OUT-2. CONTROL WORD:

D7 D6 D5 D4 D3 D2 D1 D0 1 GA GA PA PCU GB PB PCL 1 0 0 0 0 0 0 0 = 80H

All ports are configured as I/O ports in Mode-0.

MICROPROCESSOR LAB (10CSL48) 38 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 39: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 9(b) GENERATE SINE-WAVE AIM: Generate the Sine Wave using DAC interface (The output of the DAC is to be displayed on the CRO). .MODEL SMALL .DATA ARR DB 7FH,8CH,99H,0A6H,0B2H,0BFH,0CAH,0D4H,0DDH,0E6H,0EDH,0F3H,0F8H,0FDH,0FC H,OFBH,0F8H,0F3H,0EDH

DB 0E6H,0DDH,0D4H,0CAH,0BFH,0B2H,0A6H,99H,08CH,7FH,72H,65H,58H,4CH,3FH,34H DB

2AH,21H,18H,11H,0BH,06H,03H,01H,00H,01H,03H,06H,0BH,11H,18H,21H,2AH,34H,3F

H,4CH,58H,65H,72H,7FH .CODE

MOV AX,@DATA MOV DS,AX MOV DX,9803H MOV AL,80H OUT DX,AL

UP1:LEA SI,ARR MOV CX,60 UP:

MOV AL,[SI] MOV DX,9800H OUT DX,AL MOV DX,9801H OUT DX,AL CALL DELAY INC SI LOOP UP JMP UP1 MOV AH,4CH INT 21H

DELAY PROC PUSH BX PUSH CX MOV CX,0FH

REPEAT : MOV BX,0FFH HERE1 : DEC BX

JNZ HERE1

LOOP REPEAT

POP CX POP BX

RET DELAY

ENDP END

MICROPROCESSOR LAB (10CSL48) 39 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 40: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 10(a) DECIMAL UP-COUNTER AIM: Program to simulate a Decimal Up-counter to display 00-99.

.model small

.code mov al,030h

loop1: mov dl,al mov ah,02h int 21h

push ax

mov bl,030h loop2: mov dl,bl

mov ah,02h int 21h

inc bl call delay mov ah,03h

int 10h

mov dl,01h

mov ah,02h

int 10h

cmp bl,039h

jle loop2

mov dl,00h

mov ah,02h

int 10h

pop ax

inc al cmp al,039h

jle loop1

mov ah,4ch

int 21h delay proc

push cx

push bx mov cx,0fffh

loop3: mov bx,0ffffh loop4: dec bx

jnz loop4

loop loop3

pop bx

MICROPROCESSOR LAB (10CSL48) 40 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 41: Mp Lab Manual

PESIT - Bangalore South Campus

pop cx ret

delay

endp end MICROPROCESSOR LAB (10CSL48) 41 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 42: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 10(b) HALF RECTIFIED SINE WAVE AIM: Generate a Half Rectified Sine wave form using the DAC interface. (The output of the DAC is to be displayed on the CRO). .MODEL SMALL .DATA ARR DB 7FH,8CH,99H,0A6H,0B2H,0BFH,0CAH,0D4H,0DDH,0E6H,0EDH,0F3H,0F8H,0FDH,0FC H,OFBH,0F8H,0F3H,0EDH

DB 0E6H,0DDH,0D4H,0CAH,0BFH,0B2H,0A6H,99H,08CH,7FH,72H,65H,58H,4CH,3FH,34H DB

00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,

00H,00H,00H,00H,00H .CODE

MOV AX,@DATA MOV DS,AX MOV DX,9803H MOV AL,80H OUT DX,AL

UP1:LEA SI,ARR MOV CX,60 UP:

MOV AL,[SI] MOV DX,9800H OUT DX,AL MOV DX,9801H OUT DX,AL CALL DELAY INC SI LOOP UP JMP UP1 MOV AH,4CH INT 21H

DELAY PROC PUSH BX PUSH CX MOV CX,0FH

REPEAT : MOV BX,0FFH HERE1 : DEC BX

JNZ HERE1

LOOP REPEAT

POP CX POP BX

RET DELAY

ENDP END

MICROPROCESSOR LAB (10CSL48) 42 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 43: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 11(a) MOVE CURSOR TO SPECIFIED LOCATION AIM: Read a pair of input co-ordinates in BCD and move the cursor to the specified location on the screen. disp macro msg

lea dx,msg

mov ah,09h

int 21h endm .model small .data

m1 db 10,13,"ENTER ROW VALUE (00-24) $" m2 db 10,13,"ENTER COL VALUE (00-79) $" m3 db 10,13,"PRESS ANY KEY $" row db ?

col db ? .code

mov ax,@data

mov ds,ax

disp m1 call read

mov row,al

disp m2 call

read mov

ah,08h int

21h

mov col,al

disp m3

mov ah,00h

mov al,03h

int 10h

mov dh,row

mov dl,col

mov ah,02h

int 10h

mov ah,08h

int 21h

mov ah,4ch MICROPROCESSOR LAB (10CSL48) 43 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 44: Mp Lab Manual

PESIT - Bangalore South Campus

int 21h

read proc

mov ah,01h

int 21h

and al,0fh

mov bl,al

mov ah,01h

int 21h

and al,0fh

mov ah,bl

aad

ret

read

endp end MICROPROCESSOR LAB (10CSL48) 44 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 45: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 11(b) FULLY RECTIFIED SINE WAVE AIM: Generate a Fully Rectified Sine waveform using the DAC interface. (The output of the DAC is to be displayed on the CRO). .MODEL SMALL .DATA ARR DB 7FH,8CH,99H,0A6H,0B2H,0BFH,0CAH,0D4H,0DDH,0E6H,0EDH,0F3H,0F8H,0FDH,0FC H,OFBH,0F8H,0F3H,0EDH DB 0E6H,0DDH,0D4H,0CAH,0BFH,0B2H,0A6H,99H,08CH,7FH .CODE

MOV AX,@DATA MOV DS,AX MOV DX,9803H MOV AL,80H OUT DX,AL

UP1:LEA SI,ARR MOV CX,30H

UP: MOV AL,[SI] MOV DX,9800H OUT DX,AL MOV DX,9801H OUT DX,AL CALL DELAY INC SI LOOP UP JMP UP1 MOV AH,4CH INT 21H

DELAY PROC PUSH BX PUSH CX MOV CX,0FH

REPEAT : MOV BX,0FFH HERE1 : DEC BX

JNZ HERE1

LOOP REPEAT

POP CX POP BX

RET DELAY

ENDP END MICROPROCESSOR LAB (10CSL48) 45 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 46: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 12(a) FILE CREATION & DELETION AIM: Program to create a file (input file) and to delete an existing file.

.MODEL SMALL .DATA

MSG1 DB 10, 13,"PRESS 1: CREATE FILE 2: DELETE FILE$" MSG2 DB 10, 13,"ENTER YOUR CHOICE: $" MSG3 DB 10, 13,"ERROR$" F1

DB "anu.TXT$", 0 .CODE

MOV AX,@DATA MOV DS, AX LEA DX, MSG1 CALL DISP LEA DX, MSG2 CALL DISP MOV AH, 1H INT 21H CMP AL,'1' JE CREATE CMP AL,'2' JE DELETE

ERROR: LEA DX, MSG3 CALL DISP

EXIT: MOV AH, 4CH INT 21H

CREATE: MOV CX, 0 LEA DX, F1 MOV AH, 3CH INT 21H JC ERROR JMP EXIT

DELETE: LEA DX, F1

MOV AH, 41H INT 21H JC ERROR JMP EXIT

DISP PROC NEAR MOV AH, 9 INT 21H RET DISP ENDP END

MICROPROCESSOR LAB (10CSL48) 46 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 47: Mp Lab Manual

PESIT - Bangalore South Campus

ELEVATOR INTERFACE EXPERIMENTS

INTERFACE DIAGRAM: DC

POWER SUPPLY

FLOOR E

REQUEST NUMBER

X86 SWITCH(REQUEST

L POSITION OF ELEVATOR

INDICATOR)

MICRO- 8255 PPI 3(R) E G

PROCESSOR INTERFACING

V Y

A Y

OR CARD T

2(R)

PERSONAL (PCI CARD) PORT A O G

PORT B R Y

COMPUTER Y

1(R) B

G

O Y

A Y

R

0(R) G

D

ELEVATOR INTERFACE INTERNAL CONNECTIONS:

THIRD

S 5V

D Q

CP _

R

Q 270 R G 270

Y

SECOND D S Q Y

R G

CP _

R

Q Y

Y

FIRST D S Q R G

CP _

Y

R

Q

Y

S

R G

GROUND D Q

74LS4

2

_

A00

A11

A22

CP

R Q

U1

PORT A(PA7-PA4) PORT B(PB3-PB0) PORT A(PA3-PA0)

OUT IN

OUT

The following points to be noted w.r.t the usage of elevator interface by the programmer. 1. The BCD value on PA3-PA0 (Output) indicates the position of elevator (0 to 9).

Lift position LEDs (Green) indicates the position of Lift at any time. 2. The bits in the PA7-PA4 (Output) can be used to RESET Request LED (Red). The bits

corresponding to a floor must be reset to logic – 0 to turn off corresponding request LED. 3. The status of Request LEDs can be read by port PB3-PB0. Logic – 0 in a bit

indicates the Request from a floor and the corresponding Red LED is seen glowing. 4. Switches (or Keys) are used to signal elevator service request, which turns on Red LEDs. MICROPROCESSOR LAB (10CSL48) 47 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 48: Mp Lab Manual

PESIT - Bangalore South Campus

CONTROL WORD:

D7 D6 D5 D4 D3 D2 D1 D0 1 GA GA PA PCU GB PB PCL 1 0 0 0 0 0 1 0 = 82H All ports are configured as I/O ports in Mode-0. Port A is output and Port B is Input. MICROPROCESSOR LAB (10CSL48) 48 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 49: Mp Lab Manual

PESIT - Bangalore South Campus

EXPERIMENT NO.:- 12(b) ELEVATOR INTERFACE AIM: Drive an elevator interface in the following way: i. Initially the elevator should be in the ground floor, with all requests in OFF state. ii. When a request is made from a floor, the elevator should move to that floor, wait there for

a couple of seconds, and then come down to ground floor and stop. If some requests

occur during going up or coming down they should be ignored.

.MODEL SMALL .STACK .DATA

ARR DB 04H, 07H, 0AH, 0D3H, 0B6H, 79H .CODE

MOV AX,@DATA MOV DS,AX MOV DX,9803H MOV AL,82H OUT DX,AL LEA SI,ARR MOV DX,9800H MOV AL,0F0H OUT DX,AL MOV DX,9801H

UP: IN AL,DX OR AL,0F0H CMP AL,0FFH JE UP SHR AL,01H JNC DN0 SHR AL,01H JNC DN1 INC SI SHR AL,01 JNC DN1

INC SI DN1:MOV CL,[SI]

MOV BL,CL MOV DX,9800H MOV AL,0F0H

UP1:OUT DX,AL CALL DELAY INC AL LOOP UP1 ADD SI,0003H MOV AL,[SI] OUT DX,AL MOV CL,BL DEC CL UP2:DEC AL OUT DX,AL CALL DELAY LOOP UP2

MICROPROCESSOR LAB (10CSL48) 49 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 50: Mp Lab Manual

PESIT - Bangalore South Campus

JMP STOP DN0:CALL DELAY

CALL DELAY MOV DX,9800H MOV AL,0E0H OUT DX,AL STOP:MOV AH,4CH INT 21H

DELAY PROC

PUSH BX PUSH CX MOV CX,0FFFH REPEAT : MOV BX,0FFFFH

HERE1 : DEC BX JNZ HERE1

LOOP REPEAT

POP CX POP BX

RET DELAY

ENDP END MICROPROCESSOR LAB (10CSL48) 50 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM

Page 51: Mp Lab Manual

PESIT - Bangalore South Campus

MICROPROCESSOR LAB (10CSL48) 51 DEPT. OF COMPUTER SCIENCE & ENGG. IV SEM