Ec8681-Microprocessors and Microcontrollers Laboratory-1053372192-Cse MPMC Lab Manual
Ec8681-Microprocessors and Microcontrollers Laboratory-1053372192-Cse MPMC Lab Manual
ANNE’S
COLLEGE OF ENGINEERING AND TECHNOLOGY
(Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai)
(An ISO 9001: 2015 Certified Institution)
ANGUCHETTYPALAYAM, PANRUTI – 607 106.
DEPARTMENT OF
COMPUTER SCIENCE ENGINEERING
LAB MANUAL
ALGORITHM:-
a) Addition:-
(i) Start the process
(ii) Initialize the count value
(iii) Get the two data.
(iv) Add the two data values
(v) If carry exists increment the count value.
(vi) Store the result.
(vii) Stop the process.
PROGRAM
OUTPUT
16 – BIT ADDITION
Address Output
1100 2B
1101 20
1102 00
1
16 BIT ADDITION
Start
If No
Carry
Yes
Stop
2
1 B) 16 BIT SUBTRACTION
ALGORITHM:-
PROGRAM
16 – BIT SUBTRACTION
3
FLOWCHART:-
Subtraction:-
Start
If No
Carry
exists
Yes
Stop
4
1.C) 16 BIT MULTIPLICATION
ALGORITHM:-
(i) Start the process
(ii) Get the two values
(iii) Multiply the two values.
(iv) Store the result and overflow
(v) Stop the process.
PROGRAM
INPUT OUTPUT
5
FLOW CHART:-
Multiplication:-
Start
Stop
6
D) 16 BIT DIVISION
AIM:
To perform division of a 32 bit number by a 16 bit number and store the quotient and
remainder in memory
ALGORITHM:-
(i) Start the process
(ii) Get the two values
(iii) Initialize „DX‟ register as zero
(iv) Divide the values
(v) Store the quotient and remainder
(vi) Stop the process.
FLOWCHART:
7
D) 16 BIT DIVISION
PROGRAM
16 – BIT DIVISIION
RESULT:-
Thus the assembly language program for 16 Bit Arithmetic and Logical operations has been done
and verified.
8
VIVA QUES TIONS AND ANSWERS
1. What is a Microprocessor?
Microprocessor is a CPU fabricated on a single chip, program-controlled device, which fetches
the instructions from memory, decodes and executes the instructions.
9
2. PROGRAM FOR SEARCHING AND SORTING OF AN ARRAY USING 8086
10
SORTING IN ASCENDING ORDER
Start
Yes
Compare next element of array Stop
with AL
Is No
CF = 1?
Yes
11
PROGRAM
RESULT:
Thus the assembly language program to sort an array of data in ascending order using 8086
has been done and verify successfully.
12
b. SORTING AN ARRAY IN DESCENDING ORDER
AIM:-
Write an assembly language program to sort an array of data in descending order.
ALGORITHM:-
1. Set SI register as pointer for array.
2. Set CL register as count for N – 1 repetitions.
3. Initialize array pointer.
4. Set CH as count for N – 1 comparisons.
5. Increment the array pointer.
6. Get an element of array AL register.
7. Increment the array pointer.
8. Compare the next element of the array with AL.
9. Checks carry flag. If carry flag is set then go to step -12, otherwise go to next step.
10. Exchange the content of memory pointed by SI and the content of previous memory location
(For this, exchange AL and memory pointed by SI, and then exchange AL and memory pointed
SI – I).
11. Decrement the count for comparisons (CH register).
12. Check zero flag. If zero flag is reset then go to step-6, otherwise go to next step.
13. Decrement the count for repetitions‟ (CL register).
14. Check zero flag. If zero flag is reset then go to step-3, otherwise go to next step.
15. Stop.
13
SORTING IN DESCENDING ORDER
Start
Yes
Compare next element of array Stop
with AL
No
Is
CF = 0?
Yes
14
PROGRAM
RESULT:
Thus the assembly language program to sort an array of data in descending order using 8086
has been done and verify successfully.
15
2 C . SEARCHING FOR SMALLEST NUMBER IN AN ARRAY
AIM:-
Write an assembly language program to search the smallest data in an array.
ALGORITHM:
1. Load the staring address of the array in SI register.
2. Load the address of the result in DI register.
3. Load the number of bytes in the array in CL register.
4. Increment the array pointer (SI register).
5. Get the first byte of the array in AL register
6. Decrement the byte count (CL register).
7. Increment the array pointer (SI register).
8. Get next byte of the array in BL register.
9. Compare current smallest (AL) and next byte (BL) if the array.
10. Check carry flag. If carry flag is set then go to step -12, otherwise go to next step.
11. Move BL to AL.
12. Decrement the byte count (CL register).
13. Check zero flag. If zero flag is reset then go to step-7, otherwise go to next step.
14. Save the smallest data in memory pointed by DI.
15. Stop.
16
FLOWCHART
Start A
Yes
Store AL in me mory
Incre ment array pointer (SI)
Stop
Get the first byte of array in AL register
Yes Is
CF = 1?
MoveNo BL to AL
A
17
PROGRAM
Label Address Mnemonics Hex code Comments
Opcode Operand
ST ART 1000 MOV SI, 1100H C7 C6 00 11 ; Set SI register as pointer for array
1004 MOV DI, 1200H C7 C7 00 12 ; Set DI register as pointer for result
1008 MOV CL, [SI] 8A 0C ; Set CL as count for elements in the array
100A INC SI 46 ; Increment the address pointer
100B MOV AL, [SI] 8A 04 ; Set first data as smallest
100D DEC CL FE C9 ; Decrement the count
AGAIN 100F INC SI 46 ; Make SI to point to next data in array
1010 MOV BL, [SI ] 8A 1C ; Get the next data in BL register
1012 CMP AL, BL 38 D8 ; Compare current smallest data in AL
; with BL
1014 JC AHEAD 72 02 ; If carry is set then AL is less than BL
; hence proceed to AHEAD
1016 MOV AL, BL 88 D8 ; If carry is not set then make BL as
; current smallest
AHE AD 1018 DEC CL FE C9 ; Decrement the count
101A JNZ AGAIN 75 F3 ; If count is not zero repeat search
101C MOV [DI], AL 88 05 ; Store the smallest data in memory
101E HLT F4
RESULT:
Thus the assembly language program for smallest data in an array using 8086 has been done
and verify successfully.
18
2D). SEARCHING FOR LARGEST NUMBER IN AN ARRAY
AIM:-
Write an assembly language program to search the largest data in an array.
ALGORITHM:
1. Load the staring address of the array in SI register.
2. Load the address of the result in DI register.
3. Load the number of bytes in the array in CL register.
4. Increment the array pointer (SI register).
5. Get the first byte of the array in AL register
6. Decrement the byte count (CL register).
7. Increment the array pointer (SI register).
8. Get next byte of the array in BL register.
9. Compare current smallest (AL) and next byte (BL) if the array.
10. Checks carry flag. If carry flag is set then go to step -12, otherwise go to next step.
11. Move BL to AL.
12. Decrement the byte count (CL register).
13. Check zero flag. If zero flag is reset then go to step-7, otherwise go to next step.
14. Save the largest data in memory pointed by DI.
15. Stop.
19
FLOWCHART:
Start
Is Yes
CF = 0?
Set DI register as result pointer
No
No
Decrement the byte count
Store AL in me mory
20
PROGRAM
Largest
Address Input
1100 05 – count
1101 22
1102 AA
1103 FF
1104 45
1105 50
Address Output
1200 FF
RESULT:
Thus the assembly language program for largest data in an array using 8086 has been done
and verify successfully.
21
VIVA QUES TIONS AND ANSWERS
22
3. PROGRAM FOR STRING MANIPULATION OPERATIONS USING 8086
AIM:-
To write a program for string manipulation such as fill a byte, move a string; compare the string by
using 8086 microprocessor kit.
ALOGRITHM:
a) Move the string:
Step1: Start the process
Step5: If the two value are equal set the carry otherwise reset
c) Fill a Byte:
23
Move the String:
START
IF No
Ze ro
Yes
STOP
24
3a) Move the String:
PROGRAM:
Label Address Mnemonics He x c ode Comments
Opcode Operand
1000 MOV SI, 1100 C7, C6, 00, 11 Initialize the memory
1004 MOV DI,1200 C7, C7, 00, 12 Initialize the memory
1008 MOV CX, 0005 C7, C1, 05, 00 Initialize the counter
100C CLD FC Clear the direction flag
L OOP1: 100D MOVSB A4 Store the result of string
100E LOOP L OOP1 E2, FD Go to LOOP L1
1010 HLT F4 Stop the process.
Observation:
25
Compare the String:
START
If Yes
equal
No
Set Set
Zero F lag = 0 zero Flag = 1
STOP
26
3b) Compare the String:
PROGRAM
Address Input
Address Input
1200 11
1201 12 1300 11
1202 13 1301 12
1203 14 1302 13
1204 15 1303 14
1304 15
Address Output
1400 01
1401 00
27
Fill a Byte:
START
STOP
28
3c) Fill a Byte
PROGRAM
Label Address Mnemonics Hex code Comments
Opcode Operand
1000 CLD FC Clear the direction flag
1001 MOV DX, 0005 C7, C2, 05, 00 Initialize the counter
1005 MOV AL,1F C6, C0,1F Get the value of byte
1008 MOV DI,1200 C7, C7, 00, 12 Initialize the memory
L OOP1: 100C STOSB AA Store the value
100D LOOP LOOP1 E2, FD Loop L1
100F HLT F4 Stop the process
RESULT:
Thus the operation of string manipulation is done and verified using 8086 microprocessor.
29
VIVA QUES TIONS AND ANSWERS
2. What is Assembler?
The assembler translates the assembly language program text which is given as input to the
assembler to their binary equivalents known as object code.
30
4. CODE CONVERSION, DECIMAL ARITHMETIC AND MATRIX OPERATIONS
Algorithm:
1. Load the number to be converted into the accumulator.
2. If the number is less than 100 (64H), go to next step; otherwise, subtract 100 (64H)
repeatedly until the remainder is less than 100 (64H). Have the count(100‟s value) in
separate register which is the carry.
3. If the number is less than 10 (0AH), go to next step; otherwise, subtract 10 (0AH)
repeatedly until the remainder is less than 10 (0AH). Have the count(ten‟s value) in
separate register.
4. The accumulator now has the units.
5. Multiply the ten‟s value by 10 and add it with the units.
6. Store the result and carry in the specified memory location.
31
FLOWCHART:
START
Divide A by B
Divide A by 10D
Stop
32
PROGRAM
33
MATRIX OPERATION
FLOW CHART:
START
AL = Increment Pointer
CL = CL – 1
IF
NO
CL -0
YES
Store result
STOP
34
4b. MATRIX OPERATIONS USING 8086
AIM:
To write a program for addition of two 3x3 matrix by using 8086.
ALGORITHM:
35
Address Input Address Input Address Output
1200 01 1300 12 1300 13
1201 02 1301 02 1301 04
1202 03 1302 04 1302 07
1203 04 1303 06 1303 0A
1204 05 1304 08 1304 0D
1205 06 1305 02 1305 08
1206 07 1306 04 1306 0B
1207 08 1307 06 1307 0E
1208 09 1308 03 1308 0C
.MODEL SMALL
.DATA
TAB DB 3,4,5,6,0
DB 1,4,5,7,0
DB 1,8,9,0,0
DB 1,8,9,2,0
DB 1,1,1,1,0
DB 0,0,0,0,0
TOTROWS DB 0
TOTCOLS DB 0
ROWS DB 5
COLS DB 4
.CODE
MOV AX,@DATA
MOV DS,AX
; COUNTING TOTAL ROWS
LEA SI,TAB
L1: MOV CX,4
L2: MOV AH,BYTE PTR[SI]
ADD TOTROWS ,
AH INC SI
36
LOOP L2
MOV AH,TOTROWS
MOV [SI],AH
MOV TOTROWS,0
INC SI
SUB ROWS,1
CMP ROWS,0
JG L1
RESULT:
Thus the matrix operation and code conversion were executed and verified successfully.
37
VIVA QUES TIONS AND ANSWERS
38
5. MOVE A DATA BLOCK WITHOUT OVERLAP
AIM:
To convert a given Move a data block without overlap using u086 MASM assembler and
8086 kit.
ALGORITHM:
1. Initialize the memory location to the data pointer.
2. Increment B register.
3. Increment accumulator by 1 and adjust it to decimal every time.
4. Compare the given decimal number with accumulator value.
5. When both matches, the equivalent hexadecimal value is in B register.
6. Store the resultant in memory location.
39
OBSERVATION:
INPUT:
1200 = 14H
1201 = 35H
1202 = 18H
1203 = 36H
1204 = 54H
OUTPUT:
1300 = 14H
1301 = 35H
1302 = 18H
1303 = 36H
1304 = 54H
40
PROGRAM
Move data block without ove rlap using 8086 MASAM Assemble r
RESULT:
Thus the program for moving the data block without overlap was executed and verified
using 8086 MASM assembler and 8086 kit.
41
VIVA QUES TIONS AND ANSWERS
42
6. PASSWORD CHECKING, PRINT RAM SIZE AND SYSTEM DATE
AIM:
To write an 8086 MASM assembler program for performing password checking, Print
RAM size and system date.
APPARATUS REQUIRED:
SL.NO ITEM QUANTITY
1. 8086 Microprocessor kit 1
2. Intel Desktop systems with MASM 1
3. RTC Interface board 1
PROGRAM:
6 A) PASSWORD CHECKING
; PASSWORD IS MASM1234
DATA SEGMENT
PASSWORD DB 'MASM1234'
LEN EQU ($-PASSWORD)
MSG1 DB 10,13,'ENTER YOUR PASSWORD: $'
MSG2 DB 10,13,'WELCOME TO ELECTRONICS WORLD!!$'
MSG3 DB 10,13,'INCORRECT PASSWORD!$'
NEW DB 10,13,'$'
INST DB 10 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS:
DATA START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV SI,00
UP1:
MOV AH,08H
INT 21H
CMP AL,0DH
43
JE DOWN
MOV [INST+SI],AL
MOV DL,'*'
MOV AH,02H
INT 21H
INC SI
JMP UP1
DOWN:
MOV BX,00
MOV CX,LEN
CHECK:
MOV AL,[INST+BX]
MOV DL,[PASSWORD+BX]
CMP AL,DL
JNE FAIL
INC BX
LOOP CHECK
LEA DX,MSG2
MOV AH,09H
INT 21H
JMP FINISH
FAIL:
LEA DX,MSG3
MOV AH,009H
INT 21H
FINISH:
INT 3
CODE ENDS
END START
END
******************
Password set Input
1240:16 (1)
1241:1E (2)
1242:26 (3)
1243:25(4)
1244:2E(5)
Output:
Enter the Password:
Type 12345
Message: 'WELCOME TO ELECTRONICS WORLD!!$'
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
44
6 B)DISPLAY MONTH/DAY/YEAR
.MODEL SMALL
.STACK 64
.DATA
Today
SAVEDAY DB ?
SAVEMON DB ?
TEN DB 10
ELEVEN DB 11
TWELVE DB 12
DAYSTAB DB ' SUNDAY, $ ', ' MONDAY, $ '
DB ' TUESDAY, $ ', ' WEDNESDAY, $ '
DB ' THURSDAY, $ ', ' FRIDAY, $ '
DB ' SATURDAY, $ '
MONTAB DB ' JANUARY $ ', ' FEBUARY $ ', ' MARCH $ '
DB ' APRIL $ ', ' MAY $ ', ' JUNE $ '
DB ' JULY $ ', ' AUGUST $ ', ' SEPTEMBER $ '
DB ' OCTOBER $ ', ' NOVEMBER $ ', ' DECEMBER $ '
CODE
BEGIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV ES,AX
MOV AX,0600H
CALL Q10SCR
CALL Q20CURS
MOV AH,2AH
INT 21H
MOV SAVEMON,DH
MOV SAVEDAY,DL
CALL B10DAYWK
CALL C10MONTH
CALL D10DAYMO
CALL E10INPT
CALL Q10SCR
45
MOV AX,4C00H
INT 21H
BEGIN E NDP
B10DAYWK PROC NEAR
MUL TWELVE
LEA DX,DAYSTAB
ADD DX,AX
MOV AH,09H
INT 21H
RET
B10DAYWK ENDP
C10MONTH PROC NEAR
MOV AL,SAVEMON
DEC AL
MUL ELEVEN
LEA DX,MONTAB
ADD DX,AX
MOV AH,09H
INT 21H
RET
C10MONTH ENDP
.386
D10DAYMO PROC NEAR
MOVZX AX,SAVEDAY
DIV TEN
OR AX,3030H
MOV BX,AX
MOV AH,02H
MOV DL,BL
INT 21H
MOV AH,02H
MOV DL,BH
INT 21H
RET
46
****************************
D10DAYMO ENDP
47
Observation:
Input
Set Date:
1206: 05 LSB
1207: 02 MSB(Date)
1208: 01LSB
1209: 00 MSB (Month)
120A:06 LSB
120B : 01 MSB (year)
Output:
The time is displayed as ; 23:59:55
The date is displayed as ; 25:01:16
After 5 seconds the date is displayed as
Date: 26:01:15 in VBMB 8 Kit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
48
6 C) RAM SIZE
ORG 0000H
CLR
CLR
CPL A
ADD A, #01H
MOV A,R3
AGAIN: SJMP AGAIN
********************************
Observation:
OUTPUT
“RAM SIZE IS 16 KB” is displayed in the LCD.
RESULT:
Thus the output for the Password checking, Print RAM size and system date was
executed and verified using MASM assembler successfully
49
VIVA QUES TIONS AND ANSWERS
50
7. COUNTERS AND TIME DELAY
AIM:
To write an assembly language program for up counter using 8086 kit and 8086 MASM
assembler.
APPARATUS REQUIRED:
PROCEDURE:
51
PROGRAM
UP COUNTER using 8086 kit
1000 EB 2F 10 START: CALL CONVERT
1003 E8 00 1D CALL DISPLAY
1006 B9 00 00 DELAY: MOV CX,0000H
1009 41 L1: INC CX
100A 81 F9 FF FF CMP CX,0FFFFH
100E 75 F9 JNZ L1
1010 BE 00 15 MOV SI,1500H
1013 8A 04 MOV AL,[SI]
1015 FE C0 INC AL
1017 88 04 MOV [SI],AL
1019 3C 64 CMP AL,064H
101B 75 E3 JNZ START
101D B0 00 MOV AL,00H
101F 88 04 MOV [SI],AL
1021 EB DD JMP START
1023 B4 06 DISPLAY: MOV AH,06H
1025 BA 00 16 MOV DX,1600H
1028 B5 01 MOV CH,01H
102A B1,00 MOV CL,00H
102C CD 05 INT 5
102E C3 RET
102F BE 00 15 CONVERT: MOV [SI],1500H
1032 BB 02 16 MOV BX,1602H
1035 B0 24 MOV AL,24H
1037 88 07 MOV [BX],AL
1039 8A 04 MOV AL,[SI]
103B B4 00 MOV AH,00H
103D B6 0A MOV DH,0AH
103F F6 F6 DIV DH
1041 80 C4 30 ADD AH,30H
1044 4B DEC BX
1045 88 27 MOV[BX],AH
1047 4B DEC BX
1048 04 30 ADD AL,30H
104A 88 07 MOV [BX],AL
104C 4B DEC BX
104D C3 RET
104E E4 02 GETC: IN AL,02H
1050 24 FF AND AL,0FFH
1052 3C F0 CMP AL,0F0H
1054 75 F8 JNE GETC
1055 F4 HLT
52
UP COUNTER using 8086 MASM assembler
MODEL SMALL
STACK 100H
DATA
PROMPT DB 'The counting from 0 to 9 is : $'
CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX
LEA DX, PROMPT ; load and print PROMPT
MOV AH, 9
INT 21H
MOV CX, 10 ; initialize CX
MOV AH, 2 ; set output function
MOV DL, 48 ; set DL with 0
@LOOP: ; loop label
INT 21H ; print character
INC DL ; increment DL to next ASCII character
DEC CX ; decrement CX
JNZ @LOOP ; jump to label @LOOP if CX is 0
MOV AH, 4CH ; return control to DOS
INT 21H
MAIN ENDP
END MAIN
RESULT:
Thus the program for up counter using 8086 MASM assembler was executed and verified
successfully
53
VIVA QUES TIONS AND ANSWERS
1. What is a RAM?
RAM is a random access memory wh ich is used to store data temporarily.
54
8. TRAFFIC LIGHT CONTROL
AIM:-
To write an assembly program for Traffic Light Control using 8086 LCD Microprocessor
Kit.
PROGRAM:
CNTRL EQU 26H
PORT A EQU 20H
PORT B E QU 22H
PORT C E QU 24H
55
1031 CAL L OUT E8 0F 00
1034 M OV AL,[SI] 8A 04
1036 OUT (PORTC)24,AL E6 24
1038 INC SI 46
1039 M OV AL,[SI] 8A 04
103B OUT (PORTA)20,,AL E6 26
OUT : 103D CAL L DELAY 1 E8 24 00
1040 J MP REPEAT E9 C2 FF
1043 M OV AL,[BX] 8A 07
1045 OUT (PORTC)24,AL E6 24
1047 INC BX 43
1048 M OV AL,[BX] 8A 07
104A OUT (PORTB)22,AL E6 22
104C INC BX 43
104D M OV AL,[BX] 8A 07
104F OUT (PORTA)20,AL E6 20
DE L AY: 1051 CAL L DELAY E8 01 00
A: 1054 RET C3
A1: 1055 M OV DI,00040H C7 C7 40 00
1059 M OV DX,0FFFFH C7 C2 FF FF
105D DE C DX 4A
105E JNZ A1 75 FD
1060 DE C DI 4F
DE L AY1: 1061 JNZ A 75 F6
B: 1063 RET C3
B1: 1064 M OV DI,00015H C7 C7 15 00
1068 M OV DX,0FFFFH C7 C2 FF FF
106C DE C DX 4A
106D JNZ B1 75 FD
106F DE C DI 4F
LOOK UP: 1070 JNZ B 75 F6
1072 RET C3
56
LABEL: 1073 DB 12H,27H,44H,10H
1077 2BH,92H,10H,9DH
107B 84H,48H,2EH,84H
107F DB 48H,6BH,20H,49H
1083 04
2. What is the name of the peri pheral device used to interface traffic light controller wi th microprocessor?
8255 PPI(Programmable peripheral Interface)
3. What is 8255?
It is PPI- Programmab le Peripheral Interface. it is used to connect I/O devices to microprocessor and supports parallel
communicat ion.
RESULT:
Thus the assembly language program for Traffic Light Control was executed and
verified using 8086 Microprocessor kit.
57
FLOW CHART:
START
Call delay
NO If
CL = 0
YES
58
9. STEPPER MOTOR CONTROL
AIM:-
APPARATUS REQUIRED:
i. Microprocessor kit
ii. Stepper Motor Interface Card
iii. Stepper motor
ALGORITHM:-
a. Start the program
b. Store lookup table value in DI register
c. Initialize counter register CL with 04H for lookup table value.
d. Get lookup table value in CL.
e. Call delay
f. If CL = 0, go to step1 otherwise get next lookup table value.
Lookup table:-
(Anti clockwise direction) (Clockwise direction)
1200 : 09 1200 : 0A
1201 : 05 1201 : 06
1202 : 06 1202 : 05
1203 : 0A 1203 : 09
59
PROGRAM:
Labe l Address Mnemonics Hex code Comments
Opc ode Operand
ST ART 1000 M OV DI,1200 C7,C7,00,12 ; Initialize lookup table
1004 M OV CL,04 C6,C1,04 ;Initialize count value
RE PE AT 1007 M OV AL,[DI] 8A 05 Get lookup table value
1009 OUT C0,AL E6 C0 ;Sent it to output port
100B M OV DX,1010H C7 C2 10 10 ;Delay program
DELAY 100F DE C DX 4A
1010 JNZ DELAY 75 FD
1012 INC DI 47 ;Increment [DI]
1013 L OOP REPEAT E2 F2 ;if CX 0, go to Repeat
1015 J MP START E9 E8 FF ;Repeat to start
RESULT:
Thus the assembly language program for speed control of stepper motor was executed and verified using
8086 Microprocessor kit.
60
10. DIGITAL CLOCK
AIM:-
To display the digital clock specifically by displaying the hours, minutes and seconds
using 8086 kits
PROGRAM:
Labe l Address Mnemonics Hex code Comments
Opcode Operand
ST ART : 1000 MOV AL,05H C6 C0 05
1003 OUT DE,AL E6 DE
1005 MOV AL,04H C6 C0 04
1008 OUT DE,AL E6 DE
100A MOV SI,1310H C7 C6 10 13
100E MOV AL,[SI] 8A 04
1010 OUT C0,AL E6 C0
1012 INC SI 46
1013 MOV AL,[SI] 8A 04
1015 OUT D0,AL E6 D0
1017 INC SI 46
1018 MOV AL,[SI] 8A 04
101A OUT C2,AL E6 C2
101C INC SI 46
101D MOV AL,[SI] 8A 04
101F OUT D2,AL E6 D2
1021 INC SI 46
1022 MOV AL,[SI] 8A 04
1024 OUT C4,AL E6 C4
1026 INC SI 46
1027 MOV AL,[SI] 8A 04
1029 OUT D4,AL E6 D4
L1: 102B MOV SI,1320H C7 C6 20 13
102F IN AL,D4H E4 D4
1031 AND AL,0FH 80 E0 0F
1034 MOV [SI],AL 88 04
1036 IN AL, C4H E4 C4
1038 AND AL,0FH 80 E0 0F
103B INC SI 46
103C MOV [SI],AL 88 04
103E IN AL, D2H E4 D2
1040 AND AL,0FH 80 E0 0F
1043 INC SI 46
1044 MOV [SI],AL 88 04
1046 IN AL, C2H E4 C2
1048 AND AL,0FH 80 E0 0F
104B INC SI 46
104C MOV [SI],AL 88 04
61
104E IN AL, D0H E4 D0
1050 AND AL,0FH 80 E0 0F
1053 INC SI 46
1054 MOV [SI],AL 88 04
1056 IN AL, C0H E4 C0
1058 AND AL,0FH 80 E0 0F
105B INC SI 46
105C MOV [SI],AL 88 04
OUT_CHECK: 105E MOV SI,1320H C7 C6 20 13
1062 MOV AL,[SI] 8A 04
1064 OUT E0,AL E6 E0
1066 INC SI 46
1067 MOV AL,[SI] 8A 04
1069 OUT F0,AL E6 F0
106B INC SI 46
106C MOV AL,[SI] 8A 04
106E OUT E2,AL E6 E2
1070 INC SI 46
1071 MOV AL,[SI] 8A 04
1073 OUT F2,AL E6 F2
1075 INC SI 46
1076 MOV AL,[SI] 8A 04
1078 OUT E4,AL E6 E4
107A INC SI 46
107B MOV AL,[SI] 8A 04
107D OUT F4,AL E6 F4
107F JMP L1 E9 A9 FF
1082 ENDS
Observation:
Input
1200 00
1201 00
1202 00
1203 00
1204 00
Output:
Time is displayed in the RTC board as
! Hour ŀ Minutes ŀ seconds ŀ
X 0 0 0 5 9
X 0 0 1 0 0
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.
62
VIVA QUESTIONS AND ANSWERS
4. Whether 7 segment displ ay used here is common anode or common cathode type.
63
11. KEY BOARD AND DISPLAY
AIM:-
To write an assembly language program to interfacing of 8279 with 8086.
APPARATUS REQUIRED:-
8086 Microprocessor kit
8279 interface board
ALGORITHM:-
(a) Rolling Dis play
Step1: Start the process
Step2: Initialize lookup table pointer, counter of keyboard display mode of 8279.
Step3: Initialize the prescalar counter and clear the display.
Step4: Get the seven segment display & carried it, in display RAM.
Step5: Increment the look up table pointer.
Step6: Decrement the counter until it becomes zero.
Step7: Stop the process.
(b) Accept a key and display it using 8279
Step1: Start the process
Step2: Set the data to set mode & display
Step3: Initialize the counter and clear the display RAM.
Step4: Write the display RAM command.
Step5: Clear the display RAM.
Step6: Decrement the counter value until it becomes zero.
Step7: Get the key data to be displayed.
Step8: Set the memory to need the FIFO RAM.
Step9: Get the corresponding code from look up table.
Step10: Store it is necessary.
Step11: Stop the process.
64
FLOW CHART:
(a) Rolling Display START
Clear display
NO If
Count =0
YES
STOP
65
PROGRAM:-
To Display „A‟
66
FLOW CHART:-
(b) Accept a key and display
START
Clear 8 x 8 display
Decrement counter
If
NO
Count =0
YES
YES If
Count =0
NO
Set memory to read FIFO RAM
Store it in memory
67
PROGRAM:- To Rolling Display (Display message is‟ HELP US‟)
Labe l Address Mnemonics Hex code Comments
Opcode Operand
ST ART 1000 MOV SI,1200 C7 C6 00 12 ; load lookup table
1004 MOV CX,000F C7 C1 0F 00
1008 MOV AL,10 C6C010 ;Display / keyboard
100B OUT C2,AL E6 C2 mode set
100D MOV AL,0CC C6 C0 CC ; Clear Display
1010 OUT C2,AL E6 C2
1012 MOV AL,90 C6 C0 90 ; Write display RAM
1015 OUT C2,AL E6 C2
NE XT : 1017 MOV AL,[SI] 8A 04 ; Get to be displayed
1019 OUT C0,AL E6 C0 character
101B CALL DELAY E8 E2 04 ;Call display program
101E INC SI 46
101F LOOP NEXT E2 F6
1021 JMP START E9 DC FF ;Repeat
68
VIVA QUES TIONS AND ANSWERS
69
12. PRINTER STATUS
AIM:
To write an assembly language program to print a message in printer using VBMB – 005
APPARATUS REQUIRED:
1. 8086 Microprocessor kit,
2. Power supply,
3. VBMB005 interfacing board.
4. Printer
70
(LOOK – UP - TABLE) ROUTINE TO INITIALISE PRINTER
1500 1501 1502 1503 1504 1505 1506
1B 47 09 09 09 1B 0E
1507 1508 1509 150A 150B 150C 150D
56 69 20 4D 69 63 72
150E 150F 1510 1511 1512 1513 1514
6F 73 79 73 74 65 6D
1515 1516 1517 1518 1519 151A 151B
73 0A 0A 09 09 09 09
151C 151D 151E 151F 1520 1521 1522
1B 78 01 44 45 4D 4F
1523 1524 1525 1526 1527 1528 1529
20 4F 46 0A 0A 09 09
152A 152B 152C 152D 152E 152F 1530
09 1B 78 00 1B 45 1B
1531 1532 1533 1534 1535 1536 1537
47 43 45 4E 54 52 4F
1538 1539 153A 153B 153C 153D 153E
4E 49 43 53 20 50 52
153F 1540 1541 1542 1543 1544 1545
49 4E 54 45 52 20 49
1546 1547 1548 1549 154A 154B 154C
00 4E 54 45 52 46 41
154D 154E 154F 1550 1551 1552 1553
43 45 20 42 4F 41 52
1554 1555 1556 1557 1558 1559 155A
44 2E 1B 48 1B 46 END
71
PROGRAM:
Label Address Mnemonics Hex code Comments
Opcode Operand
START: 1000 MOV CL,59H C6 C1 59
1003 MOV SI,1500H C7 C6 00 15
1007 MOV AL,05 C6 C0 05
100A OUT (CONTL)D0,AL E6 D0
100C IN AL,(STAT)C0 E4 C0
100E AND AL,20H 80 E0 20
1011 CMP AL,20H 80 F8 20
1014 JNZ ERR 75 3B
PROCE E D: 1016
1016 MOV AL,[SI] 8A 04
1018 CALL PRINT ; E8 0B 00
101B INC SI 46
101C DEC CL FE C9
101E JNZ PROCEED 75 F6
1020 MOV AL,0AH C6 C0 6A
1023 CALL PRINT E8 00 00
PRINT: 1026
1026 MOV BL,AL 88 C3
1028 CALL CHECK E8 12 00
STATUS: 102B
102B MOV AL,BL 88 D8
102D OUT (DATA)C8,AL E6 C8
102F MOV AL,01 C6 C0 01
1032 OUT (CONTL)D0,AL E6 D0
1034 NOP 90
1035 NOP 90
1036 NOP 90
1037 MOV AL,05H C6 C6 05
103A OUT (CONTL)D0,AL E6 D0
103C RET C3
CHE C K: 103D
103D IN AL,(STAT)C0 E4 C0
103F AND AL,20H 80 E0 20
1042 JZ CHECK 74 F9
1044 IN AL,(STAT)C0 E4 C0
1046 AND AL,80H 80 E0 80
1049 CMP AL,80H 80 F8 80
104C JNZ STATUS 75 DD
104E JMP CHECK E9 EC FF
ERR: 1051
1051 INT 2 CD 02
RESULT:
Thus the given message was printed in the printer using 8086 Microprocessor kit and
VBMB – 005.
72
VIVA QUES TIONS AND ANSWERS
73
13. SERIAL INTERFACE AND PARALLEL INTERFACE
AIM:
To write a program to send byte value from one microprocessor kit to other kit in serial
method by using 8251.
PROCEDURE:
1. Take two no of 8086 microprocessor kits.
2. Enter the Transmit program in Transmitter kit.
3. Enter the receive program in receiver kit.
4. Interface the two kits with 9-9 serial cable in the serial port of the microprocessor kits.
5. (LCD kit means pc-pc cable; LED kit means kit-kit cable)
6. Enter the Baud rate in Transmitter and the receiver kit
7. Enter the data in Transmitter kit use the memory location 1500.
8. Execute the receiver kit.
9. Execute the Transmitter kit.
10. Result will be available in receiver kit memory location 1500.
PROGRAM: TRANSMITTER SECTION:
74
Transmitte r Receiver
Address Input Address Output
1500 01
1500 01
1501 02
1501 02
1502 03
1502 03
1503 04
1503 04
1504 05
1504 05
75
RECEIVER SECTION:
RESULT:
Thus the program to send byte value from one microprocessor kit to other kit in
serial method by using 8251has been successfully verified.
76
VIVA QUES TIONS AND ANSWERS
2. What is USART?
The device which can be programmed to perform Synchronous or Asynchronous serial
communication is called USART (Universal Synchronous Asynchronous Receiver Transmitter).
The INTEL 8251A is an example of USART.
5. What are the control words of 8251A and what are its functions?
The control words of 8251A are Mode word and Command word.
The mode word informs 8251 about the baud rate, character length, parity and stop bits. The
command word can be send to enable the data transmission and reception.
6. What are the information that can be obtained from the status word of 8251?
The status word can be read by the CPU to check the readiness of the transmitter or receiver and to
check the character synchronization in synchronous reception. It also provides information
regarding various errors in the data received. The various error conditions that can be checked from
the status word are parity error, overrun error and framing error.
77
13b). PARALLEL COMMUNICATION BETWEEN TWO 8086
MICROPROCESSORS KITS
AIM:
To write a program to send data from one microprocessor kit to other kit in
parallel method by using mode1 and mode2 of 8255.
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 your getting 8 same data‟s.
8. Data is available in transmitter kit the memory location is 100f.
9. We will change the data & execute the following procedure & get the result in receiver kit.
PROGRAM: TRANSMITTER PROGRAM:
Label Address Mnemonics Hex code Comments
Opcode Operand
1000 MOV AL,82H C7,C0,82 : MOVE 82 to AL register
1003 OUT 26H,AL E6,26
1005 MOV AL,3FH C6,C0,3F : MOV 3F to AL register
1008 OUT 20H,AL E6,20
LOOP 100A IN AL,22H E4,22 : MOVE 22H to AI register
100C SUB AL,3FH 80,E8,3F
100F JNZ LOOP 75 F9 :JUMP LOOP
1011 MOV AL,24H C6,C0,24
1014 OUT 20H,AL E6,20
1016 CALL DELAY E8,02,00 :Call delay
1019 INT 02 C0,02
DEL AY 101B MOV BL,05H C6,C3,FF
LION 101E MOV DL,0FFH C6,C2,FF
LOOP2 1021 DEC DL FF,CA :Decrement CL
1023 JNZ LOOP2 75,F9 :JUMP Loop2
1025 DEC BL FE,CB
1027 JNZ LION 75,F4 :Jump on no zero to lion
1029 RET C3
7
78
Receiver
Address Output
1200 24
1201 24
1202 24
1203 24
1204 24
1205 24
1206 24
1207 24
79
RECEIVER PROGRAM:
Label Address Mnemonics Hex code Comments
Opcode Operand
1000 MOV AL,90H C7,C0,90 : MOVE 90 to AL register
1003 OUT 26H,AL E6,26 : MOV 20 to AL register
CHE CK 1005 IN Al,20H E4,20
1007 SUB AL,3FH 80,E8,3F : MOVE 3FH to AI register
100A JNZ CHECK 75F9
100C MOV AL,3FH C6,C0,3F
100F OUT 22H,AL E6,22
1011 MOV Cl, 08 C6,C1,08 : MOVE 08H to AI register
1014 CALL DELAY E8,12,00
1017 MOV SI, 1200 C7,C8,00,12
LOOP1 101B IN AL,20H E4,20
101D MOV [SI], AL 88,04
100F CALL DELAY E8,07,00 :Call delay
1022 INC SI 46
1023 DEC CL FE,C9
1025 JNZ LOOP1 75,F4
1027 INT 02 CD,02
DEL AY 1029 MOV BL, 05H C6,C3,05
LION 102C MOV DL, 0FFH C6,C2,FF
LOOP2 102F DEC DL FE,CA :Decrement CL
1031 JNZ LOOP2 75,FC ;JUMP LOOP2
1033 DEC BL FE,CB :Decrement BL
1035 JNZ LION 75,F5 :JUMP lion
1037 RET C3
1038 RET C3
RESULT;
Thus the program to sent data in parallel method from one microprocessor kit to another
using 8255 has been verified successfully.
80
VIVA QUES TIONS AND ANSWERS
1. Give some examples of port devices used in 8085 microprocessor based system?
The various INTEL I/O port devices used in 8085 microprocessor based system are 8212, 8155, 8156,
8255, 8355 and 8755.
81
14. A/D AND D/A INTERFACE AND WAVEFORM GENERATION
AIM:-
To write an assembly language program for interfacing of ADC with 8086.
ALGORITHM:-
82
FLOW CHART:
START
STOP
83
PROGRAM:
Jumper Details:-
From s witch CH3
B B
Software A CH0 A
SOC C ALE C CH6
From latch
Box
RESULT:
Thus the assembly language program for performing the interfacing of ADC with 8086 has
been done verified.
84
14b. INTERFACING OF DAC WITH 8086
AIM:-
To write an assembly language program to generate square, triangular and saw tooth and waveform
by interfacing of DAC with 8086.
ALOGRITHM:
85
(a) Square Waveform:-
Start
Initialize AL as „00‟
Display AL value
Move FF to AL
86
(b) Saw tooth Waveform:-
Start
Incre ment AL
Compare with FF
Yes If
Ze ro
exist
No
87
(c) Triangular Waveform:-
Start
Computer with FF
Yes
If
Carry
No
Move FF to AL
Display AL value
Decrement AL value
No If
Ze ro
Yes
88
(a) To gene rate square waveform
PROGRAM:
Labe l Address Mnemonics Hex code Comments
Opcode Operand
L OOP2 : 1000 MOV AL, 00 C6 C0 00 ; Set Logic 0 level
1003 OUT C8, AL E6 C8
1005 CALL Delay E8 0B 00 ;Generate timing delay
1008 MOV AL,0FF C6 C0 FF ;Set logic 1 level
100B OUT C8, AL E6 C8
100D CALL Delay E8 03 00 ; Generate timing delay
1010 JMP LOOP2 E9 ED FF :Repeat to generates Square Wave
De la y: 1013 MOV CX, 05FF C7 C1 FF 05 :Delay Program
LOOP3: 1017 LOOP LOOP3 E2 FE
1019 RET C3
PROGRAM:
Label Address Mnemonics Hex code Comments
Opcode Operand
L OOP2 : 1000 MOV AL, 00 C6 C0 00 ; Set logic 0 level
LOOP1: 1003 OUT C0, AL E6 C0
1005 INC AL FE C0 ;Increment Logic0 toLogic1
1007 JNZ LOOP1 75 FA ;If ZF=0, jump to next
1009 JMP LOOP2 E9 F4 FF ;Repeat
89
(c) To gene rate triangular waveform
PROGRAM:
Label Address Mnemonics Hex code Comments
Opcode Operand
L OOP3 : 1000 MOV BL, 00 C6 C3 00 ;Set logic 0
LOOP1: 1003 MOV AL, BL 88 D8 ;copy logic 0
1005 OUT C8, AL E6 C8
1007 INC BL FE C3 ; Increment logic0 to logic1
1009 JNZ LOOP1: 75 F8 ; If ZF=0, jump to next
100B MOV BL, 0FF C6 C3 FF Set logic 1
LOOP2: 100E MOV AL, BL 88 D8 ;copy logic 1
1010 OUT C8, AL E6 C8
1012 DEC BL FE CB ; Decrement logic0 tologic1
1014 JNZ LOOP2 75 F8 ; If ZF=0, jump to next
1016 JMP LOOP3 E9 E7 FF ;Repeat
RESULT:
Thus an assembly language program to generate square, triangular and saw tooth waveform was
done using DAC Interface and 8086 microprocessor kit.
90
VIVA QUES TIONS AND ANSWERS
4. Define stack
Stack is a sequence of RAM memory locations defined by the programmer.
91
15. BASIC ARITHMETIC AND LOGIAL OPERATIONS USING
8051
A. 8 BIT ADDITION
AIM:
ALGORITHM:
92
FLOW CHART:
Start
Clear PSW
Select Register
ADD A & R 0
Stop
93
PROGRAM:
Address Output
4500 1A(LSB)
4501 00(MSB)
RESULT:
Thus the 8051 Assembly Language Program for addition of two 8 bit numbers was
executed.
94
FLOW CHART:
Start
IS
CF=1
Stop
95
15B. 8 BIT SUBTRACTION
AIM:
To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
PROGRAM:
Address Output
4500 05
RESULT:
Thus the 8051 Assembly Language Program for subtraction of two 8 bit numbers was
executed.
96
FLOW CHART:
Start
Multiply A with B
Stop
97
15 C. 8 BIT MULTIPLICATION
AIM:
To perform multiplication of two 8 bit data and store the result in memory.
ALGORITHM:
Address Output
4500 0F(LSB)
4501 00(MSB)
RESULT:
Thus the 8051Assembly Language Program for multiplication of two 8 bit numbers was
executed.
98
FLOW CHART:
Start
Divide A by B
Stop
99
15 D. 8 BIT DIVISION
AIM:
To perform division of two 8 bit data and store the result in memory.
ALGORITHM:
PROGRAM:
Input Output
Memory Location Data Memory Location Data
4500 (dividend) 0F 4502 (re mainder) 05
4501 (divisor) 03 4503 (quotient) 00
RESULT:
Thus the 8051 8051Assembly Language Program for division of two 8 bit numbers was
executed.
100
FLOW CHART:
START
STOP
101
15 D. MASKING BITS IN AN 8 – BIT NUMBER
AIM:
To write an assembly language program to mask bits o and 7 of an 8 – bit
number and store the result in memory using 8051 microcontroller.
APPARATUS REQUIRED:
8051 microcontroller kit
ALGORITHM:
Masking bits in a 8 bit number
Start the process
Get the two data values
Get the second data
Logically „AND‟ the two data values.
Initialize the memory value and store the result in memory.
Start the process
PROGRAM:
Output
Memory Location Data
4500 06
RESULT:
Thus the 8051assembly language program for masking bits was executed and verified.
102
VIVA QUESTIONS AND ANSWERS
1. What is DPTR?
DPTR is a data pointer register in 8051 , which is of 2 bytes(16bits)....DPH,DPL
The port is a buffered I/O, wh ich is used to hold the data transmitted fro m the microprocessor to I/O device or
vice-versa.
103
a) 1‟s and 2‟s comple ment
START
STOP
104
16. SQUARE AND CUBE PROGRAM, FIND 2‟S COMPLIMENT OF A
NUMBER
AIM:-
To write an assembly language to perform arithmetic, logical and bit manipulation instruction using
8051.
ALOGRITHM:
a) 1‟s and 2‟s complement
105
1‟s and 2‟s complement
Output
Memory Location Data
4200 FD (1‟s complement
4201 F E(2‟S Complement)
Square of a number
Input Output
Memory Location Data Memory Location Data
4200 89 4201 51
4202 49
106
b) SQUARE PROGRAM FOR 8051
$MOD51
ORG 4100H
MOV DPTR,#4200H
MOVX A,@DPTR
MOV B,A
MUL AB
INC DPTR
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
L:SJMP L
*****************************************************************************
SWAP A
ANL A,#0F0H
MOV R6,A
MOV A,R0
SWAP A
ANL A,#0F0H
MOV R0,A
MOV A,R4
SWAP A
ANL A,#0FH
MOV R4,A
MOV B,R0
ADD A,B
MOV R4,A
MOV A,R1
SWAP A
MOV B,A
MOV A,R7
SWAP A
ANL A,#0FH
ADD A,B
MOV R0,A
MOV A,R6
MOV B,R2
ADD A,B
MOV R6,A
MOV A,R3
MOV B,R4
ADDC A,B
MOV R3,A
108
MOV A,R0
MOV B,R5
ADDC A,B
MOV R0,A
MOV DPTR,#4500H
MOV A,R6
MOVX @DPTR,A
INC DPTR
MOV A,R3
MOVX @DPTR,A
INC DPTR
MOV A,R0
MOVX @DPTR,A
L:SJMP L
Cube of a number
Input Output
Memory Location Data Memory Location Data
4200 89 4500 56
4501 3C
4502 27
RESULT:
Thus the assembly language program to find 2‟s complement, Square and cube of a number
was executed and verified successfully using 8051 microcontroller
109
VIVA QUES TIONS AND ANSWERS
110
17. UNPACKED BCD TO ASCII
AIM:
RESOURCES REQUIERED:
For example
111
Input Output
Memory Location Data Memory Location Data
4200 89 4201 39
4202 38
$MOD51
ORG 4100H
MOV DPTR,#4200H
MOVX A,@DPTR
MOV B,A
ANL A,#0FH
ADD A,#30H
MOV R0,A
MOV A,B
SWAP A
ANL A,#0FH
ADD A,#30H
MOV R1,A
INC DPTR
MOV A,R0
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
L:SJMP L
RESULT:
Thus the assembly language program to convert unpacked BCD to ASCII was executed and
verified successfully using 8051 microcontroller
112
VIVA QUES TIONS AND ANSWERES
ASCII stands for American Standard Code for Information Interchange. Below is the ASCII character table,
including descriptions of the first 32 characters .
113