You are on page 1of 14

G.H.

RAISONI COLLEGE OF ENGINEERING, NAGPUR Department of Electronics and Communication Engineering Branch: -7thSem [Electronics &Telecommunication] Subject: - Advanced Microprocessors & Microcontroller
___________________________________________________________________ CYCLE-1 1) Study of 8086 and basic programs. 2) Write a program to arrange a given string in ascending / descending order. 3) Write a program to multiply two matrices. 4) Write a program to compare a given string by using string related instruction. 5) Write a program to design a digital clock to display Hrs, Min & sec. 6) Write a program GHRCE on monitor screen by using DOS functions. CYCLE-2 7) Interface following ICs with 8086 a) 8255: Write a program to generate square wave on 8255 port and use logic analyzer to observe it b) Digital to Analog Converter: Write a program to generate given waveform. 8) 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 3000h 9) Study of 8051 Microcontroller & basic programs. Introduction to Keil Compiler. 10) Write a program to display WELCOME GHRCE. 11) Write a program for serial data transmission by using serial port of 8051. 12) Write a program to generate a delay of 1 Sec. By using Timer0 of 8051 in mode2. 13) Interface LCD display with 8051 & write a program to display Message on it ES:

List Of Experiments

Experiment No.- 1 Aim: Study of 8086 processor and basic programs. Problem: Write a sample program for
1) Addition of Two 16-bit numbers. 2) To find smallest no. from a given string.

Tools Required: MASM, 8086 Kit 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 activate, these are code segment, data segment, stack segment & Extra segment. 1. Software Suit, which is used for Practical, is MASM (Microsoft Assembler) It is DOS based software suit, so we have to work with DOS prompt. 2. It consist of following application files: i) ii) iii) iv) I) Editor: It is a software tool, which allowed user to write its source code in assembly language and save the assembly file by using .ASM extension. All application programs are copied into D drive under the folder name MASM. To enter into Norton editor use following command on DOS prompt. D:\masm>NE (Press Enter Key) Enter the File Name with .ASM extension (eg. Program1.asm) Write a program in editor window with the help of assembler directives Editor (Norton Editor (NE)) Assembler (MASM) Linker (LINK) Debugger (AFDEBUG)

II) Assembler: It is a software tool, which is used to convert source code (.ASM) into object code (.OBJ). Use following command D:\masm>MASM filename.asm (Press Enter key 4-times) Eliminate all sever error then proceed for next steps. 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. D:\masm>LINK filename.obj (Press Enter key 4-times) 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. D:\masm>AFDEBUG (Press Enter key 2-Times) 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:
1) 2) 3) 4) Explain the addressing modes of 8086 in brief. What is assembler directive? Explain assembler directives of 8086 Explain general-purpose register of 8086. Explain how physical address is formed in 8086.

Experiment No. - 2 Aim: Write a program to arrange a given string in ascending / descending order. Problem: The data string of 5 bytes is present in a data memory from location
DS: 6000. Arrange the given string in ascending/ descending order in same memory location (Data Given: 6aH, 78H, 0abH, 8cH, 0daH)

Tools Required: MASM, 8086 Kit 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:
Step-1: Initialize the data memory segment from specified address. Step-2: Initialize the outer counter (counter-1) for repetitive action of finding smallest / largest no. among the string. Step-2: Fetch 1st data from data memory location into any general-purpose register (GPR). Step-3: Initialize the inner counter (counter-2) for identification of 1st smallest /largest no. among the string. Step-4: Increment data memory offset & compares data of memory with GPR. Step-5: Check the status of carry flag & swap the content of two memories depend upon requirement. Step-6: Decrement inner counter & check zero flag for 1st largest / smallest no. If ZF=0, repeat from step 4. If ZF=1 then decrement outer counter & check again ZF, whether the ring is arrange in ascending / descending order. If ZF=0, then repeat the procedure from step-2. Step-6: If ZF=1 then terminate the program by using DOS interrupt.

Conclusion:
The given data string is arranged in ascending/descending order and the result of program is observed as follows.

Viva Questions:
1. Explain importance of condition flag in 8086. 2. What are the advantages of segmentation? 3. Is overlapping of segment possible in 8086?

Experiment No. - 3 Aim: Write a program to multiply two matrixes. Problem: Multiply two matrices of 3 X 2 and 2 X 3 and stored the resultant matrix
from location ES:8000H

Tools Required: MASM, 8086 Kit 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:
Step-1: Initialize the counter for no. of rows in Matrix1 (C3) Step-2: Initialize the offset addresses for matrices. (Matrix1, Matrix2 and Resultant Matrix) Step-3: Initialize the counter for no. of columns in Matrix2 (C2) Step-4: Initialize 16-bit register (R1) for storing the result of row-column multiplication and counter for no. of elements in single row of Matrix1 (C3) Step-5: Fetch data of matrix1 into AL register Step-6: Multiply content of AL register with 1st data of Matrix2 Step-5: Add the content of R1 and AX & stored result in R1. Step-6: Increment offset of Matrix1 and Matrix2 according to logic. Step-6: Decrement element counter (C3) and check zero flag. If ZF=0 then jump to step-5 Step-7: Store the content of R1 register into destination memory location & increment offset of destination offset register by 2. Step-8: Calculate offset for matrix1 (Same Row) and matrix2 (Next Column) according to logic. Step-9: Decrement counter for column of Matrix2 (i.e. C2) and check zero flag. If ZF=0 then jump to step-4. Step-10: Calculate offset for next row of Matrix1. Step-11: Decrement row counter of Matrix1 (i.e. C1) and jump to Step-3 if ZF=0.

Conclusion:
The given matrices have been multiplied and the resultant matrix is observed as follows.

Viva Questions:
1. Explain Loop instruction of 8086. 2. Explain assembler directive PTR. 3. Explain status signals in 8086.

Experiment No. - 4 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.

Tools Required: MASM, 8086 Kit 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:
If the given strings matches the value of register BL is found to be FFh otherwise BL=00h

Viva Questions:
1. Differentiate between CMPSB and CMPSW instructions. 2. Write the same program using conditional REPEAT instruction. 3. Explain the significance of DF (Direction Flag) for string instruction.

Experiment No. - 6 Aim: Write a program to display GHRCE on monitor screen by using DOS
functions.

Problem: The string to be displayed is stored from memory logical address


5000:2000.

Tools Required: MASM, 8086 Kit Theory:


The given string has to be stored from memory address 5000:2000h terminated by an ASCII value $(End of the string). The characters 0Ah and 0Dh can be used as the line feed and carriage return characters. The offset address has to be loaded in register DX and the dedicated interrupt INT 21h is used to display the given string from the offset address. The argument that is required for this function is a byte 09h, which must be loaded in, register AH for displaying the message on the CRT Screen. After the message is displayed the control is transferred to DOS prompt.

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 Aim: Interface following ICs with 8086


a) 8255: Write a program to generate square wave on 8255 port and use logic analyzer to observe it b) Digital to Analog Converter: Write a program to generate given waveform.

Problem: 1) Interface 8255 IC with 8086 kit from addresses 40H. Generate square
wave on port A of 8255 with duty cycle of 60%.

Tools Required: MASM, 8086 Kit, DAC Card 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 8bit 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:
1. 2. 3. 4. Explain the basic modes of 8255. Which ports can be used in Mode-1? What is clock frequency of 8086 processor given on kit? Explain Mode-1 of 8255.

Experiment No. - 09 Aim: Study of 8051 Microcontroller & basic programs. Introduction to Keil
Compiler.

Problem: Register A has packed BCD; write a program to convert packed BCD to
Two ASCII numbers and place them in R2 and R6

Tools Required: UMPS, Keil compiler 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:
1. 2. 3. 4. Which are the general purpose registers in 8051? What is operating frequency of 8051? What is special function register? Explain its importance. What are the addresses of RAM, reserved for bit addressable?

Experiment No. - 11 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) 2) 3) 4) What is baud rate? What is importance of TI flag? In how many modes serial port is operated in 8051? Explain SCON register.

Experiment No. - 12 Aim: Write a program to design to generate a delay of 1 second Mode 2. Problem: The delay of 1 second is to be monitored on port 1 pin p1.0 which
connects an LED and is made off and on per second.

Tools Required: UMPS, Keil compiler 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.085sec.(Time for one clock cycle)

Procedure:
Step-1: Set initial value for the port bit P1.0. Step-2: Load the TMOD register. Step-3: Load the count in THx register. Step-4: Initiate the Timer Run Register. Step-5: Check the timer Flag. If it is 1 complement the port bit P1.0 otherwise keep monitoring the TF flag bit. Step-6: Clear the TF bit and jump to step 5.

Conclusion:
The program was executed and found that the LED connected to port bit P1.0 blinked every 1-second.

Viva Questions:
1. What is the significance of Timer Mode 2? 2. Why an odd frequency value is selected for 8051 Microcontroller? 3. Can we change the value of T=1.085 sec? How?

Experiment No. - 13 Aim: Write a program to display Microcontroller on LCD display. Problem: Interface LCD display with 8051 and display Microprocessor in the
first line of the display.

Tools Required: UMPS, Keil compiler Theory:


In recent years the LCD is finding widespread use replacing LEDs. 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 LCDs while programming i) ii) iii) RS:-Register Select. If RS=0, the instruction command code register is selected. If RS=1, the data register is selected. R/W:-Read/Write.For R/W=0/1, then the LCD can be written into/read. E:-Enable.A H-to-L pulse is required at this pin to latch the data present on the data pins.

Procedure:
Step-1: Initiate a pointer (DPTR) to point the string Microprocessor (say from memory location 2000h) Step-2: Set a counter for 14 characters. (Say R1) Step-3: Initialize 2 lines 5x7 matrix. (Load 38h into command register) Step-4: Make LCD on and Cursor on. (Load 0Eh into command register) Step-5: Set the cursor at the beginning of the first line. (Load 80h in command register) Step-6: Take a character from memory into A and send it on the display.(Use data register) Step-7: Increment the pointer DPTR for next character. Step-8: Decrement the counter R1 and check whether it is zero. Step-9: If not zero jump to step 6 and if zero stop.

Conclusion:

The program was executed and found that the LCD display showed the string Microcontroller in the first line.

Viva Questions:
1. List some LCD command codes. 2. What are the steps that should follow when writing data and writing command?

You might also like