MPMC
MPMC
ge
Poonamallee, Chennai – 600 123.
le
ol
DEPARTMENT OF ELECTRONICS & COMMUNICATION
C
ENGINEERING
g
in
er
ne
gi
En
ar
al
m
ni
Pa
VISION
ge
MISSION
le
M1: To provide best facilities, infrastructure and environment to its students, researchers and
faculty members to meet the Challenges of Electronics and Communication Engineering
ol
field.
C
M2: To provide quality education through effective teaching – learning process for their future
career, via placement and higher education.
g
M3: To expose strong insight in the core domains with industry interaction.
in
M4: Prepare graduates adaptable to the changing requirements of the society through life long
learning.
er
ne
PROGRAMME EDUCATIONAL OBJECTIVES
gi
1. To prepare graduates to analyze, design and implement electronic circuits and systems using
the knowledge acquired from basic science and mathematics.
En
2. To train students with good scientific and engineering breadth so as to comprehend, analyze,
design and create novel products and solutions for real life problems.
3. To introduce the research world to the graduates so that they feel motivated for higher studies
ar
and innovation not only in their own domain but multidisciplinary domain.
4. Prepare graduates to exhibit professionalism, ethical attitude, communication skills, teamwork
al
and leadership qualities in their profession and adapt to current trends by engaging in lifelong
m
learning.
5. To practice professionally in a collaborative, team oriented manner that embraces the
ni
PROGRAMME OUTCOMES
ge
modern Engineering IT tools including prediction and modeling to complex Engineering
activities with an understanding of the limitations.
le
6. The Engineer and society: Able to apply reasoning informed by the contextual knowledge to
ol
access societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional Engineering practice.
C
7. Environment and sustainability: Able to understand the impact of the professional
Engineering solutions in societal and environmental context, and demonstrate the knowledge
g
of, and need for sustainable development.
in
8. Ethics: Able to apply ethical principles and commit to professional ethics and responsibilities
er
and norms of the Engineering practice.
9. Individual and Team work: Able to function effectively as an individual, and as a member
ne
the Engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give and
En
the engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
al
12. Life – long learning: Able to recognize the needs for, and have the preparation and ability to
m
engage in independent and life-long learning in the broadest contest of technological change.
ni
1. Graduates should demonstrate an understanding of the basic concepts in the primary area of
Electronics and Communication Engineering, including: analysis of circuits containing both
active and passive components, electronic systems, control systems, electromagnetic
systems, digital systems, computer applications and communications.
2. Graduates should demonstrate the ability to utilize the mathematics and the fundamental
knowledge of Electronics and Communication Engineering to design complex systems which
may contain both software and hardware components to meet the desired needs.
3. The graduates should be capable of excelling in Electronics and Communication Engineering
industry/Academic/Software companies through professional careers.
ANNA UNIVERSITY SYALLABUS
OBJECTIVES
The student should be made to:
• Introduce ALP concepts and features
• Write ALP for arithmetic and logical operations in 8086 and 8051
ge
• Differentiate Serial and Parallel Interface
• Interface different I/Os with Microprocessors
le
• Be familiar with MASM
ol
LIST OF EXPERIMENTS:
C
8086 Programs using kits and MASM
1. Basic arithmetic and Logical operations
g
2. Move a data block without overlap
rin
3. Code conversion, decimal arithmetic and Matrix operations.
4. Floating point operations, string manipulations, sorting and searching
5. Password checking, Print RAM size and system date
ee
SOFTWARE:
Intel Desktop Systems with MASM - 30 no's
8086 Assembler
8051 Cross Assembler
1
OUTCOMES:
At the end of the course, the student should be able to:
• Write ALP Programmes for fixed and Floating Point and Arithmetic
• Interface different I/Os with processor
• Generate waveforms using Microprocessors
• Execute Programs in 8051
• Explain the difference between simulator and Emulator
ge
le
IIT KHARAGPUR
ol
CS43204 MICROPROCESSOR AND MICROCONROLLER LAB:
• Assembly and machine language programming
C
• signal generators
• Interfacing basic I/O devices like keypad
g
• LED display
rin
• Usage of timers and USART peripherals
• Multiport device access
ee
NIT TRICHY
ar
al
2
INTEL 8051(16 BIT MICROCONTROLLER)
• Detection of key closure(connected to port line) by polling technique
• Delay generation using (i) Nested loop and (ii) Timers
• Counting of external event occurrence through port line
• LCD interfacing
• Generation of different waveforms using DAC (0808)
ge
The course outcomes CO1 to CO5 satisfies Anna University syllabus. In order to
le
develop the programming skill of the students as per the industry expectations, experiments such
ol
as Interfacing seven segment display, LCD and DC motor with 8051 are done using
embedded C programming language. These experiments are included in the content beyond
C
syllabus. Students will be able to do projects and develop applications in real time environment.
g
rin - COURSE INSTRUCTORS
ee
in
E ng
ar
al
m
ni
Pa
3
LIST OF EXPERIMENTS
CYCLE I
ge
e. Logical operations
le
2. MOVE A DATA BLOCK WITHOUT OVERLAP
ol
3. CODE CONVERSION AND DECIMAL ARITHMETIC
a. BCD to hexadecimal conversion
C
b.Hexadecimal to BCD
g
c. Hexadecimal to ASCII
d.ASCII to Hexadecimal rin
4. MATRIX OPERATION
ee
5. STRING MANIPULATION
in
a. Copy a string
b.Reverse a string
ng
6. SORTING
E
7. SEARCHING
a. Search for a given data
al
CYCLE II
4
CYCLE III
ge
3. ONE’S AND TWO’S COMPLEMENT OF AN 8 BIT NUMBER
le
4. CODE CONVERSION
a. Unpacked BCD to ASCII
ol
C
CONTENT BEYOND SYLLABUS
1. Interfacing seven segment display with 8051
g
2. Interfacing LCD with 8051 rin
3. Interfacing DC Motor with 8051
ee
in
E ng
ar
al
m
ni
Pa
5
8086 MICROPROCESSOR
PIN DIAGRAM
ge
le
ol
C
g
rin
ee
in
Eng
ar
al
m
ni
Pa
6
ARCHITECTURAL DIAGRAM OF 8086
ge
le
ol
C
g
rin
ee
in
Eng
ar
al
m
ni
Pa
7
Review Questions:
ge
7. Give example for Non-Maskable interrupts?
le
8. What is the Maximum clock frequency in 8086?
9. What are the various segment register in 8086?
ol
10. Which Stack is used in 8086?
C
11. What are the address lines for the software interrupts?
g
12. What is a SIM and RIM instruction? rin
13. Which is the tool used to connect the user and the computer?
14. What is the position of the Stack Pointer after the PUSH instruction?
ee
15. What is the position of the Stack Pointer after the POP instruction?
in
20. What are the address lines for the hardware interrupts?
al
21. Which Segment is used to store interrupt and subroutine return address
registers?
m
22. Which Flags can be set or reset by the programmer and also used to
ni
8
8051 MICROCONTROLLER
A smaller computer
On-chip RAM, ROM, I/O ports...
Example: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X
ge
le
ol
C
g
rin
ee
in
ng
9
COMPARISON BETWEEN MICROPROCESSOR AND MICROCONTROLLER
Microprocessor Microcontroller
ge
• Expansive • For applications in which cost,
• Versatility power and space are critical
le
• General-purpose • Single-purpose
ol
C
Review Questions:
g
1. What is a state in 8031/8051 microcontroller?
rin
2. How many machine cycles are needed to execute an instruction in
ee
8031/8051 controller?
3. How to estimate the time taken to execute an instruction in 8031/8051
in
controller?
ng
11. List the instructions of 8051 that affect all the flags of 8051.
12. List the instructions of 8051 that affect overflow flag in 8051.
13. List the instructions of 8051 that affect only carry flag.
14. List the instructions of 8051 that always clear carry flag.
15. What are the operations performed by Boolean variable instructions of
8051?
10
Pa
ni
m
al
ar
Eng
in
11
ee
rin
g
C
WITH 8086
ol
le
ge
PROGRAMMING
16-BIT DATA ADDITION AND SUBTRACTION
PROGRAM:
ADDITION
MOV SI, 1100H
MOV AX, [SI]
MOV BX, [SI+2]
MOV CL, 00H
ge
ADD AX, BX
MOV [SI+4], AX
le
JNC 0113
INC CL
ol
MOV [SI+6], CL
INT A5
C
g
PROGRAM: rin
SUBTRACTION
MOV SI, 1100H
ee
SUB AX, BX
MOV [SI+4], AX
JNC 0113
E
INC CL
ar
MOV [SI+6], CL
INT A5
al
m
ni
Pa
12
16-BIT DATA ADDITION AND SUBTRACTION
AIM:
To add and subtract two 16-bit numbers stored at consecutive memory
locations.
ALGORITHM:
1. Load the first data in AX register.
ge
2. Load the second data in BX register.
3. Clear CL register.
4. Add/subtract the two data and get the sum in AX register.
le
5. Store the sum in memory.
ol
6. Check for carry, if carry flag is set then go to next step, otherwise go to
step-8.
C
7. Increment CL register.
8. Store the carry in memory.
g
9. Stop. rin
OBSERVATION:
ee
1103 – BA 1103 – A1
ar
1103 – 35 1103 – 65
RESULT:
Thus the two 16-bit numbers are added, subtracted and results are
stored at memory locations.
13
MULTI-BYTE ADDITION AND SUBTRACTION
PROGRAM:
ge
MOV DL, 00H
CLC
MOV AL, [SI+BX]
le
ADC/SBB AL, [DI+BX]
ol
MOV [BP], AL
INC BX
C
INC BP
LOOP 0112
g
JNC 0121 rin
INC DL
MOV [BP], DL
INT A5
ee
in
ADDITION:
Input Data: Output Data:
ng
1100 – 06
1101 – 07 1201 – 04 1301 – 0B
E
14
MULTI-BYTE ADDITION AND SUBTRACTION
AIM:
To add and subtract two multi-byte data.
ALGORITHM:
ge
2. Load the starting address of 2nd data in DI register.
3. Load the starting address of result in BP register.
4. Load the byte count in CL register.
le
5. Let BX register be byte pointer, initialize byte pointer as zero.
ol
6. Clear DL register to account for final carry.
7. Clear carry flag.
C
8. Load a byte of 1st data in AL register.
9. Add /subtract the corresponding byte of 2nd data in memory to AL
g
register along with previous carry. rin
10. Store the sum in memory.
11. Increment the byte pointer (BX) and result pointer (BP).
12. Decrement the byte count (CL).
ee
the data.
15. Increment the DL register.
ng
OBSERVATION:
ar
SUBTRACTION:
al
RESULT:
15
BCD ADDITION AND SUBTRACTION
PROGRAM:
ge
MOV DL, AL
MOV AL, AH
ADC/SBB AL, BH
le
DAA/DAS
ol
MOV DH, AL
JNC 011A
C
INC CL
MOV [SI+4], DX
g
MOV [SI+6], CL rin
INT A5
ee
SUBTRACTION:
Input Data: Output Data:
in
1100 – 07 1104 – 03
1101 – 08 1105 – 05
ng
1102 – 04 1106 – 00
1103 – 03
E
ar
al
m
ni
Pa
16
BCD ADDITION AND SUBTRACTION
AIM:
To add and subtract two numbers of BCD data.
ALGORITHM:
ge
2. Clear CL register to account for carry.
3. Load the first data in AX register and second data in BX register.
4. Perform binary addition/subtraction of low byte of data to get the
le
sum/difference in AL register.
ol
5. Adjust the sum/ difference of low bytes to BCD.
6. Save the sum/ difference of low bytes in DL register.
C
7. Get the high byte of first data in AL register.
8. Add/sub the high byte of second data and previous carry to AL register.
g
Now the sum of high bytes will be in AL register.
rin
9. Adjust the sum/ difference of high bytes to BCD.
10. Save the sum/ difference of high bytes in DH register.
11. Check for carry. If carry flag is set then go to next step, otherwise go to
ee
next condition.
12. Increment CL register.
in
15. Stop.
E
OBSERVATION:
ar
ADDITION:
al
1101 – 74 1105 – 18
1102 – 55 1106 – 01
ni
1103 – 43
Pa
RESULT:
Thus the addition and subtraction of two BCD numbers was performed.
17
16-BIT MULTIPLICATION AND DIVISION
PROGRAM:
ge
INT A5
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
18
16-BIT MULTIPLICATION AND DIVISION
AIM:
To multiply/divide two 16-bit data.
ALGORITHM:
1. Load the address of data in SI register.
2. Get the first data in AX register.
ge
3. Get the second data in BX register.
4. Multiply/divide the content of AX and BX. The product will be in AX and
DX.
le
5. Save the result (AX and DX) in memory. For division the quotient is stored
ol
in AX and the remainder in DX.
6. Stop.
C
OBSERVATION:
g
MULTIPLICATION:
rin
Input Data: Output Data:
1100 – 3A 1104 – 6E PRODUCT
ee
1101 – 58 1105 – ED
1102 – 63 1106 – 5E OVERFLOW
in
1103 – 15 1107 - 07
ng
DIVISION:
Input Data: Output Data:
E
1103 – 78 1107 – 48
RESULT:
19
LOGICAL OPERATIONS
PROGRAM:
OR/XOR/AND
MOV SI, 2000
MOV AX, [SI]
MOV BX, [SI+2]
OR/XOR/AND AX, BX
MOV [SI+4], AX
ge
INT A5
NOT
le
MOV SI, 2000H
ol
MOV AX, [SI]
NOT AX
C
MOV [SI+4], AX
INT A5
g
rin
OBSERVATION:
ee
OR: XOR:
Input Data: Output Data: Input Data: Output Data:
in
2002 – 10 2002 – 01
2003 – 00 2003 – 10
E
AND: NAND:
ar
2003 – 10 2003 – 11
ni
Pa
20
LOGICAL OPERATIONS
AIM:
To perform logical operations (OR/XOR/AND) on 16-bit data using 8086
microprocessor.
ALGORITHM:
ge
1. Set the Source Index address as 2000.
2. Load the data in address of SI to AX.
3. Load the Second data in address of [SI+02] to BX.
le
4. Perform OR/XOR/AND operation on AX and BX.
ol
5. Perform NOT Operation on AX Register.
6. Move the Content of AX to [SI+04] address.
C
7. Stop.
g
OBSERVATION: rin
NOR: XNOR:
Input Data: Output Data: Input Data: Output Data:
ee
2002 - 11 2002 - 01
2003 - 01 2003 - 10
ng
NOT:
Input Data: Output Data:
E
2000 - 11 2004 - EE
ar
2001 - 10 2005 - EF
al
m
ni
Pa
RESULT:
21
MOVING A BLOCK OF DATA
PROGRAM:
ge
CODE SEGMENT START CODE SEGMENT
SET THE STARTING ADDRESS OF THE
ORG 1000H
le
PROGRAM
ol
MOV SI, 1400H SET SOURCE INDEX ADDRESS AS 1400
MOVE THE COUNT VALUE FROM SI ADDRESS
C
MOV CL, [SI]
TO CL
g
MOV SI, 1500H SET SOURCE INDEX ADDRESS AS 1500
rin
MOV DI, 1600H SET DESTINATION INDEX ADDRESS AS 1600
ee
DEC CL DECREMENT CL
al
MOV AH,4CH
ni
EXIT TO DOS
INT 21H
Pa
22
MOVING A BLOCK OF DATA
AIM:
To move a block of data from Address Location 1500 to Address Location
1600 using 8086 MASM Software.
ALGORITHM:
ge
1. Load the address of data in SI register.
2. Get the count value from SI address to CL.
le
3. Load the address of data in SI register.
4. Load the address of data in DI register.
ol
5. Move data from SI address to AX.
6. Move data from AX to SI address.
C
7. Add 02 with address in SI and DI.
8. Decrement Count Value.
g
9. Stop the program. rin
OBSERVATION:
ee
ADDITION:
Input Data: Output Data:
in
1400 – 05 (COUNT)
1500 – 06 1600 - 01
ng
1501 – 07 1601 - 09
1502 – 08 1602 - 08
E
1503 – 09 1603 - 07
1504 - 01 1604 - 06
ar
al
m
ni
Pa
RESULT:
Thus the moving block of data from 1500 to 1600 using 8086 MASM
software was performed.
23
BCD TO HEXADECIMAL CONVERSION
PROGRAM:
ge
ROR AL, CL
MOV DH, 0AH
MUL DH
le
ADD AL, DL
ol
MOV [BX+1], AL
INT A5
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
24
CODE CONVERSIONS
AIM:
To convert a given BCD data into Hexadecimal data.
ALGORITHM:
ge
1. Load the address of BCD data in BX register.
le
2. Get the BCD data in AL register.
3. Copy the BCD data in DL register.
ol
4. Logically AND DL with 07H to mask upper nibble and get units digit in
DL.
C
5. Logically AND AL with 70H to mask lower nibble.
6. Move the count value for rotation in CL register.
g
7. Rotate the content of AL to move the upper nibble to lower nibble
rin
position.
8. Move 0AH to DH register.
9. Multiply AL with DH register. The product will be in AL register.
ee
12. Stop.
E ng
OBSERVATION:
ar
RESULT:
25
HEXADECIMAL TO BCD CONVERSION
PROGRAM:
ge
INC DL
JMP HUND
TEN: CMP AL, 0AH
le
JC UNIT
ol
SUB AL, 0AH
INC DH
C
JMP TEN
UNIT: MOV CL, 04
g
ROL DH, CL rin
ADD AL, DH
MOV [BX+1], AL
MOV [BX+2], DL
ee
INT A5
in
E ng
ar
al
m
ni
Pa
26
HEXADECIMAL TO BCD CONVERSION
AIM:
To convert an 8-bit hexadecimal data into BCD.
ALGORITHM:
ge
2. Get the binary data in AL register.
3. Clear DX register for storing hundreds and tens.
4. Compare AL with 64H (10010).
le
5. Checks carry flag. If carry flag is set then go to step-9, otherwise go to
ol
next step.
6. Subtract 64H (10010) from AL register.
C
7. Increments hundreds register (DL).
8. Go to step-4.
g
9. Compare AL with 0AH (1010). rin
10. Checks carry flag. If carry flag is set then go to step-14, otherwise go to
next step.
11. Subtract 0AH (1010) from AL register.
ee
18. Stop.
ar
OBSERVATION:
al
1100 – 39 1101 - 09
ni
Pa
RESULT:
27
HEXADECIMAL TO ASCII CONVERSION
PROGRAM:
ge
JC L1
SUB AL, 07H
L1: MOV [DI], AL
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
28
HEXADECIMAL TO ASCII CONVERSION
AIM:
To convert the given Hexadecimal data into ASCII.
ALGORITHM:
ge
2. Set DI as pointer for ASCII array.
3. Load the binary into AL
4. Subtract 30H from AL register
le
5. Compare 09H to AL register if equal go L1
ol
6. In that load the AL register into DI
7. checks carry, if carry flag is set got to L1
C
8. Subtract 07H to AL register
g
OBSERVATION:
rin
Input Data: Output Data:
ee
1100 – 41 1400 – 0A
in
E ng
ar
al
m
ni
Pa
RESULT:
29
ASCII TO HEXADECIMAL CONVERSION
PROGRAM:
ge
ADD AL, 07H
L1: ADD AL, 30H
MOV [DI], AL
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
30
ASCII TO HEXADECIMAL CONVERSION
AIM:
To convert an ASCII number into hexadecimal.
ALGORITHM:
ge
2. Set DI as pointer for binary array.
3. Get a byte of ASCII array in AL registers.
4. Compare AL with 09H.
le
5. If it is equal go to step L1, otherwise go to step 4.
ol
6. Check carry flag, if carry flag is set, go to step L1
7. Add 07H from AL register.
C
8. Add 07H from AL register.
9. Load the binary array in AL to DI
g
OBSERVATION:
rin
Input Data: Output Data:
ee
1100 – 0A 1400 – 41
in
E ng
ar
al
m
ni
Pa
RESULT:
31
ADDITION/SUBTRACTION OF TWO nxn MATRICES
PROGRAM:
ge
SET THE STARTING ADDRESS OF THE
ORG 1000H
PROGRAM
le
MOV SI,2000H SET SOURCE INDEX ADDRESS AS 2000
ol
SET DESTINATION INDEX ADDRESS AS
MOV DI,3000H
3000
C
MOV CL,04H SET THE COUNT VALUE 04H IN CL
g
L1: MOV AL,[SI] MOVE THE DATA FROM SI ADDRESS TO AL
rin
MOVE THE DATA FROM DI ADDRESS TO
MOV BL,[DI]
BL
ee
INC DI INCREMENT DI
E
INC SI INCREMENT SI
ar
DEC CL DECREMENT CL
al
MOV AH,4CH
ni
EXIT TO DOS
INT 21H
Pa
32
ADDITION/SUBTRACTION OF TWO nxn MATRICES
AIM:
To subtract two nxn matrices using 8086 MASM Software.
ALGORITHM:
ge
2. Set SI register as Pointer for array for 1st Matrix.
3. Set DI register as Pointer for array for 2nd Matrix.
4. Move Contents of SI register to AL.
le
5. Move contents of DI register to BL.
ol
6. Add/Subtract the contents of AL and BL.
7. Move the result from AL register to Memory.
C
8. Increment SI and DI register.
9. Decrement Count Value.
g
10. If Count Value becomes zero, stop the program.
rin
OBSERVATION:
ee
ADDITION:
in
SUBTRACTION:
al
RESULT:
Thus the addition and subtraction of two nxn matrices using 8086
MASM software was performed.
33
COPY A STRING
PROGRAM:
ge
INT A5
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
34
COPY A STRING
AIM:
To copy a string of data using 8086.
ALGORITHM:
ge
2. Set DI as pointer for output array of data’s.
3. Set CX as counter.
4. Clear direction flag (DF) for auto increment of pointers.
le
5. Move the string of data’s up to the counter value.
ol
OBSERVATION:
C
Input Data: Output Data:
g
2000 – 07 2100 – 07
rin
2001 – 03 2101 – 03
2002 – 02 2102 – 02
2003 – 01 2103 – 01
ee
in
E ng
ar
al
m
ni
Pa
RESULT:
35
REVERSE A STRING
PROGRAM:
ge
DEC SI
INC DI
le
DEC CX
JNZ L1
ol
INT A5
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
36
REVERSE A STRING
AIM:
To reverse the input string using 8086 Microprocessor.
ALGORITHM:
ge
2. Set DI as pointer for output array of data’s.
3. Set CX as Counter
4. Add counter of SI with 07
le
5. Move contents of SI address to AL and from AL TO DL address.
ol
6. Decrement SI and DI to reverse.
7. Decrement CX and report loop if DL to 0
C
8. Stop the Program.
g
OBSERVATION:
rin
Input data: Output data:
ee
2000 – 08 3000 – 01
2001 – 07 3001 – 02
in
2002 – 06 3002 – 03
2003 – 05 3003 – 04
ng
2004 – 04 3004 – 05
2005 – 03 3005 – 06
E
2006 – 02 3006 – 07
2007 – 01 3007 - 08
ar
al
m
ni
Pa
RESULT:
37
ASCENDING AND DESCENDING ORDER
PROGRAM:
ge
INC SI
REPCOM: MOV AL, [SI]
INC SI
le
CMP AL, [SI]
ol
JC/JNC AHEAD
XCHG AL, [SI]
C
XCHG AL, [SI – 1]
AHEAD: DEC CH
g
JNZ REPCOM rin
DEC CL
JNZ REPEAT
INT A5
ee
in
E ng
ar
al
m
ni
Pa
38
ARRANGE AN ARRAY OF DATA IN ASCENDING AND
DESCENDING ORDER
AIM:
To sort the given number in the ascending and descending order using
8086 microprocessor.
ALGORITHM:
ge
1. Set SI register as pointer for array.
2. Set CL register as count for N – 1 repetition.
le
3. Initialize array pointer.
ol
4. Set CH as count for N – 1 Comparisons.
5. Increment the array pointer.
C
6. Compare the next element of the array with AL.
7. Check the carry flag. If carry flag is set then go to step-12, otherwise go to
g
next step. rin
8. 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
ee
10. Check zero flag. If zero flag is reset then go to step-6, otherwise
go to next step.
ng
go to next step.
13. Stop.
ar
OBSERVATION:
al
RESULT:
Thus the ascending and descending order program is executed and thus
the numbers are arranged in ascending order.
39
SEARCH FOR A GIVEN DATA
PROGRAM:
ge
JZ AVAIL
INC SI
INC BL
le
MOV AL, [SI]
ol
CMP AL, 20H
JNZ AGAIN
C
MOV CX, 0000H
MOV [DI+1], CX
g
MOV [DI+3], CX rin
JMP OVER
AVAIL: MOV BH, 0FFH
MOV [DI+1], BH
ee
MOV [DI+2], BL
MOV [DI+3], SI
in
OVER: INT A5
E ng
ar
al
m
ni
Pa
40
SEARCH FOR A GIVEN DATA
AIM:
To search a given data in an array. Also determine the position and
address of the data in the array.
ALGORITHM:
ge
1. Set SI register as pointer for the array.
2. Set DI register as pointer for given data and result.
3. Get the data to search in DL register.
le
4. Let BL register keep track of position. Initialize the position count as one.
ol
5. Get an element of array in AL.
6. Compare an element of array (AL) with given data (DL).
C
7. Check for Zero flag. If zero flag is set then go to step-14, otherwise go to
next step.
g
8. Increment the array pointer (SI) and position count (BL).
rin
9. Get next element of array in AL register.
10. Compare AL with end marker (20H).
11. Check zero flag. If zero flag is not set, then go to step-6,
ee
OBSERVATION:
m
RESULT:
41
PASSWORD CHECKING PROGRAM
PROGRAM:
ge
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
le
MOV DS, AX
ol
WAIT: MOV CX, 09H
MOV DI, OFFSET BUFFER
C
NXTCHAR: MOV AH, 08H
INT 21H
g
CMP AL, 0DH rin
JE STOP
MOV [DI], AL
INC DI
ee
DEC CX
JNZ NXTCHAR
in
MOV ES, AX
REP CMPSB
ar
JNZ SORRY
MOV AH, 4CH
al
INT 21H
SORRY: MOV DX, OFFSET MESSAGE
m
JMP WAIT
Pa
CODE ENDS
END START
42
PASSWORD CHECKING PROGRAM
AIM:
To read password and validate the user.
ALGORITHM:
ge
2. Initialize data Segment.
3. Display Message.
4. Clear Count and number of match.
le
5. Check if count=9 if not continue.
ol
6. Road and save Character.
7. Restore Character set pointer to password.
C
8. Compare read character with password.
9. Increment match count if match occurs.
g
10. Increment pointer and counter. rin
11. If match count=9 display Message.
12. If match count<>9 display Message SORRY.
13. Stop the program.
ee
in
E ng
ar
al
m
ni
Pa
RESULT:
43
TIME DELAY
PROGRAM:
ge
ADD AL, 01
DAA
MOV DL, AL
le
MOV AL, DH
ol
ADC AL, 00
DAA
C
MOV DH, AL
MOV CX, 4000 (DELAY COUNT)
g
INT AA rin
MOV AH, 0B
INT A1
CMP AL, 00
ee
JZ LOOP1
MOV AH, 08
in
INT A1
CMP AL, 46 (FASCII)
ng
JZ LOOP2
CMP AL, 1B
E
JNZ LOOP1
INT A3
ar
JMP LOOP2
INT A5
ni
Pa
NOTE:
F TO PAUSE
S TO CONTINUE
ESC COMMAND MODE
CX4000 (MEDIUM SPEED COUNT)
CX1000 (FAST COUNT)
44
CREATING A TIME DELAY
AIM:
To create a time delay using 8086 microprocessor by the user.
ALGORITHM:
ge
2. Set the DX register as 0000.
3. Interrupt Control to AB and AC.
4. Move the Contents of AL as 04.
le
5. Interrupt to AE.
ol
6. Move the Contents of DL to AL.
7. Add the AL register with 01 data.
C
8. Adjust the decimal after addition.
9. Move AL register to DL register and similarly DH register to AL.
g
10. Add with Carry AL and 00. rin
11. Move the Contents AL register to DH.
12. Move the data 4000 to CX register.
13. Jump to loop1 if zero flag is set.
ee
OUTPUT:
E
F – TO PAUSE
ar
S – TO START
ESC – COMMAND MODE
al
RESULT:
45
Pa
ni
m
al
ar
Eng
in
46
ee 8086
rin
g
C
PROGRAMS ol
le
INTERFACING
ge
TRAFFIC LIGHT CONTROLLER WITH 8086 INTERFACING
AIM:
To interface traffic light with 8086 microprocessor.
APPARATUS REQUIRED:
1. 8086 MP KIT
2. KEYBOARD
4. TRAFFIC LIGHT INTERFACE KIT
5. INTERFACE CABLE
ge
ALGORITHMS:
le
ol
CONDITION 1:
SOUTH TO NORTH
C
SOUTH TO NORTH - VEHICLE CAN MOVE FROM
g
SOUTH TO NORTH STRAIGHT, SOUTH TO EAST RIGHT,
rin
SOUTH TO WEST LEFT, EAST TO SOUTH LEFT,
NORTH & WEST - RED
ee
CONDITION 2:
ng
ALL PEDESTRIAN ON
NORTH, SOUTH, EAST&WEST – RED
E
ALL PEDSTRIAN ON
ar
al
m
ni
Pa
47
PROGRAM:
ge
1000:0111 OUT DX,AL
1000:0112 MOV AL,86
1000:0114 MOV DX,8004
le
1000:0117 OUT DX,AL
1000:0118 MOV AL,60
ol
1000:011A MOV DX,8000
C
1000:011D OUT DX,AL
1000:011E MOV AL,48
g
1000:0120 MOV DX,8002
1000:0123 OUT DX,AL rin
1000:0124 MOV AL,64
1000:0126 MOV DX,8000
ee
1000:0129 OUT DX,AL
1000:012A MOV AL,58
1000:012C MOV DX,8002
in
ge
1000:017A MOV DX,8000
1000:017D OUT DX,AL
1000:017E MOV AL,06
le
1000:0180 MOV DX,8004
1000:0183 OUT DX,AL
ol
1000:0184 MOV AL,51
C
1000:0186 MOV DX,8000
1000:0189 OUT DX,AL
g
1000:018A MOV AL,46
1000:018C MOV DX,8004 rin
1000:018F OUT DX,AL
1000:0190 CALL 0253
ee
1000:0193 MOV AL,41
1000:0195 MOV DX,8000
1000:0198 OUT DX,AL
in
49
FLOW CHART:
Start Start
ge
Move the data from BX address to AL Get Data FFFFH in
Register Send Data in AL to Out Port
le
ol
Decrement Data in
Increment BX & Move the data from DX Register
C
BX address to AL Register Send Data
in AL to out Port A, B & C
g
rin Check No
Call Delay Subroutine ZF= 1
Yes
ee
Check No
E
Yes ZF= 1
No Check
ar
ZF= 1
Yes
al
Return to
Main Program
m
ni
Pa
RESULT:
50
INTERFACING STEPPER MOTOR WITH 8086
AIM:
Thus the assembly language program to find the 1’s and 2’s complement
of an 8-bit number using 8051 instruction set was written and executed
successfully.
THEORY:
A motor in which the rotor is able to assume only discrete stationary
ge
angular position is a stepper motor. The rotary motion occurs in a step-wise
le
manner from one equilibrium position to the next. Stepper Motors are used
ol
very wisely in position control systems like printers, disk drives, process
C
control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles.
g
Each of the four poles has its own winding. The excitation of any one winding
rin
generates a North Pole. A South Pole gets induced at the diametrically opposite
ee
side. The rotor magnetic system has two end faces. It is a permanent magnet
with one face as South Pole and the other as North Pole.
in
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a
ng
switching scheme is shown in the table given below. This scheme produces
m
more torque.
ni
ANTICLOCKWISE CLOCKWISE
Pa
51
ADDRESS DECODING LOGIC:
The 74138 chip is used for generating the address decoding logic to
generate the device select pulses; CS1 & CS2 for selecting the IC 74175.The
74175 latches the data bus to the stepper motor driving circuitry.
Stepper Motor requires logic signals of relatively high power. Therefore,
the interface circuitry that generates the driving pulses uses silicon Darlington
pair transistors. The inputs for the interface circuit are TTL pulses generated
ge
under software control using the Microcontroller Kit. The TTL levels of pulse
le
sequence from the data bus are translated to high voltage output pulses using
a buffer 7407 with open collector.
ol
C
PROCEDURE:
Enter the above program starting from location 1000 and execute the
g
same. The stepper motor rotates. Varying the count at DX register pair can
rin
vary the speed. Entering the data in the look-up TABLE in the reverse order
ee
APPARATUS REQUIRED:
1. 8086 MP kit
ng
2. Keyboard
4. Stepper motor interface kit
E
5. Interface cable
ar
ALGORITHM:
al
52
PROGRAM:
ge
OUT DX, AL
INT AAH
MOV AL, 0CH
le
OUT DX, AL
INT AAH
ol
MOV AL, 09H/0CH
C
OUT DX, AL
INT AAH
g
MOV AL, 03H
OUT DX, AL rin
INT AAH
JMP AGAIN
ee
INT A5
in
CLOCKWISE DIRECTION
06 0C 09 03
ng
ANTICLOCKWISE DIRECTION
E
03 09 0C 06
ar
al
m
ni
Pa
RESULT:
Thus a stepper motor was interfaced with 8086 and run in forward and
reverse directions at various speeds.
53
DIGITAL CLOCK IN REAL TIME
AIM:
To write an 8086 ALP to display a digital clock in real time.
ALGORITHM:
ge
2. Load the contents of AX to EX Segment.
3. Create delay by moving contents to consecutive memory locations.
le
4. Send through output port address 8c07 and 8c03.
5. Jump to display the clock.
ol
6. Set the program.
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
54
DIGITAL CLOCK IN REAL TIME
PROGRAM:
MOV AX,0000
NOP
MOV ES,AX
INT AC
MOV AL,00
MOV [1000], AL
ge
MOV [1001], AL
MOV [1002], AL
MOV [1003], AL
le
MOV [1004], AL
ol
PUSH CS
POP CX
C
MOV SI, ISR
MOV AL, 02
g
INT BE
MOV AL,7E
rin
MOV DX,8C07
OUT DX, AL
ee
MOV AL, 24
MOV DX, 8C03
in
OUT DX, AL
MOV AL, F4
ng
CMP AL, 00
JZ LOOP1
al
ADD AL, 01
DAA
ni
CMP AL, 60
JZ NXT1
Pa
MOV [1002], AL
MOV AL, 00
MOV [1003], AL
JMP DSPLY
55
MOV [1001], AL
MOV AL, 00
MOV [1003], AL
JMP DSPLY
ge
CMP AL, 13
JZ END
MOV [1000], AL
le
MOV AL, 00
MOV [1003], AL
ol
C
DSPLY (0181): MOV DL, 20
MOV AH, 02
g
INT A2
MOV AL, 02 rin
MOV DL, [1000]
INT AE
ee
MOV DL, 20
MOV AH, 02
INT A2
in
MOV AL,02
ng
MOV AH, 02
INT A2
ar
MOV AL,02
MOV DL, [1002]
al
INT AE
INT AB
m
MOV AH, 0B
ni
INT AB
MOV AH, 0B
Pa
INT A1
CMP AL,00
JNZ END
MOV BX, LOOP1
JMP BX
56
ISR (01C3): PUSH AX
MOV AL, [1004]
INC AL
CMP AL, 28
JNZ SKIP1
MOV AL, 00
MOV [1004], AL
MOV AL, 01
MOV [1003], AL
JMP SKIP3
ge
SKIP1 (01D9): MOV [1004], AL
SKIP3 (01DC): POP AX
le
RET
ol
MOV AX, 0000
C
NOP
MOV ES, AX
g
INT AC
MOV AL, 00 rin
MOV ]1000], AL
MOV [1001], AL
ee
MOV [1002], AL
MOV [1003], AL
MOV [1004], AL
in
PUSH CS
ng
POP CX
MOV SI, ISR
MOV AL, 02
E
INT BE
MOV AL, 7E
ar
MOV AL, 24
MOV DX, 8C03
m
OUT DX, AL
ni
MOV AL, F4
MOV DX, 8C03
Pa
OUT DX, AL
JMP DSPLY
ge
MOV [1001], AL
MOV AL, 00
MOV [1003], AL
le
JMP DSPLY
ol
NXT2 (016A): MOV AL, 00
C
MOV [1001], AL
MOV AL, [1000]
g
ADD AL, 01
DAA rin
CMP AL, 13
JZ END
ee
MOV [1000], AL
MOV AL, 00
MOV [1003], AL
in
ng
MOV AL,02
MOV DL, [1000]
ar
INT AE
MOV DL, 20
al
MOV AH, 02
INT A2
m
MOV AL, 02
ni
MOV DL, 20
MOV AH, 02
INT A2
MOV AL, 02
MOV DL, [1002]
INT AE
INT AB
MOV AH, 0B
INT A1
CMP AL,00
JNZ END
MOV BX, LOOP1
JMP BX
58
END (01BA): MOV AL, 76
MOV DX, 8C07
OUT DX, AL
INT A4
NOP
ge
CMP AL, 28
JNZ SKIP1
MOV AL, 00
le
MOV [1004], AL
MOV AL, 01
ol
MOV [1003], AL
C
JMP SKIP3
g
SKIP1 (01D9): MOV [1004], AL
SKIP3 (01DC): POP AX rin
RET
ee
in
E ng
ar
al
m
ni
Pa
RESULT:
59
INTERFACING 8279 KEYBOARD AND DISPLAY CONTROLLER
WITH 8086
AIM:
To interface 8279 Programmable Keyboard Display Controller to 8086
Microprocessor.
APPARATUS REQUIRED:
1. 8086 Microprocessor tool kit.
2. 8279 Interface board.
ge
3. VXT parallel bus.
ALGORITHM:
le
ol
1. Start the program.
2. Initialize the counter.
C
3. Set 8279 for 8 digit character display right entry.
4. Set 8279 for clearing the display.
g
5. Write the command to display. rin
6. Load the accumulator with character and display it.
7. Introduce the delay.
8. Repeat the above steps.
ee
in
E ng
ar
al
m
ni
Pa
60
8279 : KEYBOARD AND DISPLAY AND INTERFACING
PROGRAM:
ge
OUT DX, AL
MOV CL, 10
le
CALL DISPLAY
JMP START
ol
DISPLAY: MOV BX, 1100
NEXT: MOV AL, [BX]
C
MOV DX, 01E0
OUT DX, AL
g
INC BX rin
DEC CL
JNZ NEXT
INT A5
ee
in
Connections:
ng
INPUT
1100= C0H 1108= 80 H
al
1104= 99 H 110C= C6 H
Pa
1105= 92 H 110D= A1 H
1106= 82 H 110E= 86 H
1107= F8 H 110F= 8E H
61
DISPLAY SEGMENTS HEX VALUE
DISPLAY
dp g f e d c b a (input)
0 1 1 0 0 0 0 0 0 C0
1 1 1 1 1 1 0 0 1 F9
2 1 0 1 0 0 1 0 0 A4
3 1 0 1 1 0 0 0 0 B0
ge
4 1 0 0 1 1 0 0 1 99
le
5 1 0 0 1 0 0 1 0 92
ol
6 1 0 0 0 0 0 1 0 82
C
7 1 1 0 1 1 0 0 0 D8
g
8 1 0 0 0 0 0 0 0 80
9 1 0 0 1
rin
0 0 0 0 90
ee
a
ng
f | |b
ar
Segment glow = 0
—
al
e | | c
ni
—
Pa
. dp
d
62
OUTPUT:
ge
4 F9 0
5 A4 1
le
6 B0 2
ol
7 99 3
C
8 92 4
g
9 82 5 rin
10 F8 6
ee
11 80 7
12 90 8
in
13 88 9
ng
14 83 A
15 C6 B
E
16 A1 C
ar
17 86 D
al
18 8E E
m
19 10 F
ni
Pa
RESULT:
Thus 8279 controller was interfaced with 8086 and program for rolling
display was executed successfully.
63
INTERFACING ADC WITH 8086
AIM:
To interface ADC with 8086.
APPARATUS REQUIRED:
1. 8086 Microprocessor tool kit.
2. VBMB-003 Interface board.
3. VXT parallel bus.
4. Multimeter.
ge
ALGORITHM:
Select the channel and latch the address.
le
Send the start conversion pulse.
ol
Read EOC signal.
If EOC=1 continue, else go to before step.
C
Read the digital output.
Store it in a Memory location.
g
rin
Calculation procedure:
ee
5
ng
64
PROGRAM:
ge
MOV AL, 09
OUT DX, AL
le
MOV AL, 08
OUT DX, AL
ol
MOV AL, 83
C
OUT DX, AL
INT AC
g
MOV DX, 8807 rin
MOV AL, 0D
OUT DX, AL
ee
MOV AL, OC
OUT DX, AL
in
AND AL, 02
JNZ LOOP1
E
LOOP2: IN AL, DX
AND AL, 02
ar
JZ LOOP2
MOV AL, 0B
al
OUT DX, AL
MOV DX, 8803
ni
IN AL, DX
Pa
MOV [1100], AL
INT A5
RESULT:
Thus the ADC was interfaced with 8086 and Analog to Digital conversion
was achieved.
65
INTERFACING DAC WITH 8086
AIM:
To generate a saw tooth wave, triangular and square-wave at the output
of DAC.
APPARATUS REQUIRED:
ge
3. VXT parallel bus.
4. Power supply.
5. CRO.
le
ol
ALGORITHM:
C
Saw tooth wave
1. Start the Program
g
2. Make the accumulator ‘00’. rin
3. Display accumulator content at port.
4. Increment accumulator by 1.
5. If it is not equal to ‘0’ go to L1.
ee
Triangular wave
1. Start the Program
ng
Square wave
Pa
66
PROGRAM:
ge
INC AL
JNZ L1
le
JMP START
ol
RET
C
To create a triangular waveform at DAC1 in Micro-86 LCD kit
g
START: MOV AL, 80
rin
MOV DX, 8807
OUT DX, AL
ee
MOV AL, 00
L1: OUT DX, AL
ng
INC AL
JNZ L1
E
MOV AL, FF
L2: OUT DX, AL
ar
DEC AL
JNZ L2
al
JMP START
m
RET
ni
ge
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
RESULT:
Thus VBMB-002 was interfaced with 8086 and various waveforms are
generated at the output of DAC.
68
PARALLEL COMMUNICATION INTERFACE
AIM:
To establish parallel communication between two MP kits using 8255.
APPARATUS REQUIRED:
1. 8086 Microprocessor tool kit.
2. VXT parallel bus.
3. 8255 Interface board
ge
ALGORITHM:
le
2. Store control word in control word register.
ol
3. Read data port A.
4. Store data from port A in memory.
C
5. Place contents in port B.
6. Stop the program.
g
PROGRAM:
rin
MOV AL, 90
ee
IN AL, DX
MOV DX, 01E2
E
OUT DX, AL
MOV [1100], AL
ar
INT A5
al
OBSERVATION:
m
INPUT AT PORT A:
ni
OUTPUT AT PORT B:
PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0
0 0 0 0 1 1 1 1 =0FH
1100=0FH
RESULT:
Thus the 8255 has been interfaced to 8086 microprocessor and parallel
communication is established.
69
SERIAL COMMUNICATION INTERFACE
AIM:
To establish serial communication between two MP kits using 8251.
APPARATUS REQUIRED:
1. 8086 Microprocessor tool kit.
2. RS 232C cable.
3. 8251 Interface board
ge
ALGORITHM:
le
1. Initialize 8086 and 8251 to check the Transmission and Reception of a
ol
Character.
2. Initialize 8086 to give an output.
C
3. The command word and mode word is written to the 8251 for subsequent
operations.
g
4. The status word is read from the 8251 on completion of a serial I/O
rin
operation, or when the host CPU is checking the status of the device before
starting the next operation.
5. Stop the program.
ee
PROGRAM:
in
OUT DX, AL
INT AC
al
OUT DX, AL
INT AC
m
OUT DX, AL
ni
INT AC
MOV AL, 40
Pa
OUT DX, AL
INT AC
MOV AL, 4D
OUT DX, AL
INT AC
MOV AL, 27
OUT DX, AL
LOOP1 : IN AL, DX
AND AL, 01
70
JZ LOOP1
MOV AL, [SI]
MOV DX, 01E0
OUT DX, AL
MOV DX, 01E2
IN AL, DX
AND AL, 02
CMP AL, 02
JNZ LOOP2
ge
MOV DX, 01E0
OUT DX, AL
le
LOOP 2: MOV DX, 01E2
IN AL, DX
ol
AND AL, 02
C
CMP AL, 02
JNZ LOOP2
g
MOV DX, 01E0 rin
IN AL, DX
MOV [DI], AL
ee
INT A5
OBSERVATION:
in
INPUT:
ng
1100 AA
E
OUTPUT:
ar
1 00 1 1 DUMMY CODE
m
2 00 1 1 DUMMY CODE
ni
71
THE DATA IS SERIALLYBEING TRANSMITTED
10 81 0 0
AND RECEIVED THROUGH SERIAL PORT, START BIT=0
11 81 0 0 D0=0
12 81 1 1 D1=1
13 81 0 0 D2=0
14 81 1 1 D3=1
15 81 0 0 D4=0
ge
16 81 1 1 D5=1
17 81 0 0 D6=0
le
18 81 1 1 D7=1
ol
STOP BIT=1 DATA IS AVAILABLE ON 8251 WHICH
19 87 1 1
C
IS TO BE READ
20 AA 1 1 DATA IS BEING READ FROM RECIEVER BUFFER
g
STEP 21… control will automatically go to command mode and check the data in mem location 1
rin
ee
in
E ng
ar
al
m
ni
Pa
RESULT:
Thus the 8251 has been interfaced to 8086 microprocessor and the
serial communication between two microprocessor kits has been studied.
72
Pa
ni
m
al
ar
Eng
in
73
ee
rin
g
C
WITH 8051
ol
le
ge
PROGRAMMING
8 – BIT ADDITION AND SUBTRACTION
PROGRAM:
ADDITION/SUBTRACTION
MOV DPTR, #6200
MOV R2, #00
MOVX A, @DPTR
MOV R1, A
INC DPTR
ge
MOVX A, @DPTR
ADD A, R1/SUBB A, R1
JNC
le
INC DPTR
ol
MOVX @DPTR, A
MOV A, R2
C
INC DPTR
MOVX @DPTR, A
g
RET
rin
ee
in
E ng
ar
al
m
ni
Pa
74
8 – BIT ADDITION AND SUBTRACTION
AIM:
To write an assembly language program to add and subtract the two 8-
bit numbers using microcontroller instruction set.
ALGORITHM:
ge
1. Load Accumulator A with any desired 8 bit data.
2. Load the register R1 with the second 8 bit data.
3. Add and subtract two 8 bit numbers.
le
4. Store the result.
ol
5. Stop the Program.
C
OBSERVATION:
g
ADDITION: WITHOUT CARRY ADDITION: WITH CARRY
rin
Input Data: Output Data: Input Data: Output Data:
6200 – 25 6202 – 4B 6200 – EE 6202 – B9
6200 – 26 6203 – 00 6201 – CB 6203 – 01
ee
in
RESULT:
Thus, the assembly language program to add and sub the two 8-bit
numbers using 8051 instruction set was written and executed successfully.
75
8 – BIT MULTIPLICATION AND DIVISION
PROGRAM:
ge
INC DPTR
MOVX @DPTR, A
MOV A, F0
le
INC DPTR
ol
MOVX @DPTR, A
RET
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
76
8 – BIT MULTIPLICATION AND DIVISION
AIM:
To write an assembly language program to multiply and divide the two 8-
bit numbers using microcontroller instruction set.
ALGORITHM:
ge
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
le
4. Multiply the second data with Accumulator.
ol
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator for division quotient is
C
stored in A and remainder in B register.
7. Store the sum in memory pointed by DPTR.
g
OBSERVATION:
rin
MULTIPLICATION:
ee
6101 – 03
ng
DIVISION:
Input Data: Output Data:
E
6100 – 02 6102 – 04
6101 – 08
ar
al
m
ni
Pa
RESULT:
Thus, the assembly language program to multiply and divide the two 8-
bit numbers using 8051 instruction set was written and executed.
77
LOGICAL OPERATIONS
PROGRAM:
AND/EX-OR/OR
MOV DPTR, #6100
MOVX A, @DPTR
MOV R1, A
INC DPTR
MOVX A, @DPTR
ge
ANL A, R1/XRL A, R1/ORL A, R1
INC DPTR
MOVX @DPTR, A
le
RET
ol
NOT
C
MOV DPTR, #6100
MOVX A, @DPTR
g
CPL A
INC DPTR
rin
MOVX @DPTR, A
RET
ee
in
E ng
ar
al
m
ni
Pa
78
LOGICAL OPERATIONS
AIM:
To write an assembly language program to perform logical operations on
8-bit data using 8051 microcontroller.
ALGORITHM:
ge
1. Load 8 bit data in accumulator
2. Load R1 register with second 8 bit data.
3. Perform AND/OR/XOR operation on two data’s.
le
4. Complement the Result.
ol
5. Store the result in memory locations.
6. Stop the program.
C
OBSERVATION:
g
AND
rin
Input Data: Output Data:
6100 – BC 6102 – AC
ee
6101 - AE 6103 – 00
in
OR
Input Data: Output Data:
ng
6100 – BC 6102 – BE
6101 - AE 6103 – 00
E
EX - OR
ar
6101 – 0F
m
NOT
Input Data: Output Data:
ni
6100 – 08 6102 – F7
Pa
RESULT:
79
SQUARE OF AN 8 BIT NUMBER
PROGRAM:
ge
INC DPTR
MOVX @DPTR, A
INC DPTR
le
MOV A, F0
ol
MOVX @DPTR,A
RET
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
80
SQUARE OF AN 8 BIT NUMBER
AIM:
To write an assembly language program to find square and cube of an 8
bit number using 8051 microcontroller.
ALGORITHM:
ge
1. Load accumulator A with 8 bit data.
2. Move the 8 bit data to B register.
le
3. Multiply A and B to obtain square of a number.
ol
4. Move the result to B register.
5. Move to the memory locations.
C
6. Stop the program.
g
OBSERVATION:
rin
Input Data: Output Data:
ee
RESULT:
81
CUBE OF AN 8 BIT NUMBER
PROGRAM:
ge
MUL AB
PUSH F0
MOV F0, A
le
MOV A, R0
ol
MUL AB
INC DPTR
C
MOVX @DPTR, A
MOV A, F0
g
MOV R1, A rin
POP F0
MOV A, R0
MUL AB
ee
ADD A, R1
INC DPTR
in
MOVX @DPTR, A
MOV A, F0
ng
ADDC A, #00
INC DPTR
E
MOVX @DPTR, A
RET
ar
al
m
ni
Pa
82
CUBE OF AN 8 BIT NUMBER
AIM:
To write an assembly language program to find cube of an 8 bit number
using 8051 microcontroller.
ALGORITHM:
ge
1. Load accumulator A with 8 bit data.
2. Move the 8 bit data to B register.
3. Multiply A and B to obtain Cube of a Number.
le
4. Move to the memory locations.
ol
5. Stop the program.
C
OBSERVATION:
g
Input Data: Output Data:
rin
6100 - 02 6102 – 08 (CUBE)
ee
in
E ng
ar
al
m
ni
Pa
RESULT:
83
ONE’S AND TWO’S COMPLEMENT
PROGRAM:
ge
INC DPTR
MOVX @DPTR, A
RET
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
84
ONE’S AND TWO’S COMPLEMENT
AIM:
To write an assembly language program to find the 1’s and 2’s
complement of an 8-bit number using microcontroller instruction set.
ALGORITHM:
ge
1. Move the data to Accumulator.
2. Complement the accumulator.
3. Move the one’s complement output to the memory 6500H.
le
4. Add 01H with accumulator.
ol
5. Move the two’s complement output to the memory 6501H.
C
OBSERVATION:
g
Input Data Output Data:
rin
6000 - 03 6100 – FC (1’s Complement)
6102 – FD (2’s Complement)
ee
in
E ng
ar
al
m
ni
Pa
RESULT:
Thus the assembly language program to find the 1’s and 2’s complement
of an 8-bit number using 8051 instruction set was written and executed
successfully.
85
CODE CONVERSION
PROGRAM:
ge
ADD A, #30
INC DPTR
le
MOVX @DPTR, A
MOV A, F0
ol
ANL A, #F0
SWAP A
C
ADD A, #30
INC DPTR
g
MOVX @DPTR, A rin
RET
ee
in
E ng
ar
al
m
ni
Pa
86
UNPACKED BCD TO ASCII
AIM:
To write an assembly language program to convert unpacked BCD to
ASCII of an 8-bit number using 8051 microcontroller.
ALGORITHM:
ge
3. Add contents of A AND R1.
4. Increment DPTR register.
5. Add A and R1 contents.
le
6. Jump to loop if carry flag is set.
ol
7. Add A contents and 07.
8. Increment DPTR register.
C
9. Stop the Program.
g
OBSERVATION:
rin
Input Data: Output Data:
6100 – 46 6102 – 36
ee
6101 – 34
in
E ng
ar
al
m
ni
Pa
RESULT:
87
CONTENT BEYOND SYLLABUS
OBJECTIVE
AIM:
To interface seven segment display with 8051 to display hexadecimal
ge
values from 0 to 9 for common anode configuration.
le
APPARATUS REQUIRED: 8051 development kit, ISP programmer, Keil
ol
µVision3 compiler, ribbon cables, 5V power supply.
C
INTERFACING DIAGRAM:
g
rin
ee
in
E ng
ar
al
m
ni
Pa
PROGRAM:
void main()
{
unsigned char
no_code[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x67}; //Array
for hex values (0-9) for common anode 7 segment
ge
int k;
while(1) // repeat the loop infinitely
le
{
for(k=0;k<10;k++)
ol
{
C
P2=no_code[k];
delay_1s();
g
}
}
rin
}
ee
in
E ng
ar
al
m
ni
Pa
RESULT
Thus the interfacing seven segment display with 8051 to display hex
values was performed.
89
INTERFACING LCD WITH 8051
AIM:
To interface LCD with 8051 to display characters using embedded C
programming.
INTERFACING DIAGRAM:
ge
le
ol
C
g
rin
ee
in
ng
PROGRAM:
#define LCD_PORT P2
ar
sbit D7=P2^7;
sbit rw=P3^6;
m
void busy();
ni
ge
{
D7=1;
le
rs=0;
rw=1;
ol
while(D7!=0)
C
{
en=0;
g
en=1;
}
rin
}
void CMD_WRT(unsigned char val)// passing command to LCD
ee
{
busy();
in
LCD_PORT=val;
rs=0;
ng
rw=0;
en=1;
en=0;
E
}
void LCD_WRT(unsigned char *string) //writing string to LCD
ar
{
al
while(*string)
DATA_WRT(*string++);
m
}
void DATA_WRT(unsigned char ch) // writing data
ni
{
busy();
Pa
LCD_PORT = ch;
rs=1;
rw=0;
en=1;
en=0;}
RESULT
91
INTERFACING DC MOTOR WITH 8051
AIM:
To interface DC motor with 8051 and make it rotate in clockwise and
anticlockwise direction using embedded C programming.
INTERFACING DIAGRAM:
ge
le
ol
C
g
rin
ee
in
E ng
ar
PROGRAM:
al
sbit clk=P3^0;
sbit anticlk=P3^1;
Pa
void main()
{
}
}
ge
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
RESULT
93
PROGRAM OUTCOMES:
ge
SYLLABUS
1. Design the circuit
2. Simulate the circuit using Proteus software
le
3. Compile the embedded C code using Keil software
ol
4. Create the hex file
5. Download the hex file into the chip using PROGisp
C
6. View the desired output in the kit
g
rin
ee
in
E ng
ar
al
m
ni
Pa
94
8086 VIVA QUESTIONS
ge
1st / 2nd / 3rd / 4th generation processor, and it is made up of 4 / 8 / 16 /
32 bits.
le
3. What is the difference between microprocessor and microcontroller?
ol
In Microprocessor more op-codes, few bit handling instructions. But in
Microcontroller: fewer op-codes, more bit handling Instructions, and also it is
C
defined as a device that includes micro processor, memory, & input / output
g
signal lines on a single chip. rin
4. What is meant by LATCH?
Latch is a D- type flip-flop used as a temporary storage device controlled by a
ee
timing signal, which can store 0 or 1. The primary function of a Latch is data
storage. It is used in output devices such as LED, to hold the data for display.
in
ng
95
9. What is called .Scratch pad of computer?
Cache Memory is scratch pad of computer.
ge
Compiler is used to translate the high-level language program into machine
code at a time. It doesn’t require special instruction to store in a memory, it
le
stores automatically. The Execution time is less compared to Interpreter.
ol
12. Which processor structure is pipelined?
C
All x86 processors have pipelined structure.
g
13. What is flag? rin
Flag is a flip-flop used to store the information about the status of processor
and the status of the instruction executed most recently
ee
Stack is a portion of RAM used for saving the content of Program Counter and
general purpose registers.
E ng
shadow RAM
ni
In 8086 carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag,
Trace flag, Interrupt flag, Direction flag, and Sign flag.
96
20. What is Non-Maskable interrupts?
An interrupt which can be never be turned off (i.e., disabled) is known as Non-
Maskable interrupt.
ge
22. What are the various segments registers in 8086?
Code, Data, Stack, Extra Segment registers in 8086.
le
23. What is the position of the Stack Pointer after the PUSH instruction?
ol
The address line is 02 less than the earlier value.
C
24. What is the position of the Stack Pointer after the POP instruction?
g
The address line is 02 greater than the earlier value.
rin
25. Logic calculations are done in which type of registers?
ee
97
CONTROL & COMMAND WORDS
ge
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
98
PROGRAMMABLE SERIAL COMMUNICATION (8251)
ge
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
99
PROGRAMMABLE PERIPHERAL PARALLEL COMMUNICATION
INTERFACE (8255)
ge
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
100
PROGRAMMABLE INTERVAL TIMER (8253)
ge
le
ol
C
g
rin
ee
in
E ng
ar
al
m
ni
Pa
101
PROGRAMMABLE KEYBOARD & DISPLAY INTERFACE (8279)
0 0 0 D D K K K
ge
DD – DISPLAY MODE
le
KKK - KEYBOARD MODE
ol
C
kkk Function
g
000
rin
Encoded keyboard with 2-key lockout
001 Decoded keyboard with 2-key lockout
ee
DD Function
m
102
PROCEDURE FOR 8086 PROGRAMS USING MASM
ge
6. Type LINK file name and press the enter key 4 times
7. Type DEBUG give enter, type n space bar file name.exe give enter,
le
8. Type L give enter, Type E 2000 give enter
ol
9. Type the input data’s by pressing the space bar key give enter
10. Type g=1000 give enter
C
11. Type E 2004 give enter
g
12. Type Q give enter rin
ee
in
E ng
ar
al
m
ni
Pa
103