Microprocessor Lab Manual www.bookspar.com | Website for

advertisement
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
1b. Read the status of eight input bits from the logic controller Interface and display ‘FF’ it
is even parity bits otherwise display 00.Also display number of 1’s in the input data.
.MODEL SMALL
.CODE
MOV DX,0E403H
MOV AL,82H
OUT DX,AL
MOV DX,0E401H
IN AL,DX
MOV CL,8
MOV AH,0
N2:ROR AL,01
JC N1
DEC CL
JNZ N2
JMP NXT
N1:INC AH
DEC CL
JNZ N2
NXT:MOV AL,AH
AND AL,1
CMP AL,0
JZ DFF
MOV AL,0
JMP NEXT
DFF:MOV AL,0FFH
NEXT :MOV DX,0E400H
OUT DX,AL
MOV SI,4FFFH
RET2:MOV DI,0FFFFH
RET1:DEC DI
JNZ RET1
DEC SI
JNZ RET2
MOV AL,AH
MOV DX,0E400H
OUT DX,AL
MOV AH,4CH
INT 21H
END
page 1
; to set the control word register
; 82h- port A o/p and port B i/p
; CL- stores the no. of bits
; if the bit in CF is 1 increment no. of 1’s
; else find the next bit
; to check if the no. of 1’s is even or odd
; if even display FF
; else display 00
; delay to see clear o/p
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
2b. Perform the following function using logic control Interface
i. BCD up-down count
.MODEL SMALL
.CODE
MOV DX,0E403H
MOV AL,80H
OUT DX,AL
MOV AL,0
MOV DX,0E400H
UP:OUT DX,AL
CALL DELAY
ADD AL,1
DAA
CALL STOP
CMP AL,99H
JNE UP
DOWN:OUT DX,AL
CALL DELAY
ADD AL,99H
DAA
CALL STOP
CMP AL,99H
JNE DOWN
STOP:PUSH AX
MOV AH,1
INT 16H
JNE EXIT
POP AX
RET
EXIT:MOV AH,4CH
INT 21H
DELAY:MOV SI,2FFFH
RET2:MOV DI,0FFFFH
RET1:DEC DI
JNZ RET1
DEC SI
JNZ RET2
RET
END
ii. Ring counter.
.MODEL SMALL
.CODE
MOV DX,0E403H
MOV AL,80H
page 2
; 80H- all ports o/p
; convert hex no. to BCD
; if no. < 99H increment and display
;else decrement and display
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
OUT DX,AL
MOV DX,0E400H
MOV AL,1
BAK:OUT DX,AL
CALL DELAY
CALL STOP
ROL AL,1
JMP BAK
DELAY:MOV SI,05FFF
RET2:MOV DI,0FFFFH
RET1:DEC DI
JNZ RET1
DEC SI
JNZ RET2
RET
STOP:PUSH AX
MOV AH,1
INT 16H
JNZ XIT
POP AX
RET
XIT: MOV AH,4CH
INT 21H
END
page 3
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
3b. Read the status of two 8-bits inputs(X & Y) from the Logic Controller Interface and
display X*Y.
.MODEL SMALL
.CODE
MOV DX,0E403H
MOV AL,82H
OUT DX,AL
MOV DX,0E401H
IN AL,DX
MOV BL,AL
MOV AH,8
INT 21H
MOV DX,0E401H
IN AL,DX
MUL BL
MOV DX,0E400H
OUT DX,AL
CALL DELAY
MOV AL,AH
OUT DX,AL
MOV AH,4CH
INT 21H
DELAY:MOV SI,05FFFH
RET2:MOV DI,0FFFFH
RET1:DEC DI
JNZ RET1
DEC SI
JNZ RET2
RET
END
page 4
; take input of X(first no.) from keyboard
; wait for a keyboard i/p
; take input of Y(first no.) from keyboard
; multiply the nos. (X*Y)
; display the resultant
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
4b.Display messages FIRE and HELP alternatively 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 message(Examiner does not specify these delay values nor it is necessary for
the student to compute these values).
.MODEL SMALL
.DATA
DATA1 DB 86H,0AFH,0CFH,8EH ; seven-segment code for E,r,I,F respectively
DATA2 DB 8CH,0C7H,86h,89H
; seven-segment code for P,L,E,H respectively
.CODE
MOV AX,@DATA
MOV DS,AX
MOV DX,0E803H
MOV AL,80H
OUT DX,AL
BAK: LEA SI,DATA1
;load the effective address of erif
CALL DISPLAY
;display FIrE
CALL DELAY
;delay to have flickering effect
LEA SI,DATA2
;load the effective address of PLEH
CALL DISPLAY
;display HELP
CALL DELAY
;delay to have flickering effect
MOV AH,1
;check for keystroke to stop display
INT 16h
JZ BAK
MOV AH,4CH
INT 21H
DISPLAY: MOV CX,04
;CL- no. of letters to be displayed
BAK2: MOV BL,08
;BL- no. of segment in each LED
MOV AL,[SI]
NEXT: ROL AL,01
MOV DX,0E801H
;each segment is outputted at a time from port B
OUT DX,AL
PUSH AX
MOV DX,0E802H
;port C to generate a serial clock pulse which is needed to
MOV AL,0FFH
; output every bit
OUT DX,AL
MOV AL,00
OUT DX,AL
DEC BL
POP AX
JNZ NEXT
INC SI
LOOP BAK2
RET
DELAY: MOV SI,2FFFH
page 5
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
REP2: MOV DI,0FFFFH
REP1: DEC DI
JNZ REP1
DEC SI
JNZ REP2
RET
END
page 6
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
5b.Assume any suitable message of 12 characters length and display it in the rolling fashion
on a 7-segment display. Interface for suitable period of time. Ensure a flashing rate that
makes it easy to read both messages.(Examiner does not specify these delay values nor it is
necessary for the student to compute these values).
.MODEL SMALL
.DATA
LIST DB 0C7H,0A3H,0A7H,88H,0A1H,0ABH,088H,0ABH,088H,099H,088H,0A1H
; list seven-segment code for L,o,C,A,D,n,A,n,i,r,S respectively
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,80H
MOV DX,0E403H
OUT DX,AL
RPT:MOV CX,12
;CX-no. of characters to be displayed
LEA SI,LIST
NC: MOV AL,[SI]
CALL DISP
;Display each character
CALL DELAY
;give a delay to display in rolling fashion
CALL STOP
;check for keyboard stroke to stop
INC SI
;else display next char
LOOP NC
JMP RPT
STOP:MOV AH,1
INT 16H
JNZ EXIT
RET
EXIT: MOV AH,4CH
INT 21H
DISP: MOV BL,08
NBIT: ROL AL,1
MOV DX,0E401H
OUT DX,AL
PUSH AX
MOV DX,0E402H
MOV AL,0FFH
OUT DX,AL
MOV AL,00H
OUT DX,AL
POP AX
DEC BL
JNZ NBIT
RET
DELAY: PUSH SI
page 7
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
MOV SI,04FFFH
RET2: MOV DI,0FFFFH
RET1: DEC DI
JNZ RET1
DEC SI
JNZ RET2
POP SI
RET
END
page 8
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
6b.Convert a 16-bit binary value (assume 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
.DATA
LIST DB 0FFH,0FFH,0FFH,0FFH,?,?,?,?,?,0FFH,0FFH,0FFH,0FFH
;to store BCD equivalent 7-segment code in place of ?,?,?,?,?
TABLE DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,98H
;7-segment code from 0 to 9
BCD DB 5 DUP (?)
;to store converted BCD no.
NUM DW 0FH
;binary no. to be converted
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,80H
MOV DX,0E403H
OUT DX,AL
LEA SI,BCD
MOV AX, NUM
;to convert 16-bit binary no. to BCD
MOV BX,10000
;divide the no. by multiples of 10 and
CALL CONV
;store each no. in BCD array to get BCD no.
MOV BX,1000
CALL CONV
MOV BX,100
CALL CONV
MOV BX,10
CALL CONV
MOV [SI],DL
LEA SI,BCD
LEA DI,LIST+8
LEA BX,TABLE
MOV CX,5
;CX= no. of BCD digits
NEXT: MOV AL,[SI]
;copy the equivalent 7-segment to the LIST
XLAT
;
MOV [DI],AL
DEC DI
INC SI
LOOP NEXT
JMP START
CONV: MOV DX,0
DIV BX
MOV [SI],AL
MOV AX,DX
INC SI
page 9
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
RET
START: MOV BH,10
LEA DI,LIST
BAK1: MOV SI,DI
PUSH BX
CALL DISP
CALL DELAY
CALL STOP
POP BX
INC DI
DEC BH
JNZ BAK1
MOV BH,9
LEA DI,LIST+8
BAK2:MOV SI,DI
PUSH BX
CALL DISP
CALL DELAY
CALL STOP
POP BX
DEC DI
DEC BH
JNZ BAK2
JMP START
STOP: MOV AH,1
INT 16H
JNZ EXIT
RET
EXIT: MOV AH,4CH
INT 21H
DISP: MOV CX,4
NC: MOV BL,08
MOV AL,[SI]
NB: ROL AL,1
MOV DX,0E401H
OUT DX,AL
PUSH AX
MOV DX,0E402H
MOV AL,0FFH
OUT DX,AL
MOV AL,00H
OUT DX,AL
POP AX
DEC BL
JNZ NB
page 10
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
INC SI
LOOP NC
RET
DELAY:MOV BX,02FFFH
RET2: MOV CX,0FFFFH
RET1: LOOP RET1
DEC BX
JNZ RET2
RET
END
page 11
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
7b.Drive a stepper motor interface to rotate the motor in clock wise direction by N steps.(N
is specified by the examiner).Introduce a delay between successive steps.(Any arbitrary
value for the may be assumed by the student).
.MODEL SMALL
.CODE
MOV CX,30
MOV DX,0E403H
MOV AL,80H
OUT DX,AL
MOV DX,0E400H
MOV AL,88H
REP1:OUT DX,AL
CALL DELAY
ROR AL,1
DEC CX
JNZ REP1
MOV AH,4CH
INT 21H
DELAY:MOV SI,2FFFH
BACK2:MOV DI,0FFFFH
BACK1:DEC DI
JNZ BACK1
DEC SI
JNZ BACK2
RET
END
page 12
;CX-no. of steps
;to energize the north pole and south pole of the motor
;10 00 10 00 A & C poles are energized i.e, 10
;B & D are not energized
; gives clockwise motion
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
8b.Drive a stepper motor interface to rotate the motor in Anti-clockwise direction by N
steps.(N is specified by the examiner). Introduce suitable delay between successive
steps.(Any arbitrary value for the delay may be assumed by the student).
.MODEL SMALL
.CODE
MOV CX,20
MOV DX,0E403H
MOV AL,80H
OUT DX,AL
MOV DX,0E400H
MOV AL,88H
REP1:OUT DX,AL
CALL DELAY
ROL AL,1
DEC CX
JNZ REP1
MOV AH,4CH
INT 21H
DELAY:MOV SI,2FFFH
BACK2:MOV DI,0FFFFH
BACK1:DEC DI
JNZ BACK1
DEC SI
JNZ BACK2
RET
END
page 13
; gives anti-clockwise motion
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
9b.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 a suitable delay between
successive steps.(Any arbitrary value for the delay may be assumed by the student).
.MODEL SMALL
.CODE
MOV CX,30
MOV DX,0E403H
MOV AL,80H
OUT DX,AL
MOV DX,0E400H
MOV AL,88H
REP1:OUT DX,AL
CALL DELAY
ROR AL,1
DEC CX
JNZ REP1
MOV CX,30
REP2:OUT DX,AL
CALL DELAY
ROL AL,1
DEC CX
JNZ REP2
MOV AH,4CH
INT 21H
DELAY: MOV SI,0FFFH
BACK2: MOV DI,0FFFFH
BACK1: DEC DI
JNZ BACK1
DEC SI
JNZ BACK2
RET
END
page 14
; gives clockwise motion
; gives anti-clockwise motion
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
10b.Scan 8x3 keypad for keypad closure and to store the code of the key pressed in a
memory location or display it on the screen. Also display row and column numbers of the
key pressed.
.MODEL SMALL
.DATA
KEYS DB '0123456789ABCDEFGHIJKLMN'
;array for 24 keys of keypad
KEY DB ?
MSG1 DB 10,13, 'THE ROW NO IS ='
ROW DB ?,13,10,'$'
MSG2 DB 'THE COL NO IS ='
COL DB ?,'$'
.CODE
MOV AX,@DATA
MOV DS,AX
MOV DX,0E403H
MOV AL,90H
OUT DX,AL
REP1:MOV DX,0E402H
;to activate pc0 ie, to check row1
MOV AL,01
OUT DX,AL
MOV DX,0E400H
;take input using port B
IN AL,DX
CMP AL,00
;if key pressed in row1
JNZ FR
;jump to first row
MOV DX,0E402H
;else activate pc1 ie, to check row2
MOV AL,02
OUT DX,AL
MOV DX,0E400H
;take input using port B
IN AL,DX
CMP AL,00
;if key pressed in row2
JNZ SR
;jump to second row
MOV DX,0E402H
; else activate pc2 ie, to check row3
MOV AL,04
OUT DX,AL
MOV DX,0E400H
;take input using port B
IN AL,DX
CMP AL,00
;if key pressed in row3
JNZ TR
;jump to third row
JMP REP1
;repeat the check till any key is pressed
FR:CALL DELAY
LEA SI,KEYS
MOV ROW,31H
;31=ascii value for 1 ie, first row
MOV CL,30H
;cl=column value
NEXT1: INC CL
page 15
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
SHR AL,1
JC DISP
INC SI
JMP NEXT1
SR: CALL DELAY
LEA SI,KEYS
ADD SI,08
MOV ROW,32H
MOV CL,30H
NEXT2: INC CL
SHR AL,1
JC DISP
INC SI
JMP NEXT2
TR: CALL DELAY
LEA SI,KEYS
ADD SI,10H
MOV ROW,33H
MOV CL,30H
NEXT3:INC CL
SHR AL,1
JC DISP
INC SI
JMP NEXT3
DISP: MOV DL,[SI]
MOV AH,02H
INT 21H
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV COL,CL
LEA DX,MSG2
INT 21H
JMP EXIT
DELAY: MOV SI,2FFFH
BAK2: MOV DI,0FFFFH
BAK1: DEC DI
JNZ BAK1
DEC SI
JNZ BAK2
RET
EXIT: MOV AH,4CH
INT 21H
END
page 16
www.bookspar.com | Website for students | VTU NOTES
;check for the pressed key which will be 1
;second row starts from 8th key
;32=ascii value for 2 ie, second row
;second row starts from 16th key
;33=ascii value for 3 ie, third row
;to display the key pressed
;to display the row no.
;to display the col no.
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
11b.Scan a 3x8 keypad for key closure and simulate ADD and SUBTRACT operations as
in a calculator .(Limitation: it is a single digit calculator).
.MODEL SMALL
.DATA
FK DB 4 DUP(?)
;array to store the expression
KEY DB ?
ERMSG DB 10,13,"ERRORS$"
EXPN DB 10,13,"ENTER EXPRESSION:$"
NANS DB 0
.CODE
MOV AX,@DATA
MOV DS,AX
MOV DX,0E403H
MOV AL,90H
OUT DX,AL
LEA DX,EXPN
MOV AH,9
INT 21H
MOV DI,4
;expression contains 4 char, eg. 5+6=
LEA SI,FK
BAK:CALL READ
;read the input
CALL DELAY
MOV AL,KEY
;store the read input in FK as expression
MOV [SI],AL
INC SI
DEC DI
JNZ BAK
CMP FK[1],0BH
;compare the second char with ‘+’
JZ ADDN
;if equal jump to addition
CMP FK[1],0CH
;compare the second char with ‘-‘
JZ SUBN
;if equal jump to subtraction
JMP ERR
;if operator is neither of them jump to error
MOV AH,4CH
INT 21H
ADDN:MOV AL,FK
;to add FK[0] and FK[2]
ADD AL,FK[2]
CMP FK[3],13H
;compare the third char with ‘=’
JNZ ERR
;if not equal jump to error
CALL DISP
;display the answer
MOV AH,4CH
INT 21H
ERR:LEA DX,ERMSG
;display error
MOV AH,9
INT 21H
page 17
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
MOV AH,4CH
INT 21H
SUBN:MOV AL,FK
SUB AL,FK[2]
JNC POSITIVE
NEG AL
MOV NANS,1
POSITIVE: CMP FK[3],13H
JNZ ERR
CALL DISP
MOV AH,4CH
INT 21H
READ: MOV AL,80H
MOV KEY,0
MOV BL,3
NEXTROW:ROL AL,1
MOV BH,AL
MOV DX,0E402H
OUT DX,AL
MOV CL,8
MOV DX,0E400H
IN AL,DX
NEXTCOL: ROR AL,1
JC KEYCODE
INC KEY
DEC CL
JNZ NEXTCOL
MOV AL,BH
DEC BL
JNZ NEXTROW
JMP READ
KEYCODE: MOV DL,KEY
CMP DL,0BH
JNZ NEXT
MOV DL,'+'
MOV AH,2
INT 21H
RET
NEXT:CMP DL,0CH
JNZ NEXT1
MOV DL,'-'
MOV AH,2
INT 21H
RET
NEXT1: CMP DL,13H
page 18
www.bookspar.com | Website for students | VTU NOTES
;to subtract FK[0] and FK[2]
;if the result is a positive no. jump to positive
;else find two’s complement
;nans=negative answer=1, ie, true
;compare the third char with ‘=’
;display the answer
;bl=count for 3 rows
;al=01, check for row1
;to find the key pressed
;to compare if the key pressed is ‘+’
;to compare if the key pressed is ‘-‘
;to compare if the key pressed is ‘=’
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
JNZ NEXT2
MOV DL,'='
MOV AH,2
INT 21H
RET
NEXT2: ADD DL,30H
MOV AH,2
INT 21H
RET
DISP: CMP NANS,1
JNZ SKIP
PUSH AX
MOV DL,'-'
MOV AH,2
INT 21H
POP AX
SKIP:AAM
ADD AX,3030H
MOV BX,AX
MOV AH,2
MOV DL,BH
INT 21H
MOV DL,BL
INT 21H
RET
DELAY:MOV BX,2FFFH
B2: MOV CX,0FFFFH
B1: LOOP B1
DEC BX
JNZ B2
RET
END
page 19
www.bookspar.com | Website for students | VTU NOTES
; else the key pressed is a digit
;if negative answer is false ie, 0 jump to skip
;else add ‘-‘ symbol before the no. and display
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
12b.Genarate a sine wave using the DAC interface(The output of the DAC is to be displayed
on a CRO).
.MODEL SMALL
.DATA
A DB 00,22,43,63,81,97,109,119,125,127 ; points to plot
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,80H
MOV DX,0E403H
OUT DX,AL
MOV SI,0FFFFH
;SI-no. of sine waveforms
MOV BX,0
;BX-count no. of points
MOV DX,0E401H
;portB as o/p port
B1:MOV AL,A[BX]
ADD AL,127
;0-255 levels possible. Median is 127
OUT DX,AL
INC BX
CMP BX,9
JB B1
B2:MOV AL,A[BX]
ADD AL,127
OUT DX,AL
DEC BX
CMP BX,0
JNZ B2
B3:MOV AL,A[BX]
MOV CL,127
SUB CL,AL
MOV AL,CL
OUT DX,AL
INC BX
CMP BX,9
JB B3
B4: MOV AL,A[BX]
MOV CL,127
SUB CL,AL
MOV AL,CL
OUT DX,AL
DEC BX
CMP BX,0
JNZ B4
DEC SI
JNZ B1
page 20
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
MOV AH,4CH
INT 21H
END
page 21
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
13b.Generate a Half Rectified Sine wave form using the DAC interface.(The output of the
DAC is to display on a CRO).
.MODEL SMALL
.DATA
A DB 00,22,43,63,81,97,109,119,125,127
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,80H
MOV DX,0E403H
OUT DX,AL
MOV CX,0FFFFH
MOV BX,0
MOV DX,0E400H
;portA as o/p port
B1: MOV AL,A[BX]
ADD AL,127
OUT DX,AL
INC BX
CMP BX,9
JB B1
B2: MOV AL,A[BX]
ADD AL,127
OUT DX,AL
DEC BX
CMP BX,0
JNZ B2
MOV SI,14
RPT: MOV AL,127
;loop for half rectified wave
OUT DX,AL
DEC SI
JNZ RPT
LOOP B1
EXIT: MOV AH,4CH
INT 21H
END
page 22
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
14b. Generate a Fully Rectified Sine wave from using the DAC interface (The ouput of the
DAC is to be displayed on a CRO).
.MODEL SMALL
.DATA
A DB 00,22,43,64,82,97,110,119,125,127
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,80H
MOV DX,0E403H
OUT DX,AL
MOV CX,0FFFFH
;CX-no. of waveforms
MOV BX,0
MOV DX,0E401H
B1:MOV AL,A[BX]
ADD AL,128
OUT DX,AL
INC BX
CMP BX,9
JB B1
B2:MOV AL,A[BX]
ADD AL,128
OUT DX,AL
DEC BX
CMP BX,0
JNZ B2
LOOP B1
MOV AH,4CH
INT 21H
END
page 23
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
www.bookspar.com | Website for students | VTU NOTES
15b.Drive 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
.CODE
MOV DX,0E403H
MOV AL,82H
OUT DX,AL
BAC: MOV AH,01
INT 16H
JNE EXIT
MOV AL,0
MOV DX,0E400H
OUT DX,AL
MOV AL,0F0H
OUT DX,AL
LOOP1:CALL RQCHE
JZ LOOP1
SHR AL,1
JNC GND
SHR AL,1
JNC FF
SHR AL,1
JNC SF
JMP TF
RQCHE:MOV DX,0E401H
IN AL,DX
OR AL,0F0H
CMP AL,0FFH
RET
GND:CALL DELAY
CALL DELAY
MOV AL,0F0H
JMP BAC
FF:MOV AL,0F0H
MOV CL,03
CALL MUP
CALL DELAY
CALL DELAY
MOV CL,03
CALL DOWN
JMP BAC
page 24
;port B as i/p port
;if a key is pressed from the keyboard then exit
;check if there is a request
;if no request wait
;check for gnd floor
;if equal go to gnd
;check for 1st floor
;if equal go to FF
;check for 2nd floor
;if equal go to 2nd floor
;else go to 3rd floor
;take the i/p from the interface
;compare if no key is pressed
;stay in ground floor for few secs
;clear the i/p data and jump for next request
;clear the i/p data
;cl=count for no. of LED’s,for first floor LED’s=3
;to move upwards
;to move downwards
;go to bac for next request
www.bookspar.com | Website for students | VTU NOTES
Microprocessor Lab Manual
SF:MOV AL,0F0H
MOV CL,06
CALL MUP
CALL DELAY
CALL DELAY
MOV CL,06
CALL GODW
JMP BAC
TF:MOV AL,0F0H
MOV CL,09H
CALL MUP
CALL DELAY
CALL DELAY
MOV CL,09H
CALL GODW
JMP BAC
EXIT:MOV AH,4CH
INT 21H
MUP:MOV DX,0E400H
UP:INC AL
CALL DELAY
OUT DX,AL
LOOP UP
RET
GODW:MOV DX,0E400H
DOWN:DEC AL
CALL DELAY
OUT DX,AL
LOOP DOWN
RET
DELAY:MOV SI,2FFFH
RPT2:MOV DI,0FFFFH
RPT1:DEC DI
JNZ RPT1
DEC SI
JNZ RPT2
RET
END
page 25
www.bookspar.com | Website for students | VTU NOTES
;cl=count for no. of LED’s, for second floor LED’s=6
;cl=count for no. of LED’s, for third floor LED’=9
;send the o/p to port A
;increment the value of AL to move up
;loop till CL=0
;send the o/p to port A
;decrement the value of AL to come down
;loop till CL=0
www.bookspar.com | Website for students | VTU NOTES
Download