Professional Documents
Culture Documents
VIK 85 Krishna - College Lab Manual
VIK 85 Krishna - College Lab Manual
VIK 85 Krishna - College Lab Manual
Lab Manual
SKEC
Page 1
List of Experiments:
Ex.No
Title of Experiment
8085 Programming:
String Manipulation
Interfacing:
10
SKEC
Page 2
Ex. No: 01
AIM
ADDITION:
1.
2.
3.
4.
5.
6.
7.
SUBTRACTION:
1.
2.
3.
4.
5.
6.
7.
MULTIPLICATION:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
SKEC
Page 3
11.
12.
13.
Store accumulator
Store carry register
Stop the program.
DIVISION:
1.
2.
3.
4.
5.
6.
7.
8.
SKEC
Page 4
FLOWCHART:
ADDITION:
START
INITIALIZE THE
DATA
IF
CARRY
NO
INCREMENT THE
CARRY
YES
STORE THE
RESULT
STOP
SKEC
Page 5
SUBTRACTION
START
INITIALIZE THE
DATA
SUBRACT THE
DATA
IF
BORROW=0
INCREMENT THE
BORROW
STOP
SKEC
Page 6
MULTIPLICATION
START
IF
CARRY
INCREMENT THE
CARRY
DECREMENT THE CARRY
SKEC
Page 7
INCREMENT
ON NON-
STOP
SKEC
Page 8
DIVISION
START
YES
IF
DIVIDEND>DIVIS
OR
NO
STOP
SKEC
Page 9
PROGRAM:
ADDITION
ADDRESS
9100
LABEL
MNEMONICS
LDA 9200
HEXCODE
3A,00,92
9103
MOV B,A
47
9104
LDA 9201
3A,01,92
9107
ADD B
80
9108
910A
910D
910E
9111
9112
9115
MVI C,00
JNC 910E
INR C
STA 9600
MOV A,C
STA 9601
RST 1
0E,00
02,910E
0C
32,00,96
79
32,01,96
CF
MNEMONICS
LDA 8200
MOV B,A
HEXCODE
3A,00,32
47
8104
8107
8109
LDA 8201
MVI C,00
SUB B
3A,01,82
0E,00
90
810A
810D
810E
JNC 8110
CM A
INR A
02,10,81
2F
3C
810F
INR C
6C
8110
8113
STA 8600
MOV A,C
32,00,86
79
8114
8117
STA 8601
RST 1
34,01,86
CF
COMMENTS
loads the content of memory
location to the accumulator
moves the accumulator content
to b register
loads the content of memory
location to accumulator
add the B register content with
accumulator
initialize carry as 00
checks the carry flag
increments carry flag
stores the result
Moves the carry in accumulator
Stores the carry in 9601
Halt the program
SUBTRACTION
ADDRESS
8100
8103
LABEL
SKEC
COMMENTS
Load the I value in accumulator
Move the content to the B
register
Load accumulator to the II data
Initialize carry as 00
Content B reg from
accumulator
Checks the carry flag
Complement of a
Increment the content of A
register
Increment the content of c
register
Store the diff value
Move content of reg A to
accumulator
Store the borrow
Terminate the program
Page 10
MULTIPLICATION
ADDRESS
9100
9103
LABEL
MNEMONICS
LDA 9200
MOV D,A
HEXCODE
3A,00,92
57
9104
9107
LDA 9201
MOV B,A
3A,01,92
47
9108
910A
910B
910C
910F
9110
9111
9114
9117
MVI C,00
XRA A
ADD D
JNC 9110
INR C
DCR B
JNZ 910B
STA 9600
MOV A,C
0E,00
AF
82
D2,02,01
OC
05
C2,DB,91
32,00,96
79
9118
911B
STA 9601
RST 1
32,01,96
CF
MNEMONICS
MVI C,00
LDA 9500
MOV B,A
HEXCODE
0E,00
3A,00,95
47
9106
9109
910A
910D
910E
LDA 9501
CMP B
JC 9112
SUB B
INR C
3A,01,95
B8
DA,12,91
90
0C
910F
9112
9115
9116
9119
JMP 9109
STA 9600
MOV A,C
STA 9601
RST 1
32,00,96
79
32,01,96
CF
COMMENTS
Load the multiplier
Move the content of
accumulator to D reg
Load the multiplier
Move the content of
accumulator to B reg
Move carry as 0
Clear all
Add the content of D register
If no carry jump to next
Increment the c register
Decrement the B register
Store result in 9600
Store the carry in 9601
Move the content of C to B
register
Store the result
Stop the program
DIVISION
ADDRESS
9100
9102
9105
LABEL
SKEC
COMMENTS
Initialize the c register to 00
Load the data divisor
Move the content of
accumulator to B reg
Get the dividend
Compare B & C
Jump on carry
Subtract B from A
Increment the content of C
register
Store the values of A
Move the content C to A
Store the result
Terminate the program
Page 11
Output:
Addition
MEMORY ADDRESS
(Input)
9201
9200
DATA-I
DATA-II
DATA-III
F2
F3
E1
E2
D3
D6
(Output)
9600 (sum)
9601(carry)
E5
01
C3
01
A9
01
Subtraction
MEMORY ADDRESS
(Input)
8200
8201
DATA-I
DATA-II
DATA-III
07
03
04
06
0B
0A
(Output)
9600
9601
04
01
02
00
01
01
MULTIPLICATION
MEMORY ADDRESS
(Input)
9200
9201
DATA-I
DATA-II
DATA-III
06
02
07
04
0F
0A
(Output)
9600
9601
0C
00
1C
00
96
00
DIVISION
MEMORY ADDRESS
(Input)
9500
9501
DATA-I
04
08
04
04
05
0A
(Output)
9600
9601
00
02
00
01
00
02
DATA-II
SKEC
DATA-III
Page 12
RESULT:
Thus the Basic arithmetic operations have been performed successfully on
8085 microprocessor by Assembly Language Programming (ALP).
SKEC
Page 13
Ex. No: 02
Searching:
AIM
To search a number (largest, smallest) in the array using 8085
APPARATUS REQUIRED:
8085 Microprocessor Kit.
ALGORITHM
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
SKEC
Page 14
FLOWCHART:
LARGEST NUMBER IN AN ARRAY
START
NO
IF
ACC<B
YES
MOVE THE CONTENT OF B REG TO ACC
NO
IF
I=0
YES
STORE THE RESULT
STOP
SKEC
Page 15
NO
IF
CARRY
NO
YES
DECREMENT C
MOVE B TO A
IF
I=0
YES
STOP
SKEC
Page 16
PROGRAM:
ADDRESS
9100
9103
LABEL
MNEMONICS
LXI H,9500
HEXCODE
21,00,95
MVI C,05
0E,05
9105
MOV A,M
7E
9106
INX H
23
COMMENTS
Load the data into memory
MOV B,M
46
Compare B
9108
CMP B
B8
9109
JNC 910D
(JC 910D)
D2,OD,91
(C2,0D,91)
910C
MOV A,B
78
DCR C
00
Decrement C
910E
JNZ 9106
C2,06,91
Jump on 9106
9111
STA 9600
32,00,96
Store the result
9114
RST 1
CR
Stop the program
SKEC
Page 17
OUTPUT:
LARGEST NUMBER IN THE ARRAY
MEMORY ADDRESS
(Input)
9500
9501
9502
9503
9504
9505
DATA-I
DATA-II
DATA-III
09
08
07
06
05
04
01
03
04
02
06
05
09
08
07
03
01
0A
(Output)
9600
09
06
0A
DATA-I
09
08
07
06
05
04
0A
0B
0C
0D
0E
0F
AA
BB
CC
DD
EE
FF
(Output)
9600
04
0A
AA
DATA-II
SKEC
DATA-III
Page 18
SORTING :
AIM:
To perform Sorting of an array using 8085.
APPARATUS REQUIRED:
8085 Microprocessor Kit.
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
SKEC
Page 19
FLOWCHART:
START
SET H AS MEMORY POINTER
COMPARE BYTES
YES
IF
A<2ND
NO
GET THE 2ND BYTE FOR EXCHANGE
YES
IF
COMP
COUNT
STOP
=0
A
CS 2259 Microprocessors Lab
SKEC
Page 20
PROGRAM:
ADDRESS
9100
LABEL
MNEMONICS
LXI H,9200
HEXCODE
21,00,92
COMMENTS
Set memory pointer
9103
MVI D,00
16,00
9105
MVI C,04
DE,04
9107
MOV A,M
4E
9108
INX H
23
9109
CMP M
BE
Compare byte
910A
JC 9114
(JNC 9114)
DA,14,91
910D
MOV B,M
46
910E
MOV M,A
77
910F
DCX H
28
9110
MOV M,B
70
9111
INX H
23
9112
MVI D,01
1601
9114
DCR C
0D
9115
JNZ 9107
C2,07,91
Decrement comparison
count if comparison 10,80
Get flag hit in A
SKEC
Page 21
9118
MOV A,D
7A
9119
RRC
0F
If carry, exchange occurs
DA,00,91
JC 9100
911A
End of string
CF
RST 1
911D
Output:
ASCENDING ORDER
MEMORY ADDRESS
(Input)
9200
9201
9202
9203
9204
DATA-I
DATA-II
09
02
04
06
05
0D
0A
0C
0B
0F
(Output)
9200
9201
9202
9203
9204
02
04
05
06
09
0A
0B
0C
0D
0F
DECENDING ORDER
MEMORY ADDRESS
(Output)
9200
9201
9202
9203
9204
DATA-I
DATA-II
0F
0D
0C
0B
0A
09
06
05
04
02
SKEC
Page 22
RESULT:
Thus the SEARCHING & SORTING of an array has been performed using 8085
Microprocessor.
SKEC
Page 23
Ex.No: 03
CODE CONVERSION
AIM:
To perform code conversions like HEX to ASCII , Binary to BCD and Vice versa.
APPARATUS REQUIRED:
8085 Microprocessor Kit.
a.)HEXADECIMAL TO ASCII
ALGORITHM:
1. Set the SI pointer for binary array
2. Set the DI pointer for ASCII
3. Mark the lower bit data with F0
4. Move me count to CL reg.
5. Rotate the lower nibble to upper nibble
6. Call the subroutine to compare with DA
7. If less than 10, then jump to next
8. Add with DA, with AL reg
9. If greater than 10, then add to 10H else return to 6
10. Store the data in D reg
11. Stop the program.
SKEC
Page 24
FLOWCHART:
START
INCREMENT DI REGISTER
STOP
SKEC
Page 25
SUB ROUTINE
START
COMPARE AL WITH 0A
YES
IF
AL>0A
NO
ADD 07
ADD 30
RETURN
SKEC
Page 26
PROGRAM:
ADDRESS
9100
LABEL
MNEMONICS
LXIH, 9000
HEXCODE
01,00,90
COMMENTS
Load address
9103
LXI D, 9200
11,00,92
Load data
9106
MOV A,M
7E
9107
ANI, 0F
E6,0F
Add of
9109
CALL ASCII
CD
910C
MOV C,A
4F
Move A to C reg
910D
MOV A,B
78
Move B reg to A
910E
ANI F0
E6,F0
AND F0
9100
RLC
07
9111
RLC
07
9112
RLC
07
9113
RLC
07
9114
CALL ASCII
CD
9117
STA 9201
32,01,92
911A
MOV A,C
79
Move C to A
SKEC
Page 27
911B
STA 9202
32,02,192
911E
RST 1
CF
Break point
CPI 09
FE,09
Compare with 09
911F
ASCII
Jump no carry
9121
JNC Next
9124
ADI 07
C6,07
ADI 30
C6,30
RET
C9
9126
Next
9128
Add immediately
Output:
MEMORY ADDRESS
(Input)
9200
DATA-I
DATA-II
05
AC
(Output)
9201
9202
30
35
41
43
SKEC
Page 28
SKEC
Page 29
FLOWCHART:
START
MOVE
MOVE
STOP
CS 2259 Microprocessors Lab
SKEC
Page 30
PROGRAM:
ADDRESS
1000
LABEL
MNEMONICS
MOV AL,[1200]
HEXCODE
A0,00,12
COMMENTS
Move the id to 1 reg
1003
MOV AH,AL
88,C4
1005
AND AH,0F
80,EA,DF
1008
MOV BL,AH
888,E3
100A
AND AL,F0
24,F0
100C
MOV CL,04
B1,DH
Move the CL by 04
ROL AL,CL
D2,CD
1010
MOV AH,0A
34,DA
Multiply
1012
MUL AH
F6,E7
Add the data
1014
ADD AL,BL
C0,D8
1016
MOV [1600],AL
A2,00,16
1019
INT 3
CC
SKEC
Page 31
Output:
MEMORY ADDRESS
(Input)
1200
DATA-I
DATA-II
0A
1D
(Output)
1600
0A
17
RESULT:
Thus the code conversion has been performed .
SKEC
Page 32
SKEC
Page 33
FLOWCHART:
START
CL = CL -- 1
IF
NO
CL=0
YES
STORE RESULT
STOP
SKEC
Page 34
PROGRAM:
ADDRESS
1500
LABEL
MNEMONICS
MOV CL,09
HEXCODE
BL,09
COMMENTS
Count for 33 matrix
1502
MOV SI,2000
BE,00,20
Address in SI
1505
MOV DI,300
BF,00,30
Address in DI
1508
MOV AL,[SI]
BA,04
150A
MOV BL,[DI]
8A,10
150C
ADD AL,BL
00,08
150E
MOV [DI],AL
88,05
Store result
1510
INC DI
4F
Increment DI
1511
INC SI
46
Increment SI
1512
DEC CL
FE,C9
Decrement CL
1514
JNZ 1508
75,F2
1516
INT 3
CC
Break point
Output:
CS 2259 Microprocessors Lab
SKEC
Page 35
INPUT
2000-02
2001-02
2002-02
2003-02
2004-02
2005-02
2006-02
2007-02
2008-02
OUTPUT
3000-04
3001-04
3002-04
3003-04
3004-04
3005-04
3006-04
3007-04
3008-04
3000-02
3001-02
3002-02
3003-02
3004-02
3005-02
3006-02
3007-02
3008-02
RESULT:
Thus the output for the addition for two matrix was executed successfully.
SKEC
Page 36
Initialize the counter to the memory for staring the data and result.
Load DI with search byte
Load CL with count
Load AC with data from memory
Compare AC with DL if its equal
Store result else go to 2
Store the result
Stop the program.
SKEC
Page 37
FLOWCHART:
START
IF
CL=CL -- 1
AL=D
STOP
SKEC
Page 38
PROGRAM:
ADDRESS
1000
MNEMONICS
MOV SI,1100
HEXCODE
BE,00,11
COMMENTS
Set SI reg for array
1003
MOV DI,1200
BE,00,12
1006
MOV DI,[DL]
8A,15
1008
MOV BL,01
B3,DL
100A
MOV AL,[SI]
8A,04
CMP AL,DL
35,00
Compare an element of
array
100E
JZ AVAIL
74,15
1010
INC SI
46
Increment SI
1011
INC BL
FE,03
Increment BL count
1013
MOV AL,[SI]
8A,04
1015
CMP AL,20
3C,20
1017
JNZ AGAIN
72,F3
If not JZ to again
MOV CX,0000
B9,00,00
Initialize CX to zero
101C
MOV [DI+1],CX
89,4D,01
101F
MOV [DI+3],CX
89,4D,03
100C
1019
LABEL
START
AGAIN
NOT
AVAIL
SKEC
Page 39
JMP 102F
EB,0F,110
MOV BH,FF
B7,FF
1026
MOV [DI+1],BH
88,7D,01
Store FF to result
1029
MOV [DI+2],BL
88,5D,02
Availability of data
102C
MOV [DI+3],SI
89,75,03
1022
1024
AVAIL
INT 3
102F
Output:
MEMORY ADDRESS
(Input)
1100
1101
1102
1103
1104
1105
(Output)
1200
1201
1202
1203
1204
DATA-I
DATA-II
05
05
03
04
07
08
05
04
09
02
03
01
05
FF
01
00
11
02
FF
04
03
11
RESULT:
Thus the output for searching an element in array using 8086 microprocessor was
executed successfully.
SKEC
Page 40
Ex. No: 4
a) ADDITION
ALGORITHM:
Label
STORE:
Mnemonics
Machine Code
Comments
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
DATA 1
DATA 2
DATA 2
34
12
78
56
AC
68
00
SKEC
Page 41
b) SUBTRACTION
ALGORITHM:
Label
STORE:
Mnemonics
Machine Code
Comments
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
DATA 1
DATA 2
DATA 2
88
44
33
22
55
22
00
SKEC
Page 42
C) MULTIPLICATION
ALGORITHM:
I.
II.
III.
IV.
V.
VI.
Program:
Address
Label
Mnemonics
MOV
MOV
MUL
MOV
MOV
INT 3
Machine Code
Comments
AX, [2000H]
BX, [2002H]
BX
[3000], AX
[3002], DX
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
3003H
DATA 1
DATA 2
DATA 2
0A
00
0A
00
64
00
00
00
SKEC
Page 43
D)DIVISION
I.
II.
III.
IV.
V.
VI.
Program:
Address
Label
Mnemonics
MOV
MOV
DIV
MOV
MOV
INT 3
Machine Code
Comments
AX, [2000H]
BX, [2002H]
BX
[3000], AX
[3002], DX
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
3003H
DATA 1
DATA 2
DATA 2
68
00
0A
00
0A
00
04
00
SKEC
Page 44
Load starting address of array in to SI reg. and initialize DI reg for result.
Load the byte to be searched in DL reg. & initialize BH reg for position as 01
Get the 1st element into Accumulator
AGAIN : Compare Accumulator with DL reg
Check zero flag, if set goto AVAIL
Update SI and Increment BL
Get next element into Accumulator and compare with EOA
If not zero, goto AGAIN.
Initialize CX reg to zero
Store result for Not Available and goto END
AVAIL: Get word for available in to BL reg.
Store position, address and status of serach.
END: Halt
Program:
Address
Label
Mnemonics
Machine Code
Comments
CMP AL, DL
JZ AVAIL
INC SI
SKEC
Page 45
INC BL
MOV AL, [SI]
CMP AL, E0
JNZ AGAIN
NOTAVL MOV CX, 0000H
MOV [DI+1], CX
MOV [DI+3], CX
JMP END
AVAIL:
MOV BL, FF
MOV [DI+1], BX
MOV [DI+3], SI
END:
INT 3
OUTPUT VERIFIACTION:
INPUT
DATA 1
3000H(BYTE)
05
2000H
AA
2001H
BB
2002H
CC
2003H
55
2004H
77
DATA 2
SKEC
DATA 2
Page 46
2018H
05
2032H
EO
OUTPUT
3000H
05
3001H
FF
3002H
19
3003H
18
3004H
20
SKEC
Page 47
Ascending/Descending order
Algorithm:
i.
Load SI reg with pointer to array
ii.
Load array length to CL & CH for two counters (CL for repetitions & CH for
comparisons)
iii.
REPEAT : Get an element into accumulator
iv.
NEXT: Compare with next element
v.
Check carry flag, if set goto SKIP
vi.
Swap elements of array
vii.
SKIP: Decrement CH and if not zero go to NEXT
viii. Decrement CL , if not zero go to REPEAT
ix.
Halt
Program:
Address
Label
Mnemonics
Machine Code
Comments
NEXT:
SKIP:
DEC CH
SKEC
Page 48
JNZ NEXT
DEC CL
JNZ REPEAT
INT 3
OUTPUT VERIFIACTION:
INPUT
DATA 1
1500(COUNT)
07
1501
AA
1502
BB
1503
CC
1504
55
1505
77
1506
11
1507
99
DATA 2
DATA 2
OUTPUT
1501
11
1502
55
1503
77
SKEC
Page 49
1504
99
1505
AA
1506
BB
1507
CC
SKEC
Page 50
Ex.No: 05
STRING MANIPULATION
AIM:
To perform string manipulation in 8086 microprocessor.
APPARATUS REQUIRED:
8086 Microprocessor Kit.
a) Block Transfer
Algorithm:
i.
ii.
iii.
iv.
v.
vi.
Program:
Address
Label
Mnemonics
Machine Code
Comments
OUTPUT VERIFIACTION:
INPUT
2000H (Block
Size)
2001H
2002H
2003H
2004H
2005H
DATA 1
DATA 2
DATA 2
05
12
34
56
78
9A
SKEC
Page 51
OUTPUT
3000H
3001H
3002H
3003H
3004H
12
34
56
78
9A
b) Table search
Algorithm:
i. Initialize BX reg with table size
ii. Get address of table and symbol in DI & SI reg.
iii. Clear direction flag.
iv. Load counter with 08(length)
v. Compare bytes if successful goto FOUND
vi. Point to the next symbol
vii. Decrement BX, if not zero repeat the steps
viii. Show not found
ix. FOUND: Show found status.
x. Halt
Program:
Address
Label
LOOP1
NOTFOUND:
FOUND:
END:
Mnemonics
Machine Code
Comments
SKEC
Page 52
OUTPUT VERIFIACTION:
INPUT
3000H
3001H
3002H
3003
00
30
00
00
2000H
2001H
2002H
2003H
00
12
00
00
Note: The table has to be loaded from memory location 3000H & the search string in
1200H.
Table size can be any 16 bit number
c) Code Conversion
Algorithm
i. Initialize BX reg with address of translation table
ii. Load source and destination address in SI & DI reg.
iii. Clear direction flag
iv. Load counter with length
v. Get first element into AL , check whether the input is valid
vi. If invalid go to end
vii. Else translate code from table
viii. Store code
ix. Loop until counter becomes zero
x. Halt
SKEC
Page 53
Program:
Address
Label
Mnemonics
Machine Code
Comments
DATA 1
DATA 2
DATA 2
03
05
4F
6D
7
segment
code
3F
06
5B
4F
66
6D
7D
07
7F
6F
SKEC
Page 54
Label
Mnemonics
Machine Code
Comments
LOOP1:
DONE:
OUTPUT VERIFIACTION:
INPUT
2000H
(COUNT)
2001H
2002H
DATA 1
DATA 2
DATA 2
05
CC
AA
3000H
3001H
3002H
3003H
3004H
OUTPUT
11
CC
22
CC
33
3000H
3001H
11
AA
SKEC
Page 55
3002H
3003H
3004H
22
AA
33
RESULT:
Thus the string manipulation has been performed successfully.
SKEC
Page 56
Ex.No: 06
8279:
Keyboard Interfacing:
Algorithm:
i.
ii.
iii.
iv.
v.
Else read Data code from input port and suppress unwanted bits(b7&b6)
vi.
Break point
Address
Label
Mnemonics
MOV
Machine Code
Comments
AL,12h
MOV
DX,FF52h
OUT
DX,AL
MOV
AL,3Eh
OUT
DX,AL
display/write inhibit
Wait:
MOV
AL,A0h
OUT
DX,AL
read status of 8279
IN
AND
AL,DX
FIFO empty?
AL,07h
If Yes loop back to wait
JZ
Wait
Data register
MOV
Read Code from data port
DX,FF50h
SKEC
Page 57
IN
AL,DX
Break point
AND
INT
AL,3Fh
3
Row/Column
24
23
22
21
1c
1b
1a
19
14
13
12
10
0c
0b
0a
09
Display interfacing:
Algorithm:
i.
ii.
iii.
Load display write inhibit word and count for clearing display
iv.
v.
Get the input code from table and send to display through output port
vi.
Break point
SKEC
Page 58
Program:
Address
Label
Clear:
Mnemonics
MOV
AL,12h
Comments
Control word to define 8279 in
8 bit 8 character display
MOV
DX,FF52h
OUT
DX,AL
MOV
AL,3Eh
OUT
DX,AL
MOV
AL,A0h
OUT
DX,AL
display/write inhibit
send to control reg
MOV
AH,08h
MOV
DX,0FF50h
MOV
AL,00h
data =0
OUT
DX,AL
DEC
AH
JNZ
Clear
MOV
MOV
Back:
Machine Code
Clear up to AH= 00
Data reg
CL,06
BX,2000h
MOV
AL,[BX]
OUT
DX, AL
INC
BX
DEC
CL
DX,FF50h
MOV
JNZ
Back
Loop back
SKEC
Page 59
DIGIT
7
SEGMENT FC 60 BA F2
CODE
66 D6 DE 70 FE
Algorithm:
ii. Select the counter reg by sending appropriate data to control reg.
iii. Get lower order count in to AL and send to selected counter reg
iv. Get higher order count in to AL and send to selected counter reg.
v. Wait and terminate.
Program:
Address
Label
Mnemonics
Machine Code
Comments
Division Factor
MOV
AX,0050H
MOV
CX,AX
MOV
AL,36H
MOV
DX, FF56H
OUT
DX,AL
MOV
AL,CL
Count Lsb
MOV
DX, FF50H
Counter 0 Reg
OUT
DX,AL
MOV
AL,CH
Counter0 Is Selected
Control Reg
Count Msb
SKEC
76 7E CE 9C EA 9E 1E
8253:
i.
Page 60
OUT
DX,AL
NOP
INT
3H
Result:
Thus the Keyboard/Display controller and Interval Timer has been interfaced and the
program for key scan and square wave executed successfully.
SKEC
Page 61
Ex.No: 07
AIM:
To perform parallel/serial communication using 8085 and 8086 by interfacing 8255 and
8251.
APPARATUS REQUIRED:
i)
ii)
i)
ii)
iii)
ALGORITHM:
PARALLEL DATA COMMUNICATION USING 8085/8086
Transmitter:
1.
2.
3.
4.
Get the control word of 8255 so as to have one of its as an output port.
Sent it to control reg of 8255
Get the byte to the transmitted acc
Send it to output port
Receiver:
1.
2.
3.
Get the control word of 8255 so as to have one of its port as an input port
Read it as control reg of 8255
Read the data at the input port, if there isn`t carry, check again after delay.
SKEC
Page 62
PROGRAM:
ADDRESS
LABEL
MNEMONICS
HEXCODE
COMMENTS
Transmitter:
8500
MVI A,82
3E,82
Move 82 to A reg
8502
OUT 23
D3,23
8504
MVI A,55
3E,55
Move 55 to A reg
SKEC
Page 63
8506
OUT 20
D3,20
8508
RST 1
CF
Break point
8500
MVI A,99
35,99
Move 99 to A reg
8502
OUT 23
D3,23
8504
IN 20
DB,20
8506
NOP
00
No operation
8507
NOP
00
No operation
8508
NOP
00
No operation
8509
NOP
00
No operation
850A
RST 1
CF
Break point
Receiver:
SKEC
Page 64
LABEL
MNEMONICS
HEXCODE
COMMENTS
Transmitter:
9000
MOV DX,FF26
BA,26,FF
9003
MOV AL,82
BO,82
Move 82 to AC reg
9005
OUT DX,AL
EE
SKEC
Page 65
9006
MOV DX,FF24
BA,24,FF
9009
MOV AL,00
B0,00
Move 00 to A reg
900B
OUT DX,AL
EE
900C
MOV DX,FF20
BA,20FF
900F
MOV AL,55
BO,55
Move 55 to A reg
9011
OUT DX,AL
EE
9012
MOV DX,FF24
BA,24,FF
9015
MOV AL,FF
BO,FF
Move FF to A reg
9017
OUT DX,AL
EE
9018
INT 3
CC
Break point
8300
MOV DX,FF26
BA,26,FF
8303
MOV AL,99
BO,99
Move 99 to A reg
8305
OUT DX,AL
EE
Receiver:
SKEC
Page 66
8306
MOV DX,FF24
3A,24,FF
8309
IN AL,DX
EC
830A
JZ 8309
74,FD
Jump on 8309
830C
MOV DX,FF20
BA,20,FF
830F
IN AL,DX
EC
8310
INT 3
CC
Break point
LABEL
MNEMONICS
HEXCODE
COMMENTS
9000
LDA 9200
3A,00,92
9003
MOV A,B
47
9004
LDA 9201
3A,01,92
9007
ADD B
80
Add with A
SKEC
Page 67
9008
MVI C,00
0E,00
Initialize carry as 0
900A
JNC 910E
02,0E,90
900D
INR C
0C
Increment C
900E
STA 9600
32,00,96
9011
MOV A,C
79
9012
STA 9601
32,01,96
9013
RST 1
CF
MOV AX,1100
A1,00,11
1003
ADD AX,1102
D3,06,02,11
1007
MOV 1104,AX
A3,04,11
SKEC
Page 68
100A
INT 3
CC
TRANSMITTER
55
RECEIVER
55
SKEC
Page 69
Output 8086:
TRANSMITTER
RECEIVER
09FF
CF55
(G9000)
(G8300)
INPUT
OUTPUT
02
9200
(9600)
04
02
9201
Output 8086:
MEMORY
ADDRESS
OUTPUT
2000-01
3000-01
02
2001-02
3001-02
04
2002-03
3002-03
06
2003-04
3003-04
08
SKEC
Page 70
2004-05
3004-05
0A
RESULT:
Thus the execution of data communication of parallel/serial is executed successfully by means of
8255 and 8251.
Ex.No:08
AIM:
To write a program to interface a stepper motor using 8085/8086/8051 microprocessor.
APPARATUS REQUIRED:
SKEC
Page 71
i)
ii)
iii)
iv)
ALGORITHM:
1.
2.
3.
4.
5.
6.
LABEL
MNEMONICS
MVI A,80
HEXCODE
3E,80
SKEC
COMMENTS
Control port of 8255
Page 72
OUT 23
D3,23
Control word
MVI A,80
3E,A0
9006
OUT 20
D3,20
Out it in port A
9008
CALL DELAY
CD 0091
900B
MVI A,E0
3E,E0
900D
OUT 20
D3,20
Out it in port A
900F
CALL DELAY
CD 0091
9012
MVI A,C0
3E,10
9014
OUT 20
D3,20
Out it in port A
9002
9004
BACK
SKEC
Page 73
9016
CALL DELAY
CD 0091
9019
MVI A,80
3E,C0
901B
OUT 20
03,20
Out it in port A
901D
CALL DELAY
CD,00,91
9020
JMP BACK
C3,04
Jump back
MVI B,10
06,10
9102
MVI A,FF
3E,FF
9104
NOP
00
No operation
9105
NOP
00
No operation
9100
DELAY
SKEC
Page 74
9106
NOP
00
No operation
9107
NOP
00
No operation
9108
DCR A
3D
Decrement A
9109
JNZ 9104
C2,0491
910C
DCR B
05
Decrement B
910D
JNZ 9102
C2,02,91
9110
RET
C9
LABEL
MNEMONICS
HEXCODE
SKEC
COMMENTS
Page 75
9000
MOV DX,FF26
BA,26FF
9003
MOV AL,80
B0,80
Control word
9005
OUT DX,AL
EE
9006
MOV DX,FF20
BA,20FF
9009
MOV AL,A0
BO,AD
900B
OUT DX,AL
EE
900C
CALL DELAY
E8,F100
900F
MOV AL,E0
BO,E0
9011
OUT DX,AL
EE
9012
CALL DELAY
E8,EB,00
SKEC
Out it in port A
Call delay
Out it in port A
Call delay
Page 76
9015
MOV AL,C0
B0,E0
9017
OUT DX,AL
EE
Out in port A
9018
CALL DELAY
E8,EB00
901B
MOV AL,80
BO,80
901D
OUT DX,AL
EE
901E
CALL DELAY
E8,EB,00
9021
JMP 9006
EB,E3
MOV BX,0002
BB,9000
Change count
9026
MOV AL,FF
BO,FF
9028
NOP
00
9023
DELAY
SKEC
No operation
Page 77
9029
NOP
00
No operation
902A
NOP
00
No operation
902B
NOP
00
No operation
902C
DEC AL
FFF CD
Decrement AL
902E
JNZ 9028
75 F8
Jump on non-zero
9030
DEC BX
Decrement BX
9031
JNZ 9026
9033
RET
SKEC
Page 78
9003
9005
9006
LABEL
MNEMONICS
MOV DPTR,#
4003
MOV A,#80
MOV X@DPTR,
A
MOV
DPTR,#4000
HEXCODE
COMMENTS
90,4003
74,80
Control word
F0
90,4000
MOV A,#A0
74,A0
9009
MOV
X@DPTR,A
F0
900B
Out in A
LCALL DELAY
12,9100
900C
Call delay
MOV A,#E0
74,A0
900F
MOV X@DPTR,
A
9011
F0
SKEC
Out it in port A
Page 79
LCALL DELAY
9012
12,9100
Call delay
74,C0
F0
Out it in port A
12,9100
Call delay
74,80
MOV A,#C0
9015
MOV X@DPTR,
A
9017
LCALL DELAY
9018
MOV A,#80
901B
MOV
X@DPTR,A
901D
L CALL DELAY
F0
Out it in port A
901E
LJMP 9009
12,9100
Call delay
9021
MOV R1,#0A
02,9009
MOV A,#A0
79,0A
9024
DELAY
SKEC
Page 80
9026
DELAY1
NOP
74,40
9028
BACK
NOP
00
No operation
9029
NOP
00
No operation
902A
NOP
00
No operation
902B
DEC A
00
No operation
902C
JNZ BACK
14
Jump on non-zero
902D
JNZ R1,DELAY1
70,F9
Jump on non-zero
902F
RET
D9,F5
9031
22
SKEC
Page 81
PHASE SEQUENCE:
PA7
PA6
PA5
PA4
PA3
PA2
PA1
PA0
80
A0
E0
C0
SKEC
Page 82
DC Motor:
Algorithm:
i.
ii.
Get control word so as to program 8255 ports as O/P port & send to control reg
iii.
iv.
v.
vi.
Call delaylow
vii.
Continue cycle
Program:
Address
Label
CONT:
Mnemonics
Machine Code
Comments
MOV DX , FF26H
MOV AL ,80H
OUT DX ,AL
MOV AL ,01H
Start Pulse
MOV DX , FF20H
Port C Address
OUT DX ,AL
CALL DELAYHIGH
Stop Pulse
MOV AL,00H
OUT
DX,AL
CALL DELAYLOW
JMP CONT
Continue Cycle
DELAYHIGH:
MOV AH,01H
LOOP1:
NOP
NOP
NOP
DEC
AH
SKEC
Page 83
JNZ LOOP1
RET
DELAYLOW:
MOV AL,01H
LOOP2:
NOP
NOP
DEC AL
JNZ LOOP2
RET
Procedure:
i) Connect DC motor interface with VIK-86 through data bus and connect DC motor with
interface.
ii) Give power supply to interface kit
iii) Load program and execute to run motor
iv) Change delay Count to control Speed
RESULT:
Thus the interfacing of stepper motor and DC motor has been
done successfully and the speed control achieved.
SKEC
Page 84
Ex.No: 09
Aim:
To program 8051 using its Arithmetic and Logical and Bit Manipulation
instructions.
a) Arithmetic operations
Address
Label
Mnemonics
MOV
Machine Code
Comments
DPTR, #8500
MOVX A, @DPTR
MOV
B, A
MOV R0, A
INC DPTR
MOVX
A, @DPTR
MOV R1, A
ADD A, B
INC DPTR
MOVX @DPTR, A
MOV R2, A
MOV A, R1
SUBB A, B
INC DPTR
MOVX @DPTR, A
MOV R3, A
MOV B, R2
MUL AB
SKEC
Page 85
INC DPTR
MOVX @DPTR, A
MOV A, R2
MOV B, R3
DIV AB
INC DPTR
MOVX @DPTR, A
LCALL 00BB
Input: M8500 - a
M8501 - b
Output: M8502 : sum (a+b)
M8503: difference (a-b)
M8504: Product ((a+b)(a-b))
M8505: Quotient ((a+b)/(a-b))
SKEC
Page 86
b) 32 bit subtraction
Address
Label
Mnemonics
Machine Code
Comments
CLR C
MOV
A, 43
SUBB A, 53
MOV 63, A
MOV
A, 42
SUBB A, 52
MOV 62, A
MOV
A, 41
SUBB A, 51
MOV 61, A
MOV
A, 40
SUBB A, 50
MOV 60, A
LCALL 00BB
SKEC
Page 87
C) Fibonacci series
Address
Label
Mnemonics
MOV
Machine Code
Comments
R0, 60
MOVX @DPTR, A
INC DPTR
RPT:
MOV R2, A
ADD A, R1
MOV 01, 02
MOVX @DPTR, A
SKEC
Page 88
INC DPTR
DJNZ R0, RPT
EXIT:
LCALL 00BB
so on
SKEC
Page 89
Ex.No: 10
PROCEDURE:
PC to Kit:
1.
2.
3.
4.
5.
6.
Kit to PC:
1.
2.
3.
4.
SKEC
Page 90
SKEC
Page 91
SKEC
Page 92