CSE 2006 – MICROPROCESSOR AND INTERFACING LABORATORY MANUAL
FALL SEMESTER 2020 - 2021
Submitted By
Name: AVILIPA PATTANAYAK
[Link].: 19BPS1042
CONTENTS
Exp. No. Date of Exp. Title of Exp. Page No.
1. 15.07.2020 Basic Math Operations on two 1
hexa-decimal numbers
2. 22.07.2020 Sum and average of array of 9
hexa-decimal numbers
3. 29.07.2020 Sorting and finding 13
largest/smallest number
4. 05.08.2020 Permutation/ Computation 18
5. 26.08.2020 Code Converters 25
6. 02.09.2020 String Reversal 36
7. 09.09.2020 8087 Experiments 39
8. 16.09.2020 Palindrome 43
9. 14.10.2020 TinkerCAD – LED Blinking 48
10. 21.10.2020 TinkerCAD – Stepper Motor & 7- 57
segment LED
DATE:15/7/20 EXP: 1 BASIC MATHEMATICAL OPERATIONS ON TWO 16 BIT AND 8 BIT
NUMBERS MATHEMATICAL
OPERATIONS OF 16BIT AND 8 BIT NUMBERS
Aim:
To perform basic mathematical operation on two 16 bit and 8 bit numbers
Tool Used:
Assembler - MASM 611
Algorithm:
Step 1: Start
Step 2: store the two 16 bit/8 bit numbers in two variables
Step 3: perform the add/sub/mul/div command to perform the required operation
Step 4: observe the output and verify the result
Step 5: end
Program:
ADDITION
8 BIT NUMBERS
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
16 BIT NUMBERS
SUBTRACTION
8BIT NUMBERS
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
16 BIT NUMBERS
MULTIPLICATION
8 BIT NUMBER
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
16 BIT NUMBER
DIVISION OF 16 BIT NUMBER BY 8 BIT NUMBER
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Sample Input:
ADDITION
8 BIT NUMBERS
A=10
B=20
16 BIT NUMBERS
A=1042
B=2002
SUBTRACTION
8 BIT NUMBERS
A=08
B=07
16 BIT NUMBERS
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
A=1042
B=1000
MULTIPLICATION
8 BIT NUMBERS
A=10
B=20
16 BIT NUMBERS
A=1042
B=2002
DIVISION
DIVIDEND A=1042(HEXADECIMAL NUMBER)
DIVISOR B=20(OCTAL NUMBER)
Sample Output:
ADDITION
8BIT
Output displayed: 1E (IN DECIMAL=30)
16BIT
Output displayed: 0BE4 (IN DECIMAL=3044)
SUBTRACTION
8BIT
Output displayed: 01 (IN DECIMAL=01)
16BIT
Output displayed: 002A (IN DECIMAL=42)
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
MULTIPLICATION
8BIT
Output displayed: C8 (IN DECIMAL=200)
16BIT
Output displayed: D4C4001F (IN DECIMAL=3569614879)
DIVISION
Output displayed: 34 (IN DECIMAL =52)
Register/ Memory Contents for I/O:
General Purpose Register: AX (addition, subtraction and division)
General Purpose Register: AX AND DX (multiplication)
Snapshot of the Output:
ADDITION
8 BIT NUMBERS
16 BIT NUMBERS
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
SUBTRACTION
8 BIT NUMBERS
16 BIT NUMBERS
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
MULTIPLICATION
8 BIT NUMBERS
16 BIT NUMBERS
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
DIVISION
Result:
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Aim:
To compute the sum and average of ten 8 bit numbers in an array
Tool Used:
Assembler - MASM 611
Algorithm:
SUM
Step 1: Start
Step 2: Store the Ten 8 bit numbers in an array
Step 3: perform the sum operation on the numbers
Step 4: observe the output and verify the results
Step 5: End
AVERAGE
Step 1: Start
Step 2: Store the Ten 8 bit numbers in an array
Step 3: perform the sum operation on the numbers
Step 4: average will be obtained by dividing sum by 10
Step 5: observe the output and verify the results
Step 6 : End
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Program:
SUM OF THE TEN 8 BIT NUMBERS IN THE ARRAY
AVERAGE OF THE TEN 8 BIT NUMBERS IN THE ARRAY
Sample Input:
FOR SUM AND AVERAGE
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
11,34,32,14,86,09,61,21,22,24
Sample Output:
SUM
The output displayed was: 3A(IN DECIMAL =58)
AVERAGE
The output displayed was: 05(IN DECIMAL=05)
Register/ Memory Contents for I/O:
For both ,sum and average operation, AX was used
Snapshot of the Output:
SUM
AVERAGE
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Result:
The sum and average of ten 8 bit numbers in the array were computed and output was verified
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Date:- 29/07/20
Exp. 3 :-Arrange 10 numbers in ascending and descending order, and hence compute the smallest and
largest numbers in the array
Aim:
To arrange 10 numbers in ascending and descending order, and hence compute the smallest and largest
numbers in the array by using bubble sort
Tool Used:
Assembler - MASM 611
Algorithm:
Step 1: Start
Step 2: Store the Ten numbers in an array
Step 3: compare each number with their adjacent numbers and swap according to the requirement of
getting ascending or descending respectively
Step 4: observe the output and verify the results
Step 5: End
Program:
ASCENDING ORDER
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
DESCENDING ORDER
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Sample Input:
Ascending order
85H,82H,90H,28H,76H,09H,45H,87H,99H,43H
Descending order
59H,27H,99H,88H,66H,34H,84H,93H,70H,19H
Sample Output:
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Ascending order
09,28,43,45,76,82,85,87,90,99
Smallest- 09
Descending order
99,93,88,84,70,66,59,34,27,19
Largest-99
Register/ Memory Contents for I/O:
In both the ascending and descending order sorting, AX was used
Snapshot of the Output:
ASCENDING ORDER
DESCENDING ORDER
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Result:
The elements in the respective arrays were arranged in ascending and descending order using bubble sort.
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Date: 6/8/20 Exp.4 FACTORIAL,PERMUTATIONS AND
COMBINATIONS
Aim:
To find the factorial, permutation and combination of a given number
Tool Used:
Assembler - MASM 611
Algorithm:
Step 1: store the required numbers in the variables Step 2: using mul
and div, find factorial of the number
Step 3: find the respective permutation and combination for the number as well by using the
factorial
Step 4: display the result
PART 1
FACTORIAL
Program:
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Sample Input:
06
Sample Output:
2D0H=720
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Manual Verification:
6!=720
Register/ Memory Contents for I/O:
INPUT: N IN DATA SEGMENT
OUTPUT:AX REGISTER HOLDS THE FACTORIAL
Snapshot of the Output:
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
PART 2
PERMUTATION
Program:
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Sample Input:
06,04
Sample Output:
168H=360
Manual Verification:
6P4=6!/(4-2)!=360
Register/ Memory Contents for I/O:
INPUT: N,R IN DATA SEGMENT
OUTPUT:AX REGISTER HOLDS THE PERMUTATION
Snapshot of the Output
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
PART 3
COMBINATION
Program:
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Sample Input:
05,04
Sample Output:
05
Register No.: 19BPS1042 Name: AVILIPA M PATTANAYAK
Manual Verification:
5C4=5!/(4!*(5-4)!)=5
Register/ Memory Contents for I/O:
INPUT: N,R IN DATA SEGMENT
OUTPUT: AX REGISTER HOLDS COMBINATION
Snapshot of the Output
Result:
The result of all the operations were obtained and verified manually.
Aim: To perform the logical operation and number conversion
Tool Used:
Assembler - MASM 611
Algorithm:
BCD to ASCII conversion:
a) Start
b) As usually, moved the data to accumulator and accumulator to data segment.
c) Take the value in AL and copy to AH also.
d) And operation of AL with 0FH.
e) Extract the last number – Rotate right the number 4 times and do AND operation to it with 0F
f) Add the AX with 3030H or add 30H individually to AH and AL.
g) End.
BCD to Hexadecimal conversion:
a) Start
b) Moved the data to accumulator and accumulator to data segment.
c) Move the BCD value to AX register and perform AND operation with 0FH.
d) Move the value of AX to BX. And again load the AX with the same BCD number.
e) Now, again perform AND operation with 0F0H.
f) Do ROR operation 4 times to get 10th digits place value.
g) Store the CX register with 0AH (10) value and multiply with AX.
h) Hence the result stored in AX.
i) End.
Program:
AND
OR
XOR
NOT
SHR AND SHL
ROR AND ROL
BCD TO ASCII
BCD TO HEXA
Sample Input:
AND operation: 7, 2
OR operation: 7, 2
NOT operation: 6
XOR operation: 7, 2
SHL and SHR operation: 5
ROR and ROL operation: 5
BCD to ASCII conversion: 12h
BCD to Hexadecimal conversion: 15h
Sample Output:
AND operation: 2
OR operation: 7
NOT operation: FFF9
XOR operation: 5
SHL and SHR operation: 09 and 02
ROR and ROL operation: 0A and 82
BCD to ASCII conversion: 3132
BCD to Hexadecimal conversion: 000F
Manual Verification:
AND
7(111) ,2(010)= 2(010)
OR
7(111) ,2(010)= 2(010)
NOT
6(110)= FFF9(1111111111111001)
XOR
7(111) ,2(010)= 5(101)
SHL and SHR operation:
09 and 02
ROR and ROL operation:
0A and 82
BCD to ASCII conversion:
31 32
BCD to Hexadecimal conversion:
000F
Register/ Memory Contents for I/O:
In all the above operations, AX was used
Snapshot of the Output:
AND
OR
NOT
XOR
ROR AND ROL
SHL AND SHR
BCD TO HEXA
BCD TO ASCII
Result: The above operations were performed and results were verified
Aim:
To receive a string in from the user and reverse it using assembly language program.
Tools Used: Assembler-
MASM611 Algorithm:
Move data to ax Move ax to ds
Display given string Load null
string to si
Load given string to di Add di
with length-1
Move length of string to cx Rev:
Move offset di to al Move al to
offset si Increment si
Decrement di
Loop Rev
Display “Reversed string is :” Display the
updated null string End program
Program:
DATA SEGMENT
STR1 DB 0DH,0AH,'ENTER STRING: -$' STR2 DB
0DH,0AH,'REVERSED STRING IS: $' NL DB 0DH,0AH,'$'
DATA ENDS CODE
SEGMENT START:
ASSUME CS:CODE,DS:DATA MOV
AX,DATA
MOV DS,AX DIS:
LEA DX,STR1 MOV
AH,09H INT 21H MOV
CL,00 MOV AH,01H
READ:INT 21H MOV
BL,AL PUSH BX
INC CX
CMP AL,0DH JZ
DISPLAY JMP READ
DISPLAY: LEA
DX,STR2
MOV AH,09H INT 21H
LEA DX,NL MOV
AH,09H INT 21H
ANS: MOV AH,02H POP BX
MOV DL,BL INT 21H
LOOP ANS HLT
CODE ENDS END
START
Sample Input :
ENTER THE STRING :- HELLO
Sample Output :
REVERSED STRING IS :- OLLEH
Snapshots of the Output :
Result:
Thus, the string is reversed and the output is verified .
Date: 09.09.2020 Exp.7. 8087 Experiments
Aim:
To perform the volume of a cone using 8087 .
Tool Used:
Assembler - MASM 611
Algorithm:
1. Define the height of the cone.
2. Define the radius of the cone.
3. Define constants 0.333
4. Constant pi=3,14
5. Calculate the volume of the cone 1/3 pi x r2 x h
6. Define volume and assign the volume of the cone to it.
Program :
code segment
assume cs:code, ds:data
.8087
org 000ah start:
mov ax, data mov ds, ax
finit
fld radius fld height
fst st(2)
fmul st(0), st(1) ;
fmul st(0), st(2) ; fld const ;
fmul ;
fldpi ;
fmul ;
fst volume hlt
code ends data
segment
radius dd 2.608
height dd 1.130
const dd 0.333 volume dd 01
dup(?)
data ends end
start
Sample Input :
radius - 2.608
height - 1.130
const - 0.333
Sample Output :
7.68
Output :
Result :
The volume of the cone is obtained and the results are verified .
Date: 16.09.2020 Exp.8 Palindrome String
Aim:
To check if the user inputted string is a palindrome or not and print the output accordingly along
with the reverse of the string
Tools Used:
Assembler-MASM611
Algorithm:
Move data to ax Move
ax to ds
Move offset of string to si Loop1:
Move offset si to ax Compare al with
null string If equal jump to palin
Else increment si Jump
to loop1 Palin:
Move offset string to di
Decrement si
Loop2:
Compare si and di
If si<di, display “PALINDROME”
Else move offset si to ax Move
offset di to bx Compare al and bl
If al not equal to bl, display “NOT A PALINDROME”
Decrement si Increment
di Jump to loop2 End
program Program:
Msg ‘Reverse of the entered string:- $’
msg2 db"the entered string is a palindrome",10,13,'$' msg3 db"the entered
string is not a palindrome",10,13,'$' str db 10H dup('$')
data ends extra segment
revstr db 10h extra
ends code segment
assume cs:code,ds:data,es:extra start:
mov ax,data mov ds,ax
mov ax,extra mov
es,ax mov ah,09 lea
dx,msg int 21h
mov ah,0ah lea dx,str
int 21h
lea si,str inc si
mov cl,[si] mov bl,cl
mov ch,0 inc si
lea di,revstr add di,cx
dec di back: cld
lodsb
std stosb
loop back lea si,str
inc si
inc si
lea di,revstr mov cl,bl
mov ch,0 cld
repe cmpsb jnz no
mov ah,09 lea
dx,msg2
int 21h jmp skip
no: mov ah,09 lea
dx,msg3 int 21h
skip:
mov ah,4ch int 21h
hlt
code ends end start
Sample Input :
MICRO
ABABA
Sample Output :
ORCIM
THE ENTERED STRING IS NOT A PALINDROME
ABABA
THE ENTERED STRING IS A PALINDROME
Snapshot of the Output :
Result :
The task is performed and the results are verified .
Date: 14-10-2020 Exp -9 Basic Arduino LED experiments using
tinkercad
(a) Aim:
To test the blinking of an LED (light emitting diode) using Arduino’s digital
output. Tools used :
TINKERCAD
Algorithm :
void setup()
pinMode(13, OUTPUT);
void loop()
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s) digitalWrite(13,
LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
Observations :
Result :
The blinking in the LED is observed using an Arduino output .
(b) Aim:
To test the blinking of multiple LEDs using Arduino and breadboard .
Tools used :
TINKERCAD
Algorithm :
int animationSpeed = 0;
void setup()
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
animationSpeed = 400;
digitalWrite(13, HIGH);
delay(animationSpeed); // Wait for animationSpeed millisecond(s) digitalWrite(13,
LOW);
delay(animationSpeed); // Wait for animationSpeed millisecond(s) digitalWrite(12,
HIGH);
delay(animationSpeed); // Wait for animationSpeed millisecond(s) digitalWrite(12,
LOW);
delay(animationSpeed); // Wait for animationSpeed millisecond(s)
digitalWrite(11, HIGH);
delay(animationSpeed); // Wait for animationSpeed millisecond(s) digitalWrite(11,
LOW);
Observations :
Result :
The blinking of multiple LEDs are observed using Arduino and breadboard .
(c) Aim:
To test the fading of an LED using Analog output .
Tools used :
TINKERCAD
Algorithm :
int brightness = 0; void
setup()
pinMode(9, OUTPUT);
void loop()
for (brightness = 0; brightness <= 255; brightness += 5) { analogWrite(9,
brightness);
delay(30); // Wait for 30 millisecond(s)
for (brightness = 255; brightness >= 0; brightness -= 5) { analogWrite(9,
brightness);
delay(30); // Wait for 30 millisecond(s)
}
Observations :
Result :
The fading of a LED is observed using an Analog output .
(d) Aim:
To test RGB LED colour mixing .
Tools used :
TINKERCAD
Algorithm :
int counter;
void setup()
pinMode(11, OUTPUT); pinMode(10,
OUTPUT); pinMode(9, OUTPUT);
pinMode(13, OUTPUT);
void loop()
analogWrite(11, 255);
analogWrite(10, 204);
analogWrite(9, 102);
delay(1000); // Wait for 1000 millisecond(s) analogWrite(11,
255);
analogWrite(10, 204);
analogWrite(9, 102);
delay(1000); // Wait for 1000 millisecond(s)
for (counter = 0; counter < 10; ++counter) { analogWrite(11,
255);
analogWrite(10, 0);
analogWrite(9, 0);
delay(1000); // Wait for 1000 millisecond(s) analogWrite(11,
255);
analogWrite(10, 255);
analogWrite(9, 255);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s) digitalWrite(13,
LOW);
delay(1000); // Wait for 1000 millisecond(s)
Observations :
Result :
The RGB LED colour mixing is observed .
REGISTRATION NO. – 19BPS1042 NAME : AVILIPA M PATTANAYAK
Date: 21.10.20 Exp 10 -Stepper Motor and 7 Segment LED
EXPERIMENT 10: STEPPER MOTOR
AIM :
To simulate the stepper motor and interface a 7 segment display with arduino.
TOOLS USED :
TINKERCAD
ALGORITHM :
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11: Stepper
myStepper(stepsPerRevolution, 8, 9, 10, 11);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// nothing to do inside the setup
void loop() {
// read the sensor value:
int sensorReading = analogRead(A0);
REGISTRATION NO. – 19BPS1042 NAME : AVILIPA M PATTANAYAK
// map it to a range from 0 to 100:
int motorSpeed = map(sensorReading, 0, 1023, 0, 250);
// set the motor speed:
if (motorSpeed > 0) { [Link](stepsPerRevolution /
100);
}
OBSERVATIONS :
REGISTRATION NO. – 19BPS1042 NAME : AVILIPA M PATTANAYAK
RESULT :
A stepper motor is designed and a 7 segment display is observed .
REGISTRATION NO. – 19BPS1042 NAME : AVILIPA M PATTANAYAK
EXPERIMENT 2: 7 SEGMENT DISPLAY
AIM :
TO DESIGN A 7 SEGMENT DISPLAY .
TOOLS USED :
TINKERCAD
ALGORITHM :
void setup()
pinMode(2, OUTPUT); pinMode(3,
OUTPUT); pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
void loop()
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
REGISTRATION NO. – 19BPS1042 NAME : AVILIPA M PATTANAYAK
delay(1000); // Wait for 1000 millisecond(s)
OBSERVATIONS :
Register No.: 19bps1042 Name: Avilipa M pattanayak
RESULT :
THE 7 SEGMENT DISPLAY IS SUCCESSFULLY DESIGNED AND GIVES THE DESIRED OUTPUT .