Professional Documents
Culture Documents
List Of Experiments
___________________________________________________________________
15) Write a program to sort out even and odd numbers from given data
string.
16) Write a program to sort out positive and negative numbers from given
data string.
Theory:
The 8086 is a 16-bit processor having 20 address lines, 16- Data lines & 8-bit
as well as 16-bit registers is as follows
1) General purpose registers: AX (AH-AL), BX (BH-BL), CX (CH-CL), DX
(DH-DL).
2) Flag register.- 9-Bit Flag
3) Segment & offset registers- CS, DS, SS, ES these are four segment
registers. SI, DI, BP, SP, IP & BX these are offset registers.
4) Segmentation of memory: Memory of 8086 is divided into different
segments. One segment having maximum capacity of 64Kb, so max. 16
segments are there.
At a time four segments can be activating, these are code segment, data
segment, stack segment & Extra segment.
I) Editor:
Enter the File Name with .ASM extension (eg. Program1.asm) Write a
program in editor window with the help of assembler directives
II) Assembler:
It is a software tool, which is used to convert source code (.ASM) into object
code (.OBJ). Use following command
III) Linker:
Once source code is assembled, the resulting object file is passed to the linker.
At this point, the linker may combine several object files into an executable
program. The linker:
1) Combines segments according to the instructions in the object files,
rearranging the positions of segments that share the same class or group.
2) Fills in placeholders for offsets (relocatable addresses).
3) Writes relocations for segments into the header of .EXE files
4) Writes the result as an executable program file.
IV) Debugger:
It is a software tool, which is used to load the .EXE file in RAM memory
location and execute it in single stepping mode.
There you will observe command prompt of debug window i.e. CMD
Use different command for different operation. Press F4 key to view different
command. (e.g. L operator is used to load the .EXE file to executable window)
Execute the program by pressing F1 key.
Sample Program:
Step-1: Initialize the data memory segment where two 16-bit data are present.
Step-2: Fetch 1st 16-bit data into any 16-bit general-purpose register (GPR).
Step-3: Add the content of GPR and 2nd word (16-bit data) of data memory.
Step-4: Observe 16-bit LSB result in GPR and carry status in CF.
Step-5: Terminate the program by using DOS interrupt.
Conclusion:
The 8086 have been studied and the result of sample program is observed as
follows.
Viva Questions:
Theory:
For arranging a given string in Ascending/Descending order first decides
which algorithm/method we have to use. (e.g. Bubble Sort)
By comparing 1st data of memory with rest of the data, we can identify either
1st largest or 1st smallest byte. Place this byte at last address of data memory.
Repeat the same procedure or identification of next smallest or largest byte
and arrange this byte above the 1st one. Repeat the same procedure up to last
byte. Use LEA instruction for offset.
Procedure:
Conclusion:
The given data string is arranged in ascending/descending order and the result
of program is observed as follows.
Viva Questions:
Theory:
The given matrices cannot be stored in the forms of Rows & Columns.
Logically decide the data of matrices (Element) is stored in Row fashion or
Column fashion. In this program steps are given in Row fashion. The elements
of matrix are stored in consecutive memory location as a row element. So
according requirement of element of matrix1 and matrix2 offset is calculated
and perform multiplication using MUL instruction.
Procedure:
Conclusion:
The given matrices have been multiplied and the resultant matrix is observed
as follows.
Viva Questions:
Aim: Write a program to compare a given string by using string related instruction.
Problem: Two strings are present from logical addresses 5000:2500h and
6000:2500h in DMS and EMS respectively. Compare the strings and if found
equal, load register BL with FFh otherwise load 00h.
Theory:
Assume that the strings contain 10 characters each. Using string compare
instruction go on comparing individual characters until characters are
matching. If end of string is reached in that way, the strings are equal
otherwise at any point if match not found then the strings are not equal.
Procedure:
Step-1: Store the given strings from the offset addresses 2500h and 2500h in
DMS and EMS respectively.
Step-2: Initialize the data memory segment and Extra memory segment from
specified address.
Step-3: Load register CL with the count value.
Step-4: Load the effective addresses in SI and DI registers respectively.
Step-5: Using CMPSB instruction to compare individual character from DMS
and EMS.
Step-6: Check whether ZF=1. If ZF=1, then go to next step otherwise go to
step 8.
Step 7: Decrement the count value from register CL. Check whether the count
is zero. If it is zero then load register BL=FFh and terminate otherwise
go to step 5.
Step 8: Load register BL=00h and terminate.
Conclusion:
Viva Questions:
Theory:
Procedure:
Step-1: Store the given string fro the offset address 2000h.
Step-2: Initialize the data memory segment from specified address.
Step-3: Set the function value for the display AH=09h.
Step-4: Load the offset address in register DX.
Step-5: Invoke the interrupt INT 21h.
Step-6: Return to DOS.
Conclusion:
The given data string is displayed on the screen which is the output of the
program.
Viva Questions:
1. What are various services that are provided by INT 21h interrupt?
2. Why it is necessary to terminate a given string by ‘$’?
3. What is the ASCII value of ‘$’?
Experiment No. - 7
Theory:
The 8255 is called as a PPI (Programmable Peripheral Interface), which is
used as a mediator between processor and input/output devices. It has three 8-
bit port i.e. Port A (PA) and Port B (PB) & Port C (PC). Port C can be
configure in two 4-bit port i.e. Pcupper & Pclower. It has different controlling
signals ie. RD, WR, CS are low-level active signals and A0, A1 & Reset are
high-level active signal.
Procedure:
Step-1: Interface 8255 Ad-on card with 8086 kit and Port A pin with Logic
analyzer
Step-2: Initialize the Control Word Register (CWR) in I/O mode
Step-3: Transfer 00H on Port A by using OUT instruction
Step-3: Call a delay of Toff time period (40% of total time)
Step-4: Transfer FFH on port A & call a delay of Ton time period (60% of
Total Time).
Step-5: Use unconditional jump and repeat the sequence from step-3
Conclusion:
The square wave has been observed on Logic analyzer with duty cycle of 60%
Viva Questions:
Theory:
8051 is an 8-bit microcontroller. It has following features
1) Four 8-bit ports, which are bit addressable,
2) 128 bytes on chip RAM,
3) 4K ROM,
4) Two timer of 16-bit each
5) One serial port
Keil compiler is used for writing a program in ‘C’ language also can rite in
assembly
Sample Program:
Procedure:
Step-1: Take BCD number in register A.
Step-2: Keep copy of BCD data in register R2.
Step-3: Mask the upper nibble; make it an ASCII, save it in R6.
Step-4: Get original data and mask lower nibble.
Step-5: Rotate the content by four bits towards right.
Step-6: convert it into ASCII and it in R2.
Conclusion:
The study of 8051 & Keil compiler has been completed. The result of sample
program is as shown below.
Viva Questions:
Aim: Write a program for serial data transmission by using serial port of 8051
Problem: Write a program to transfer a message “WELCOME GHRCE” serially a
9600 baud, 8-bit data, 1-stop bit. Do this continuously.
Tools Required: UMPS, Keil compiler
Theory:
To perform serial transmission, we have to use serial port. The baud rate is a
unit of data transmission in bits/sec. The SCON register is an 8-bit register
used to program the start bit, sop bit and data framing, among other things.
SBUF is a serial buffer register to store transfer or receive data.
Procedure:
Step-1: Load TMOD register with value 20H. (Set Timer-1, in mode-2).
Step-2: TH1 is loaded with value to se baud rate
Step-3: Initialize SCON register.
Step-4: TR1 is set to 1 to start timer1, clear TI.
Step-5: The character byte to be transferred serially is written into the SBUF
register
Step-6: Monitor TI bit to check whether character has been transferred or not.
Step-7: To transfer next characters go to step-4.
Conclusion:
The given character string is transfer serially with the given baud rate.
Viva Questions:
1) What is baud rate?
2) What is importance of TI flag?
3) In how many modes serial port is operated in 8051?
4) Explain SCON register.
Experiment No. - 12
Theory:
Mode 2 is the auto reload mode of the timer. In this mode initially the TMOD
register is loaded with the value needed and the count is loaded in THx
register. When the timer is started (TRx) the count value (TLx) is
automatically loaded into TLx register and the counter starts incrementing
(Up-counter). We monitors the timer flag bit TFx. When it becomes 1 we clear
it and same procedure is repeated for the same count, which is reloaded
automatically from the THx, register. For one cycle we complement the bit
P1.0. We use the standard input frequency for 8051 Microcontroller – 11.0592
MHz. This crystal frequency is internally divided by 12 to give
T=1.085µsec.(Time for one clock cycle)
Procedure:
Conclusion:
The program was executed and found that the LED connected to port bit P1.0
blinked every 1-second.
Viva Questions:
Problem: Interface LCD display with 8051 and display “Microprocessor” in the
first line of the display.
Theory:
In recent years the LCD is finding widespread use replacing LED’s. This is
due to the following reasons
1. Declining prices
2. Ability to display numbers, characters and graphics.
3. Incorporation of a refreshing controller into the LCD.
4. Ease of programming.
5. The following pins are important to LCD’s while programming
Procedure:
Conclusion:
The program was executed and found that the LCD display showed the string
“Microcontroller” in the first line.
Viva Questions:
Aim: Write a program to identify smallest / largest number from given string
of 10 bytes data.
Problem:
The data string of 10 bytes is present in a data memory from location
DS: 6000. Find the smallest / largest number. (Data Given: 6aH, 78H,
0abH, 8cH, 0daH, 45H, 70H, 90H, 05H, 60H)
Theory:
Compare the ith number of the series with the (i+1)th number using CMP instruction.
It will set the flags appropriately depending upon whether the ith number or the
(i+1)th number is smallest / largest number. If the ith number is greater/smaller than
(i+1), leave it in AX (any register may be used). Otherwise, load the (i+1) th number
in AX, replacing the ith number in AX. The procedure is repeated till all the numbers
in the array have been compared.
Procedure:
Conclusion:
The smallest / largest number has been identified from the given string and the
result of program is observed as follows.
Viva Questions:
Aim: Write a program to sort out even and odd numbers from given data
string.
Problem: The data string of 10 bytes is present in a data memory from location
DS: 6000. Sort out even and odd numbers from given data string and
store the numbers in same memory location (Data Given: 00H, 90H,
34H, 50H, 78H, 6aH, 78H, 0abH, 8cH, 0daH)
Theory:
For identifying even and odd number from given string of 10 bytes data, first decides
which algorithm/method we have to use.
The simplest logic to decide weather a binary number is even or odd, is to check the
least significant bit of the number. If the bit is zero, the number is zero or the number
is odd. Check the LSB by rotating the number through carry flag, and increment even
or odd number counter.
Procedure:
Step1: Initialize the data memory segment
Step2: Initialize the memory pointer.
Step3: Rotate the contents of accumulator right with carry and check the least
significant bit of the number
Step 4: If the bit is zero, the number is zero or the number is odd.
Step 5: Check the LSB by rotating the number through carry flag, and
increment even or odd number counter.
Conclusion:
The even and odd numbers has been identified from the given string and the
result of program is observed as follows.
Viva Questions:
1. How DF = 1 works?
2. How DF = 0 works?
Aim: Write a program to sort out positive and negative numbers from given
data string.
Problem: The data string of 10 bytes is present in a data memory from location
DS: 9000. Sort out positive and negative numbers from given data
string and store the numbers in same memory location.
Theory:
For identifying positive and negative number from given string of 10 bytes data, first
decides which algorithm/method we have to use. Take the ith number in any of the
registers. Rotate it left through carry. The status of carry flag, i.e. the most
significant bit of the number will give the information about the sign of the number.
If CF is 1, the number is negative otherwise it is positive.
Procedure:
Conclusion:
The positive and negative numbers has been identified from the given string
and the result of program is observed as follows.
Viva Questions:
Problem: Write a program to perform addition of two 3*3 matrices. The matrices
are stored in the form of list (row wise). Store the result of addition in
the third list.
Theory:
In the addition of two matrices, the corresponding element is added to form the
corresponding elements of the result matrix.
The matrix A can be stored in memory at an offset MAT1, such as a11, a12, a13,
a21, a22, a23, a31, a32, a33 etc. The second matrix B can be stored in memory at an
offset MAT2, such as b11, b12, b13, b21, b22, b23, b31, b32, b33 etc. A total of
3*3=9 additions are to be done.
Procedure:
Step1: Initialize the data memory segment.
Step2: Initialize both the matrices A and B.
Step3: The matrix A can be stored in memory at an offset MAT1, and the
second matrix B can be stored in memory at an offset MAT2
Step4: The corresponding element is added to form the corresponding
elements of the result matrix.
Conclusion:
The given matrices have been added and the resultant matrix is observed as
follows.
Viva Questions:
Problem: Interface 8086 with 8251. Set the 8251in asynchronous mode as a
transmitter & receiver with even parity enabled, 2 stop bits, 8-bit
character length, with given frequency & baud rate.
a. Write a program to transmit 100 bytes of data string starting at location
DS: 2000h.
b. Write a program to receive 100 bytes of data string and store it at
ES:3000h
Theory:
The 8251 can be programmed to operate in its various modes using its mode control
words. A set of control words is written into the internal registers of 8251 to make it
operate in the desired mode. The control words of 8251 are divided into two
functional types as Mode Instruction control word and Command Instruction control
word. For interfacing connections of 8251 with 8086, set asynchronous mode control
word as 0FEH as for given information.
Procedure:
Procedure to transmit 100 bytes of data:
Step 1: Initialize data segment register.
Step 2: Initialize counter.
Step 3: Out mode control word 0FEH to D0-D7.
Step 4: Load command word to transmit enable and error reset and read
status.
Step 5: Check transmitter enable bit, if zero wait for the transmitter to be
ready.
Step 6: If ready, first byte of string data is transmitted and point to next byte.
Step 7: Decrement counter.
Step 8: If counter is not zero, go for next byte and if counter is zero then
return to DOS.
Viva Questions:
1. What are the interrupt vector addresses of the following interrupts in the 8086
IVT?
a. INTO
b. NMI
c. INT 20H
d. INT 55H
Aim: Write a program to find the given byte from a string using string
related instructions.
Problem: Write a program to find out whether a given byte is in the string or not.
If it is in the string, find out the relative address of the byte from the
starting location of the string.
Theory:
The given string is scanned for the given byte. If it is found in the string, the zero flag
is set, else it is reset. Use of the SCASB instruction is quite obvious here. A count
should be maintained to find out the relative address of the byte found out.
Procedure:
Conclusion:
The given number has been identified from the given string and the result of
program is observed as follows.
Viva Questions:
Aim: Interface 8253 timer IC with 8086 and write a program to ring the
buzzer after a delay of 2 Min.
Problem: Design a programmable timer using 8253 and 8086. Interface 8253 at
an address 0040H for counter 0 and write the program to generate a
square wave of period 1ms.
Theory:
Neglecting the higher order address lines (A16-A8), the 8253 is interfaced with lower
order data bus (d0-D7), hence A0 is used for selecting the even bank. The A0 and A1
of the 8253 are connected with A1 and A2 of the processor. The counter address can
be decoded as 40H for Counter 0, 42H for Counter 1, 44 for Counter 2, 46H for
Control word register.
For generating a square wave, 8253 should be used in mode 3. Let us select counter 0
for this purpose that will be operated in BCD mode. Now suitable count is to be
calculated for generating 1ms time period.
Procedure:
Viva Questions:
1) What is the use of Interrupts in any system?
Aim: Interface 8279 with 8086 to read the character from keyboard and
display it on 7-segment display.
Problem:
Interface keyboard and display controller 8279 with 8086 at addresses 0080H. Write
an ALP to set up 8279 in scanned keyboard mode with encoded scan, N-key rollover
mode. Use a 16-character display in right entry display format. Then clear the
display RAM with zeroes. Read the FIFO for key closure. If any key is closed, store
its code to register CL. Then write the byte 55 to all the displays and return to DOS.
The lock input to 8279 is 2MHz, operate it at 100 kHz.
Theory:
The 8279 is interfaced with lower byte of the data bus, i.e. D0-D7. Hence the A0
input of 8279 is connected with address line A1. The data register of 8279 is to be
addressed as 0080H, i.e. A0=0. For addressing the command or status word A0 input
of 8279 should be 1 (the address line A1 of 8086 should be 1), i.e. the address of the
command word should be 0082H.
Procedure:
Viva Questions:
1) What addressing mode is used the following instruction
a) MOV AX, BX c) MOV AX, [DI]
b) MOV [SI + BP] d) MOV CX, 2342H