Labprograms 1A2A3A
Labprograms 1A2A3A
Microprocessor Lab
Manual (10CS56)
GUIDELINES TO WRITE YOUR Lab Book/Record
1. Assembly Language Programs with Comments (ALP’s), Theoretical Result and Practical
Result should be on right side. While Writing ALP, make sure Labels,
instructions/assembler directives, operands and comments align to separate columns
2. Flow Chart /Algorithm should be on left side, followed by details of DOS/BIOS services
used in the program
Part B Programs- Related to Interfacing, using 8086 ALP, 8051 ALP, 8051 Embedded C;
covers Switches, Leds, SevenSegmentDisplays, LCD, Keyboard, StepperMotor, ADC,
DAC, Timers, Industrial Sensors.
1a. Write an 8086 ALP to search an element in a list of ‘n’ 16-bit numbers using the
Binary Search algorithm. [Use Codeview to demonstrate the result]
1b. Write an ALP to implement decimal UP/decimal Down/Ring counter using Interface
module
2a. Write an 8086 ALP to sort a given set of ‘n’ numbers in ascending or descending orders
using Bubble sort algorithm. [Use Codeview to demonstrate the result]
2b. Write an ALP to read the status of 8 inputs bits from 8bit switch and display ‘FF’ if it is
even parity otherwise display 00. Also display number of 1’s in the input data on the
LED outputs, using interface module
3a. Write the macros using 8086 ALP to perform following tasks using DOS/BIOS
interrupts,
Write these macros in seperate file “util-macros.asm”, Using these macros write a
program(in a different file) to read a string terminated by carriage return from
keyboard and print the same on the Monitor after clearing the screen and setting the
cursor to the center of the screen.
3b. Write an ALP to read the status of two 8-bit inputs(X and Y) and display the result
X*Y using the interface module
4a. Write an 8086 ALP to read two strings, store them in locations str1, str2, check whether
they are equal or not and display appropriate messages. Also display the length of the
stored strings
4b. Write an ALP/Embedded C program to display messages “FIRE” & “HELP” on 4 digit
seven segment display alternately with a suitable delay, [ the exact delay value not
specified]
5a. Write an 8086 ALP to read password and validate the user and display appropriate
message, also display the count of characters in the password.
5b. Write an ALP/Embedded C program to Interface LCD for displaying a string on single
line / two line. Also demonstrate moving display of a string [When the string width is
more than LCD display width]
i) “read_8” – read 2 digit hex number from keyboard, AL should return the val
Using the above procedures write an ALP to read 8bit number and compute its factorial
and display the result. Store the procedures in different file and link it with the main
program.
6b. Write an ALP/Embedded C program to interface matrix keyboard using lookup table
and display the key pressed on the Seven segment display/LCD
display/Hyperterminal/Monitor
7a. Write an 8086 ALP to implement Stack Data Structure, with all the operations
8a. Write an 8086 ALP to compute nCr using recursive procedure. Assume that ‘n’ and ‘r’
are non-negative integers.
8b. Write an ALP/Embedded C program to rotate stepper motor in clock wise / anti-clock
wise / clock wise & anticlockwise direction for “N” steps
9a. Write an 8086 ALP to compute GCD of two 16 bit Positive Integer numbers
10a. Write an 8086 ALP to compute LCM of two 16 bit Positive Integer numbers
10b. Write an ALP/Embedded C program to generate sine waveform [full wave / half-
rectified wave / full-rectified wave] using 8bit DAC
11a. Write an 8086 ALP to read the 4 digit hex number and convert 4digit Hex number to
decimal number, and display the decimal number.
12a. Write an 8086 ALP to generate the first ‘n’ Fibonacci numbers. Input the value of n and
display the Fibonacci numbers.
12b. Write an ALP/Embedded C program to read the status of Industrial Sensor and control
the High power device as per the sensor status (no algorithm required)
Here with Sample programs for 1a,2a and 3a are given; but students are encouraged to
use their own ways/methods to implement the problems; Also students are
required to observe the result in Codeview or any other debugger.
1.a. Write an 8086 ALP to search an element in a list of ‘n’ 16-bit numbers using the Binary
Search algorithm. [Use Codeview to demonstrate the result]
1.a. Write an 8086 ALP to search an element in a list of ‘n’
16-bit numbers using the Binary Search algorithm.
[Use Codeview to demonstrate the result]
.MODEL SMALL
.DATA
NUMS DW 1000H,2000H,2050H,3050H,4060H
COUNT DW ($-NUMS)/2
KEY DW 1000H
;set up start and end pointers to set of numbers
BEGPTR DW ?
ENDPTR DW ?
;display messages
MES1 DB 10,13,"Number found at position: "
POS DB ?,'$'
MES2 DB 10,13,"Number Not Found..$"
.CODE
MOV AX,@DATA
MOV DS,AX
MOV BEGPTR,00
MOV AX,COUNT
DEC AX
MOV ENDPTR,AX
SECONDBLK:
SHR BX,1
INC BX
MOV BEGPTR,BX
JMP CONTINUE
NOTFOUND:
MOV DX,OFFSET MES2
JMP LAST
FOUND:
SHR BX,1
ADD BL,30H
MOV POS,BL
MOV DX,OFFSET MES1
LAST:
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
END
2.a Write an 8086 ALP to sort a given set of ‘n’ numbers in ascending or descending orders
using Bubble sort algorithm. [Use Codeview to demonstrate the result]
.MODEL SMALL
.DATA
DIRECTION EQU 0 ; 1 FQOR ASCENDING 0 FOR DESCENDING
NUMS DB 1,2,3,4,5 ;5H,4H,3H,2H,1H
COUNT DW ($-NUMS)/TYPE NUMS
.CODE
MOV AX,@DATA
MOV DS,AX
;set up the counter for no. of iterations
;no.of iterations=count of nums - 1
MOV BX,COUNT
DEC BX
;set up the pointer to nums to access the no.s one by one
OUTER: LEA SI,NUMS
;set up the counter for no. of comparisions
MOV CX,BX
;compare the nos in consecutive memory locations
INNER: MOV AL,[SI]
ADD SI,TYPE NUMS;
CMP AL,[SI]
IF DIRECTION
JB SKIP
ELSE
JA SKIP
ENDIF
;exchange the contents of memory locations
XCHG AL,[SI]
MOV [SI-TYPE NUMS],AL
SKIP: LOOP INNER
DEC BX
JNZ OUTER
;return to dos
MOV AH,4CH
INT 21H
end
3.a Write the macros using 8086 ALP to perform following tasks using DOS/BIOS
interrupts,
Write these macros in seperate file “util-macros.asm”, Using these macros write a
program(in a different file) to read a string terminated by carriage return from
keyboard and print the same on the Monitor after clearing the screen and setting the
cursor to the center of the screen.
.MODEL SMALL
.DATA
STR DB 10 DUP(?)
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,STR
CONT: READCHAR
MOV [SI],AL
INC SI
CMP AL,0DH ;compare with Enter key(CR)
JE NEXT
JMP CONT
NEXT: CLRSCR
SETCUR
LEA SI,STR
READCHAR MACRO
MOV AH,01H
INT 21H
ENDM
WRITECHAR MACRO
MOV AH,02H
INT 21H
ENDM
;clr the screen
;INT 10H(video services),Function 07h
;I/P AL-no.of lines to scroll(0-entire window)
; CH,CL - row and col of upper left corner of window
; DH,DL - row and col of lower right corner of window
; BH -attribute used to write blank lines
CLRSCR MACRO
MOV AH,07H
MOV AL,00
MOV BH,07
MOV CX,0000 ;CH-00;CL-00
MOV DH,24
MOV DL,79
INT 10H
ENDM
;set the cursor to the center of the screen
;INT 10H(video services),Function 02h
;I/P BH-video page no, DH-row no, DL-col no (25x80-text screen size)
SETCUR MACRO
MOV AH,02H
MOV BH,00
MOV DH,12
MOV DL,40
INT 10H
ENDM
Note:
Students are compulsorily required to understand, practice the programs before attending their
lab sessions and must be ready to make changes to the above programs as indicated by the lab
faculty and face the viva related to the programs.