0% found this document useful (0 votes)
52 views11 pages

Labprograms 1A2A3A

The document provides guidelines and a syllabus for a Microprocessor Lab Manual. It outlines 12 lab programs to be completed in Assembly Language for the 8086 microprocessor and in Embedded C on topics like searching, sorting, string manipulation, stack operations, mathematical functions, interfacing and more. Sample programs are provided for problems 1a, 2a and 3a to demonstrate binary search, bubble sort, and macros for keyboard input, screen output and clearing.

Uploaded by

Rajiv Seth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views11 pages

Labprograms 1A2A3A

The document provides guidelines and a syllabus for a Microprocessor Lab Manual. It outlines 12 lab programs to be completed in Assembly Language for the 8086 microprocessor and in Embedded C on topics like searching, sorting, string manipulation, stack operations, mathematical functions, interfacing and more. Sample programs are provided for problems 1a, 2a and 3a to demonstrate binary search, bubble sort, and macros for keyboard input, screen output and clearing.

Uploaded by

Rajiv Seth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Department of Computer Science

R. V. College of Engineering, Bangalore

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

Label: Instruction/Directive Operands ; comments

2. Flow Chart /Algorithm should be on left side, followed by details of DOS/BIOS services
used in the program

Syllabus ( Lab Programs) :

Part A programs – 8086 ALP (includes Macros,Procedures,DOS&BIOS services)

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,

i) To read a character from the keyboard

ii) To display a character

iii) To clear the screen

iii) To exit to DOS operating system.

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]

6a. Write 8086 ALP Procedures to perform the following functions,

i) “read_8” – read 2 digit hex number from keyboard, AL should return the val

ii) “disp_16” - display 4 digit decimal/hex number, AX contains the number

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

7b. Write an ALP/Embedded C program program to perform,

- Read ADC connected to potentiameter and display the output


- Read ADC connected to temperature sensor and display the output

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

9b. Write an ALP/Embedded C program to implement real time clock

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.

11b. Write an ALP/Embedded C program to generate a waveform of frequency N khz for


given duty cycle

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.

Part A – Software Programs

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

;set up the start and end indicators

MOV BEGPTR,00
MOV AX,COUNT
DEC AX
MOV ENDPTR,AX

;compute the mid value


CONTINUE:
MOV BX,BEGPTR
CMP BX,ENDPTR ;
JA NOTFOUND
ADD BX,ENDPTR
SHR BX,1
SHL BX,1 ;word adjustment
MOV AX,KEY
CMP AX,NUMS[BX] ;compare the KEY
;with the num at mid position
JE FOUND
JA SECONDBLK
SHR BX,1
DEC BX
MOV ENDPTR,BX
JMP CONTINUE

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,

i) To read a character from the keyboard

ii) To display a character

iii) To clear the screen

iii) To exit to DOS operating system.

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.

INCLUDE MACROS.ASM ;includes READCHAR,WRITECHAR,CLRSCR,SETCUR macros

.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

CONT1: MOV DL,[SI]


WRITECHAR
INC SI
CMP AL,0DH ;compare with Enter key(CR)
JE EXIT
JMP CONT1

EXIT: MOV AH,4CH


INT 21H
END
;Reads character from standard input device
;INT 21H,function 01h
;I/P -- AH = 01H,function no
;O/P -- AL = 8bit input data(Ascii code of the input key)

READCHAR MACRO

MOV AH,01H
INT 21H

ENDM

;Write Character to Standard output device


;INT 21H,function 02h
;I/P -- AH = 02H, function number
;O/P -- DL = ASCII code of the character to be displayed

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.

You might also like