Microprocessor LAB
Microprocessor LAB
Page Marks
Exp.No Date Name of Experiment Sign
no. Awarded
Page Marks
Exp.No Date Name of Experiment Sign
no. Awarded
EC8681 MICROPROCESSORS AND MICROCONTROLLERS
LABORATORY L T P C 0 0 4 2
LIST OF EXPERIMENTS:
ADDITION:
INPUT OUTPUT
DATA
SUBTRACTION:
INPUT OUTPUT
MEMORY 1200 1201 1202 1203 1204 1205 1206 1207
DATA
MULTIPLICATION:
INPUT OUTPUT
DATA
DIVISION:
INPUT OUTPUT
PROBLEM STATEMENT:
Write an ALP in 8086 to add and subtract two byte numbers stored in the
memory location 1000H to 1003H and store the result in the memory location
1004H to 1005H.Also provide an instruction in the above program to consider
the carry also and store the carry in the memory location 1006H.
ALGORITHM:
(i) 16-bit addition
h) Initialize the MSBs of sum to 0
i) Get the first number.
j) Add the second number to the first number.
k) If there is any carry, increment MSBs of sum by 1.
l) Store LSBs of sum.
m) Store MSBs of sum.
3
(ii) Division of 16-bit numbers.
a) Get the dividend
b) Get the divisor
c) Initialize the quotient to 0.
d) Dividend = dividend –divisor
e) If the divisor is greater, store the quotient. Go to step g.
f) If dividend is greater, quotient = quotient + 1. Repeat from step (d)
Store the dividend value as remainder.
1015 89060412
MOV [1204], AX Store the sum
4
PROGRAM: 16 BIT SUBTRACTION
1015 89060412
MOV [1204], AX Store the sum
5
PROGRAM: 16 BIT MULTIPLICATION
Copy the
100E 89D8 higher order
product to
MOV AX,DX AX
Store the
1010 89060812
MOV [1206],AX higher order
product
1014 HLT F4 Stop the program
Copy the
100E 89D8
higher order
MOV AX,DX product to AX
Store the
1010 89060812
MOV [1206],AX higher order
product
1014 F4
HLT Stop the program
6
RESULT:
Thus the Assembly Language Program for basic arithmetic and logical operations has been
performed and the result was stored.
7
OUTPUT: Block Transfer without Overlap
INPUT:
OUTPUT:
8
Ex.No.: 02
Date :
Block Transfer without Overlap
AIM :
To write an Assembly Language Program (ALP) for moving a data block without overlap using
8086.
APPARATUS REQUIRED:
8086 kit
PROGRAM: (MOVING A DATA BLOCK USING 8086 kit)
1010 INC SI 46
1011 INC SI 46
1012 INC DI 47
1013 INC DI 47
1016 HLT F4
RESULT:
Thus the Assembly Language Program for moving a data block without overlap has
been performed and the result is stored.
9
OUTPUT:
INPUT OUTPUT
1200 1201
10
Ex.No.: 03(A)
Date :
CODE CONVERSION
AIM:
To Convert
a. ASCII Number to Decimal
b. hex (FFFF) number into its equivalent decimal value and stored at consecutive memory
locations.
APPARATUS REQUIRED:
8086 kit
PROGRAM
100C 72 FF JC L1
1012 L1 INC SI
8804
1010 HLT
F4
11
hex (FFFF) number into its equivalent decimal
Address Label Mnemonics opcode Comments
MOV
1000 AX,0FFFFh C7C0FFFF
04 MOV DX,0h
C7C20000
MOV
1008 CX,2710H C7C11027
DIV CX
100C F7F1
AND AX,00FFh
100E 81E0FF00
MOV SI,1200h
1012 C7C60012
MOV [SI],AL
1016 8804
MOV AX,DX
1018 89D0
MOV DX,0h
101A C7C20000
MOV
101E CX,03E8H
C7C13E00
DIV CX
1022 F7F1
AND AX,00FFh
1026 81E0FF00
1028 INC SI 46
MOV [SI],AL
1029 8804
MOV AX,DX
102B 89D0
1032 INC SI 46
MOV AL,AH
1039 88E0
MOV AH,0h
3B C6C400
12
DIV BL
1041 F6F3
1043 INC SI 46
MOV [SI],AL
1044 8804
INC SI
1046 46
MOV [SI],AH
1047 8824
HLT F4
1049
RESULT:
Thus the Convert ASCII Number to Decimal and Hex to Binary performed using 8086. hex
(FFFF) number into its equivalent decimal value and stored at consecutive memory locations.
13
OUTPUT: Decimal
Addition INPUT
1100 :
1101 :
OUTPUT
1102 :
INPUT
1100 :
1101 :
OUTPUT
1102 :
14
Ex.No.: 03 (B)
Date :
DECIMAL ARITHMATIC OPERATIONS
AIM:
To perform a addition and subtracton operations between two decimal numbers.
THEORY:
Get the two numbers from mentioned address using MOV instruction.After that add two valuesand
display the result will be decimal value using DAA (DECIMAL ADJUST ADDITION) instruction.
Get the two numbers from mentioned address using MOV instruction .After that subtract the second
byte from first byte using SUB instruction and display the result will be decimal value using DAS
(DECIMAL ADJUST SUBTRACTION) instruction.
ADDITION:
Address Label Mnemonics opcode Comments
1006 INC SI 46
100B DAA 27
100C INC SI 46
100F HLT F4
15
SUBTRACTION
1006 INC SI 46
100B DAS 2F
C INC SI 46
100F HLT F4
16
RESULT:
Thus the addition and subtraction operation between decimal numbers has been executed and
stored at consecutive memory locations.
17
OUTPUT:MATRIX ADDITION
INPUT
INPUT
OUTPUT
INPUT
OUTPUT
18
Ex.No.: 03(C)
Date :
MATRIX OPERATION
AIM:
To Write ALP for Matrix Addition and subtraction and result stored at consecutive memory
locations.
APPARATUS REQUIRED:
8086 kit
PROGRAM
MATRIX ADDITION
L1: 47
1013 INC DI
46
1014 INC SI
1019 HLT F4
19
Matrix subtraction
L1:
1013 INC DI 47
1014 INC SI 46
1019 HLT F4
20
RESULT:
Thus the Matrix Addition and subtraction is performed using 8086.
21
a) OUTPUT: COPYING
A STRING
INPUT
DATA
OUTPUT
MEMORY
1300 1301 1302 1303 1304
DATA
22
Ex.No.: 04(A)
Date :
FLOATING POINT OPERATIONS, STRING MANIPULATIONS,
SORTING AND SEARCHING
A) COPYING A STRING
AIM:
To move a string of length FF from source to destination.
ALGORITHM:
a. Initialize the data segment .(DS)
b. Initialize the extra data segment .(ES)
c. Initialize the start of string in the DS. (SI)
d. Initialize the start of string in the ES. (DI)
e. Move the length of the string(FF) in CX register.
Move the byte from DS TO
ES, till CX=0.
A)COPYING A STRING
ADDRESS OPCODES PROGRAM COMMENTS
RESULT:
Thus a string of a particular length is moved from source segment to destination segment.
23
OUTPUT: SEARCHING
A STRING
INPUT
MEMORY
1300 1301 1302 1303 1304
DATA
OUTPUT
DATA
24
Ex.no:4B
Date :
B) SEARCHING A STRING
AIM:
To scan for a given byte in the string and find the relative address of the byte from
the starting location of the string.
ALGORITHM:
a. Initialize the extra segment .(ES)
b. Initialize the start of string in the ES. (DI)
c. Move the number of elements in the string in CX register.
d. Move the byte to be searched in the AL register.
Scan for the byte in ES. If the byte is found ZF=0, move the
address pointed by ES:DI to BX.
RESULT:
Thus a given byte or word in a string of a particular length in the extra
segment(destination) is found .
25
OUTPUT:.
ASCENDING
INPUT OUTPUT
MEMORY
DATA
DESCENDING
INPUT OUTPUT
MEMORY
DATA
26
Ex.No.: 04(C)
Date :
AIM:
To write an Assembly Language Program (ALP) to sort a given array
in ascending and descending order.
APPARATUS REQUIRED:
PROBLEM STATEMENT:
ALGORITHM:
(i) Sorting in ascending order:
a. Load the array count in two registers C1 and C2.
b. Get the first two numbers.
c. Compare the numbers and exchange if necessary so that the two numbers are
in ascending order.
d. Decrement C2.
e. Get the third number from the array and repeat the process until C2 is 0.
f. Decrement C1 and repeat the process until C1 is 0.
(ii) Sorting in descending order:
a. Load the array count in two registers C1 and C2.
b. Get the first two numbers.
c. Compare the numbers and exchange if necessary so that the two numbers are
in descending order.
d. Decrement C2.
e. Get the third number from the array and repeat the process until C2 is 0.
f. Decrement C1 and repeat the process until C1 is 0.
27
ASCENDING:
28
DESCENDING
RESULT:
Thus given array of numbers are sorted in ascending & descending order.
29
OUTPUT:.
LARGEST
INPUT OUTPUT
MEMORY
DATA
SMALLEST
INPUT OUTPUT
MEMORY
DATA
30
Ex.No.: 04(D)
Date :
LARGEST& SMALLEST
AIM:
To write an Assembly Language Program (ALP) to find the
largest and smallest number in a given array.
APPARATUS REQUIRED:
PROBLEM STATEMENT:
ALGORITHM:
(i) Finding largest number:
a. Load the array count in a register
C1. b. Get the first two numbers.
c. Compare the numbers and exchange if the number is small.
d. Get the third number from the array and repeat the process until C1 is 0.
31
LARGEST
SMALLEST
32
RESULT:
Thus largest and smallest number is found in a given array.
33
A. OUTPUT: PASSWORD CHECKING
password set input :
After executing type the password via keyboard and press enter button the lcd
show the output.
34
Ex.No.: 05(A)
Date : PASSWORD CHECKING
AIM:
To check whether the password is correct or not.
THEORY:
Steps to be followed
i)initialization of lcd
ii)display “ENTER PASSWORD”
iii)store the password key value
iv)get the key value from keyboard and compare to it stored value
v)if password matched display” PASSWORD OK”
vi) if password mismatched display ” PASSWOR
vii)clear the key value to be stored
CPLD ADDRESSES TO BE USED:
LCD DATA/COMMAND :04H
RS :06H
KEYBOARD :02H
CODE:
0000 code segment
assume cs:code,ds:code
1000 org 1000h
1000 E8 1105 R CALL L10
1003 E8 110C R CALL L11
1006 B0 38 MOV AL,38h
1008 E6 04 OUT 04h,AL
100A E8 1105 R CALL L10
100D E8 110C R CALL L11
1010 B0 0E MOV AL,0Eh
1012 E6 04 OUT 04h,AL
1014 E8 1105 R CALL L10
1017 E8 110C R CALL L11
101A B0 01 MOV AL,01h
101C E6 04 OUT 04h,AL
101E E8 1105 R CALL L10
1021 E8 110C R CALL L11
1024 B0 06 MOV AL,06h
1026 E6 04 OUT 04h,AL
1028 E8 1105 R CALL L10
102B E8 110C R CALL L11
102E B0 80 MOV AL,80h
1030 E6 04 OUT 04h,AL
1032 E8 1105 R CALL L10
1035 E8 110C R CALL L11
1038 B0 0C MOV AL,0Ch
103A E6 04 OUT 04h,AL
103C B1 10 MOV CL,10h
103E BE 111C R MOV SI,offset mess
1041 E8 1105 R L7 CALL L10
1044 E8 1111 R CALL L12
35
1047 8A 04 MOV AL,[SI]
1049 E6 04 OUT 04h,AL
104B FE C9 DEC CL
104D 83 C6 01 ADD SI,01h
1050 8A C1 MOV AL,CL
1052 2C 01 SUB AL,01h
1054 75 EB JNZ L7
1056 E8 1105 R CALL L10
1059 E8 110C R CALL L11
105C B0 C4 MOV AL,0C4h
105E E6 04 OUT 04h,AL
1060 BF 1220 MOV DI,1220h
1063 E4 02 L6: IN AL,02h
1065 24 FF AND AL,0FFh
1067 3C F0 CMP AL,0F0h
1069 75 F8 JNZ L6
106B E8 1116 R CALL L13
106E E4 02 IN AL,02h
1070 24 FF AND AL,0FFh
1072 3C 5A CMP AL,5Ah
1074 74 11 JZ LA
1076 88 05 MOV [DI],AL
1078 83 C7 01 ADD DI,01h
107B E8 1105 R CALL L10
107E E8 1111 R CALL L12
1081 B0 2A MOV AL,2Ah
1083 E6 04 OUT 04h,AL
1085 EB DC JMP L6
1087 BE 1240 LA: MOV SI,1240h
108A BF 1220 MOV DI,1220h
108D B7 06 MOV BH,06h
108F FE CF L5: DEC BH
1091 8A C7 MOV AL,BH
1093 0C 00 OR AL,00h
1095 74 33 JZ LF
1097 8A 04 MOV AL,[SI]
1099 8A 1D MOV BL,[DI]
109B 83 C6 01 ADD SI,01h
109E 83 C7 01 ADD DI,01h
10A1 3A C3 CMP AL,BL
10A3 74 EA JZ L5
10A5 E8 1105 R CALL L10
10A8 E8 110C R CALL L11
10AB B0 C0 MOV AL,0C0h
10AD E6 04 OUT 04h,AL
10AF B1 0F MOV CL,0Fh
10B1 BE 1137 R MOV SI,offset mess2
10B4 E8 1105 R L4: CALL L10
10B7 E8 1111 R CALL L12
36
10BA 8A 04 MOV AL,[SI]
10BC E6 04 OUT 04h,AL
10BE FE C9 DEC CL
10C0 83 C6 01 ADD SI,01h
10C3 8A C1 MOV AL,CL
10C5 0C 00 OR AL,00h
10C7 75 EB JNZ L4
10C9 F4 HLT
10CA E8 10CD R LF: CALL L14
10CD L14:
10CD E8 1105 R CALL L10
10D0 E8 110C R CALL L11
10D3 B0 C0 MOV AL,0C0h
10D5 E6 04 OUT 04h,AL
10D7 B1 0C MOV CL,0Ch
10D9 BE 112B R MOV SI,offset mess1
10DC E8 1105 R L2: CALL L10
10DF E8 1111 R CALL l12
10E2 8A 04 MOV AL,[SI]
10E4 E6 04 OUT 04h,AL
10E6 FE C9 DEC CL
10E8 83 C6 01 ADD SI,01h
10EB 8A C1 MOV AL,CL
10ED 0C 00 OR AL,00h
10EF 75 EB JNZ L2
10F1 BE 1220 MOV SI,1220h
10F4 B1 05 MOV CL,05h
10F6 B0 00 L1: MOV AL,00h
10F8 8804 MOV [SI],AL
10FA 83 C6 01 ADD SI,01h
10FD FE C9 DEC CL
10FF 8AC1 MOV AL,CL
1101 0C 00 OR AL,00h
1103 75 F1 JNZ L1
1105 L10 :
1105 B0 4F MOV AL,4Fh
1107 2C 01 L3: SUB AL,01h
1109 75 FC JNZ L3
110B C3 RET
110C L11:
110C B000 MOV AL,00h
110E E6 06 OUT 06h,AL
1110 C3 RET
1111 L12:
1111 B0 01 MOV AL,01h
1113 E6 06 OUT 06h,AL
1115 C3 RET
1116 L13:
1116 B9 0FFF MOV CX,0FFFh
1119 E2 FE HE: LOOP HE
111B C3 RET
37
111C 20 45 4E 54 45 52 mess db " ENTER PASSWORD" 20
50 41 53 53 57
4F 52 44
112B 50 41 53 53 57 4F mess1 db "PASSWORD OK "
52 44 20 4F 4B 20
1137 50 41 53 53 57 4F mess2 db "PASSWORD NOT OK"
52 44 20 4E 4F 54
20 4F 4B
1146 code ends
End
38
RESULT:
Thus the password has entered and verified.
39
B. OUTPUT: Print RAM size
40
Ex.No.: 05(B)
Date :
DISPLAY RAM SIZE
AIM:
To find display the RAM SIZE of the system.
THEORY:
Steps to be followed in program
i) fill the memory with data in RAM
ii) check how much memory correctly filled with data
iii) initialization of lcd
iv) display “RAM SIZE”
v) Read the count value and display the count value as RAM
size. CPLD ADDRESSES TO BE USED:
LCD DATA/COMMAND :04H
RS :06H
CODE:
0000 code segment
assume cs:code,ds:code
1000 org 1000h
1000 BE 0000 MOV SI,0000h
1003 B9 1000 MOV CX,1000h
1006 B0 11 L1: MOV AL,11h
1008 88 04 MOV [SI],AL
100A 46 INC SI
100B E2 F9 LOOP L1
100D BE 2000 MOV SI,2000h
1010 BA 1FFF MOV DX,1FFFh
1013 B9 7FFF MOV CX,7FFFh
1016 B0 44 L3: MOV AL,44h
1018 88 04 MOV [SI],AL
101A 8A 1C MOV BL,[SI]
101C 46 INC SI
101C CMP AL,BL
101F 75 07 JNZ L2
41
1021 83 C2 01 ADD DX,01h
1024 E2 F0 LOOP L3
1026 F4 HLT
1027 90 NOP
1028 L2:
1028 E8 10D1 R CALL L10
102B E8 10D8 R CALL L11
102E B0 38 MOV AL,38h
1030 E6 04 OUT 04h,AL
1032 E8 10D1 R CALL L10
1035 E8 10D8 R CALL L11
1038 B0 0E MOV AL,0Eh
103A E6 04 OUT 04h,AL
103C E8 10D1 R CALL L10
103F E8 10D8 R CALL L11
1042 B0 01 MOV AL,01h
1044 E6 04 OUT 04h,AL
1046 E8 10D1 R CALL L10
1049 E8 10D8 R CALL L11
104C B0 06 MOV AL,06h
104E E6 04 OUT 04h,AL
1050 E8 10D1 R CALL L10
CALL L11
1056 B0 80 MOV AL,80h
1058 E6 04 OUT 04h,AL
105A E8 10D1 R CALL L10
105D E8 10D8 R CALL L11
1060 B0 0C MOV AL,0Ch
1062 E6 04 OUT 04h,AL
1064 E8 10D1 R CALL L10
1067 B1 0C MOV CL,0ch
1069 BE 10E2 R MOV SI,offset mess
106C E8 10D1 R L4: CALL L10
106F E8 10DD R CALL L12
1072 8A 04 MOV AL,[SI]
42
1074 E6 04 OUT 04h,AL
076 FE C9 DEC CL
1078 46 INC SI
1079 8A C1 MOV AL,CL
107B 0C 00 OR AL,00h
107D 75 ED JNZ L4
107F E8 10D1 R CALL L10
1082 E8 10DD R CALL L12
1085 8B C2 MOV AX,DX
1087 BA 0000 MOV DX,0
108A B9 03FF MOV CX,03FFH
108D F7 F1 DIV CX
108F B3 0A MOV BL,0AH
1091 F6 F3 DIV BL
1093 8A D0 MOV DL,AL
1095 8A F4 MOV DH,AH
1097 E8 10D1 R CALL L10
109A E8 10D8 R CALL L11
109D B0 C4 MOV AL,0C4h
109F E6 04 OUT 04h,AL
10A1 E8 10D1 R CALL L10
10A4 E8 10DD R CALL L12
10A7 8A C2 MOV AL,DL
10A9 04 30 add AL,30h
10AB E6 04 OUT 04h,AL
10AD E8 10D1 R CALL L10
10B0 E8 10DD R CALL L12
10B3 8A C6 MOV AL,DH
10B5 04 30 ADD AL,30h
10B7 E6 04 OUT 04h,AL
10B9 E8 10D1 R CALL L10
10BC E8 10DD R CALL L12
10BF B0 6B MOV AL,6Bh
10C1 E6 04 OUT 04h,AL
10C3 E8 10D1 R CALL L10
43
10C6 E8 10DD R CALL L12
10C9 B0 42 MOV AL,42h
10CB E6 04 OUT 04h,AL
10CD E8 10D1 R CALL L10
10D0 F4 HLT
10D1 L10:
10D1 B0 7F MOV AL,7Fh
10D3 2C 01 L8: SUB AL,01h
10D5 75 FC JNZ L8
10D7 C3 RET
10D8 L11:
10D8 B0 00 MOV AL,00h
10DA E6 06 OUT 06h,AL
10DC` E C3 RET
10DD L12:
10DD B0 01 MOV AL,01h
10DF E6 06 OUT 06h,AL
10E1 C3 RET
44
RESULT:
Thus the find display the RAM SIZE of the system has executed and verified.
45
C. OUTPUT: SYSTEM DATE
INPUT:
46
Ex.No.: 05(C)
Date :
SYSTEM DATE
AIM:
To display the date using microprocessor.
THEORY:
Interfacing VBMB-15 to 8086
Steps to be followed in program
i) set 24 hours format
ii) set time(23:55:55)
iii) set date(dd:mm:yy)
iv) read time &date
CODE:
0000 code segment
assume cs:code,ds:code
1000 org 1000h
1000 B0 05 MOV AL,05H
1002 E6 DE OUT 0DEH,AL
1004 B0 04 MOV AL,04H
1006 E6 DE OUT 0DEH,AL
1008 BE 1200 MOV SI,1200H
100B 8A 04 MOV AL,[SI]
100D E6 C0 OUT 0C0H,AL
100F 46 INC SI
1010 8A 04 MOV AL,[SI]
1012 E6 D0 OUT 0D0H,AL
1014 46 INC SI
1015 8A 04 MOV AL,[SI]
1017 E6 C2 OUT 0C2H,AL
1019 46 INC SI
101A 8A 04 MOV AL,[SI]
101C E6 D2 OUT 0D2H,AL
101E 46 INC SI
101F 8A 04 MOV AL,[SI]
47
1021 E6 C4 OUT 0C4H,AL
1023 46 INC SI
1024 8A 04 MOV AL,[SI]
1026 E6 D4 OUT 0D4H,AL
1028 46 INC SI
1029 8A 04 MOV AL,[SI]
102B E6 C6 OUT 0C6H,AL
102D 46 I NC SI
102E 8A04 MOV AL,[SI]
1030 E6 D6 OUT 0D6H,AL
1032 46 INC SI
1033 8A 04 MOV AL,[SI]
1035 E6 C8 OUT 0C8H,AL
1037 46 INC SI
1038 8A04 MOV AL,[SI]
103A E6 D8 OUT 0D8H,AL
103C 46 INC SI
103D 8A04 MOV AL,[SI]
103F E6 CA OUT 0CAH,AL
1041 46 INC SI
1042 8A04 MOV AL,[SI]
1044 E6 DA OUT 0DAH,AL
1046 BE 1300 LOOP: MOV SI,1300H
1049 E4 D6 IN AL,0D6H
104B 24 0F AND AL,0FH
104D 88 04 MOV [SI],AL
104F E4 C6 IN AL,0C6H
1051 24 0F AND AL,0FH
1053 46 INC SI
1054 88 04 MOV [SI],AL
1056 E4 D8 IN AL,0D8H
1058 24 0F AND AL,0FH
105A 46 INC SI
105B 8804 MOV [SI],AL
105D E4C8 IN AL,0C8H
48
105F 24 0F AND AL,0FH
1061 46 INC SI
1062 8804 MOV [SI],AL
1064 E4 DA IN AL,0DAH
1066 24 0F AND AL,0FH
1068 46 INC SI
1069 88 04 MOV [SI],AL
106B E4 CA IN AL,0CAH
106D 24 0F AND AL,0FH
106F 46 INC SI
1070 8804 MOV [SI],AL
1072 BE 1300 MOV SI,1300H
1075 8A 04 MOV AL,[SI]
1077 E6 E0 OUT 0E0H,AL
1079 46 INC SI
107A A 04 MOV AL,[SI]
107C E6 F0 OUT 0F0H,AL
107E 46 INC SI
107F 8A 04 MOV AL,[SI]
1081 E6 E2 OUT 0E2H,AL
1083 46 INC SI
1084 8A 04 MOV AL,[SI]
1086 E6 F2 OUT 0F2H,AL
1088 46 INC SI
1089 8A 04 MOV AL,[SI]
108B E6 E4 OUT 0E4H,AL
108D 46 INC SI
108E 8A 04 MOV AL,[SI]
1090 E6 F4 OUT 0F4H,AL
1092 EB B2 JMP LOOP
1094 code ends
End
RESULT:
Thus the display the date using 8086 microprocessor has executed and verified.
49
OUTPUT: COUNTERS AND TIME DELAY
INPUT:
SET TIME DELAY:
OUTPUT:
50
Ex.No.: 06
Date :
TIME DELAY USING COUNTERS
AIM:
To provide the time delay using counters.
THOERY:
Here the time delay is generated using CX register
Steps to be followed in program
i) lcd initialization
ii) display one character
iii) get the time delay value and display character with time delay
CPLD ADDRESSES TO BE USED:
LCD DATA/COMMAND :04H
RS :06H
PROGRAM
Address Label Mnemonic Opcode Comments
1000 CALL L10 E87400
1003 CALL L11 E87A00
51
102C CALL L10 E84800
52
1074 JMP L1 E9CBFF
L10:
1077
107F RET C3
1080 L11:
1085 RET C3
1086 L12
108B RET C3
10A2 RET C3
RESULT :
Thus the value displayed in lcd with time delay
53
Ex.No.:
Date :
PROGRAM USING MASM SOFTWARE
AIM:
To write ALP for Arithmetic and logic operation using MASAM.
SOFTWARE REQUIRED:
PROGRAM:
16-BIT ADDITION
ASSUME CS: CODE, DS: DATA,ES: EXTRA
DATA SEGMENT
NUM1 DW 23C5H
NUM2 DW 6789H
DATA ENDS
EXTRA SEGMENT
RESULT DW 0000H
EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
SUB AX,AX //Note :
MOV AX, NUM1
MOV BX, NUM2
ADD AX,BX
MOV RESULT,AX
INT 03H
CODE ENDS
END START
END
54
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
SUB AX,AX
MOV AX, NUM1
MOV BX, NUM2
SUB AX,BX
MOV RESULT,AX
INT 3H
CODE ENDS
END START
END
LOGICAL AND:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
AND AL, BL
INT 3H
CODE ENDS
END START
LOGICAL OR:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
OR AL, BL
INT 3H
CODE ENDS
END START
LOGICAL XOR:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
XOR AL, BL
INT 3H
CODE ENDS
END
55
NOT OPERATION:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
NOT AL
INT 3H
CODE ENDS
END START
NAND OPERATION:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
AND AL, BL
NOT AL
INT 3H
CODE ENDS
END START
RESULT:
Thus the Assembly Language Program for Arithmetic and Logic operation has been
performed and the result is stored using MA
56
Ex.No.: 07
Date :
TRAFFIC LIGHT CONTROLLER USING 8086
AIM:
PROGRAM:
57
1119 EE OUT DX,AL
111A E8 07 00 CALL DELAY
111D E2 F1 INC BX
111E LOOP NEXT
1120 EB E4 JMP START
1122 DELAY: 51 PUSH CX
1124 B9 00 05 MOV CX,0005H
1126 REPEAT: BA FF FF MOV DX,0FFFFH
1129 LOOP2: 4A DEC DX
112A 75 FD JNZ LOOP2
112C E2 F8 LOOP REPEAT
112E 59 POP CX
112F C3 RET
LOOK UP TABLE
Address Opcode
1200 80H
1201 21H,09H,10H,00H (SOUTH
WAY)
1205 0CH,09H,80H,00H (EAST
WAY)
1209 64H,08H,00H,04H (NOURTH
WAY)
120D 24H,03H,02H,00H (WEST
WAY)
1211 END
58
RESULT:
Thus the assembly language program for traffic light controller has been impleme
59
Ex.No.: 08
Date :
STEPPER MOTOR INTERFACING
AIM:
To write an assembly language program in 8086 to rotate the motor at different speeds.
APPARATUS REQUIRED:
PROBLEM STATEMENT:
Write a code for achieving a specific angle of rotation in a given time and particular
number of rotations in a specific time.
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular
position is a stepper motor. The rotary motion occurs in a stepwise manner from one
equilibrium position to the next. Two-phase scheme: Any two adjacent stator windings are
energized. There are two magnetic fields active in quadrature and none of the rotor pole faces
can be in direct alignment with the stator poles. A partial but symmetric alignment of the
rotor poles is of course possible.
ALGORITHM:
MEMORY A1 A2 B1 B2 HEX
LOCATION CODE
4500 1 0 0 0 09 H
4501 0 1 0 1 05 H
4502 0 1 1 0 06 H
4503 1 0 1 0 0A H
60
FLOWCHART:
START
DELAY
DECREMENT COUNTER
YES
IS B = 0 ?
NO
PROGRAM TABLE
ADDRESS PROGRAM COMMENTS
1000 Initialize memory location to
START : MOV DI, 1200H store the array of
number
1004 MOV CX, 0004H Initialize array size
1008 LOOP 1 : MOV AL,[DI] Copy the first data in AL
100A
OUT 0C0,AL Send it through port address
100C MOV DX, 1010H
1010 L1 : DEC DX Introduce delay
1011 JNZ L1
101B INC DI Go to next memory location
1014 LOOP LOOP1 Loop until all the dat
1016 Go to start location for
JMP START continuous rotation
1200 : 09,05,06,0A Array of datas
61
RESULT:
Thus the assembly language program for rotating stepper motor in both clockwise and
anticlockwise directions is written and verified.
62
OUTPUT: DIGITAL CLOCK
1500
1501
1502
63
Ex.No.: 09
Date :
DIGITAL CLOCK
AIM
To display the digital clock specifically by displaying the hours, minutes
and seconds using 8086 kits.
APPARATUS REQUIRED
Preliminary Settings
Org 1000h
Store time value in memory location 1500- Seconds
1501- Minutes
1502- Hours
Digital clock program
64
68
ADDRESS MNEMONICS OPCODE
1099 MOV[BX],AL 8B07
109B DEC BX 4B
109C MOV AL,3AH C6C0
109F MOV[BX],AL 8807
10A1 DEC BX 4B
10A2 INC SI 46
10A3 MOV AL,[SI] 8A04
10A5 MOV AH,0 C6C400
10A8 MOV DH,0AH C6C60A
10AB DIV DH F6F6
10AD ADD AH,30H 80C430
10B0 MOV[BX],AH 8827
10B2 DEC BX 4B
10B3 ADD AL,30H 80C030
10B6 MOV [BX],AL 8807
10B8 MOV AL,3AH C6C03A
10BB MOV [BX],AL 8807
10BD DEC BX 4B
10BE INC SI 46
10BF MOV AL,[SI] 8A04
10C1 MOV AH,0 C6C400
10C4 MOV DH,OAH C6C60A
10C7 DIV DH F6F6
10C9 ADD AH,30H 80C430
10CC MOV [BX],AH 8827
10CE DEC BX 4B
10CF ADD AL,30H 80C030
10D2 MOV [BX],AL 8807
10D4 RET C3
10D5 GETC C3
10D6 IN AL,02H E402
10DB CMP AL,0F0H 80F8F0
10DE JNE GETC 75F5
69
RESULT:
Thus the digital clock program has been written and executed using 8086
microprocessor kit and the output of digital clock was displayed as [hours: minutes: seconds]
successfully.
70
OUTPUT: Keyboard and Display
71
Ex.No.: 10
Date :
INTERFACING 8279 WITH 8086
AIM:
To display Rolling message in display using 8279 programmable keyboard/display controller by
interfacing it with 8086.
APPARATUS REQUIRED:
S.No Apparatus Quantity
1 Microprocessor kit-8086 1
2 Keyboard display Interface-8279 1
3 Connecting cable -
DESCRIPTION:
The INTEL 8279 is specially developed for interfacing keyboard and display devices to
8085/8086/8088 microprocessor based system.
The important features of 8279 are,
Simultaneous keyboard and display operations.
Scanned keyboard mode.
Scanned sensor mode.
8-character keyboard FIFO.
16-character display.
Right or left entry 1 6-byte display RAM.
Programmable scan timing.DISPLAY SECTION:
The display section has eight output lines divided into two groups A0-A3 and B0-B3.
The output lines can be used either as a single group of eight lines or as two groups of our
lines, in conjunction with the scan lines for a multiplexed display.
The output lines are connected to the anodes through driver transistor in case of common
cathode 7-segment LEDs.
The cathodes are connected to scan lines through driver transistors.
0 0 0 D D K K K
0 0 0 1 0 0 0 0
72
Clear Display Command: [CC]
1 0 0 AI A A A A
1 0 0 1 0 0 0 0
H 1 0 0 1 1 0 0 0 98
E 0 1 1 0 1 0 0 0 68
L 0 1 1 1 1 1 0 0 7C
P 1 1 0 0 1 0 0 0 C8
U 0 0 0 1 1 1 0 0 1C
S 0 0 1 0 1 0 0 1 29
In common anode type seven segment display, 0 is used for a segment to glow and 1 for a
segment to remain in off condition.
73
ALGORITHM :
1. Store the look up table which contains the common anode seven segment code for the message
„HELP US‟ from memory location 12
2. Load the number of characters to be displayed in CX reg.
3. Move display mode set up command to acc. And then load it in command reg.
4. Move clear command to acc. and then load it in command reg.
5. Move display RAM command to acc. And then load it in command reg.
6. Then move common anode seven segment codes one by one for the character to be
displayed to accumulator from memory and then load it in data reg.
7. Call delay subroutine between each code.
8. Repeat step 2 to 7 to get continuous disp
PROGRAM -1 :
PROGRAM –2 :
ROLLING DISPLAY:
75
100D 80C8 MOV AL,CL
100F E6 C2 OUT C2,AL
1011 C6 C0 90 MOV AL,90
1014 E6 C2 OUT C2,AL
1016 NEXT: 8A 04 MOV AL,[SI]
1018 E6 C0 OUT C0,AL
101A E8 06 00 CALL DELAY
101D 46 INC SI
101E E2 F6 LOOP NEXT
1020 E9 DD FF JMP START
1023 DELAY: C7 C2 FF A0 MOV DX,0A0FF
1027 LOOP1: 4A DEC DX
1028 75 FD JNZ LOOP1
102A C3 RET
LOOK UP TABLE:
1200 FF FF FF FF
1204 FF FF FF FF
1208 98 68 7C C8
120C FF 1C 29 FF
76
RESULT:
Thus the keyboard display controller 8279 is interfaced with 8086 p and the message
„HELPUS‟ is displayed.
77
Ex.No.: 11(A)
Date :
:
SERIAL INTERFACE AND PARALLEL INTERFACE
Aim
To connect two 8086 microprocessor kits and to serially communicate
with each other by considering transmitter and receiver kits.
Apparatus required
Procedure
1. Take two no of 8086 microprocessor kits.
2. Enter the transmitter program in transmitter kit.
3. Enter the receiver program in receiver kit.
4. Interface the two kits with 9-9 serial cable in the serial port of the microprocessor kits.
(LCD kit means PC-PC cable. LED kit means kit-kit cable)
5. Enter the data in transmitter kit use the memory location 1500.
6. Execute the receiver kit.
7. Execute the transmitter kit.
8. Result will be available in receiver kit memory location 1500.
Transmitter Prog
78
Receiver Program
79
RESULT:
Thus the serial communication between two 8086 microprocessor kits
has been established and the data is transmitted in one kit and received in the
other kit successfully.
80
Ex.No.: 11(B)
Date :
PARALLEL COMMUNICATION BETWEEN TWO 8086
MICROPROCESSORS KITS
Aim
To connect two 8086 microprocessor kits and to establish parallel communication with
each other by considering transmitter and receiver kits.
Apparatus required
Procedure
1. Take two 8086 microprocessor kits.
2. Enter the transmitter program in transmitter kit.
3. Enter the receiver program in receiver kit.
4. Interface the two kits with 26-core cable on PPI-1.
5. Execute the receiver kit.
6. Execute the transmitter kit.
7. Go and see the memory location 1200 in receiver to get same eight data.
8. Data is available in transmitter kit in the memory location.
9. Change the data & execute the following procedure & get the result in receiver kit.
Transmitter program
83
Receiver Program
84
RESULT:
Thus the serial communication between two 8086 microprocessor kits has been
established and the data is transmitted in one kit and received in the other kit successfully.
85
RESULT: Analog to Digital
ANALOG DIGITAL DATA ON LED
VOLTAGE DISPLAY
86
Ex.No.: 12(A)
Date :
A/D INTERFACE AND WAVEFORM GENERATION
AIM:
NO
IS EOC = 1?
YES
STOP
87
PROGRAM TABLE
ADD OPCODE
RESS PROGRAM COMMENTS
88
RESULT:
Thus the ADC was interfaced with 8086 and the given analog inputs were
converted into its digital equivalent.
89
OUTPUT: WAVEFORM GENERATION: DIGITAL TO ANALOG
Square Waveform
Saw-tooth waveform
Triangular waveform
90
Ex.No.: 12(B)
Date :
INTERFACING DIGITAL –TO –ANALOG CONVERTER
AIM :
1. To write an assembly language program for digital to analog conversion
2. To convert digital inputs into analog outputs & To generate different waveforms
APPARATUS REQUIRED:
SL.NO ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 Vi Microsystems 1
2. Power Supply +5 V, dc,+12 V dc 1
3. DAC Interface board - 1
PROBLEM STATEMENT:
The program is executed for various digital values and equivalent analog voltages
are measured and also the waveforms are measured at the output ports using CRO.
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is between –5v
and +5v. The output voltage varies in steps of 10/256 = 0.04 (approximately). The digital
data input and the corresponding output voltages are presented in the table. The basic idea
behind the generation of waveforms is the continuous generation of analog output of DAC.
With 00 (Hex) as input to DAC2 the analog output is –5v. Similarly with FF H as input, the
output is +5v. Outputting digital data 00 and FF at regular intervals, to DAC2, results in a
square wave of amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to
DAC2. Repeat this sequence again and again. As a result a saw-tooth wave will be
generated at DAC2 output. Output digital data from 00 to FF in constant steps of 01 to
DAC2. Output digital data from FF to 00 in constant steps of 01 to DAC2. Repeat this
sequence again and again. As a result a triangular wave will be generated at DAC2 output.
ALGORITHM:
Measurement of analog voltage:
(i) Send the digital value of DAC.
(ii) Read the corresponding analog value of its output.
Waveform generation:
Square Waveform:
(i) Send low value (00) to the DAC.
(ii) Introduce suitable delay.
(iii) Send high value to DAC.
(iv) Introduce delay.
(v) Repeat the above
procedure. Saw-tooth waveform:
(i) Load low value (00) to accumulator.
(ii) Send this value to DAC.
(iii) Increment the accumulator.
(iv) Repeat step (ii) and (iii) until accumulator value reaches FF.
(v) Repeat the above procedure from step 1.
Triangular waveform:
(i) Load the low value (00) in accumulator.
(ii) Send this accumulator content to DAC.
(iii) Increment the accumulator.
(iv) Repeat step 2 and 3 until the accumulator reaches FF, decrement
the accumulator and send the accumulator contents to DAC.
(v) Decrementing and sending the accumulator contents to DAC.
91
PROGRAM TABLE: Square Wave
PROGRAM COMMENTS
PROGRAM COMMENTS
92
PROGRAM TABLE: Triangular Wave
PROGRAM COMMENTS
MODEL GRAPH:
Triangular waveform
RESULT:
Thus the DAC was interfaced with 8085 and different waveforms have been generated.
93
PROGRAMS USING 8051
AND MASM
94
OUTPUT: 8BIT ADDITION
INPUT OUTPUT
DATA
95
Ex.No.: 13(A)
Date :
8 BIT ADDITION
AIM:
To write a program to add two 8-bit numbers using 8051 microcontroller.
ALGORITHM:
RESULT:
Thus the 8051 ALP for addition of two 8 bit numbers is executed.
96
OUTPUT: SUBTRACTION
INPUT OUTPUT
DATA
97
Ex.No.: 13(B)
Date :
8 BIT SUBTRACTION
AIM:
To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
a. Clear the carry flag.
b. Initialize the register for borrow.
c. Get the first operand into the accumulator.
d. Subtract the second operand from the accumulator.
e. If a borrow results increment the carry register.
Store the result in memory. 8 Bit
Subtraction (Immediate Addressing)
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 CLR C C3 Clear CY flag
RESULT:
Thus the 8051 ALP for subtraction of two 8 bit numbers is executed.
98
OUTPUT: 8Bit Multiplication
INPUT OUTPUT
DATA
100
Ex.No.: 13(C)
Date :
8 BIT MULTIPLICATION
AIM:
To perform multiplication of two 8 bit data and store the result in memory.
ALGORITHM:
a. Get the multiplier in the accumulator.
b. Get the multiplicand in the B register.
c. Multiply A with B.
d. Store the product in memory.
8 Bit Multiplication
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 MOV A ,#data1 74, data1 Store data1 in
Accumulator
4102 MOV B, #data2 75,data2 Store data2 in B reg
RESULT
Thus the 8051 ALP for multiplication of two 8 bit numbers is executed.
101
OUTPUT: 8bit Division
INPUT OUTPUT
DATA
102
Ex.No.: 13(D)
Date :
8 BIT DIVISION
AIM:
To perform division of two 8 bit data and store the result in memory.
ALGORITHM:
1. Get the Dividend in the accumulator.
2. Get the Divisor in the B register.
3. Divide A by B.
4. Store the Quotient and Remainder in memory.
8 Bit Division
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 MOV A, # data1 74,data1 Store data1 in
accumulator
4102 MOV B, # data2 75,data2 Store data2 in B reg
RESULT:
Thus the 8051 ALP for division of two 8 bit numbers is executed.
103
OUTPUT: SQUARE
OUTPUT
MEMORY LOCATION DATA
4500
OUTPUT: CUBE
OUTPUT
MEMORY LOCATION DATA
4500
104
Ex.No.: 14(A)
Date :
PROGRAM TO FIND SQUARE AND CUBE OF A NUMBER
AIM :
To write an assembly language program to find square and cube of a number using 8051.
APPARATUS REQUIRED:
8051 Microprocessor Kit
ALGORITHM:
1. Store the eight bit number x in A, rO & B registers.
2. Multiply A and B registers to obtain the square (say SQH:SQL) of the number x
3. Check if bit 01 is set If set go to end (storing the result), else do the cube operations.
4. The high pail of the square result (SQH) is stored on the stack.
5. Multiply the low part of the square result (SQL) with x (partial cube result).
6. Store the low part of the above result at 9001H & the high part in R2.
7. Retrieve the high part of the square result (SQH) stored on the stack & multiply with x.
8. Add the low part of the above result (SQH*X) with R2 and store in 9002H.
9. Add the high part (SQH*X) with the resulting carry and store in 9003.
PROGRAM: SQUARE:
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 MOV A ,#02 7402 Store data1 in
Accumulator
4102 MOV B, A F5F0 Store data2 in B reg
105
CUBE:
HEX
ADDRESS LABEL MNEMONIC CODE COMMENTS
4105 MUL AB A4
410B MUL AB A4
4114 MOVX F0
@DPTR,A
4115 STOP SJMP 4115 80FE
106
RESULT:
Thus the Assembly Language Program to find square and cube of a given number using 8051 has
been performed and the result is stored.
107
OUTPUT: 2’S COMPLEMENT OF A NUMBER USING 8051
INPUT OUTPUT
MEMORY 4101 4200
DATA
108
Ex.No.: 14(B)
Date :
2’S COMPLEMENT OF A NUMBER USING 8051
AIM :
PROCEDURE:
1) Enter the opcodes and the data in the trainer.
2) Execute the program and check for results.
3) Change data and check for the corresponding results.
RESULT:
Thus the assembly language program for obtaining 2’s complement of a number has been
given.
109
Ex.No.: 15
Date :
ALGORITHM:
1. Get unpacked BCD number into accumulator
2. OR it with 30H to get ASCII number
3. Display it at PO.
PROGRAM:
ORG 00
SJMP START
MOV B,A
ANL A,#0FH
ADD A,#30H
MOV R0,A
MOV A,B
ANL A,#F0H
SWAP A
ADD A,#30H
MOV R1,A
MOV DPTR,#4500
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
SJMP HERE
RESULT:
Thus the Assembly Language Program to convert unpacked BCD to ASCII code conversion
using 8051 has been performed and the result is stored.
111