MP and MC Lab Manual Eee PDF
MP and MC Lab Manual Eee PDF
MP and MC Lab Manual Eee PDF
Experiment No.1
EQUIPMENT REQUIRED:
1. TASM Software
2. PC with DOS and Debug program
ALGORITHM:
1. Define the values in data segment as per the addressing mode.
2. Initialize the data segment register with data segment address
3. Load the words as per the addressing mode and perform addition/
subtraction/ multiplication/ division and store the sum/
difference/product/quotient-remainder to the result address
4. Terminate the program
A. 16 BIT ADDITION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 1243 n1 dw 1243h
5 0002 4567 n2 dw 4567h
6 0004 ???? n3 dw ?
7 0006 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 A1 0000r mov ax,n1
16 0008 8B 1E 0002r mov bx,n2
17 000C 03 C3 add ax,bx
18 000E A3 0004r mov n3,ax
19 0011 BE 0004r lea si,n3
20 0014 CC int 3
21
22 0015 code ends
23 end start
1
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
B. 16 BIT SUBTRACTION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 FFFF n1 dw 0ffffh
5 0002 4567 n2 dw 4567h
6 0004 ???? n3 dw ?
7 0006 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 A1 0000r mov ax,n1
16 0008 8B 1E 0002r mov bx,n2
17 000C 2B C3 sub ax,bx
18 000E A3 0004r mov n3,ax
19 0011 BE 0004r lea si,n3
20 0014 CC int 3
21
22 0015 code ends
23 end start
C. 16 BIT MULTIPLICATION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 4444 n1 dw 4444h
5 0002 4567 n2 dw 4567h
6 0004 ???????? n3 dd ?
7 0008 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 A1 0000r mov ax,n1
16 0008 8B 1E 0002r mov bx,n2
17 000C F7 E3 mul bx
18 000E BE 0004r lea si,n3
19 0011 89 04 mov [si],ax
20 0013 89 54 02 mov [si+2],dx
2
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
21
22 0016 CC int 3
23
24 0017 code ends
25 end start
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 0444 n1 dw 0444h
5 0002 45 n2 db 45h
6 0003 ???? n3 dw ?
7 0005 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 A1 0000r mov ax,n1
16 0008 8A 1E 0002r mov bl,n2
17 000C F6 F3 div bl
18
19 000E A3 0003r mov n3,ax
20 0011 BE 0003r lea si,n3
21
22 0014 CC int 3
23
24 0015 code ends
25 end start
RESULT:
A. 16 BIT ADDITION
AX= 57AA & SI=0004 ; D 0004 0005 AA 57
B. 16 BIT SUBTRACTION
AX= BA98 & SI=0004 ; D 0004 0005 98 BA
C. 16 BIT MULTIPLICATION
AX= CB5C & SI=0004 ; D 0000 0005 44 44 67 45 5C CB
3
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
E. 16 BIT ADDITION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 0444 n1 dw 0444h
5 0002 4545 n2 dw 4545h
6 0004 ???? n3 dw ?
7 0006 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 BE 0000r lea si,n1
16 0008 BF 0002r lea di,n2
17 000B 8B 04 mov ax,[si]
18 000D 8B 1D mov bx,[di]
19 000F 03 C3 add ax,bx
20
21 0011 BD 0004r lea bp,n3
22 0014 89 46 00 mov [bp],ax
23
24
25
26 0017 CC int 3
27
28 0018 code ends
29 end start
4
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
F. 16 BIT SUBTRACTION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 AAAA n1 dw 0aaaah
5 0002 4545 n2 dw 4545h
6 0004 ???? n3 dw ?
7 0006 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 BE 0000r lea si,n1
16 0008 BF 0002r lea di,n2
17 000B 8B 04 mov ax,[si]
18 000D 8B 1D mov bx,[di]
19 000F 2B C3 sub ax,bx
20
21 0011 BD 0004r lea bp,n3
22 0014 89 46 00 mov [bp],ax
23
24
25
26 0017 CC int 3
27
28 0018 code ends
29 end start
RESULT:
E. 16 BIT ADDITION
AX= 4989 , SI=0000 , DI=0002, BP=0004
D 0004 0005 89 49
F. 16 BIT SUBTRACTION
AX= 65 65 , SI=0000 , DI=0002, BP=0004 D 0004 0005 65 65
5
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
G. 16 BIT ADDITION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 5AAA n1 dw 5aaah
5 0002 4545 n2 dw 4545h
6 0004 ???? n3 dw ?
7 0006 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 A1 0000r mov ax,n1
16 0008 03 06 0002r add ax,n2
17 000C A3 0004r mov n3,ax
18 000F BE 0004r lea si,n3
19
20 0012 CC int 3
21
22 0013 code ends
23 end start
H. 16 BIT SUBTRACTION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 5AAA n1 dw 5aaah
5 0002 4545 n2 dw 4545h
6 0004 ???? n3 dw ?
7 0006 data ends
8
9 0000 code segment
10
11 0000 start:
12 0000 B8 0000s mov ax,data
13 0003 8E D8 mov ds,ax
14
15 0005 A1 0000r mov ax,n1
16 0008 2B 06 0002r sub ax,n2
17 000C A3 0004r mov n3,ax
6
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT:
G. 16 BIT ADDITION
AX= 9FEF , SI=0004 ; D 0004 0005 EF 9F
H. 16 BIT SUBTRACTION
AX= 6565 , SI=0004 ; D 0004 0005
7
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
J. 16 BIT SUBTRACTION
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 ???? n3 dw ?
5 0002 data ends
6
7 0000 code segment
8
9 0000 start:
10 0000 B8 0000s mov ax,data
11 0003 8E D8 mov ds,ax
12
13 0005 B8 ABCD mov ax,0abcdh
14 0008 2D 7893 sub ax,7893h
15 000B A3 0000r mov n3,ax
16 000E BE 0000r lea si,n3
17
18 0011 CC int 3
19
20 0012 code ends
21 end start
RESULT:
I. 16 BIT ADDITION
AX= DDEE , SI=0000 ; D 0000 0001 EE DD
J. 16 BIT SUBTRACTION
AX= 333A , SI=0000 ; D 0000 0001 3A 33
VIVA QUESTIONS:
8
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
9
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.2
A. ASCENDING ORDER
EQUIPMENT REQUIRED:
1. TASM Software
2. PC with DOS and Debug program
ALGORITHM:
1. Define the values in data segment
2. Initialize the data segment register with data segment address
3. Clear the various registers
4. Initialize outer counter for arranging the given numbers
5. Initialize inner counter for performing comparisons
6. Compare the first two values, if carry is generated then continue for next values
7. Otherwise, exchange both values and continue for next values
8. Continue from step 5 till the count is zero.
9. Terminate the program
PROGRAM:
1 assume cs:code,ds:data
2 0000 data segment
3
4 0000 0198 0135 0234 0098 n1 dw 198h,135h,234h,098h
5 0008 0A*(0000) res dw 10 dup(0)
6 =0003 count equ 3
7
8 001C data ends
9 0000 code segment
10 0000 start:
11 0000 B8 0000s mov ax,data
12 0003 8E D8 mov ds,ax
13
14 0005 33 C0 xor ax,ax
15 0007 33 D2 xor dx,dx
16 0009 33 C9 xor cx,cx
17
18 000B BA 0003 mov dx,count
19 000E B9 0003 x1:mov cx,count
20 0011 BE 0000r lea si,n1
10
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT:
AX=0234 , SI=0000
D 0000 0007 98 00 35 01 98 01 34 02
B. DESCENDING ORDER
EQUIPMENT REQUIRED:
1. TASM Software
2. PC with DOS and Debug program
ALGORITHM:
1. Define the values in data segment
2. Initialize the data segment register with data segment address
3. Clear the various registers
4. Initialize outer counter for arranging the given numbers
5. Initialize inner counter for performing comparisons
6. Compare the first two values, if no carry is generated then continue for next
values
7. Otherwise, exchange both values and continue for next values
8. Continue from step 5 till the count is zero.
9. Terminate the program
11
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
PROGRAM:
1 assume cs:code,ds:data
2 0000 data segment
3
4 0000 0198 0135 0234 0098 n1 dw 198h,135h,234h,098h
5 0008 0A*(0000) res dw 10 dup(0)
6 =0003 count equ 3
7
8 001C data ends
9 0000 code segment
10 0000 start:
11 0000 B8 0000s mov ax,data
12 0003 8E D8 mov ds,ax
13
14 0005 33 C0 xor ax,ax
15 0007 33 D2 xor dx,dx
16 0009 33 C9 xor cx,cx
17
18 000B BA 0003 mov dx,count
19 000E B9 0003 x1:mov cx,count
20 0011 BE 0000r lea si,n1
21 0014 8B 04 mov ax,[si]
22 0016 3B 44 02 x:cmp ax,[si+2]
23 0019 73 05 jnc l1
24 001B 87 44 02 xchg ax,[si+2]
25 001E 89 04 mov [si],ax
26 0020 46 l1:inc si
27 0021 46 inc si
28 0022 8B 04 mov ax,[si]
29 0024 E2 F0 loop x
30 0026 4A dec dx
31 0027 75 E5 jnz x1
32
33 0029 BE 0000r lea si,n1
34
35 002C CC int 3h
36 002D code ends
37 end start
RESULT:
AX=0098 , SI=0000
D 0000 0007 34 02 98 01 35 01 98 00
12
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
VIVA QUESTIONS:
1. Give the concept of Jump with return and jump with non return.
2. What are the flags that are effected by compare statement?
3. What is the Significance of inserting label in programming.
4. What is the Significance of int 3h.
5. What is the purpose of offset?
13
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.3
EQUIPMENT REQUIRED:
1. TASM Software
2. PC with DOS and Debug program
ALGORITHM:
1. Define the values in data segment
2. Initialize the data segment register with data segment address
3. Clear all the various registers
4. Initialize the counter for number of comparisons
5. Compare the input with the numbers in an array one at a time
6. If zero flag is set, display the message ‘number found’
7. If zero flag is not set even after all the comparisons i.e., till the count is zero then
display the message ‘number not found’
8. Terminate the program
PROGRAM:
1 assume cs:code,ds:data
2
3 0000 data segment
4 0000 12CD 3BCD 34CD n1 dw 12cdh,3bcdh,34cdh
5 0006 04CD n2 dw 04cdh
6 0008 70 61 73 73 77 6F 72+ msg1 db "number found
$"
7 64 20 66 6F 75 6E 64+
8 20 24
9 0018 70 61 73 73 77 6F 72+ msg2 db "number not
found $"
10 64 20 6E 6F 74 20 66+
11 6F 75 6E 64 20 24
12 =0003 count equ 3
13 002C data ends
14
15 0000 code segment
16 0000 start:
17 0000 B8 0000s mov ax,data
18 0003 8E D8 mov ds,ax
19 0005 33 C0 xor ax,ax
14
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT:
Input of 04cdh, the message password found is displayed.
Input of 2340h, the message password not found is displayed.
15
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.4
EQUIPMENT REQUIRED:
1. TASM Software
2. PC with DOS and Debug program
ALGORITHM:
1. Define the string to be displayed in data segment
2. Initialize the data segment register with data segment address
3. Initialize the source pointer to the starting address of defined string
4. Initialize the destination pointer to the location where the string is to be stored
5. Move the contents from the source to the destination till the ‘$’ (termination
character) is found
6. Display the string from the destination location
7. Terminate the program
PROGRAM:
1 assume cs:code,ds:data
2
3 0000 data segment
4
5 0000 20 68 65 6C 6C 6F 20+ msg db " hello everyone","$"
6 65 76 65 72 79 6F 6E+
7 65 24
8
9 0010 0A 0D 24 nline db 10,13,'$'
10
11 0013 28*(24) msg1 db 40 dup('$')
12
13 003B data ends
14
15
16
17 0000 code segment
18
19 0000 B8 0000s start:mov ax,data
20 0003 8E D8 mov ds,ax
16
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
21
22 0005 B4 09 mov ah,09h
23 0007 BA 0000r lea dx,msg
24 000A CD 21 int 21h
25
26 000C BE 0000r lea si,msg
27 000F BF 0013r lea di,msg1
28
29 0012 8A 04 l1: mov al,[si]
30 0014 3C 24 cmp al,'$'
31 0016 74 06 je l2
32 0018 88 05 mov [di],al
33 001A 46 inc si
34 001B 47 inc di
35 001C EB F4 jmp l1
36
37 001E B4 09 l2:mov ah,09h
38 0020 BA 0010r lea dx,nline
39 0023 CD 21 int 21h
40
41 0025 B4 09 mov ah,09h
42 0027 BA 0013r lea dx,msg1
43 002A CD 21 int 21h
44
45 002C B4 4C mov ah,4ch
46 002E CD 21 int 21h
47
48 0030 code ends
49 end start
VIVA QUESTIONS:
17
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
AIM : Program to reverse the string read from the keyboard and display
EQUIPMENT REQUIRED:
1. TASM Software
2. PC with DOS and Debug program
ALGORITHM:
1. Define the prompt messages to be displayed in data segment
2. Initialize the data segment register with data segment address
3. Use 0ah function to read the string from the keyboard
4. Initialize the source pointer to the end of the read string
5. Initialize the destination pointer to the location where the reversed string is to be
stored
6. Initialize the counter to the actual length of the entered string
7. Copy the contents from the source to the destination till the counter is zero
8. Display the reversed string
9. Terminate the program
PROGRAM:
1 assume cs:code,ds:data
2
3 0000 data segment
4
5 0000 20 65 6E 74 65 72 20+ msg db " enter the string : ","$"
6 74 68 65 20 73 74 72+
7 69 6E 67 20 3A 20 24
8
9 0015 str1 label byte
10 0015 14 strmax db 20
11 0016 ?? stract db ?
12 0017 0A*(24) strfld db 10 dup('$')
13
14 0021 0A 0D 24 nline db 10,13,'$'
15
16 0024 0A*(24) rev db 10 dup('$')
17
18 002E 20 74 68 65 20 72 65+ msg1 db " the reversed string is : " , "$"
19 76 65 72 73 65 64 20+
18
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
20 73 74 72 69 6E 67 20+
21 69 73 20 20 3A 20 24
22
23
24
25 004A data ends
26
27
28
29 0000 code segment
30
31 0000 B8 0000s start: mov ax,data
32 0003 8E D8 mov ds,ax
33
34 0005 B4 09 mov ah,09h
35 0007 BA 0000r lea dx,msg
36 000A CD 21 int 21h
37
38 000C B4 0A mov ah,0ah
39 000E BA 0015r lea dx,str1
40 0011 CD 21 int 21h
41
42 0013 B4 09 mov ah,09h
43 0015 BA 0021r lea dx,nline
44 0018 CD 21 int 21h
45
46 001A BE 0017r lea si,strfld
47 001D BF 0024r lea di,rev
48
49 0020 33 C9 xor cx,cx
50 0022 8A 0E 0016r mov cl,stract
51
52 0026 03 F1 add si,cx
53 0028 4E dec si
54
55
56
57 0029 8A 04 top: mov al,[si]
58 002B 88 05 mov [di],al
59 002D 47 inc di
60 002E 4E dec si
61 002F E2 F8 loop top
62
63
64 0031 B4 09 mov ah,09h
65 0033 BA 0021r lea dx,nline
19
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
VIVA QUESTIONS:
EQUIPMENT REQUIRED:
1. TASM Software
2. PC with DOS and Debug program
ALGORITHM:
1. Define the prompt messages to be displayed in data segment
2. Initialize the data segment register with data segment address
3. Use 0ah function to read the string from the keyboard
4. Initialize the source pointer to the end of the read string
5. Initialize the destination pointer to the location where the reversed string is to be
stored
20
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
PROGRAM:
1 assume cs:code,ds:data
2
3 0000 data segment
4
5 0000 65 6E 74 65 72 20 74+ msg db "enter the string","$"
6 68 65 20 73 74 72 69+
7 6E 67 24
8
9 0011 str1 label byte
10 0011 14 strmax db 20
11 0012 ?? stract db ?
12 0013 0A*(24) strfld db 10 dup('$')
13
14 001D 0A 0D 24 nline db 10,13,'$'
15
16 0020 0A*(24) rev db 10 dup('$')
17
18 002A 74 68 65 20 65 6E 74+ msg1 db "the entered string
is palindrome","$"
19 65 72 65 64 20 73 74+
20 72 69 6E 67 20 69 73+
21 20 70 61 6C 69 6E 64+
22 72 6F 6D 65 24
23 004B 74 68 65 20 65 6E 74+ msg2 db "the entered string
is not palindrome","$"
24 65 72 65 64 20 73 74+
25 72 69 6E 67 20 69 73+
26 20 6E 6F 74 20 70 61+
27 6C 69 6E 64 72 6F 6D+
28 65 24
29
30
31 0070 data ends
21
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
32
33
34
35 0000 code segment
36
37 0000 B8 0000s start: mov ax,data
38 0003 8E D8 mov ds,ax
39
40 0005 B4 09 mov ah,09h
41 0007 BA 0000r lea dx,msg
42 000A CD 21 int 21h
43
44 000C B4 09 mov ah,09h
45 000E BA 001Dr lea dx,nline
46 0011 CD 21 int 21h
47
48 0013 B4 0A mov ah,0ah
49 0015 BA 0011r lea dx,str1
50 0018 CD 21 int 21h
51
52 001A B4 09 mov ah,09h
53 001C BA 001Dr lea dx,nline
54 001F CD 21 int 21h
55
56 0021 B4 09 mov ah,09h
57 0023 BA 0013r lea dx,strfld
58 0026 CD 21 int 21h
59
60 0028 BE 0013r lea si,strfld
61 002B BF 0020r lea di,rev
62
63 002E 33 C9 xor cx,cx
64 0030 8A 0E 0012r mov cl,stract
65
66 0034 03 F1 add si,cx
67 0036 4E dec si
68
69 0037 8A 04 top: mov al,[si]
70 0039 88 05 mov [di],al
71 003B 47 inc di
72 003C 4E dec si
73 003D E2 F8 loop top
74
75
76 003F B4 09 mov ah,09h
77 0041 BA 001Dr lea dx,nline
22
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
23
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
VIVA QUESTIONS:
1. What is a palindrome?
2. Specify string instructions.
3. What is the syntax of compare string instruction?
4. What is the use of data segment in 8086 processor?
5. What is use of index registers?
24
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No. 5
A. A TO D CONVERTER
AIM: Write an ALP to convert the analog signal into its equivalent digital form.
EQUIPMENT REQUIRED:
1. 8086 kit
2. A to D converter interfacing card
3. Flat ribbon cable bus
4. Power supply to 8086 kit
5. Jumper.
b) This port B is read port of ADC while Pc1 (lower port C) is input while Pc4,5,6
(upper port C) is output commands.
INTERFACING CIRCUIT:
25
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
ADC 0808:
* The ADC chips 0808 are 8 bit CMOS, successive approximation converters.
Block diagram of ADC
26
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
These converters do not need any external zero (or) full scale adjustments as they
are already taken care of by internal circuits. These converters internally have a
3:8 analog multiplexer so that at a time 8 different analog inputs can be connected
to chips.
27
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
PROGRAM:
MOV AL, 81
MOV DX, 8807 ; Configuring ports as output ports except port C
OUT DX, AL
MOV AL, 00
MOV DX, 8803 ; Sending channel addr on port B
OUT DX, AL
MOV AL, 08
MOV DX, 8807 ; Generate ALE signal on PC3
OUT DX, AL
MOV AL, 09
MOV DX, 8803
OUT DX, AL ; Configure port B as input port
MOV AL, 0B
MOV DX, 8807; Set O/P enable signal high
OUT DX, AL
INT 3 ; TERMINATE
RESULT: When potentiometer was in minimum position the digital output is 00 and
when maximum output at AL is FF.
28
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
VIVA QUESTIONS:
29
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
B. D TO A CONVERTER
AIM: Write an ALP to convert Digital data into its equivalent Analog Form.
a. Generate a Triangular waveform
b. Generate a Square waveform
EQUIPMENT REQUIRED:
1. 8086 kit
2. D to A converter interfacing card
3. Flat ribbon cable-buses
4. Power supply to 8086 kit
5. CRO.
INTERFACING CIRCUIT:
DAC 0800:
30
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
FIGURE:
1. Initialization of 8255 by writing the control word into the control register
2. Load the accumulator with required data
3. Send the data out in the required way to generate the waveform through port A of
8255
4. Observe the desired output waveform in the CRO.
31
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
MOV AL, 80
MOV DX, 8807 ; Initialize the 8255 with control word
OUT DX, AL
EXPECTED GRAPH
FF--
00 t
MOV AL,80
MOV DX,8807 ; Initialize the 8255 with control word
OUT DX,AL
32
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
EXPECTED GRAPH
FF
00
t
RESULT:
Observed the generated triangular waveform & square waveform in CRO.
VIVA QUESTIONS:
1. Explain the difference between the near call and the far call
2. Explain the generation technique to convert Digital signal into Analog form.
3. Compare R-2R ladder method to Weighted resister method
1. Explain about the specifications of DAC
2. How the DAC are interfaced with processor
3. What is meant by resolution of DAC
4. What is meant by settling time
5. Define linearity, accuracy for DAC
6. Give some applications of DAC
7. What is the importance of Op-amp in DAC
33
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No. 6
EQUIPMENT REQUIRED:
1. 8086 microprocessor trainer kit
2. Stepper motor interfacing module
3. Flat ribbon cable bus
4. Keyboard
5. Power chord
INTERFACING CIRCUIT:
34
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Stepper motors are very useful electro –mechanical transducers for position control. They
are used in a number of industrial control applications.
The dual stepper motor interface designed to be used with ALS-SDA-86 can
simultaneously control two stepper motors. It can be used to control single phase, two
phase , three phase and four phase indigenous and imported stepper motors.
The interface is designed with high speed switching Darlington transistors with MAX
1A, 80V rating with appropriate heat sinks. These switches are driven through open
collector TTL buffers which interface the lines to the motor circuits. The logic power
and motor power are supplied directly to the interface .This allows the use of motors with
different input voltage ratings with same drive circuit .The interface is also provided with
current limiting circuits which protects the power devices against overload or accidental
voltages. The LEDs on the interface indicate the phases which are energized for easy
demonstration. There are suppression circuits which clamp the transient voltages to safe
limits during switching of phases. By suitable switch sequences the motor can be used in
three modes of operation:
a. One phase ON (medium torque)
b. Two phase ON (high torque )
c. Half stepping ( low torque )
The interface can be connected to the 8255 ports in 8086 trainer kit using 26 core flat
cable. In order to generate logic sequences conveniently using the Bit-Set/Reset facility
of port C in 8255, the interface uses port C signals to drive the switches.
Switching logic:
The stepping action is caused by sequential switching of supply to the two phases of the
motor.
Four step input sequence gives 1.8 degree (full) step function.
35
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
0 1 0 0=4
0 1 1 0=6
0 0 1 0=2
Eight step input sequence gives 0.9 degree (half) step function.
To change the directions follow the sequence from bottom to top. The step rate ( speed of
rotation ) is governed by the frequency of switching.
PROGRAM 1 :
36
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
2104 90 NOP
2105 90 NOP
2106 49 DEC CX
2107 75 FA JNZ L1
2109 C3 RET
PROGRAM 2 :
37
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
2104 90 NOP
2105 90 NOP
2106 49 DEC CX
2107 75 FA JNZ L1
2109 C3 RET
RESULTS:
VIVA QUESTIONS:
38
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.7
AIM: Program using arithmetic, logical and bit manipulation instructions of 8051.
EQUIPMENT REQUIRED:
1. 8051 Trainer kit
2. RS232 cable
3. Max 232 IC,
4. Keil µ Vision 3 software
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler
2. Load the two values into two registers
3. Perform the required operation using corresponding operator
4. End the program
PROGRAM:
A. ARITHMETIC OPERATIONS
ADDITION:
C:0X0000 7405 MOV A,#0X05
C:0X0002 74F005 MOV B(0XF0),#0X05
C:0X0005 25F0 ADD A,B(0XF0)
END
SUBSTRACTION:
C:0X0000 7405 MOV A,#0X05
C:0X0002 75F002 MOV B,B(0XF0),#0X02
C:0X0005 95F0 ADD A,B(0XF0)
END
MULTIPLICATION:
C:0X0000 7402 MOV A,#0X05
C:0X0002 74F003 MOV B(0XF0),#0X03
C:0X0005 AA MUL AB
END
DIVISION:
C:0X0000 7409 MOV A,#0X09
C:0X0002 75F003 MOV B(0XF0),#0X03
C:0X0005 84 DIV AB
END
39
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT:
ADDITION: A=05
SUBTRACTION:A=03
MULTIPLICATION:A=0F
DIVISION:A=03
B.LOGICAL OPERATIONS
OR LOGIC:
C:0X0000 7403 MOV A,#0X03
C:0X0002 74F002 MOV B(0XF0),#0X02
C:0X0005 45F0 ORL A,B(0XF0)
END
AND LOGIC:
C:0X0000 7404 MOV A,#0X04
C:0X0002 75F002 MOV B(0XF0),#0X02
C:0X0005 55F0 ANL A,B(0XF0)
END
XOR LOGIC:
C:0X0000 7404 MOV A,#0X04
C:0X0002 75F002 MOV B(0XF0),#0X02
C:0X0005 65F0 XRL A,B(0XF0)
END
RESULT:
OR LOGIC: A=03
AND LOGIC: A=00
XOR LOGIC: A=06
40
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
C:0X0002 14 SWAP A
END
RESULT:
ROTATE RIGHT:A=07
ROTATE RIGHT WITH CARRY:A=02
ROTATE LEFT:A=0A
ROTATE LEFT WITH CARRY:A=18
SWAP:A=80
VIVA QUESTIONS:
1.What are the types of instructions in 8051
2. Discuss the various bit manipulation instructions
3. Discuss the various arithmetic and logical instructions
41
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.8
EQUIPMENT REQUIRED:
1. 8051 Trainer kit
2. RS232 cable
3. Max 232 IC
4. Keil µ Vision 3 software
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Load the delay values into timer 0
3. Complement the port line and start timer
4. If timer is complete, complement the port line and again start the timer by
reloading values
5. This is repeated continuously
PROGRAM:
42
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT: As the timer 0 rolls over ,the port line p1.5 status toggles continuously.
B. PROGRAMMING COUNTER
AIM: Assuming that clock pulses are fed into pin T1,Write a program for counter 1 in
mode 2 to
count the pulses and display the state of the TL1 count on P2.
EQUIPMENT REQUIRED:
1. 8051 Trainer kit
2. RS232 cable
3. Max 232 IC
4. Keil µ Vision 3 software.
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Choose the counter mode for operation
3. Run the counter and it starts counting the pulses from T1 pin
4. If counter is stopped, the count value is displayed
5. This is repeated continuously
PROGRAM:
MOV TMOD, #01100000B ; counter 1, mode 2, C/T=1
; External pulses
MOV TH1 , #0 ;clear TH1
SETB P3.5 ; make T1 input
AGAIN : SETB TR1 ; start the counter
BACK : MOV A,TL1 ; get copy of count TL1
MOV P2,A ; display it on port2
JNB TF1, BACK ; keep doing it if TF=0
CLR TR1 ; stop the counter 1
CLR TF1 ; make TF=0
SJMP AGAIN ; keep doing it
RESULT:
The counter counts and displays the count value on port 2.
VIVA QUESTIONS:
1. What are the addresses of the two timers
2. What is the purpose of timers
3. What are the modes in which they work
4. What are the SFRs used to define modes for counters
5. What is the purpose of counters
6. What are the modes in which they work
7. What is the significance of gate bit in TMOD register.
43
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.9
AIM: Write a program to generate a square wave of 50 Hz frequency on pin P1.2. Use an
interrupt for timer 0. Assume the XTAL =11.0592 MHz.
EQUIPMENT REQUIRED:
1. 8051 Trainer kit
2. RS232 cable
3. Max 232 IC
4. Keil µ Vision 3 software
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Load the delay values into timer 0
3. Complement the port line and start timer
4. If timer is complete, the corresponding timer interrupt is generated, complement
the port line and again start the timer by reloading values
5. This is repeated continuously
PROGRAM:
ORG 0
LJMP MAIN
ORG 000BH ; ISR for timer0
CPL P1.2 ; complement p1.2
MOV TL0,#00 ;reload timer values
MOV TH0,#0DCH
RETI ; return from interrupt
ORG 30H ; main program for initialization
MAIN: MOV TMOD,#01H ;timer 0, mode 1
MOV TL0,#00H
MOV TH0,#0D2H
MOV IE,#82H ;enable timer 0 interrrupt
SETB TR0 ; start timer
HERE: SJMP HERE ; stay here until interrupted
END
44
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT:
The functionality of timer interrupts is verified.
EQUIPMENT REQUIRED:
1. 8051 Trainer kit
2. RS232 cable
3. Max 232 IC
4. Keil µ Vision 3 software
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Load the delay values into timer 0
3. Complement the port line and start timer
4. If an interrupt is generated, complement the port line and again start the timer by
reloading values
5. This is repeated continuously
PROGRAM:
ORG 000H
LJMP MAIN ;bypass interrupt vector table
;--ISR for hardware interrupt INT1 to turn on the LED
ORG 0013H ;INT1 ISR
SETB P1.3 ; turn on LED
MOV R3, #255 ; load counter
BACK: DJNZ R3, BACK ; keep LED on for a while
CLR P1.3 ; turn off the LED
RET1 ; return from ISR
;-- MAIN Program for initialization
ORG 30H
MAIN: MOV IE,#1000100B ; enable external INT1
HERE: SJMP HERE ; stay here until interrupted
END
45
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT:
The functionality of external interrups is verified.
EQUIPMENT REQUIRED:
1. 8051 Trainer kit
2. RS232 cable
3. Max 232 IC
4. Keil µ Vision 3 software
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Load the delay values into timer 0
3. Complement the port line and start timer
4. If timer is complete, complement the port line and again start the timer by
reloading values
5. This is repeated continuously
PROGRAM:
ORG 0
LJMP MAIN
ORG 23H
LJMP SERIAL ; Jump to serial interrupt ISR
ORG 30H
MAIN: MOV P1, #0FFH ; Make P1 an input port
MOV TMOD, #20H ; timer 1, mode 2(auto-reload)
MOV TH1, #0FDH ; 9600 baud rate
MOV SCON, #50H ; 8-bit, 1 stop, REN enabled
MOV IE, #10010000B ; enable serial interrupt
SETB TR1 ; Start timer 1
BACK: MOV A,P1 ; read data from port 1
MOV SBUF, A ; give a copy to SBUF
MOV P2, A ; send it to p2
SJMP BACK ; Stay in loop indefinitely
46
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
;
;----------------------------- Serial port ISR
ORG 100H
SERIAL: JB T,TRANS ; jump if T1 is high
MOV A, SBUF ; otherwise due to receive
CLR RI ; clear RI since CPU does not
RETI ; return from ISR
RESULT:
The functionality of serial i.e., transmit interrupt and receive interrupt is verified.
VIVA QUESTIONS:
1. What is the interrupt structure of 8051
2. What are the SFRs used with interrupts of 8051
3. What are the vector addresses of these interrupts.
4. What is the priority of interrupts
47
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.10
RxD ( P3.0)
10 12
RxD (P3.0) 0
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Compile it and dump the hex file as per the procedure given above.
3. Place this Microcontroller in the trainer kit and fix it properly.
4. Power up the trainer kit from the mains supply.
5. In order to establish communication between PC and Microcontroller, Serial
cable RS232 and Voltage converter MAX232 IC are used. This section is
available on the system board.
6. For serial communication, port 3(pins 10 and 11 of Microcontroller) are used as
reception and transmission pins respectively.
7. The pins 10 and 11 of Microcontroller are connected to the pins 12 and 11 of
MAX232 IC respectively.
8. Connect one end of the serial cable to the processor and the other end to the DB9
pin provided on the system board.
9. Check the connections before switching on the mains.
48
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
10. An LED is provided in the power supply section of the trainer kit to indicate if
the board is powered or not.
11. After the board is powered up , open the Hyperterminal window in the PC.
12. According to the program written in the Microcontroller, the characters entered
in the Hyperterminal window in the PC can be seen on the LCD display i.e., the
Microcontroller receives the data from PC.
PROGRAM:
ORG 00H
MOV TMOD,#20H ;TO SELECT TIMER 1 IN MODE 2(AUTO
RELOAD)
MOV SCON,#50H ; TO SELECT SERIAL COMMUNICATION IN
MODE 1
; AND RECEIVER ENABLE
MOV TH1,#0FDH ; TO SET THE BAUD RATE TO 9600
MOV DPTR,#MSG
BACK: CLR A
MOVC A,@A+DPTR ; TO LOAD THE MESSAGE INTO
ACCUMULATOR
; CHARACTER BY CHARACTER
JZ NEXT
ACALL TRANSMIT ; CALL SUBROUTINE FOR TRANSMISSION
INC DPTR
SJMP BACK
NEXT: SJMP NEXT ; TERMINATION OF THE PROGRAM
END
RESULT:
The data bytes is transmitted serially out and is displayed on hyper-terminal of PC.
49
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
B.SERIAL RECEPTION
EQUIPMENT REQUIRED:
1. 8051 Trainer kit
2. RS232 cable
3. Max 232 IC,
4. Keil µ Vision 3 software
RxD ( P3.0)
10 12
RxD (P3.0) 0
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Compile it and dump the hex file as per the procedure given above.
3. Place this Microcontroller in the trainer kit and fix it properly.
4. Power up the trainer kit from the mains supply.
5. In order to establish communication between PC and Microcontroller, Serial cable
RS232 and Voltage converter MAX232 IC are used. This section is available on
the system board.
6. For serial communication, port 3(pins 10 and 11 of Microcontroller) are used as
reception and transmission pins respectively.
7. The pins 10 and 11 of Microcontroller are connected to the pins 12 and 11 of
MAX232 IC respectively.
50
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
8. Connect one end of the serial cable to the processor and the other end to the DB9
pin provided on the system board.
9. Check the connections before switching on the mains.
10. An LED is provided in the power supply section of the trainer kit to indicate if
the board is powered or not.
11. According to the program written in the Microcontroller, the message can be seen
in the LCD display of the microcontroller kit.
PROGRAM:
ORG 00H
MOV DPTR,#CMD ;INITIALIZATION OF LCD COMMANDS
BACK1: CLR A
MOVC A,@A+DPTR
JZ NEXT
ACALL COMMAND
INC DPTR
SJMP BACK1
51
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
CMD: DB 38H,0EH,01H,06H,80H,0
END
RESULT:
The message received is displayed on the LCD screen of microcontroller kit.
VIVA QUESTIONS:
1. What are the SFRs used in UART mode of 8051
2. What are the modes in which serial communication can be done
3. How the baudrate are calculated in different serial communication modes of 8051
52
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.11
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
53
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
2. In order to display any message on the LCD, first the LCD should be initialized.
This is done by writing some commands in the programs. LCD contains both data
and commands.
3. 3 Pins for commands and 8 pins for data of LCD are connected to the
microcontroller port pins in the program.
4. Compile it and dump the hex file as per the procedure given above.
5. Place this microcontroller in the trainer kit and fix it properly.
6. Power up the trainer kit from the mains supply.
7. Now connect the Port 1(pins 1 to 8 of Microcontroller) to the data pins of LCD
provided on the system board using 8-pin connector.
8. Similarly connect the Port 2(pins 21, 22, 23 of microcontroller) to the command
pins of LCD provided on the system board using 3-pin connector.
9. Check the connections before switching on the mains.
10. An LED is provided in the power supply section of the trainer kit to indicate if the
board is powered or not.
11. After the board is powered up, the message will be displayed on the LCD.
12. According to the program written in the microcontroller, the message can be seen
on the LCD provided on the system board.
PROGRAM:
54
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
55
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
RESULT:
The message displayed on the LCD screen is observed.
VIVA QUESTIONS:
1. What LCD stands for and what is it principle
2. What is the advantage of LCD over LED
3. What are the applications of LCD
4. What is command mode and data mode of LCD
5. What are the various commands used in LCD.
56
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
Experiment No.12
57
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
PROCEDURE:
1. Write the assembly language program for this task in the keil compiler.
2. Compile it and dump the hex file as per the procedure given above.
3. Place this Microcontroller in the trainer kit and fix it properly.
4. Power up the trainer kit from the mains supply.
5. In order to establish communication between PC and Microcontroller, Serial
cable RS232 and Voltage converter MAX232 IC are used. This section is
available on the system board.
6. For serial communication, port 3(pins 10 and 11 of Microcontroller) are used as
reception and transmission pins respectively.
7. The pins 10 and 11 of Microcontroller are connected to the pins 12 and 11 of
MAX232 IC respectively.
8. Connect one end of the serial cable to the processor and the other end to the DB9
pin provided on the system board.
9. Check the connections before switching on the mains.
10. An LED is provided in the power supply section of the trainer kit to indicate if
the board is powered or not.
11. After the board is powered up , open the Hyperterminal window in the PC.
12. According to the program written in the Microcontroller, the characters entered in
the Hyperterminal window in the PC can be seen on the LCD display i.e., the
Microcontroller receives the data from PC.
PROGRAM:
58
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
59
4/1 EEE- Microprocessors and Microcontrollers Lab Manual Aurora’s Engineering College
ORG 300H
KCODE0: DB ‘0’,’1’,’2’,’3’ ; ROW 0
KCODE1: DB ‘4’,’5’,’6’,’7’ ; ROW 1
KCODE2: DB ‘8’,’9’,’A’,’B’ ; ROW 2
KCODE3: DB ‘C’,’D’,’E’,’F’ ; ROW 3
END
VIVA QUESTIONS:
60