Microprocessor Manual
Microprocessor Manual
COMMUNICATION ENGINEERING
REGULATION-2023
LABORATORY MANUAL
LABORATORY
PREPARED BY VERIFIED BY
1.Ms.R.ABINAYA/AP Dr.P.RAJESWARI/HOD
2.Mrs.R.GAYATHRI/AP
LIST OF EXPERIMENTS
AIM:
To write an Assembly Language Program (ALP) for performing the Arithmetic operation of two-
byte numbers
APPARATUS REQUIRED:
S. No. Item Specification Quantity
01 Microprocessor Kit 8086 1
02 Power Supply +5 Vdc 1
ALGORITHM:
16- bit
Addition
Initialize the MSBs of sum to 0
Get the first number.
Add the second number to the first number.
If there is any carry, increment MSBs of sum by 1.
Store LSBs of sum.
Store MSBs of sum.
16- bit Subtraction
Initialize the MSBs of difference to Zero
Get the first number
Subtract the second number from the first number.
If there is any borrow, increment MSBs of difference by 1.
Store LSBs of difference
Store MSBs of difference.
16- bit Multiplication
Get the multiplier.
Get the multiplicand
Initialize the product to 0.
Product = product + multiplicand
Decrement the multiplier by 1
If multiplicand is not equal to 0, repeat from step (d) otherwise store the
product.
16- bit Division
Get the dividend
Get the divisor
Initialize the quotient to 0.
Dividend = dividend – divisor
If the divisor is greater, store the quotient. Go to step g.
If dividend is greater, quotient = quotient + 1. Repeat from step (d) Store the
dividend value as remainder.
PROGRAM
ADDITION
ADDRESS OPCODE MNEMONICS 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 the
JNC L1 Check for carry
INC CX If carry exists, increment the
L1 : MOV [1206],CX Store the carry
MOV [1204], AX Store the sum
HLT Stop the program
SUBTRACTION
ADDRESS OPCODE MNEMONICS 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
from AX
JNC L1 Check for borrow
INC CX If borrow exists, increment the
CX
L1 : MOV [1206],CX Store the borrow
MOV [1204], AX Store the difference
HLT Stop the program
MULTIPLICATION
ADDRESS OPCODE MNEMONICS COMMENTS
MOV AX,[1200] Get the first data
MOV BX, [1202] Get the second data
MUL BX Multiply both
MOV [1206],AX Store the lower order product
Copy the higher order product
MOV AX,DX
to AX
MOV [1208],AX Store the higher order product
HLT Stop the program
DIVISION
ADDRESS OPCODE MNEMONICS COMMENTS
MOV AX,[1200] Get the first data
MOV DX, [1202] Get the second data
DIV BX Divide the dividend by divisor
MOV [1206],AX Store the lower order product
Copy the higher order product
MOV AX,DX
to AX
MOV [1208],AX Store the higher order product
HLT Stop the program
OUTPUT:
ADDITION
MEMORY
DATA
SUBTRACTION
MEMORY
DATA
MULTIPLICATION
MEMORY
DATA
DIVISION
MEMORY
DATA
RESULT:
Thus Arithmetic operations of two byte numbers are performed and the result
is stored.
EX.NO:2a Programs for Sorting and Searching
SORTING
AIM
To write an Assembly Language Program (ALP) to sort a given array in
ascending and descending order.
APPARATUS REQUIRED:
ALGORITHM:
(i) Sorting in ascending order:
INPUT OUTPUT
Memory Memory
Data Data
DESCENDING
INPUT OUTPUT
Memory Memory
Data Data
RESULT:
Thus given array of numbers are sorted in ascending & descending order.
EX.NO:2b SEARCHING
AIM:
To write an Assembly Language Program (ALP) to find the largest and
smallest number in a given array.
APPARATUS REQUIRED:
ALGORITHM:
(i) Finding largest number:
Get the third number from the array and repeat the process until C1 is 0.
Get the third number from the array and repeat the process until C1 is 0.
PROGRAM: LARGEST
SMALLEST
ADDRESS OPCODES MNEMONICS 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 data’s
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 1300 location
HLT Stop
OUTPUT:
LARGEST
INPUT OUTPUT
Memory Memory
SMALLEST
INPUT OUTPUT
Memory Memory
RESULT:
Thus largest and smallest number is found in a given array.
APPARATUS REQUIRED:
S. No. Item Specification Quantity
01 Microprocessor Kit 8086 1
02 Power Supply +5 Vdc 1
ALGORITHM:
PROGRAM
OUTPUT
INPUT
MEMORY
DATA
OUTPUT
MEMORY
DATA
RESULT:
APPARATUS REQUIRED:
S. No. Item Specification Quantity
01 Microprocessor Kit 8086 1
02 Power Supply +5 Vdc 1
ALGORITHM:
PROGRAM
ADDRESS OPCODES MNEMONICS COMMENTS
MOV DI,1300H Initialize destination address
MOV SI, 1400H Initialize starting address
MOV CX, 0006H Initialize array size
CLD Clear direction flag
MOV AL, 08H Store the string to be searched
REPNE SCASB Scan until the string is found
DEC DI Decrement the destination
address
MOV BL,[DI] Store the contents into BL reg
MOV [SI],BL Store content of BL in source
address
HLT Stop
OUTPUT
MEMORY
DATA
RESULT:
Thus a given byte or word in a string of a particular length in the extra segment
(destination) is found.
APPARATUS REQUIRED:
S. No. Item Specification Quantity
01 Microprocessor Kit 8086 1
02 Power Supply +5 Vdc 1
ALGORITHM:
PROGRAM
ADDRESS OPCODES MNEMONICS COMMENTS
MOV DI,1300H Initialize destination
address
MOV SI,1400H Initialize starting address
MOV CX, 0006H Initialize array size
CLD Clear direction flag
MOV AL, 08H Store the string to be
searched
MOV BH,30H Store the string to be
replaced
REPNE SCASB Scan until the string is
found
DEC DI Decrement the destination
address
MOV BL,[DI] Store the contents into BL
reg
MOV [SI],BL Store content of BL in
source address
MOV [DI],BH Replace the string
HLT Stop
OUTPUT
INPUT
MEMORY
DATA
OUTPUT
MEMORY
DATA
RESULT:
Thus a given byte or word in a string of a particular length in the extra segment
(destination) is found and is replaced with another character.
APPARATUS REQUIRED:
PRELIMINARY SETTINGS
Org 1000h
Store time value in memory location
1500 -Seconds
1501- Minutes
1502- Hours
ALGORITHM:
PROGRAM:
ADDRESS OPCODES LABEL MNEMONICS
START CALL CONVERT
CALL DISPLAY
OUT 16H,AL
MOV CL,07H
S2 MOV AL,88H
OUT 14H,AL
MOV AL,80H
OUT 14H,AL
S1 MOV AL,80H
OUT 16H,AL
NOP
NOP
NOP
NOP
IN AL,14H
MOV DL,AL
IN AL,14H
OR AL,DL
JNZ S1
DEC CL
JNZ S2
MOV S1,1500H
MOV AL,[SI]
INC AL
MOV [SI],AL
CMP AL,3CH
JNZ START
MOV AL,00H
MOV [SI],AL
INC SI
MOV [SI],AL
INC AL
MOV [SI],AL
CMP AL,3CH
JNZ START
MOV AL,0
MOV [SI],AL
INC SI
MOV [AL],SI
INC AL
MOV [SI],AL
CMP AL,18H
JNZ START
MOV AL,0
MOV [SI],AL
JMP START
MOV DX,1600H
MOV CH,01H
MOV CL,0H
INT 5
RET
MOV BX,1608H
MOV AL,24H
MOV [BX],AL
SECONDS
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
DEC BX
MOV [BX],AH
DEC BX
ADD AL,30H
MOV [BX],AL
DEC BX
MOV AL,3AH
MOV [BX],AL
DEC BX
MINUTES
INC SI
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
MOV [BX],AH
DEC BX
ADD AL,30H
MOV [BX],AL
DEC BX
MOV AL.3AH
MOV [BX],AL
DEC BX
HOURS
INC SI
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
MOV [BX],AL
DEC BX
ADD AL,30H
MOV [BX],AL
RET
GETC
IN AL,02H
AND AL,0FFH
CMP AL,0F0H
JNE GETC
RESULT
Thus the digital clock program has been written and executed using 8086
microprocessor kit and the output of digital clock was displayed as [hours: minutes:
seconds] successfully.
ALGORITHM:
Select the channel and latch the address.
Send the start conversion pulse.
Read EOC signal.
If EOC = 1 continue else go to step (iii)
Read the digital output.
Store it in a memory location.
PROGRAM:
MOV AL,00
MOV AL,00
L1 IN AL, 0D8H Read the EOC signal from port & check for
AND AL,01 end of conversion
CMP AL,01
HLT Stop
RESULT:
Thus the ADC was interfaced with 8086 and the given analog inputs were
converted into its digital equivalent.
EX.NO:5b INTERFACING DIGITAL – TO – ANALOG CONVERTER
AIM:
ALGORITHM:
1. Measurement of analog voltage:
Send the digital value of DAC.
Read the corresponding analog value of its output.
2. 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.
PROGRAM:
HLT Stop
SQUARE WAVE
TRIANGULAR WAVE
OUTPUT:
MEASUREMENT OF ANALOG VOLTAGE:
WAVEFORM GENERATION:
WAVEFORMS AMPLITUDE TIMEPERIOD
Square Waveform
Triangular Waveform
MODEL GRAPH:
Result:
Thus the DAC was interfaced with 8086 and different waveforms have been
generated.
EX.NO:6 Interfacing and Programming Keyboard and Display.
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 “
Initialize the counter
Set 8279 for 8 digit character display, right entry
Set 8279 for clearing the display
Write the command to display
Load the character into accumulator and display it
Introduce the delay
Repeat from step 1.
PROGRAM:
RESULT:
Thus the output for the interfacing programmable keyboard & display
controller 8279 was executed successfully.
EX.NO:7 Interfacing and Programming of Stepper Motor.
AIM:
To write an assembly language program in 8086 to rotate the motor at different speeds.
APPARATUS REQUIRED:
ALGORITHM:
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
PROGRAM:
ADDRESS OPCODES MNEMONICS COMMENTS
START : MOV DI, 1200H Initialize memory location to
store the array of number
MOV CX, 0004H Initialize array size
RESULT:
Thus the assembly language program for rotating stepper motor in both clockwise
and anticlockwise directions is written and verified.
EX.NO:8 Finding number of and number of in a given 8-bit number using 8051
AIM:
To write an assembly language program in 8051 to count the number of ones(1a) and
APPARATUS REQUIRED:
ALGORITHM:
DATA in R1
MOV R2,#00H Initialize 0s counter
OUTPUT:
in R2
NUMBER OF 1s: MOV A,R0 Move number to
NUMBER OF 0s: accumulator A
MOV R3,#08H Set loop counter in
R3
LOOP RLC A Rotate accumulator
left through carry
JC ONE If carry=1,jump to
label one
INC R2 Else increment 0s
counter
SJMP NEXT
Skip one ,go to next
ONE INC R1 Increment 1s
counter
NEXT DJNZ R3,LOOP Decrement R3 and
jump to loop if not
zero
HLT
End of program
RESULT:
Thus the assembly language program in 8051 to count the number of ones(1a) and
Start the Keil software. Go to the Project > New Project then choose a
location to store your program, and give a name and Save.
Now in the next window select the device from different manufacturers. We are
selecting Microchip, and then by expanding we are selecting AT89C51 device
and click ok.
Now go to the File in the menu and select New. It will open a new editor to write
code.
Go to the save option and save the program file with .asm extension.
Write the code for 8051 Microcontroller.
Now from the left panel, select Source Group 1, and Add Existing Files to Group ‘Source
Group 1’. Then select the program (asm file) then add and close
Now go to the Project > Build Target to build the project. If there is some error
the building will be failed, after correcting the errors it can be build.
Ex.no:11 Programming using Arithmetic, Logical instructions of 8051 Micro controller.
Aim
To write ALP for performing Arithmetic , Logical , Bit manipulation operations
in 8051
Apparatus required
Pc with keil µvision 5 simulation tool.
Program:
1. Arithematic operations
//arithmetic operations
mov a,#25h
mov b,#12h
add a,b
mov 40h,a
mov a,#25h
subb a,b
mov 41h,a
mov a,#25h
mul ab
mov 42h,a
mov 43h,b
mov a,#25h
mov b,#12h
div ab
mov 44h,a
mov 45h,b
mov a,#25h
inc a
mov 46h,a
dec a
mov 47h,a
end
2. Logical operations:
mov r0, #0fh
mov r1, #foh
mov r2, #66h
; And operation
mov a, #ffh
anl a, r0
mov 40h, a
; Or operation
mov a, #ffh
orl a, r1
mov 41h, a
; Xor operation
mov a, 03h
mov a, #ffh
xrl a, r2
mov 42h, a
lcall 0003h
end
; clear register A
mov a, #0fh
clr a
mov 40h, a
; swap nibbles of register A
mov a, #56h
swap a
mov 41h, a
; Complement the bit of register A
mov a, #66h
cpl a
mov 42h, a
; Rotate the register contents towards right
mov a, #63h
rr a
xrl a, r
mov 43h, a
; Rotate the register contents towards left
mov a, #43h
rl a
xrl a, r
mov 44h, a
lcall 0003h
end
3. Bit manipulation operations:
Program:
MOV24H,10H;Copy item from 10H to 24H
CPL24.2;Complement bit b2
MOVC,24.5;Copy b5 to C
MOV24.4,C;Move C to b4
MOVC,24.0;Make copy of b0 to C
ORLC,/1;OR C and complement of b1
SETB24.6;Set bit b6
CLR24.3;Reset bit b3
MOV30H,24H; Store the result at 30H
HALT: SJMP HALT
Address Value
...
10H AEH
11H
...
30H 72H
31H
Result:
Thus the Arithmetic ,Logical and bit manipulation operation is done in 8051
microcontroller using simulation.
Ex.no:12 Programming and verifying Timer operation in 8051 Micro controller
Aim
Apparatus required
PROGRAM
AGAIN:
MOV TL0,#0Ch ;LOAD LOW BYTE OF COUNT IN TIMER 0 LOW ORDER COUNT
REGISTER
MOV TH0,#0FEh ;LOAD HIGH BYTE OF COUNT IN TIMER 0 HIGH ORDER COUNT
REGISTER
WAIT:
END
OUTPUT
Result: