Escolar Documentos
Profissional Documentos
Cultura Documentos
LAB MANUAL
CYCLE 1
CYCLE 2
12 SUM of N Series Numbers using 8051
13 Data Transfer using 8051
14 Search for largest number using 8051
15 Print ODD or EVEN using 8051
16 BCD To HEX Conversion using 8051
17 Square wave generation using 8051
18 Interfacing DAC with 8051
19 Interfacing of keyboard with 8051
20 Interfacing of LCD with 8051
21 Serial data communication with PC
EXPERIMENT – 1
INTRODUCTION TO M86-02
M86-02 is a single board microprocessor trainer kit configured around the
Intel’s 16 bit microprocessor 8086 .The kit has been designed to operate in the
maximum mode. The kit communicates with the outside world through an IBM
PC compatible keyboard with 20X2 LCD display. The kit also has the capacity of
interacting with PC.
M86-02 is packed up with powerful monitor in 16K bytes of factory
programmed EPROMS and 16KB of read /writes memory. The total memory on
the board can be expanded to 256 Kbytes system has 72 programmable I/O
lines. The serial I/O communication is made possible through 8251.
SYSTEM CAPABILITIES:
1 Examine /modify the memory location.
2 Examine/modify any of internal register of 8086
3 Move a block of data /program from one location to another location
4 Fill a particular memory area with a constant
5 To execute the program in full clock speed
6 To execute program in single instruction execution
OPERATING COMMANDS
A - Assemble
D - Display/modify the RAM’s hexadecimal
F - Fill data in to the RAM
G - Proceed to the address for execution
I - Interrupt
M - Moving data
P - Print
T - Trace program
U - Unassembled
Conclusion
4
EXPERIMENT – 2
16 BIT BCD ADDITION
OBJECTICVE:
To write an assembly language program to add two 16 bit BCD numbers
ALGORITHM
1. Load the address of data in SI register.
2. Clear CL register for account for carry
3. Load the first data in AX register and the second data I BX register.
4. Perform binary addition of low byte of data to get the sum in AL
register.
5. Adjust the sum of low bytes to BCD.
6. Save the sum of low bytes in DL register.
7. Get the high byte of first data in AL register.
8. Add the high byte of second data and previous carry to AL register
Now the sum of high bytes will be in AL register
9. Adjust the sum of high bytes to BCD
10. Save the sum of high bytes in DH register
11. Check for carry .If carry flag is set then go to the next step, otherwise
go to step 13
12. Increment CL register
13. Save the sum (DX register) in memory
14. Save the carry (CL register) in memory.
15. Stop.
PROGRAM
Set SI register as
BE3000 MOV SI,3000
pointer
B100 MOV CL,00 Clear CL register
Get first data in AX
8B04 MOV AX,[SI]
register
Load the second
8B 5C 02 MOV BX, [SI+2]
data I BX register
get the sum of low
02 C3 ADD AL, BL byte of data in AL
register.,
Conclusion:
6
EXPERIMENT -3
OBJECTICVE :
ALGORITHM
1. Start
2. Get SI and DI registers as pointers for source and destination
3. Get the CL and BL registers are cleared.
4. Move the contents of SI to CL and increment the SI once.
5. Move the contents of SI to AL
6. Increment the SI reg.
7. Check whether the contents of SI and AL are same or not, if yes goto step
8
else goto step 9
8. Increment BL reg
9. Return to step 6 until SI is incremented the number of times equal to the
size
of the array. Repeat step 9.
10. Move the contents of BL to the destination reg DI
11. Stop.
PROGRAM:
contents of ALand SI
If not equal ,jump to
7502 JNE LI
LI
Increment BL
FEC3 INC BL
register.
Continue with loop
LI E2F7 LOOP LII
LII
Move the contents of
881D MOV [DI],BL
BL to DI register
CC INT 03 Stop the program
Conclusion:
8
EXPERIMENT - 4
OBJECTICVE
:
To write an assembly language program to sort an array of data in ascending
order.
ALGORITHM
1. Load the starting address of the array in SI register.
2. Set CL register as count forN-1 repetition
3. Initialize array pointer
4. Set CH register as count for N-1 comparisons
5. Increment array pointer
6. Compare the next element of array with AL
7. Check the carry flag, If carry flag is set then go to step 12 otherwise
go to next step.
8. Exchange the content of memory pointed by SI and AL register
9. Decrement the count for comparison (CH register)
10. Check zero flag, If zero flag is reset then go to step6, otherwise go to
next step
11. Decrement the count for repetition (CL register)
12. Check zero flag, If zero flag is reset then go to step3, otherwise go to
next step
13. Stop the program
PROGRAM:
Set SI register as
BE 00 70 MOV SI,0700
pointer
8A 0C MOV CL,[SI] Set CL as count
Decrement the count
FE C9 DEC CL
Set SI register as
REP BE 00 70 MOV SI,0700
pointer
Set CH register as
counter for N-1
8A 2C MOV CH , [SI]
comparisons
Conclusion:
10
EXPERIMENT – 5
OBJECTICVE :
ALGORITHM
1. Set BX as pointer for input data.
2. set DI as pointer for result
3. get one data in AX reg
4. get another data in CX reg
5. Compare the two data
6. Check zero flag. if zero flag is set then go to step 14,otherwise go to next
step.
7. Check carry flag .if zero is reset then go to step 9, otherwise go to next
step.
8. Exchange the content of AX and BX, so that the larger among the two is
dividend and smaller is the divisor.
9. clear the DX reg
10. Divide AX reg by CX reg.
11. Compare DX reg with 0000H.
12. Check zero flag .if zero flag is set then go to step 14, otherwise go to next
step.
13. Move the remainder to AX and go to step 5
14. Save the contents of CX register as GCD in memory.
15. Stop.
PROGRAM:
Set BX register as
BB 1100 MOV BX,1100
pointer
Set DI as pointer fo
BF 1200 MOV DI,1200
result
Get the first data in
8B 07 MOV AX, [BX]
AX
Get second data in
8B 4F 02 MOV CX, [BX+02]
CX
Compare the two
RPT 3B C2 CMP AX, CX
data
74 11 JE STORE If the two data are
11
equal, store cx as
GCD
If AX is greater tha
73 01 JNC SKIP CX, then go to sep
skip
If AX is less than
91 XCHG AX, CX CX,then exchange
AX and CX
SKIP BA 0000 MOV DX,0000
F7 F1 DIV CX
Check whether
83 FA 00 CMP DX,00
reminder is zero
If zero, then set CX
74 04 JE STORE
as GCD
If reminder is not
BB C2 MOV AX, DX zero, move reminder
to AX
Repeat comparison
EB EB JMP RPT
and division
STORE 89 0D MOV [DI], CX Store CX as GCD
CC INT 03 Stop the program
Conclusion:
12
EXPERIMENT - 6
ALGORITHM
1. Set SI register as pointer for data.
2. Get the data in AL register and clear AH register to convert the data to 16
bit.
3. Clear BP register to keep initial value of second word of final product as
zero.
4. Compare AX register with 01
5. Check zero flag, If zero flag is set then go to step19, otherwise go to next
step
6. Set CX register as count forN-1 multiplications
7. Move AX and BX register ,so that the initial multiplier in BX is the given
data
8. Decrement the multiplier ,(BX)
9. Multiply AX and BX to get the product in AX and DX
10. Save the product1 in stack
11. Load the second word of previous product in BP to Ax
12. Multiply AX and BX to get the product2 in AX and DX
13. Get the upper word of product1 in DX
14. Add AX and DX to get the second word of final product in AX
15. Move AX to BP to save the the final product in BP
16. Get the first word of product in Ax
17. Decrement multiplication counter
18. If CX is not zero, then go step8,otherwise go to next step.
19. Store AX and BP in memory locations
20. Stop the program
PROGRAM:
Set SI register as
BE 00 70 MOV SI,0700
pointer
8A 04 MOV AL,[SI] Get data in AL
B4 00 MOV AH,00 Clear AH register
Initialize the upper
BD 00 00 MOV BP,0000
word of result as zero
Check whether data is
3D 0001 CMP AX, 0001 01
13
EXPERIMENT – 7
OBJECTICVE
ALGORITHM
1. Set SI register as pointer for data.
2. Load the given data in CL register.
3. Set as pointer for the result.
4. Initialize the number to check as 01 in BL register.
5. Save 01 as first prime number.
6. Increment the result pointer(DI)
7. Increment the number to be checked(BL).
8. Load the initial divisor 02 in CL register.
9. Compare CL and BL registers.
10. Check zero flag. If zero flag is set then go to step 16, otherwise go to
next step.
11. Clear AH register and load the number to be checked in AlL register.
12. Divide AX by CL register.
13. Compare the reminder (AH) with zero.
14. Check zero flag. If zero flag is set then go to step 18, otherwise go to
next step
15. Increment the divisor and go to step 9
16. Save the prime number.
17. Increment the result pointer (DI).
18. Increment the number to be checked (BL).
19. Compare DL and BL registers
20. Check zero flag. If zero flag is reset then go to step 8, otherwise stop
PROGRAM:
Set SI register as
BE 00 70 MOV SI,0700 pointer for end data
N
Get data N in DL
8A 14 MOV DL,[SI]
register
Get DI as pointer
BF 12 00 MOV DI,1200 for storing prime
numbers
B3 01 MOV BL,01 Initialize the
15
number to 01
Save the first prime
88 1D MOV [DI],BL number
Increment the
47 INC DI address pointer
Increment BL
FE C3 INC BL
Set initial divisor as
GEN B1 02 MOV CL,02
02
If BL=CL,jump to
REP 3A D9 CMP BL,CL
store
Decrement the
74 0F JZ STORE
multiplier
B4 00 MOV AH,00 Clear AH register
Set the number to
8A C3 MOV AL,BL be checked as
dividend
F6 F1 52 DIV CL
Check whether the
80 FC 00 CMP AH,00
reminder is zero
If reminder is not
74,07 JZ NEXT zero, then
increment
FE C1 INC CL
The divisor and
EB ED JMP REP
jump to REP
Save the prime
STORE 88 1D MOV [DI],BL
number
Increment address
47 INC DI
pointer
Increment the
NEXT FE C3 INC BL number to be
checked
Check whether the
number to be
checked is not
3A DA CMP BL,DL
equal to N,then
continue generation
,otherwise stop
JNE GEN
INT 03
Conclusion:
16
EXPERIMENT – 8
FAMILIARISATION OF 8255
OBJECTIVE:
To familiarize 8255
ALGORITHM
1. Load AL with 80 to set the control word
2. Move the content of AL to control register
3. Load AL with 00
4. Load the content AL register to port A
5. Call Delay subroutine(step 8)
6. Increment AL
7. Jump to step 4
8. Load CX register with 6F
9. Decrement CX
10. Compare with zero ,if not equal jump to step 9 else next step
11. Return
PROGRAM
Conclusion:
17
EXPERIMENT - 9
ALGORITHM
PROGRAM:
Move count to CX
DELAY1 B9 00 08 MOV CX,800 register
Decrement count
LP1 49 DEC CX in CX
Conclusion
19
EXPERIMENT - 10
OBJECTICVE:
To generate triangular waveform using DAC
ALGORITHM:
1. Initialize the control port
2, Input the control word to assign all ports as output ports
3. Initialize port A
6. Clear AL register and out that to output port A
7. Increment AL register and out to output port A
8. Compare AL with BL
9. IF zero flag is reset then go to step7 otherwise go to next step
10. Decrement AL register and out to output port
11. Compare AL with 00
12. IF zero flag is set then go to step 6otherwise go to step10
PROGRAM:
E8 04 22 INC AL
B0 F6 CMP AL,0FF
E6 70 JNE L1
L2 E8 04 22 DEC AL
B0 F5 OUT 70,AL
E6 70 CMP AL,00
E8 04 22 JNE L2
B0 F9 JMP START
EXPERIMENT - 11
OBJECTICVE:
To interface analog to digital with 8086
ADC 0809 A/D card is an 8 bit analog to digital converter with 8 channel
multiplexer and microprocessor compatible control logic. The data line of ADC
809 D0 to D7 is connected to portA as input port .SOC is connected to PC0 as
output port. EOC is connected to PC1=4 as input port and ALE is connected to
PC1 as output port. All 8 inputs of 0-5V ADC-809 analog with external clock,
external EOC, external SOC signals are brought to 26 pin connector
.
ALGORITHM:
PROGRAM:
COMMENT
ADDRESS LABEL OPCODE MNEMONICS
Set Control
B0 98 MOV AL ,98
Word
Input control
word to control
E6 76 OUT 76, AL
register
Select channel
START B0 00 MOV AL, 00
E6 74 OUT 74,AL
21
E6 74 OUT 74,AL
E6 74 OUT 74,AL
Read EOC
EOC E4 74 IN AL ,74
Check EOC
24 10 AND AL,10
74 FA JZ EOC
MOV AL, 04 Set OE high
B0 04
E6 74 OUT 74,AL
IN AL,70 Read data
E4 70
Stop
CC INT 03
Conclusion:
EXPERIMENT – 12
22
OBJECTICVE:
To add a series of N numbers by using 8051 trainer
ALGORITHM:
1. Initialize the memory location.
2. Move contents from memory location to accumulator.
3. Copy the content of accumulator to register B
4. Increment accumulator
5. Multiply the content of registers A &B
6. Move the data 02 to register B
7. Divide the accumulator by the content of register B
8. Stop the program
PROGRAM:
Initialize the
MOV DPTR,#4000 memory location
Move contents from
memory location to
MOVX A, @ DPTR
accumulator.
OBJECTICVE:
ALGORITHM:
PROGRAM
R0
Decrement the
content of R0
DEC R0
Conclusion
EXPERIMENT -14
DATA TRANSFER
26
OBJECTIVE:
ALGORITHM
PROGRAM
Conclusion
EXPERIMENT-15
OBJECTIVE:
To print the given number is odd or even
ALGORITHM
1. Call the subroutine 0AC1(subroutine for reading address)
2. Increment DPTR
3. Copy the content of DPTR to A
4. OR the content of register A with data FE
5. Compare the content of A with data FE,if it is equal jump to step 8
otherwise next step
6. Copy the content of label MSG2 to DPTR
7. Jump to step 9
8. Copy the content of label MSG1 to DPTR
9. Call the subroutine 0A3C(subroutine for display)
10. Stop the program
PROGRAM
SJMP DISP
Display even or odd
ODD MOV DPTR Copy the content of
#MSG1 label MSG1 to DPTR
DISP LCALL 0A3C Subroutine for display
MSG1
4E,55,4D,42,45,52,20,49,53,20,4F,44,44,20,20,20,20,20,20,20
MSG 2
4E,55,4d,42,45,52,20,49,53,20,45,56,45,4E,20,20,20,20,20,20
Conclusion
30
EXPERIMENT – 16
ALGORITHM
PROGRAM
RRA
RRA
MOV R1,A Copy the content of
accumulator to register
31
R1
MOV A,R5
ANL A,#0F
Copy the content of
MOV R2,A accumulator to register
R2
Add accumulator with
MOV A,R1
register R2
Copy the data 0A to
MOV F0,#0A register B.
Multiply accumulator
MUL AB with B to get the value
of 10th position
Add accumulator with
ADD A,R2
register R2
INC PTR Increment DPTR
MOVX @PTR,A
Conclusion
32
EXPERIMENT-17
SQUARE WAVE GENERATION USING 8051
OBJECTIVE:
ALGORITHM
1. Complement port 1
2. Call delay subroutine
3. Jump to step 1
4. Copy the data 0F9 to register R2
5. Decrement the data until become zero
6. Return
PROGRAM
REPT Complement
CPL P1.0
Port 1
LCALL DELAY Call delay
SJMP REPT Jump to label
Copy 0F9 to
MOV R2,#0F9
register R2
L1 DJNZ R2,L1 Decrement R2
RET
Conclusion
33
EXPERIMENT - 18
OBJECTICVE:
To generate sine wave using DAC in 8051
ALGORITHM:
PROGRAM:
MOV DPTR,#4000
DJNZ R1, nxt Decrement R1 and if not
zero, then jump to step 5
Conclusion