Lab Manual
Lab Manual
PAIYANOOR
DEPARTMENTOFELECTRICALANDELECTRONICS
ENGINEERING
MICROCONTROLLERSLAB
2017R
LABMANUAL
AIM:
Write a program to add two 8 bit numbers and store the result in memory
location 4200 and 4201.
APPARATUS REQUIRED:
OBSERVATION:
Is carry NO
Flag
Set?
YES
Increment C register by one
Stop
PROGRAM FOR 8 BIT ADDITIONS:
RESULT:
Thus the program for addition of two 8-bit numbers has been written and
executed and the sum is verified.
AIM:
Write a program to subtract two 8 bit numbers and store the result in memory
location 4502 and 4503.
APPARATUS REQUIRED:
ALGORITHM:
Step 5: If the carry flag is reset go to step 7, else proceed to the next step.
Step 6: Take 2’s complement of the accumulator content and increment C register.
Step 7: Store the difference & borrow in memory location 4502 and 4503.
OBSERVATION:
ADDRESS DATA COMMENTS
Is carry NO
Flag
Set?
YES
Stop
PROGRAM FOR 8-BIT SUBTRACTION
RESULT:
Thus the subtraction program has been written & executed and the difference and
borrow were verified.
Experiment No: Date:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
OBSERVATION:
ADDRESS DATA COMMENTS
NO
Is carry flag
Set?
YES
Is multiplier NO
Zero
YES
Stop
RESULT:
Thus the Assembly Language Program for the multiplication of two 8-bit data
had been written and executed & the results were stored in desired memory locations.
Experiment No: Date:
AIM:
To write an Assembly Language Program for dividing two 8-bit numbers and
store the result in memory locations 4502 and 4503.
ALGORITHM:
\
Get dividend & divisor, Initialize C reg. for Quotient
Is
Dividend NO
>
Divisor
YES
Subtract Divisor from Dividend
Stop
PROGRAM FOR 8-BIT DIVISION
RESULT:
Thus the Assembly Language Program for the Division of two 8-bit data had
been written and executed & the results were stored in desired memory locations.
Experiment No: Date:
AIM:
To write an Assembly Language Program to find the largest number in the given
Array.
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Initialize the HL register pair with the address 4700H.
Step 2: Get the first Data in accumulator.
Step 3: Get the count (i.e., Length of the array) in B register.
Step 4: Compare the next data from the memory address pointed by HL pair to
the accumulator.
Step 5: Check the Carry Flag. If the CF is reset go to step 7 otherwise go to next
step.
Step 6: Move the data from the memory address pointed by HL pair to the
accumulator.
Step 7: Decrement the count (content of B register)
Step 8: If the content of B register is not equal to zero, go to step 4, otherwise
go to next step.
Step 9: Store the content of accumulator in the address 5000H.
Step 10: Stop the Process.
OBSERVATION:
Start
Is A content YES
Large?
NO
Move M to A
Decrement B reg
NO Is
Count=0
YES
Store the Content of accumulator as largest number
Stop
PROGRAM:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Initialize the HL register pair with the address 4700H.
Step 2: Get the first Data in accumulator.
Step 3: Get the count (i.e., Length of the array) in B register.
Step 4: Compare the next data from the memory address pointed by HL pair to
the accumulator.
Step 5: Check the Carry Flag. If the CF is set, go to step 7 otherwise go to next
step.
Step 6: Move the data from the memory address pointed by HL pair to the
accumulator.
Step 7: Decrement the count (content of B register)
Step 8: If the content of B register is not equal to zero, go to step 4, otherwise
go to next step.
Step 9: Store the content of accumulator in the address 5000H.
Step 10: Stop the Process.
OBSERVATION:
Start
Is A content YES
Small?
NO
Move M to A
Decrement B reg.
NO Is
Count=0
YES
Store the Content of accumulator as smallest number
Stop
PROGRAM:
LABEL ADDRESS MNEMONICS OPCODE OPERAND COMMENTS
START 4100 LXI H, 4700H 21 00, 47 Initialize the memory
pointer with the address
4700H
4103 MOV B,M 46 Get the length of the
array in B reg.
8085-ASCENDING ORDER
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Initialize the HL register pair with the address 4700H.
MICROCONTROLLERS LAB AVIT/EEE
Step 2: Get the count 1, number of repetitions (length of array - 1) in B
register.
Step 3: Get the count 2, number of comparisons (length of array -1) in C
register.
Step 4: Save the count 2 in E register.
Step 5: Move the content of E to C register.
Step 6: Initialize the HL register pair with the address 4701H.
Step 7: Move the data from memory location pointed by HL pair to the
Accumulator.
Step 8: Compare the data from next memory location with the content of
Accumulator.
Step 9: Check CF. If carry flag is set (accumulator content is smaller than the
other number), go to step 12 otherwise do next step.
Step 10: Check ZF. If zero flag is set (accumulator content is equal to the other
number), go to step 12 otherwise do next step.
Step 11: Store the smallest number to the previous memory location & greatest to
the current memory location.
Step 12: Decrement the number of comparisons (count 2).
Step 13: If the number of comparison is not equal to zero, go to step 7, otherwise
do the next step.
Step 14: Decrement the number of repetitions (count 1).
Step 15: If the number of repetitions is not equal to zero, go to step 5, otherwise
do next step.
Step 16: Stop the Process.
FLOWCHART 8085-ASCENDING ORDER
YES
Decrement COUNT 2
NO
Is COUNT 2 =
Zero?
YES
Decrement COUNT 1
NO
Is COUNT 1 =
zero?
YES
Stop
PROGRAM FOR SORTING A SERIES IN ASCENDING ORDER
410C INX H 23
4116 DCX H 2B
4118 INX H 23
SKIP 4119 DCR C 0D Decrement count 2
8085-DESCENDING ORDER
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Initialize the HL register pair with the address 4700H.
Step 2: Get the count 1, number of repetitions (length of array - 1) in B
register.
Step 3: Get the count 2, number of comparisons (length of array -1) in C
register.
Step 4: Save the count 2 in E register.
Step 5: Move the content of E to C register.
Step 6: Initialize the HL register pair with the address 4701H.
Step 7: Move the data from memory location pointed by HL pair to the
Accumulator.
Step 8: Compare the data from next memory location with the content of
Accumulator.
Step 9: Check CF. If carry flag is reset (accumulator content is larger than the
other number), go to step 12 otherwise do next step.
Step 10: Check ZF. If zero flag is set (accumulator content is equal to the other
number), go to step 12 otherwise do next step.
Start
YES
Decrement COUNT 2
NO
Is COUNT 2
= zero?
YES
Decrement COUNT 2
NO
Is COUNT 1
= zero?
YES
Stop
410C INX H 23
4116 DCX H 2B
4118 INX H 23
SKIP 4119 DCR C 0D Decrement count 2
AIM:
APPARATUS REQUIRED:
ALGORITHM:
OBSERVATION:
ADDRESS DATA COMMENTS
Decrement C reg.
NO
Is
ZF=1?
YES
Stop
PROGRAM OF BLOCK DATA TRANSFER:
RESULT:
Thus the assembly language program to transfer the block of data from memory
location 4700H to 4800H had been written and verified.
Experiment No: Date:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Get the Decimal data in A reg. and save in E reg.
Step 2: Mask the lower nibble of the decimal data in A reg.
Step 3: Rotate the upper nibble to the lower position.
Step 4: Clear the Accumulator.
Step 5: Move the 0AH to C reg.
Step 6: Add B reg. content to the A reg. Content.
Step 7: Decrement the C reg. If ZF=0 go to step 6. I f ZF=1 go to next step.
Step 8: Save the product in B reg.
Step 9: Get the decimal in A reg. from E reg. and mask the upper nibble(units).
Step 10: Add the units (A reg.) to product (B reg.).
Step 11: Stop the Process.
OBSERVATION:
Rotate the content of A reg. four times right & save it in B reg.
Decrement C reg.
NO Check
if ZF=1
YES
Move the content of A reg. to B reg.
Move the decimal data from E reg. to A reg. and mask the upper nibble
Stop
PROGRAM:
4109 RLC 07
410F DCR C 0D
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Initialize the BL reg. with 00H to account for carry.
Step 2: Move one of the data to AX reg.
Step 3: Move next data to CX reg.
Step 4: Clear Carry Flag.
Step 5: ADD the CX reg. content with the AX reg. Jump to step 7 if no carry
occurs. Otherwise go to next step.
Step 6: Increment BL reg.
Step 7: Move the sum to 1200H.
Step 8: Move the carry to 1202H.
Step 9: Stop the Process
OBSERVATION:
ADDRESS DATA COMMENTS
1202H 01 carry
FLOWCHART:
Is Carry NO
Set?
` YES
Increment BL reg
Stop
PROGRAM:
LABEL ADDRESS MNEMONICS OPCODE OPERAND COMMENTS
START 1000H MOV BL,00H C6,C3 00 Move 00H to BL reg. to
account for carry.
1003H MOV C7,C0 FF,FF Move the data FFFFH to AX
AX,FFFFH reg.
1007H MOV CX,001FH C7,C1 1F,00 Move the data 001FH to CX
reg.
100BH CLC F8 Clear Carry Flag.
AIM:
To write an assembly language program to Subtract two 16 bit numbers and store
the difference in the memory location 1200H and borrow in 1202H.
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Initialize the BL reg with 00H to account for borrow.
Step 2: Move Minuend to AX reg.
Step 3: Move Subtrahend to CX reg.
Step 4: Clear Carry Flag.
Step 5: Subtract the CX reg. content from the AX reg. Jump to step 7 if no carry
occurs. Otherwise go to next step.
Step 6: Increment BL reg.
Step 7: Move the difference to 1200H.
Step 8: Move the borrow to 1202H.
Step 9: Stop the Process
OBSERVATION:
ADDRESS DATA COMMENTS
1202H 00 Borrow
FLOWCHART:
NO
Is Carry
Set?
YES
Increment BL reg
Stop
PROGRAM:
LABEL ADDRESS MNEMONICS OPCODE OPERAND COMMENTS
START 1000H MOV BL,00H C6,C3 00 Move 00H to BL reg. to
account for carry.
1003H MOV C7,C0 FF,FF Move the data FFFFH to AX
AX,FFFFH reg.
1007H MOV C7,C1 1F,00 Move the data 001FH to CX
CX,OO1FH reg.
100BH CLC F8 Clear Carry Flag.
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Initialize the BL reg. with 00H to account for carry.
Step 2: Move Multiplicand to AX reg.
Step 3: Move Multiplier to CX reg.
Step 4: Clear Carry Flag.
Step 5: Multiply the CX reg. with the AX reg. Jump to step 7 if no carry occurs.
Otherwise go to next step.
Step 6: Increment BL reg.
Step 7: Move the content of AX & BL to the specified memory locations.
Step 9: Stop the Process
OBSERVATION:
ADDRESS DATA COMMENTS
1204H 00 Carry
FLOWCHART:
Is Carry NO
Set?
YES
Increment BL reg
Stop
PROGRAM:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Move the lower order byte of dividend to AX reg. and higher order byte of
dividend to DX reg.
Step 2: Move Divisor to CX reg.
Step 3: Divide the content of AX&DX by CX reg.
Step 4: Move the content of AX & DX in the specified memory locations.
Step 5: Stop the Process.
OBSERVATION:
ADDRESS DATA COMMENTS
Stop
PROGRAM:
AIM:
To perform the addition of two 8 bit numbers using immediate addressing and
store the result in memory.
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Clear register R0.
Step 2: Get the first data in accumulator.
Step 3: Add the second data with the first data.
Step 4: Make the data pointer to point the address 4500H.
Step 5: Check the carry flag. If no carry occurs, go to step 7, otherwise do next
step.
Step 6: Increment the register R0.
Step 7: Store the sum (content of accumulator) in the address pointed by the data
pointer.
Step 8: Make the data pointer to point the next address by incrementing the
DPTR.
Step 9: Store the carry in that address.
Step 10: Stop the process.
OBSERVATION:
Start
Is NO
Carry
Set?
YES
Increment R0 reg.
Stop
PROGRAM:
AIM:
To perform the subtraction of two 8 bit numbers using immediate addressing and
store the result in memory.
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Clear register R0
MICROCONTROLLERS LAB AVIT/EEE
Step 2: Get the data in accumulator.
Step 3: Subtract the second data from the first data.
Step 4: Make the data pointer to point the address 4500H.
Step 5: Check the carry flag. If no carry occurs, go to step 7, otherwise do next
step.
Step 6: Increment the register R0.
Step 7: Store the difference (content of accumulator) in the address pointed by the
data pointer.
Step 8: Make the data pointer to point the next address by incrementing the
DPTR.
Step 9: Store the borrow in that address.
Step 10: Stop the process.
OBSERVATION:
Is NO
CY flag set?
YES
Increment R0 reg.
Stop
PROGRAM:
AIM:
To write an 8051 assembly language program to multiply two 8-bit numbers and
store the result in memory.
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Get the first data in accumulator.
Step 2: Get the second data in reg B.
Step 3: Multiply two 8-bit data.
Step 4: Get the data pointer to point the address 4500H.
Step 5: Store the LSB of the result from the accumulator to the address pointed by
DPTR.
Step 6: Increment the data pointer.
OBSERVATION:
Stop
PROGRAM:
AIM:
To write an 8051 assembly language program to divide two 8-bit numbers and
store the result in memory.
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Get the first data in accumulator.
Step 2: Get the second data in reg B.
Step 3: Divide two 8-bit data.
MICROCONTROLLERS LAB AVIT/EEE
Step 4: Get the data pointer to point the address 4500H.
Step 5: Store the Quotient of the result from the accumulator to the address
pointed by DPTR.
Step 6: Increment the data pointer.
Step 7: Store the remainder of the result in the address pointed by DPTR.
Step 8: Stop the process.
OBSERVATION:
Stop
PROGRAM:
AIM:
To control the traffic light system using 8085 assembly language program.
APPARATUS REQUIRED:
ALGORITHM:
OBSERVATION:
ADDRESS DATA COMMENTS
4500H 80 Control Word
4501H 1A First Step Data
4502H A1 First Step Data
4503H 81 Second Step Data
4504H 5A Second Step Data
FLOWCHART:
Start
Call Delay
Decrement C register
If NO
C=0
YES
Is NO
DE=0 ?
YES
Décrément B reg
NO Is
B=0?
YES
POP stack to PC reg.
Return
PROGRAM:
LABEL ADDRESS MNEMONICS OPCODE OPERAND COMMENTS
START 4100H LXI H,4500H 21 00,45 Initialize HL pair with
4500H
` 4103H MVI C,02H 0E 02 Move data 02H to C reg.
4105H MOV A,M 7E Get data from memory to
accumulator.
4106H OUT CNT D3 0F Send data to control reg.
AIM:
APPARATUS REQUIRED:
OBSERVATION:
ADDRESS DATA DATA
INPUT 411AH 0A 09
411BH 06 05
411CH 05 06
411DH 09 0A
Décrément DE reg
Is NO
DE=0 ?
YES
Increment HL reg. pair
Decrement B reg.
Is NO
B=0?
YES
PROGRAM:
LABEL ADDRESS MNEMONICS OPCODE OPERAND COMMENTS
START 4100H LXI H,411AH 21 1A,41 Initialize HL reg. pair
with 411AH.
4103H MVI B,04H 06 04 Load data 04H to B reg.
Step A1 A2 B1 B2 A1 A2 B1 B2
1 1 0 0 0 1 0 0 0
2 0 0 0 1 0 0 1 0
3 0 1 0 0 0 1 0 0
4 0 0 1 0 0 0 0 1
Two Phase Stepping Scheme:
Clock wise Anti clock wise
Step A1 A2 B1 B2 A1 A2 B1 B2
1 1 0 0 1 1 0 1 0
2 0 1 0 1 0 1 1 0
3 0 1 1 0 0 1 0 1
4 1 0 1 0 1 0 0 1
RESULT:
Thus the program has been written and the stepper motor was rotated in two
directions at different speeds.
Experiment No: Date:
APPARATUS REQUIRED:
SQUARE WAVEFORM
ALGORITHM:
Step 1: Get the data 00H & output data at DAC1.
Step 2: Get the data FFH & output data at DAC4.
Step 3: Maintain data for sometime.
Step 4: Repeat the above steps.
SAWTOOTH WAVEFORM
ALGORITHM:
Step 1: Get the data 00H & output data at DAC1.
Step 2: Increment data to FFH.
Step 3: Repeat the above steps.
Step 4: Stop the process.
TRIANGULAR WVEFORM
ALGORITHM:
Step 1: Get the data 00H & output data at DAC1 or DAC2.
Step 2: Increment data to FFH.
Step 3: Decrement data from FFH to 00H.
Step 4: Repeat the above steps.
Step 5: Stop the process.
FLOWCHART:
Jump
DELAY:
Decrement C reg.
YES Is
C ≠ 0?
NO
Decrement B reg.
Is YES
B≠0?
NO
Return
FLOWCHART:
SAWTOOTH WAVEFORM
Start
Increment A
Is
YES A ≠ 0?
NO
Is
YES L ≠ 0?
NO
Move data FFH to L reg.
Is
YES L ≠ 0?
NO
PROGRAM:
SQUARE WAVEFORM
LABEL ADDRESS MNEMONICS OPCODE OPERAND COMMENTS
START 4300H MVI A,00H 3E 00
4319H DCR B 05
431DH RET C9
SAWTOOTH WAVEFORM
4504H INR A 3C
4605H INR L 2C
460EH DCR L 2D
Thus different waveforms were generated using DAC and 8085 microprocessor.
Experiment No: Date:
DC MOTOR INTERFACING
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Step 1: Run DC motor at full speed by latching FF to the DAC.
Step 2: Make the gate of channel 0 to logic 0.
Step 3: Call Delay for stable running.
Step 4: set mode as interrupt on terminal port.
Step 5: Load maximum value FFFFH to timer channel 0.
Step 6: Enable gate for one second.
Step 7: Make gate low.
Step 8: Store the count value from timer CH 0 to memory.
Step 9: Get the actual counter value & divide it by 4.
Step 10: Multiply it with 60 to convert RPM.
Step 11: Convert hexadecimal into decimal for actual RPM.
OBSERVATION:
CALL DELAY
Stop
DELAY:
Is NO
DE=0
YES
Decrement C reg
Is NO
C=0
YES
Return
PROGRAM:
412AH HLT 76
DELAY 412BH MVI C,03H 0E 03 Load C reg with data
03H.
LOOP2 412DH LXI H,A3C3H 21 C3,A3 Load HL reg with
A3C3H.
LOOP1 4130H DCX H 2B Decrement HL reg.
4132H ORA H B4
RESULT:
Thus the program had been written and the speed of DC motor was measured as
65400rpm.