2.microprocessor microcontroller lab 1
TRANSCRIPT
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
1/73
CHENDU
COLLEGEOFENGINEERINGANDTECHNOLOGY
MADURANTAKAM.
KANCHEEPURAM-603311.
CS6412 MICROPROCESSOR ANDMICROCONTROLLER
LABORATORY MANUAL
Prepared byN.S.SHINIJA, ASSISTANT PROFESSOR
Faculty of Electronics & Communication Engineering
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
2/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
2
EXPT.NO NAME OF THE EXPERIMENT PAGENO
1 Basic arithmetic and Logical operations 3
2 Move a Data Block Without Overlap 10
3 Code conversion, decimal arithmetic and Matrixoperations.
11
4 Floating point operations, string manipulations, sortingand searching
17
5 Password Checking, Print Ram Size And System Date 31
6 Counters and Time Delay 36
7 Traffic light control 38
8 Stepper motor control 40
9 Digital clock 42
10 Key board and Display 45
11 Printer status 48
12 Serial interface and Parallel interface 49
13 A/D and D/A interface and Waveform Generation 53
14 Basic arithmetic and Logical operations 59
15 Square and Cube program, Find 2s complement of a
number70
16 Unpacked BCD to ASCII 72
INDEX
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
3/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
3
EXPT NO: 01 DATE:
AIM:To write an Assembly Language Program (ALP) for performing the Arithmetic
operation of two byte numbers.
APPARATUS REQUIRED:
SL.NO
ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 kit 1
2. Power Supply +5 V dc 1
PROBLEM STATEMENT:Write an ALP in 8086 to add and subtract two byte numbers stored in the
memory location 1000H to 1003H and store the result in the memory location1004H to 1005H.Also provide an instruction in the above program to consider thecarry also and store the carry in the memory location 1006H.
ALGORITHM:
(i) 16-bit addition
Initialize the MSBs of sum to 0
Get the first number.
Add the second number to the firstnumber.
If there is any carry, increment
MSBs of sum by 1.
Store LSBs of sum.
Store MSBs of sum.
(ii) 16-bit subtraction
Initialize the MSBs of difference to0
Get the first number
Subtract the second number fromthe first number.
If there is any borrow, incrementMSBs of difference by 1.
Store LSBs of differenceStore MSBs of difference.
(iii) Multiplication of 16-bit
numbers:
Get the multiplier. Get the multiplicand
Initialize the product to 0.
Product = product +multiplicand
Decrement the multiplier by 1
If multiplicand is not equal to0,repeat from step (d) otherwisestore the product.
(iv)
Division of 16-bit numbers.
Get the dividend
Get the divisor
Initialize the quotient to 0. Dividend = dividenddivisor
If the divisor is greater, store thequotient. Go to step g.
If dividend is greater, quotient= quotient + 1. Repeat fromstep (d)Store the dividend
value as remainder.
BASIC ARITHMETIC AND LOGICAL OPERATIONS USING 8086
PROGRAMMING
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
4/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
4
FLOWCHART
ADDITION SUBTRACTION
START
SET UP COUNTER (CY)
GET SECOND OPERAND
TO A
A = A + B
STORE THE SUM
START
GET FIRST
OPERAND TO A
SUBTRACT
SECOND OPERANDFROM MEMORY
STORE THE
DIFFERENCE
STOP
IS THEREANY CARRY
GET FIRST OPERAND
COUNTER =
COUNTER + 1
STORE THE CARRY
STOP
SET UP COUNTER (CARRY)
IS THEREANY CY
COUNTER =
COUNTER + 1
STORE THE CARRY
NO
YES
YES
NO
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
5/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
5
ADDITION
ADDRESS Opcodes PROGRAM COMMENTS
MOV CX, 0000H Initialize counter CX
MOV AX,[1200] Get the first data in AX reg
MOV BX, [1202] Get the second data in BX reg
ADD AX,BX Add the contents of both theregs AX & BX
JNC L1 Check for carry
INC CX If carry exists, increment theCX
L1 : MOV [1206],CX Store the carry
MOV [1204], AX Store the sum
HLT Stop the program
SUBTRACTION
ADDRESS OPCODES PROGRAM COMMENTS
MOV CX, 0000H Initialize counter CX
MOV AX,[1200] Get the first data in AX reg
MOV BX, [1202] Get the second data in BX reg
SUB AX,BX Subtract the contents of BX fromAX
JNC L1 Check for borrow
INC CX If borrow exists, increment theCX
L1 : MOV [1206],CX Store the borrow
MOV [1204], AX Store the difference
HLT Stop the program
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
6/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
6
RESULT:.
ADDITION
MEMORY
DATA
SUBTRACTION
MEMORY
DATA
MANUAL CALCULATION
.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
7/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
7
FLOWCHART
MULTIPLICATION DIVISION
Start
Get Multiplier & Multiplicand
MULTIPLICAND
REGISTER=00
REGISTER =REGISTER +
MULTIPLICAND
Multiplier=MU
LTIPLIER1
MULTIPLIER
IS
=0?
NO
YES
Start
Load Divisor &
Dividend
QUOTIENT = 0
DIVIDEND =
DIVIDEND-DIVISOR
QUOTIENT = QUOTIENT+1
DIVIDEND BL go to L1
DEC SI Else, Decrement the memory location
MOV [SI],AL Store the largest data
MOV AL,BL Get the next data AL
JMP L2 Jump to L2
L1 : DEC SI Decrement the memory location
MOV [SI],BL Store the smallest data in memorylocation
L2 : INC SI Go to next memory location
DEC DL Decrement the count
JNZ L3 Jump to L3, if the count is not reachedzero
MOV [SI],AL Store data in memory location
DEC CL Decrement the count
JNZ L4 Jump to L4, if the count is not reachedzero
HLT Stop
RESULT:.
ASCENDING
MEMORY
DATA
DESCENDING
MEMORY
DATA
Thus given array of numbers are sorted in ascending & descending order.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
27/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
27
LARGEST& SMALLEST
AIM:
To write an Assembly Language Program (ALP) to find the largest and
smallest number in a given array.
APPARATUS REQUIRED:
SL.NO
ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 1
2. Power Supply +5 V dc 1
PROBLEM STATEMENT:
An array of length 10 is given from the location. Find the largest andsmallest number and store the result.
ALGORITHM:
(i) Finding largest number:
a. Load the array count in a register C1.b. Get the first two numbers.c.
Compare the numbers and exchange if the number is small.d. Get the third number from the array and repeat the process until C1 is 0.
(ii) Finding smallest number:
e. Load the array count in a register C1.f. Get the first two numbers.g. Compare the numbers and exchange if the number is large.h. Get the third number from the array and repeat the process until C1 is 0.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
28/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
28
FLOWCHART
LARGEST NUMBER IN AN ARRAY SMALLEST NUMBER IN AN ARRAY
MAX = POINTER
IS MAX
INITIALIZECOUNT
PONITER =
POINTER + 1
COUNT = COUNT-1
STORE MAXIMUM
IS COUNT = 0?
YES
NO
YES
NO
STOP
START START
INITIALIZECOUNT
PONITER =
POINTER + 1
IS MIN
MIN = POINTER
COUNT = COUNT-1
IS COUNT = 0?
STORE MINIIMUM
STOP
YES
NO
NO
YES
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
29/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
29
LARGEST
ADDRESS OPCODES PROGRAM COMMENTS
MOV SI,1200H Initialize array size
MOV CL,[SI] Initialize the count
INC SI Go to next memory location
MOV AL,[SI] Move the first data in AL
DEC CL Reduce the count
L2 : INC SI Move the SI pointer to next data
CMP AL,[SI] Compare two datas
JNB L1 If AL > [SI] then go to L1 ( no swap)
MOV AL,[SI] Else move the large number to AL
L1 : DEC CL Decrement the count
JNZ L2 If count is not zero go to L2
MOV DI,1300H Initialize DI with 1300H
MOV [DI],AL Else store the biggest number in 1300location
HLT Stop
SMALLEST
ADDRESS OPCODES PROGRAM COMMENTS
MOV SI,1200H Initialize array size
MOV CL,[SI] Initialize the count
INC SI Go to next memory location
MOV AL,[SI] Move the first data in AL
DEC CL Reduce the count
L2 : INC SI Move the SI pointer to next data
CMP AL,[SI] Compare two datas
JB L1 If AL < [SI] then go to L1 ( no swap)
MOV AL,[SI] Else move the large number to AL
L1 : DEC CL Decrement the count
JNZ L2 If count is not zero go to L2
MOV DI,1300H Initialize DI with 1300H
MOV [DI],AL Else store the biggest number in 1300location
HLT Stop
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
30/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
30
RESULT:.
LARGEST
MEMORY
DATA
SMALLEST
MEMORY
DATA
Thus largest and smallest number is found in a given array.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
31/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
31
EXPT NO:05 DATE:
AIM:To write an Assembly Language Program (ALP) for performing the Arithmetic
operation of two byte numbers
APPARATUS REQUIRED:
SL.NO
ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 kit 1
2. Power Supply +5 V dc 1
PROGRAM:;PASSWORD IS MASM1234DATA SEGMENTPASSWORD 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 ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXLEA DX,MSG1MOV AH,09HINT 21H
MOV SI,00UP1:MOV AH,08HINT 21HCMP AL,0DHJE DOWNMOV [INST+SI],ALMOV DL,'*'MOV AH,02HINT 21HINC SIJMP UP1DOWN:
PASSWORD CHECKING, PRINT RAM SIZE AND SYSTEM DATE
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
32/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
32
MOV BX,00MOV CX,LENCHECK:MOV AL,[INST+BX]MOV DL,[PASSWORD+BX]
CMP AL,DLJNE FAILINC BXLOOP CHECKLEA DX,MSG2MOV AH,09HINT 21HJMP FINISHFAIL:LEA DX,MSG3MOV AH,009H
INT 21HFINISH:INT 3CODE ENDSEND STARTEND
;Today.asm Display month/day/year.; Feb 1st, 2012;CIS 206 Ken Howard
.MODEL small
.STACK 100h
.DATAmess1 DB 10, 13, 'Today is $' ; 10=LF, 13=CR.CODE
Today PROCMOV AX, @data
MOV DS, AXMOV DX, OFFSET mess1 ; Move string to DX
MOV AH, 09h ; 09h call to display string (DX > AH > DOS)
INT 21H ; Send to DOS; CX year, DH month, DL dayMOV AH, 2AH ; Get the date (appendix D)INT 21H ; Send to DOSPUSH CX ; Move year to the stack
MOV CX, 0 ; Clear CX
MOV CL, DLPUSH CX ; Move day to stackMOV CL, DH ; Move month > CL
PUSH CX ; Move month to stack
MOV DH, 0 ; Clear DH; ************************** DISPLAY MONTH ************************
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
33/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
33
; Set up for division; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX; Remainder will be in DX
MOV DX, 0 ; Clear DX
POP AX ; Remove month from stack into AXMOV CX, 0 ; Initialize the counter
MOV BX, 10 ; Set up the divisordividem:
DIV BX ; Divide (will be word sized)PUSH DX ; Save remainder to stackADD CX, 1 ; Add one to counter
MOV DX, 0 ; Clear the remainderCMP AX, 0 ; Compare quotient to zeroJNE dividem ; If quoient is not zero, go to "dividem:"
divdispm:
POP DX ; Remove top of stack into DXADD DL, 30h ; ADD 30h (2) to DL
MOV AH, 02h ; 02h to display AH (DL)INT 21H ; Send to DOSLOOP divdispm ; If more to do, divdispm again
; LOOP subtracts 1 from CX. If non-zero, loop.MOV DL, '/' ; Character to display goes in DL
MOV AH, 02h ; 02h to display AH (DL)INT 21H ; Send to DOS
; ************************** DISPLAY DAY ************************; Set up for division
; Dividend will be in DX/AX pair (4 bytes); Quotient will be in AX; Remainder will be in DX
MOV DX, 0 ; Clear DXPOP AX ; Remove day from stack into AXMOV CX, 0 ; Initialize the counterMOV BX, 10 ; Set up the divisor
divided:DIV BX ; Divide (will be word sized)
PUSH DX ; Save remainder to stack
ADD CX, 1 ; Add one to counterMOV DX, 0 ; Clear the remainderCMP AX, 0 ; Compare quotient to zeroJNE divided ; If quoient is not zero, go to "divided:"
divdispd:POP DX ; Remove top of stack
ADD DL, 30h ; ADD 30h (2) to DLMOV AH, 02h ; 02h to display AH (DL)INT 21H ; Send to DOS
LOOP divdispd ; If more to do, divdispd again; LOOP subtracts 1 from CX. If non-zero, loop.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
34/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
34
MOV DL, '/' ; Character to display goes in DLMOV AH, 02h ; 02h to display AH (DL)INT 21H ; Send to DOS
; ************************** DISPLAY YEAR ************************; Set up for division
; Dividend will be in DX/AX pair (4 bytes); Quotient will be in AX; Remainder will be in DX
MOV DX, 0 ; Clear DXPOP AX ; Remove month from stack into AXMOV CX, 0 ; Initialize the counter
MOV BX, 10 ; Set up the divisordividey:
DIV BX ; Divide (will be word sized)PUSH DX ; Save remainder to stackADD CX, 1 ; Add one to counter
MOV DX, 0 ; Clear the remainderCMP AX, 0 ; Compare quotient to zeroJNE dividey ; If quoient is not zero, go to "dividey:"
divdispy:POP DX ; Remove top of stack into DX
ADD DL, 30h ; ADD 30h (2) to DLMOV AH, 02h ; 02h to display AH (DL)INT 21H ; Send to DOS
LOOP divdispy ; If more to do, divdisp again; LOOP subtracts 1 from CX. If non-zero, loop.
MOV al, 0 ; Use 0 as return codeMOV AH, 4ch ; Send return code to AHINT 21H ; Send return code to DOS to exit.
Today ENDP ; End procedureEND Today ; End code. Start using "Today" procedure.MVI A, 80H: Initialize 8255, port A and port BOUT 83H (CR): in output modeSTART: MVI A, 09HOUT 80H (PA): Send data on PA to glow R1 and R2MVI A, 24H
OUT 81H (PB): Send data on PB to glow G3 and G4MVI C, 28H: Load multiplier count (40) for delayCALL DELAY: Call delay subroutineMVI A, 12HOUT (81H) PA: Send data on Port A to glow Y1 and Y2OUT (81H) PB: Send data on port B to glow Y3 and Y4MVI C, 0AH: Load multiplier count (10) for delayCALL: DELAY: Call delay subroutineMVI A, 24HOUT (80H) PA: Send data on port A to glow G1 and G2MVI A, 09H
OUT (81H) PB: Send data on port B to glow R3 and R4MVI C, 28H: Load multiplier count (40) for delay
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
35/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
35
CALL DELAY: Call delay subroutineMVI A, 12HOUT PA: Send data on port A to glow Y1 and Y2OUT PB: Send data on port B to glow Y3 and Y4MVI C, 0AH: Load multiplier count (10) for delay
CALL DELAY: Call delay subroutineJMP STARTDelay Subroutine:DELAY: LXI D, Count: Load count to give 0.5 sec delayBACK: DCX D: Decrement counterMOV A, DORA E: Check whether count is 0JNZ BACK: If not zero, repeatDCR C: Check if multiplier zero, otherwise repeatJNZ DELAYRET: Return to main program
Ram size:
ORG 0000HCLR PSW3CLR PSW4
CPL AADD A, #01HMOV A,R3
AGAIN: SJMP AGAIN
RESULT:Thus the output for the Password checking, Print RAM size and system date was
executed successfully
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
36/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
36
EXP.NO: 06 DATE:
AIM:To write an assembly language program in 8086 to Counters and Time Delay
APPARATUS REQUIRED:SL.NO ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc,+12 V dc 1
3. Stepper Motor Interface board - 1
4. Stepper Motor - 1
PROGRAM:.MODEL SMALL.DATA
MSGIN DB 'Enter delay duration (0-50): $'MSG1 DB 'This is Microprocessor!$'DELAYTIME DW 0000H
.CODE
MOV DX,@DATAMOV DS,DXLEA DX,MSGINMOV AH,09HINT 21H
IN1:MOV AH,01HINT 21HCMP AL,0DH ;
JE NXTSUB AL,30HMOV DL,ALMOV AX,BXMOV CL,0AHMUL CLMOV BX,AXAND DX,00FFHADD BX,DXMOV DELAYTIME,BXLOOP IN1
Counters and Time Delay
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
37/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
37
NXT: MOV CX,DELAYTIMEMOV DL,10MOV AH,02HINT 21H
LEA SI,MSG1
LP: PUSH DXMOV DL,[SI]CMP DL,'$'JE NXT2
MOV AH,02HINT 21HADD SI,1POP DXMOV DI,DELAYTIME
MOV AH, 0INT 1AhMOV BX, DX
Delay:MOV AH, 0INT 1AhSUB DX, BXCMP DI, DXJA Delay
LOOP LP
NXT2: MOV AH,4CHINT 21H
END
RESULT:Thus the output for the Counters and Time Delay was executed successfully
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
38/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
38
EXP.NO: 07 DATE:
AIM:To write an assembly language program in 8086 to Traffic light control
APPARATUS REQUIRED:
SL.NO ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc,+12 V dc 1
3. Traffic light control Interfaceboard
- 1
PROGRAM:
TRAFFIC LIGHT CONTROL
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
39/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
39
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
40/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
40
EXP.NO: 08 DATE:
AIM:To write an assembly language program in 8086 to rotate the motor at different speeds.
APPARATUS REQUIRED:
SL.NO ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc,+12 V dc 1
3. Stepper Motor Interface board - 1
4. Stepper Motor - 1
PROBLEM STATEMENT:
Write a code for achieving a specific angle of rotation in a given time and particularnumber of rotations in a specific time.
THEORY:
A motor in which the rotor is able to assume only discrete stationary angularposition is a stepper motor. The rotary motion occurs in a stepwise manner from one
equilibrium position to the next.Two-phase scheme: Any two adjacent stator windings areenergized. There are two magnetic fields active in quadrature and none of the rotor pole facescan be in direct alignment with the stator poles. A partial but symmetric alignment of therotor poles is of course possible.
ALGORITHM:
For running stepper motor clockwise and anticlockwise directions(i)
Get the first data from the lookup table.(ii) Initialize the counter and move data into accumulator.(iii)
Drive the stepper motor circuitry and introduce delay
(iv)
Decrement the counter is not zero repeat from step(iii)(v)
Repeat the above procedure both for backward and forward directions.
SWITCHING SEQUENCE OF STEPPER MOTOR:
MEMORY
LOCATION
A1 A2 B1 B2 HEX
CODE
4500 1 0 0 0 09 H
4501 0 1 0 1 05 H
4502 0 1 1 0 06 H
4503 1 0 1 0 0A H
STEPPER MOTOR INTERFACING
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
41/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
41
FLOWCHART:
PROGRAM TABLE
ADDRESS OPCODE PROGRAM COMMENTS
START : MOV DI, 1200H Initialize memory location to store thearray of number
MOV CX, 0004H Initialize array size
LOOP 1 : MOV AL,[DI] Copy the first data in AL
OUT 0C0,AL Send it through port address
MOV DX, 1010H Introduce delayL1 : DEC DX
JNZ L1
INC DI Go to next memory location
LOOP LOOP1 Loop until all the datas have been sent
JMP START Go to start location for continuousrotation
1200 : 09,05,06,0A Array of datas
RESULT: Thus the assembly language program for rotating stepper motor in both clockwiseand anticlockwise directions is written and verified.
START
INTIALIZE COUNTER FOR LOOK UP TABLE
GET THE FIRST DATA FROM THE ACCUMULATOR
MOVE DATA INTO THE ACCUMULATOR
DRIVE THE MOTOR
DECREMENT COUNTER
GET THE DATA FROM LOOK UP
IS B = 0 ?
DELAY
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
42/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
42
EXP.NO: 09 DATE:
AimTo display the digital clock specifically by displaying the hours, minutes and seconds
using 8086 kits
Apparatus required
S.No Item Specification
1 Microprocessor kit 8086
2 Power Supply 5V
Preliminary SettingsOrg 1000h
Store time value in memory location 1500- Seconds1501- Minutes1502- Hours
Digital clock program
DIGITAL CLOCK
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
43/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
43
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
44/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
44
ResultThus 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.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
45/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
45
EXP.NO:10 DATE:
AIM :To display the rolling message HELP US in the display.
APPARATUS REQUIRED:8086 Microprocessor kit, Power supply, Interfacing board.
ALGORITHM :Display of rolling message HELP US
1.
Initialize the counter2. Set 8279 for 8 digit character display, right entry3.
Set 8279 for clearing the display4. Write the command to display5.
Load the character into accumulator and display it6. Introduce the delay7.
Repeat from step 1.
1. Display Mode Setup: Control word-10 H
0 0 0 1 0 0 0 0
0 0 0 D D K K K
DD00- 8Bit character display left entry01- 16Bit character display left entry10- 8Bit character display right entry11- 16Bit character display right entry
KKK- Key Board Mode000-2Key lockout.
2.Clear Display:Control word-DC H
1 1 0 1 1 1 0 0
1 1 0 CD CD CD CF CA
11 A0-3; B0-3 =FF
INTERFACING PRGRAMMABLE KEYBOARD AND
DISPLAY CONTROLLER- 8279
1-Enables Clear display
0-Contents of RAM will be displayed
1-FIFO Status is cleared
1-Clear all bits
(Combined effect of CD)
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
46/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
46
3. Write Display: Control word-90H
1 0 0 1 0 0 0 0
1 0 0AI A A A A
FLOWCHART
SEGMENT DEFINITION
DATA BUS D7 D6 D5 D4 D3 D2 D1 D0
SEGMENTS d c b a dp g f e
Selects one of the 16 rows of display.
Auto increment = 1, the row address selected will be incremented after each of read andwrite operation of the display RAM.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
47/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
47
PROGRAM TABLE
PROGRAM COMMENTS
START : MOV SI,1200H Initialize array
MOV CX,000FH Initialize array size
MOV AL,10 Store the control word for display mode
OUT C2,AL Send through output port
MOV AL,CC Store the control word to clear display
OUT C2,AL Send through output port
MOV AL,90 Store the control word to write display
OUT C2,AL Send through output port
L1 : MOV AL,[SI] Get the first data
OUT C0,AL Send through output port
CALL DELAY Give delay
INC SI Go & get next data
LOOP L1 Loop until all the datas have been taken
JMP START Go to starting location
DELAY : MOV DX,0A0FFH Store 16bit count value
LOOP1 : DEC DX Decrement count value
JNZ LOOP1 Loop until count values becomes zero
RET Return to main program
LOOK-UP TABLE:
1200 98 68 7C C8
1204 FF 1C 29 FF
RESULT:
MEMORY
LOCATION
7-SEGMENT LED FORMAT HEX DATA
d c b a dp e g f
1200H 1 0 0 1 1 0 0 0 98
1201H 0 1 1 0 1 0 0 0 68
1202H 0 1 1 1 1 1 0 0 7C
1203H 1 1 0 0 1 0 0 0 C8
1204H 1 1 1 1 1 1 1 1 FF
1205H 0 0 0 0 1 1 0 0 1C
1206H 0 0 1 0 1 0 0 1 29
1207H 1 1 1 1 1 1 1 1 FF
Thus the rolling message HELP US is displayed using 8279 interface kit.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
48/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
48
EXP.NO:11 DATE:AIM:To display the Printer Status in the display
APPARATUS REQUIRED:8086 Microprocessor kit, Power supply, interfacing board.
PROGRAM:
XOR AX, AXXOR BX, BX
;this divides my 3digit number by 100 giving me my, hundredth digitMOV AX, RESMOV BX, 100DIV BX
;prints the hundredth digitADD AL, '0'MOV DL, ALPUSH AX ; save AX on the stackMOV AH, 02hINT 21hPOP AX ; restore ax
;divides the remainder by 10 giving me my tens digitMOV BX, 10DIV BX
;prints my tens digitADD AL, '0'MOV DL, AL
PUSH AX ; save AX on the stackMOV AH, 02hINT 21hPOP AX ; restore ax
;print my last remainder which is my onesADD AH, '0'MOV DL, AHMOV AH, 02hINT 21h
RESULT:Thus the output for the Move a data block without overlap was executed successfully
PRINTER STATUS
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
49/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
49
EXP.NO: 12 DATE:
AimTo connect two 8086 microprocessor kits and to serially communicate with
each other by considering transmitter and receiver kits.
Apparatus required
Procedure
1. Take two no of 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 9-9 serial cable in the serial port of the microprocessor kits.(LCD kit means PC-PC cable. LED kit means kit-kit cable)
5. Enter the data in transmitter kit use the memory location 1500.
6. Execute the receiver kit.
7. Execute the transmitter kit.
8. Result will be available in receiver kit memory location 1500.
Transmitter Program
SERIAL INTERFACE AND PARALLEL INTERFACE
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
50/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
50
Receiver Program
Result
Thus the serial communication between two 8086 microprocessor kits has beenestablished and the data is transmitted in one kit and received in the other kitsuccessfully
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
51/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
51
PARALLEL COMMUNICATION BETWEEN TWO 8086 MICROPROCESSORS KITS
AimTo connect two 8086 microprocessor kits and to establish parallel communication with eachother by considering transmitter and receiver kits.
Apparatus required
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 to get same eight data.
8. Data is available in transmitter kit in the memory location.
9. Change the data & execute the following procedure & get the result in receiver kit.
Transmitter program
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
52/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
52
Receiver Program
ResultThus the serial communication between two 8086 microprocessor kits has been establishedand the data is transmitted in one kit and received in the other kit successfully.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
53/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
53
EXPT NO:13 DATE:AIM:
To write an assembly language program to convert an analog signal into a digital signalusing an ADC interfacing.
APPARATUS REQUIRED:
SL.NO ITEM SPECIFICATION QUANTITY1. Microprocessor kit 8086 1
2. Power Supply +5 V dc,+12 V dc 1
3. ADC Interface board - 1
THEORY:An ADC usually has two additional control lines: the SOC input to tell the ADC when to
start the conversion and the EOC output to announce when the conversion is complete. Thefollowing program initiates the conversion process, checks the EOC pin of ADC 0809 as towhether the conversion is over and then inputs the data to the processor. It also instructs the
processor to store the converted digital data at RAM location.
ALGORITHM:(i) Select the channel and latch the address.(ii) Send the start conversion pulse.(iii) Read EOC signal.(iv) If EOC = 1 continue else go to step (iii)(v) Read the digital output.
(vi)
Store it in a memory location.FLOW CHART:
START
SELECT THE CHANNEL AND LATCH
SEND THE START CONVERSION PULSE
READ THE DIGITALOUTPUT
STORE THE DIGITAL VALUE IN THE
MEMORY LOCATION SPECIFIED
IS EOC = 1?
STOP
NO
YES
A/D AND D/A INTERFACE AND WAVEFORM GENERATION
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
54/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
54
PROGRAM TABLE
PROGRAM COMMENTS
MOV AL,00 Load accumulator with value for ALE high
OUT 0C8H,AL Send through output port
MOV AL,08 Load accumulator with value for ALE low
OUT 0C8H,AL Send through output port
MOV AL,01 Store the value to make SOC high in the accumulator
OUT 0D0H,AL Send through output port
MOV AL,00
Introduce delayMOV AL,00
MOV AL,00MOV AL,00 Store the value to make SOC low the accumulator
OUT 0D0H,AL Send through output port
L1 : IN AL, 0D8H
Read the EOC signal from port & check for end of
conversionAND AL,01
CMP AL,01
JNZ L1 If the conversion is not yet completed, read EOC signal
from port again
IN AL,0C0H Read data from port
MOV BX,1100 Initialize the memory location to store data
MOV [BX],AL Store the data
HLT Stop
RESULT:
ANALOG
VOLTAGE
DIGITAL DATA ON LED
DISPLAY
HEX CODE IN MEMORY
LOCATION
Thus the ADC was interfaced with 8086 and the given analog inputs were converted into itsdigital equivalent.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
55/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
55
INTERFACING DIGITALTOANALOG CONVERTER
AIM :1. To write an assembly language program for digital to analog conversion2. To convert digital inputs into analog outputs & To generate different waveforms
APPARATUS REQUIRED:
SL.NO ITEM SPECIFICATION QUANTITY1. Microprocessor kit 8086 Vi Microsystems 1
2. Power Supply +5 V, dc,+12 V dc 1
3. DAC Interface board - 1
PROBLEM STATEMENT:The program is executed for various digital values and equivalent analog voltages are
measured and also the waveforms are measured at the output ports using CRO.
THEORY:Since DAC 0800 is an 8 bit DAC and the output voltage variation is between 5v
and +5v. The output voltage varies in steps of 10/256 = 0.04 (approximately). The digital datainput and the corresponding output voltages are presented in the table. The basic idea behindthe generation of waveforms is the continuous generation of analog output of DAC. With 00(Hex) as input to DAC2 the analog output is 5v. Similarly with FF H as input, the output is+5v. Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square waveof amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to DAC2. Repeatthis sequence again and again. As a result a saw-tooth wave will be generated at DAC2output. Output digital data from 00 to FF in constant steps of 01 to DAC2. Output digital datafrom FF to 00 in constant steps of 01 to DAC2. Repeat this sequence again and again. As aresult a triangular wave will be generated at DAC2 output.
ALGORITHM:
Measurement of analog voltage:
(i)
Send the digital value of DAC.(ii)
Read the corresponding analog value of its output.
Waveform generation:Square Waveform:(i) Send low value (00) to the DAC.(ii)
Introduce suitable delay.(iii) Send high value to DAC.(iv) Introduce delay.(v) Repeat the above procedure.Saw-tooth waveform:(i)
Load low value (00) to accumulator.
(ii)
Send this value to DAC.(iii)
Increment the accumulator.(iv) Repeat step (ii) and (iii) until accumulator value reaches FF.(v)
Repeat the above procedure from step 1.Triangular waveform:(i)
Load the low value (00) in accumulator.(ii) Send this accumulator content to DAC.(iii) Increment the accumulator.(iv) Repeat step 2 and 3 until the accumulator reaches FF, decrement the
accumulator and send the accumulator contents to DAC.(v) Decrementing and sending the accumulator contents to DAC.
(vi)
The above procedure is repeated from step (i)
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
56/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
56
FLOWCHART:MEASUREMENT OF ANALOG VOLTAGE SQUARE WAVE FORM
TRIANGULAR WAVEFORM
SAWTOOTH WAVEFORM
START
SEND THEDIGITALVALUE TO
ACCUMULATOR
TRANSFER THEACCUMULATOR
READ THE CORRESPONDINGANALOG VALUE
STOP
INTIALISE THEACCUMULATOR SEND ACC
LOAD THE ACC WITH MAXVALUE SEND ACC CONTENT
START
INITIALIZE
ACCUMULATOR
SEND ACCUMULATOR
INCREMENTACCUMULATOR
IS ACC
FF
YESNO
START
INITIALIZEACCUMULATOR
SEND ACCUMULATOR
CONTENT TO DAC
INCREMENTACCUMULATOR
DECREMENT
ACCUMULATOR CONTENT
SENDACCUMULATOR
START
DELAY
DELAY
IS ACCFF
NO
YES
IS ACC00YES NO
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
57/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
57
MEASUREMENT OF ANALOG VOLTAGE:
PROGRAM COMMENTS
MOV AL,7FH Load digital value 00 in accumulator
OUT C0,AL Send through output port
HLT Stop
DIGITAL DATA ANALOG VOLTAGE
PROGRAM TABLE: Square Wave
PROGRAM COMMENTS
L2 : MOV AL,00H Load 00 in accumulator
OUT C0,AL Send through output port
CALL L1 Give a delay
MOV AL,FFH Load FF in accumulator
OUT C0,AL Send through output port
CALL L1 Give a delay
JMP L2 Go to starting location
L1 : MOV CX,05FFH Load count value in CX register
L3 : LOOP L3 Decrement until it reaches zero
RET Return to main program
PROGRAM TABLE: Saw tooth Wave
PROGRAM COMMENTS
L2 : MOV AL,00H Load 00 in accumulator
L1 : OUT C0,AL Send through output port
INC AL Increment contents of accumulator
JNZ L1 Send through output port until it reaches FF
JMP L2 Go to starting location
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
58/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
58
PROGRAM TABLE: Tri angular Wave
PROGRAM COMMENTS
L3 : MOV AL,00H Load 00 in accumulatorL1 : OUT C0,AL Send through output port
INC AL Increment contents of accumulator
JNZ L1 Send through output port until it reaches FF
MOV AL,0FFH Load FF in accumulator
L2 : OUT C0,AL Send through output port
DEC AL Decrement contents of accumulator
JNZ L2 Send through output port until it reaches 00
JMP L3 Go to starting location
RESULT:WAVEFORM GENERATION:
WAVEFORMS AMPLITUDE TIMEPERIOD
Square Waveform
Saw-tooth waveform
Triangular waveform
MODEL GRAPH:
Square Waveform Saw-tooth waveform
Triangular waveform
Thus the DAC was interfaced with 8085 and different waveforms have been generated.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
59/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
59
EXPT NO:14 DATE:
8 BIT ADDITION
AIM:To write a program to add two 8-bit numbers using 8051 microcontroller.
ALGORITHM:
1. Clear Program Status Word.2. Select Register bank by giving proper values to RS1 & RS0 of PSW.3. Load accumulator A with any desired 8-bit data.4. Load the register R0with the second 8- bit data.5. Add these two 8-bit numbers.6. Store the result.7. Stop the program.
FLOW CHART:
START
Clear PSW
Select Register
Load A and R0with 8- bit datas
Add A & R0
Store the sum
STOP
BASIC ARITHMETIC AND LOGICAL OPERATIONS
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
60/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
60
8 Bit Addition (Immediate Addressing)
ADDRESS LABEL MNEMONIC OPERAND HEX
CODE
COMMENTS
4100 CLR C C3 Clear CY Flag
4101 MOV A, data1 74,data1 Get the data1 inAccumulator
4103 ADDC A, # data 2 24,data2 Add the data1 with
data2
4105 MOV DPTR, #
4500H
90,45,00 Initialize the memory
location
4108 MOVX @ DPTR, A F0 Store the result in
memory location
4109 L1 SJMP L1 80,FE Stop the program
RESULT:
OUTPUT
MEMORY LOCATION DATA
4500
Thus the 8051 ALP for addition of two 8 bit numbers is executed.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
61/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
61
8 BIT SUBTRACTION
AIM:To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
a.
Clear the carry flag.b. Initialize the register for borrow.c.
Get the first operand into the accumulator.d. Subtract the second operand from the accumulator.e.
If a borrow results increment the carry register.f. Store the result in memory.
FLOWCHART:
START
CLEAR CARRY
FLAG
GET IST
OPERAND IN
ACCR
SUBTRACT THE
2ND OPERANDFROM ACCR
STORERESULT IN
MEMORY
STOP
IS CF=1
INCREMENTTHE BORROW
REGISTER
Y
N
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
62/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
62
8 Bit Subtraction (Immediate Addressing)
ADDRESS LABEL MNEMONIC OPERAND HEX
CODE
COMMENTS
4100 CLR C C3 Clear CY flag
4101 MOV A, # data1 74, data1 Store data1 inaccumulator
4103 SUBB A, # data2 94,data2 Subtract data2 from
data1
4105 MOV DPTR, # 4500 90,45,00 Initialize memory
location
4108 MOVX @ DPTR, A F0 Store the difference
in memory location
4109 L1 SJMP L1 80,FE Stop
RESULT:
OUTPUTMEMORY LOCATION DATA
4500
Thus the 8051 ALP for subtraction of two 8 bit numbers is executed .
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
63/73
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
64/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
64
8 Bit Multiplication
ADDRESS LABEL MNEMONIC OPERAND HEX
CODE
COMMENTS
4100 MOV A ,#data1 74, data1 Store data1 in
accumulator
4102 MOV B, #data2 75,data2 Store data2 in B reg
4104 MUL A,B F5,F0 Multiply both
4106 MOV DPTR, #
4500H
90,45,00 Initialize memory
location
4109 MOVX @ DPTR, A F0 Store lower order
result
401A INC DPTR A3 Go to next memory
location
410B MOV A,B E5,F0
Store higher order
result410D MOV @ DPTR, A F0
410E STOP SJMP STOP 80,FE Stop
RESULT:
INPUT OUTPUTMEMORY LOCATION DATA MEMORY LOCATION DATA
4500 4502
4501 4503
Thus the 8051 ALP for multiplication of two 8 bit numbers is executed .
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
65/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
65
8 BIT DIVISION
AIM:To perform division of two 8 bit data and store the result in memory.
ALGORITHM:1. Get the Dividend in the accumulator.2.
Get the Divisor in the B register.3. Divide A by B.4.
Store the Quotient and Remainder in memory.
FLOWCHART:
START
GET DIVIDEND
IN ACCR
GET DIVISOR INB REG
DIVIDE A BY B
STOREQUOTIENT &REMAINDERIN MEMORY
STOP
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
66/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
66
8 Bit Division
ADDRESS LABEL MNEMONIC OPERAND HEX
CODE
COMMENTS
4100 MOV A, # data1 74,data1 Store data1 in
accumulator
4102 MOV B, # data2 75,data2 Store data2 in B reg
4104 DIV A,B 84 Divide
4015 MOV DPTR, # 4500H 90,45,00 Initialize memory
location
4018 MOVX @ DPTR, A F0 Store remainder
4109 INC DPTR A3 Go to next memory
location
410A MOV A,B E5,F0
Store quotient
410C MOV @ DPTR, A F0
410D STOP SJMP STOP 80,FE Stop
RESULT:
INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
4500 (dividend) 4502 (remainder)
4501 (divisor) 4503 (quotient)
Thus the 8051 ALP for division of two 8 bit numbers is executed .
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
67/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
67
LOGICAL AND BIT MANIPULATION
AIM:
To write an ALP to perform logical and bit manipulation operations using 8051microcontroller.
APPARATUS REQUIRED:8051 microcontroller kit
ALGORITHM:
1. Initialize content of accumulator as FFH2. Set carry flag (cy = 1).3. AND bit 7 of accumulator with cy and store PSW format.4. OR bit 6 of PSW and store the PSW format.5. Set bit 5 of SCON.
6.
Clear bit 1 of SCON.7. Move SCON.1 to carry register.8.
Stop the execution of program.
FLOWCHART:
START
Set CY flag, AND CY with MSB of
Store the PSW format OR CY with bit 2 IE re
Clear bit 6 of PSW, Store PSW
Set bit 5 of SCON , clear bit 1 and storeSCON
Move bit 1 of SCON to CY and store PSW
STOP
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
68/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
68
PROGRAM TABLE
ADDRESS HEX
CODE
LABEL MNEMONICS OPERAND COMMENT
4100 90,45,00 MOV DPTR,#4500 Initialize memorylocation
4103 74,FF MOV A,#FF Get the data in
accumulator
4105 D3 SETB C Set CY bit
4016 82,EF ANL C, ACC.7 Perform AND with 7t
bit of accumulator
4018 E5,D0 MOV A,DOH
Store the result410A F0 MOVX @DPTR,A
410B A3 INC DPTR Go to next location
410C 72,AA ORL C, IE.2 OR CY bit with 2nd
bit
if IE reg
410E C2,D6 CLR PSW.6 Clear 6t
bit of PSW
4110 E5,D0 MOV A,DOH
Store the result4112 F0 MOVX @DPTR,A
4113 A3 INC DPTR Go to next location
4114 D2,90 SETB SCON.5 Set 5th
of SCON reg
4116 C2,99 CLR SCON.1 Clear 1st bit of SCON
reg
4118 E5,98 MOV A,98H
Store the result411A F0 MOVX @DPTR,A
411B A3 INC DPTR Go to next location
411C A2,99 MOV C,SCON.1 Copy 1st bit of SCON
reg to CY flag
411E E5,D0 MOV A,DOHStore the result
4120 F0 MOVX @DPTR,A
4122 80,FE L2 SJMP L2 Stop
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
69/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
69
RESULT:
MEMORY
LOCATION
SPECIAL FUNCTION REGISTER FORMAT BEFORE
EXECUTION
AFTER
EXECUTION
4500H (PSW) CY AC FO RS1 RS0 OV - P 00H 88H
4501H (PSW) CY AC FO RS1 RS0 OV - P 40H 88H
4502H (SCON) SM0 SM1 SM2 REN TB8 RB8 TI RI 0FH 20H
4503H (PSW) CY AC FO RS1 RS0 OV - P FFH 09H
Thus the bit manipulation operation is done in 8051 microcontroller.
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
70/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
70
EXPT NO: 15 DATE:
AIM:To convert Square and Cube program, Find 2s complement of a numberusing 8051
micro controller
RESOURCES REQUIERED:
8051 microcontroller kit
Keyboard
Power supply
PROGRAM:
org 0000h; sets the program counter to 0000h
mov a,#n;assign value 'n' in decimal to A which is converted to it's
equivalent hexadecimal value
mov b,#n;assign value 'n' in decimal to B which is converted to it's
equivalent hexadecimal value
mov r0,#n;assign value 'n' in decimal to R0 which is converted to it's
equivalent hexadecimal value
mul ab; multiplying 'A' with 'B'
mov 40h,a; lower byte is stored in address 40h
mov 41h,b; higher byte is stored in address 41h
mov r1,a; move value of 'A' to R1
mov a,b; move value of 'B' to 'A'
mov b,r0; move value of R0 to b
mul ab; multiply 'A' and 'B'
mov b,a; lower byte obtained is moved from 'A' to 'B'
mov r2,b; move value of 'B' to R2
mov a,r1; move value of R1 to 'A'
mov b,r0; move value of R0 to 'B'
mul ab; multiplying 'A' and 'B'
mov 50h,a; Lower byte obtained is stored in address 50h
Square and Cube program, Find 2s complement of a number
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
71/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
71
mov r3,b; higher byte obtained is stored in R3
mov a,r2; move value from R2 to 'A'
add a,r3; add value of 'A' with R3 and store the value in 'A'
mov b,a; move value from 'A' to 'B'
mov 51h,b; store value obtained in address 51h
end
SQUARE PGM USING 8051
ORG 00h
02 LJMP MAIN
03 DELAY:
04 ;MOV R0,#205 MOV TMOD, #01H
06 MOV TH0, #HIGH (-50000)
07 MOV TL0, #LOW (-50000)
08 SETB TR0
09 JNB TF0,
10 CLR TF0
12 ;DJNZ R0,DELAY
13 RET
14 MAIN:
15 MOV DPTR,#300H
16 MOV A,#0FFH
17 MOV P1,A
18 BACK:
19 LCALL DELAY
20 MOV A,P1
21 MOVC A,@A+DPTR
22 ;MOV P2,#00H23 ;LCALL DELAY
24 MOV P2,A
25 SJMP BACK
26 ORG 300H
27 XSQR_TABLE:
28 DB 0,1,4,9,16,25,36,49,64,81
29 END
Thus the Square and Cube program, Find 2s complement of a number is done in
8051 microcontroller
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
72/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
72
EXPT NO:16 DATE:
AIM:To convert BCD number into ASCII by using 8051 micro controller
RESOURCES REQUIERED:
8051 microcontroller kit
Keyboard
Power supply
Unpacked BCD to ASCII
Downloaded from www.Rejinpaul.com
Get Unique study materials from www.rejinpaul.com
-
7/26/2019 2.Microprocessor Microcontroller Lab 1
73/73
CS6412MICROPROCESSOR AND MICROCONTROLLER LAB DEPT OF CSE
FLOWCHART:
Downloaded from www.Rejinpaul.com