Sunteți pe pagina 1din 92

Department of Electronics and Communication Engineering

BVRIT Hyderabad College of Engineering for Women


Rajiv Gandhi Nagar, Bachupally, Hyderabad -90

MICROPROCESSORS & MICROCONTROLLERS


LAB MANUAL
III Year II semester ECE(R15,R16)
III Year I semester EEE(R16)

Prepared by Verified by

Microprocessor
Programs: R. Shylaja Anwar Bhasha Pattan

Microcontroller
Programs: Anwar Bhasha Pattan R. Shylaja
Department of Electronics and Communication Engineering
BVRIT Hyderabad College of Engineering for Women
Rajiv Gandhi Nagar, Bachupally, Hyderabad -90

MICROPROCESSORS & MICROCONTROLLERS LAB


III Year II semester ECE (R15,R16)
III Year I semester EEE (R16)

Vision and Mission of the Department

Vision
To emerge as a centre of academic and research excellence in Electronics and
Communication Engineering and create globally competent women technocrats with a high
degree of social consciousness in a holistic learning environment.

Mission

 
To provide quality education to the students with emphasis on training related to latest
technologies as per industrial needs.

  and moral values to the students by committed and
To impart research culture, professional ethics
competent faculty striving for excellence.


To inculcate a perceptive alacrity in students to identify real life problems, formulate strategies
and evolve into contextually effective solutions.
Department of Electronics and Communication Engineering
BVRIT Hyderabad College of Engineering for Women
Rajiv Gandhi Nagar, Bachupally, Hyderabad -90

MICROPROCESSORS & MICROCONTROLLERS LAB


III Year II semester ECE (R15,R16)
III Year I semester EEE (R16)

Cycle of Experiments

CYCLE 1: (6 lab sessions)

1. Arithmetic operations on 16-Bit Unsigned numbers


2. Sorting of an Array of Numbers
3. Program for searching for a number or character in a string for 8086.
4. Program for string manipulations for 8086.
5. Program for digital clock design using 8086
6. Interfacing ADC and DAC to 8086
7. Parallel communication between two microprocessors using 8255.
8. Serial communication between two microprocessor kits using 8251
9. Interfacing to 8086 and programming to control stepper motor.

CYCLE 2: (7 lab sessions)

1. Programming using arithmetic, logical and bit manipulation instructions of 8051.


2. Program and verify Timer/Counter in 8051.
3. Program and verify Interrupt handling in 8051
4. UART Operation in 8051
5. Interfacing Switches and LEDs to 8051

6. Communication between 8051 kit and PC


7. Interfacing Matrix Keypad and LCD to 8051
8. Data transfer from peripheral to memory through DMA controller 8237/8257
Equipment Required

1. Personnel Computer
2. 8086 microprocessor kits
3. 8051 microcontroller kits
4. Interfacing Modules
5. Cathode Ray Oscilloscope (30MHz)

  Revision – 2 Lab Sessions


 
Internal Lab Exams – 2 Lab Sessions

Note: Minimum 12 Experiments to be conducted


Department of Electronics and Communication Engineering
BVRIT Hyderabad College of Engineering for Women
Rajiv Gandhi Nagar, Bachupally, Hyderabad -90

MICROPROCESSORS & MICROCONTROLLERS LAB


III Year II semester ECE (R15,R16)
III Year I semester EEE (R16)
Syllabus as per JNTU Hyderabad

List of Experiments

1. Programs for 16 bit arithmetic operations for 8086 (using Various Addressing Modes).
2. Program for sorting an array for 8086.
3. Program for searching for a number or character in a string for 8086.
4. Program for string manipulations for 8086.
5. Program for digital clock design using 8086.
6. Interfacing ADC and DAC to 8086.
7. Parallel communication between two microprocessors using 8255.
8. Serial communication between two microprocessor kits using 8251.
9. Interfacing to 8086 and programming to control stepper motor.
10. Programming using arithmetic, logical and bit manipulation instructions of 8051.
11. Program and verify Timer/ Counter in 8051.
12. Program and verify Interrupt handling in 8051
13. UART Operation in 8051.
14. Communication between 8051 kit and PC.
15. Interfacing LCD to 8051.
16. Interfacing Matrix/ Keyboard to 8051.
17. Data Transfer from Peripheral to Memory through DMA controller 8237 / 8257.
Department of Electronics and Communication Engineering
BVRIT Hyderabad College of Engineering for Women
Rajiv Gandhi Nagar, Bachupally, Hyderabad -90

MICROPROCESSORS & MICROCONTROLLERS LAB


III Year II semester ECE (R15,R16)
III Year I semester EEE (R16)
Index
S.No Name of the Expt. Date of Day to Day Observation Record Total Signature
Expt. Evaluation Marks Marks Marks of
Done (5M) (5M) (5M) (15 M) Lecturer
1

10
S.No Date of Day to Day Observation Record Total Signature
Name of the Expt. Expt. Evaluation Marks Marks Marks of Lecturer
Done (5M) (5M) (5M) (15 M)
11

12

13

14

15

16

17
PART – A
EXPERIMENTS USING 8086 MICROPROCESSOR
INTRODUCTION TO MASM

Editor
An editor is a program, which allows you to create a file containing the assembly language
statements for your program. As you type in your program, the editor stores the ASCII codes
for the letters and numbers in successive RAM locations. When you have typed in all of your
programs, you then save the file on a floppy of hard disk. This file is called source file. The
next step is to process the source file with an assembler. In the MASM /TASM assembler, you
should give your source file name the extension, .ASM
Assembler
An assembler program is used to translate the assembly language mnemonics for instructions
to the corresponding binary codes. When you run the assembler, it reads the source file of your
program the disk, where you saved it after editing on the first pass through the source program
the assembler determines the displacement of named data items, the offset of labels and pails
this information in a symbol table. On the second pass through the source program, the
assembler produces the binary code for each instruction and inserts the offset etc that is
calculated during the first pass. The assembler generates two files on floppy or hard disk. The
first file called the object file is given the extension .OBJ. The object file contains the binary
codes for the instructions and information about the addresses of the instructions. The second
file generated by the assembler is called assembler list file. The list file contains your assembly
language statements, the binary codes for each instructions and the offset for each instruction.
In MASM/TASM assembler, MASM/TASM source file name ASM is used to assemble the
file. Edit source file name LST is used to view the list file, which is generated, when you
assemble the file.
Linker
A linker is a program used to join several object files into one large object file and convert to
an exe file. The linker produces a link file, which contains the binary codes for all the
combined modules. The linker however doesn‟t assign absolute addresses to the program, it
assigns is said to be reloadable because it can be put anywhere in memory to be run. In
MASM/TASM, LINK/TLINK source filename is used to link the file.
Debugger
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to look at
the contents of registers and memory locations after your program runs. It allows you to
change the contents of register and memory locations after your program runs. It allows you to
change the contents of register and memory locations and return the program. A debugger also
allows you to set a break point at any point in the program. If you inset a breakpoint the
debugger will run the program upto the instruction where the breakpoint is set and stop
execution. You can then examine register and memory contents to see whether the results are
correct at that point. In MASM/TASM, td filename is issued to debug the file.
Debugger Functions
1. Debugger allows looking at the contents of registers and memory locations
2. We can extend 8-bit register to 16-bit register which the help of extended register option.
3. Debugger allows setting breakpoints at any point with the program.
4. The debugger will run the program upto the instruction where the breakpoint is set and
then stop execution of program. At this point, we can examine registry and memory
contents at that point.
5. With the help of dump we can view register contents.
6. We can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8
The DOS -Debugger
The DOS “Debug” program is an example of simple debugger that comes with MS-DOS. Hence
it is available on any PC .it was initially designed to give the user the capability to trace logical
errors in executable file.

The basic DOS - Debugger commands

COMMAND SYNTAX
Assemble A [address]
Compare C range address
Dump D [range]
Enter E address [list]
Fill F range list
Go G [=address] [addresses]
Hex H value1 value2
Input I port
Load L[address] [drive][first sector][number]
Move M range address
Name N[pathname][argument list]
Output O port byte
Proceed P [=address][number]
Quit Q
Register R[register]
Search S range list
Trace T [=address][value]
Unassembled u [range]
Write W[address][drive][first sector][number]
MS-MASM
Microsoft‟s Macro Assembler (MASM) is an integrated software package Written by Microsoft
Corporation for professional software developers. It consists of an editor, an assembler, a linker
and a debugger (Code View). The programmer‟s workbench combines these four parts into a
user-friendly programming environment with built in on line help. The following are the steps
used if you are to run MASM from DOS.
MICROPROCESSOR LAB EXECUTION PROCEDURE

STEP1: Opening the DOS prompt


Click start menu button and click on Run and then type cmd at command prompt immediately
DOS window will be appeared.
STEP2: Checking the MASM installation
To know MASM is installed or not simply type masm at the command prompt upon that it
replies masm version vendor (Microsoft), etc... If you get any error there is no masm in that PC.
STEP3: Directory changing (create a folder with your branch and no in D drive)
Change the current directory to your won directory suppose your folder in D drive type the
following commands to change the directory at command prompt type D: hit enter now you are
in D drive type cd folder name hit the enter
Ex. D cd ece10 , Now we are in folder ece10
STEP4: writing the program
At the command prompt type the edit
programname.asm Ex. Edit add.asm
Immediately editor window will open and there you have to write the program. Type the
program in that window after completion save the Program, to save the program Go to file opt in
the menu bar and select save opt now your code is ready to Assemble.
STEP5: Assembling, Linking and Executing the program
Go to file opt click exit opt now DOS prompt will be displayed to assemble the program type
the following commands at the DOS prompt
Masm Program Name, Program Name, Program Name, Program Name hit the enter
Ex: Masm add, add, add,
add enter OR
Ex: Masm add.asm
If there are any errors in the program assembler reports all of them at the command prompt
with line no‟s, if there are now bugs your ready to link the program. To link the program type
the following line at command prompt Link program name,,,,, (5 commas)
Ex: Link add,,,,,
OR
Ex: link add.obj
After linking you are ready to execute the program. To execute the program type the following
command
Debug program name.exe hit the enter
Ex: Debug add.exe
Now you entered into the execution part of the program here you have to execute the program
instruction by instruction (debugging) first of all press the r key(register) hit the enter key it‟ll
displays all the registers and their initial values in HEXDECIMAL note down the values of all
the register which are used in the program. To execute the next instruction press t key (TRACE)
hit the enter it‟ll execute that instruction and displays the contents of all the register. You have to
do this until you reach the last instruction of the program. After execution you have to observe
the results (in memory or registers based on what you have written in the program).
STEP6: Copying list file (common for all programs):
A list file contains your code starting address and end address along with your program .For
every program assembler generates a list file at your folder, programname.lst (ex. Add.lst) you
should copy this to your lab observation Opening a list file.
Edit programname.lst Ex. Edit add.lst
1. Programs for 16 bit arithmetic operations for 8086
(using Various Addressing Modes).

1. a) Addition

Aim: To perform addition of two 16-bit numbers for 8086 using direct addressing mode in ALP.

Requirements: PC with MASM of 6.11 version software.

Program:
data segment
num1 dw 1111h
num2 dw 2222h
sum dw ?
data ends
assume cs:code, ds:data
code segment
start : mov ax, data ; initialize the data segment

mov ds, ax

mov ax, num1 ; move operand1 to register ax

mov bx, num2 ; move operand2 to register bx

add ax, bx ; add the two operands

mov sum, ax ; save the result present in ax

int 03h ; terminate the program

code ends

end start

Result:
1. b) Subtraction

Aim: To perform subtraction of two 16-bit numbers for 8086 using indirect addressing mode
in ALP.

Requirements: PC with MASM 6.11 version software.

Program:

data segment
num1 dw 4444h
num2 dw 2222h
diff dw ?
data ends
assume cs:code ,ds:data code segment
start : mov ax,data ; initialize the data segment mov ds,ax

mov ax, num1 ; move operand1 to the register ax


mov bx,offset num2 ; move address of operand2 to the register bx
sub ax,[bx] ; perform subtraction
mov diff,ax ; save the result
int 03h ; terminate the program
code ends
end start

Result:
1. c) Multiplication

Aim: To perform multiplication of two 16-bit numbers for 8086 using immediate addressing
mode in ALP.
Requirements: PC with MASM 6.11 version software.
Program:
assume cs:code
code segment
start : mov ax,1111h ; move operand1 to the register ax
mov bx,2222h ; move operand2 to the register bx
mul bx ; perform multiplication
int 03h ; terminate the program
code ends
end start

Result:
1. d) Division

Aim: To perform division of two 16-bit numbers for 8086 using implicit addressing mode in
ALP.
Requirements: PC with MASM of 6.11 version software.
Program:
data segment
num1 dw 2222h
num2 dw 1111h
quotient dw ?
reminder dw ?
data ends
assume cs:code ,ds:data code segment
start : mov ax,data ; initialize the data segment
mov ds,ax
mov ax,num1 ; move operand1 to the register ax
mov bx,num2 ; move operand2 to the register bx
div bx ; perform division
mov quotient,ax ; save quotient
mov reminder,dx ; save reminder
int 03h ; terminate the program
code ends
end start

Result:
2. Program for sorting an array for 8086
2. a) Ascending Order

Aim: To sort the given array of numbers in ascending order.


Requirements: PC with MASM of 6.11 version software.
Program:
data segment
count db 05h
array db 15h,12h,03h,07h,05h.
data ends
code segment
assume cs:code, ds:data
start : mov ax,data ; initialize data segment
mov ds,ax
mov cl,count ; move the count value (number of iterations) into CL
dec cl ; decrement the count
again : lea si,array ; load starting address of array of numbers
mov ch,count ;move the number of comparisons in each iteration into CH
dec ch ; decrement the count
above : mov al,[si] ; move first element of array into al
inc si ; increment SI
cmp al,[si] ; compare the two adjacent numbers
jc ahead ; if 1st number is smaller continue comparing with next
;numbers
xchg al,[si] ; if 1st number is bigger exchange the 2 numbers to get
;correct order
xchg al,[si-1] ; exchange to keep the small number in correct position
ahead : dec ch ; decrement count
jnz above ; continue comparing with next number as count is
;not zero
dec cl ; decrement the count of iterations
jnz again ; go to next iteration as count is not zero
int 03 ; as count is zero all iterations are completed terminate
;program
code ends
end start

Result:
2. b) Descending Order

Aim: To sort the given array of numbers in descending order.


Requirements: PC with MASM of 6.11 version software.
Program:
data segment
count db 05h
array db 15h,14h,05h,06h,02h.
data ends
code segment
assume cs:code, ds:data
start : mov ax,data ; initialize data segment
mov ds,ax
mov cl,count ; move the count value (number of iterations) into
;CL
dec cl ; decrement the count
again : lea si,array ; load starting address of array of numbers
mov ch,count ; move the number of comparisons in each iteration
;into CH
dec ch ; decrement the count
above : mov al,[si] ; move first element of array into
inc si ; increment SI
cmp al,[si] ; compare the two adjacent numbers
jnc ahead ; if first number is bigger continue comparing with
;next numbers
xchg al,[si] ; if first number is smaller exchange two numbers
;to get correct order
xchg al,[si-1] ; exchange to keep the big number in correct
;position
ahead : dec ch ; decrement count
jnz above ; continue comparing with next number as count is
;not zero
dec cl ; decrement the count of iterations
jnz again ; go to next iteration as count is not zero
int 03h ; as count is zero all iterations are completed terminate
;program
code ends
end start

Result:
3. Program for searching for a number or character in a string for 8086.

3. a) Searching for a number

Aim: To find the number in the given string.


Requirements: PC with MASM of 6.11 version software.
Program:
assume cs: code, ds:data, es:data
data segment
list db 53h, 15h, 19h,02h
count db 05h
str1 db „number found$‟
str2 db „number not found$‟
data ends
code segment
start: mov ax, data ; intialize data segment and extra segment
mov ds, ax
mov es,ax
mov al, 15h ; move number to be searched into AL
mov di, offset list ; moving the starting address of list into DI
mov cx, count ; move count into CX
repne scasb ; search for number in list
jz down ; jump down if the number is found
mov ah, 09h ; display commands
mov dx,offset str2
int 21h
jmp exit ; jump to exit
down: mov ah,09h ; display commands
mov dx,offset str1
int 21h
exit: int 03h ; interrupt
code ends
end start

Result:
3. b) Searching for a character

Aim: To find a character in the given string.


Requirements: PC with MASM of 6.11 version software.
Program:
assume cs: code, ds:data , es:data
data segment
list db „bvrit$‟
count db 05h
str1 db „character found$‟
str2 db „character not found$‟
data ends
code segment
start: mov ax, data ; intialize data segment and extra segment
mov ds, ax
mov es,ax
mov al, „r‟ ; move character to be searched into AL
mov di, offset list ; moving the starting address of list into DI
mov cx, count ; move count into CX
repne scasb ; search for character in list
jz down ; jump down if the character is found
mov ah,09h ; display commands
mov dx, offset str2
int 21h
jmp exit ; jump to exit
down: mov ah,09h ; display commands
mov dx, offset str1
int 21h
exit: int 03h ; interrupt
code ends
end start
Result:
4. Program for string manipulations for 8086

4. a) Length of the String

Aim: To find the length of the given string.


Requirements: PC with MASM of 6.11 version software.
Program:
data segment
num1 db „microprocessor$‟
data ends
assume cs:code, ds:data
code segment
start : mov ax,data ; intialize data segment and extra segment
mov ds,ax
lea si,num1 ; load starting address of the string
xor ax,ax ; to make AX zero
mov cx,00h ; move the zero value into the CX
mov al,‟$‟ ; move „$‟ into AL to find end of the string
back: cmp al,[si] ; compare AL with SI content
jz next ; jump if it is equal
inc cl ; increment count
inc si ; increment SI address
jmp back ; if count is not zero jump to back
next: int 03h ; interrupt
code ends
end start

Result:
4. b) Reversing a String

Aim: To find the reverse of the given string.


Requirements: PC with MASM of 6.11 version software.
Program:
data segment
str1 db „micro‟
str2 db 06 dup(0)
count equ 06h
data ends

assume cs:code, ds:data

code segment
start : mov ax,data ; initialize data segment and extra segment
mov ds,ax
mov es,ax
lea si,str1 ; load starting address of the string str1 into SI
lea di,str2 ; load starting address of the string str2 into DI
mov cl,count ; move count into CL
xor ax,ax ; to make AX zero
add si,05h ; add 05 to SI address to point the last character
again: mov al,[si] ; move SI content into AL
mov [di],al ; move AL into DI address
inc di ; increment DI address
dec si ; decrement SI address
dec cl ; decrement count
jnz again ; if count is not zero jump to again
mov[di],‟$‟ ; move „$‟in to DI address to indicate end of string
mov dx,offset str2 ; display commands
mov ah,09h
int 21h
int 03h ; interrupt
code ends
end start

Result:
4. c) Byte Insertion

Aim: To insert a character in the given string.


Requirements: PC with MASM of 6.11 version software.
Program:
data segment
str1 db „mico$‟
str2 db 06 dup(0)
data ends

assume cs:code, ds:data , es:data

code segment
start: mov ax,data ; intialize data segment and extra segment
mov ds,ax
mov es,ax
lea si,str1 ; load starting address of the string str1 into SI
lea di,str2 ; load starting address of the string str2 into DI
mov cl,06h ; move count into CL
back: mov al,[si] ; move SI content into AL
mov [di],al ; move AL into DI address
inc si ; increment SI address
inc di ; increment DI address
dec cl ; decrement count
cmp cl,00h ; compare count with 00h
jz next ; if count equal to zero go to next position
cmp cl,03h ; compare count with 03h to check the position to
;insert
jnz back ; if count not equal to 03h go to back
mov al,‟r‟ ; count equal to 03h move character „r‟ into AL
mov[di],al ; insert character „r‟ from AL to DI address
inc di ; increment DI
loop back ; if count not equal to zer loop to back
next : mov dx,offset str2 ; display commands
mov ah,09h
int 21h
int 03h ; interrupt
code ends
end start

Result:
4. d) Byte Deletion

Aim: To delete a character from a given string.


Requirements: PC with MASM of 6.11 version software.
Program:
data segment
str1 db „miscro$‟
str2 db 06h dup(0)
data ends

assume cs:code,ds:data, es:data

code segment
start: mov ax,data ; intialize data segment and extra segment
mov ds,ax
mov es,ax
lea si,str1 ; load starting address of the string str1 into SI
lea di,str2 ; load starting address of the string str2 into DI
mov cl,07h ; move count into CL
back: mov al,[si] ; move SI content into AL
cmp al,‟s‟ ; compare AL with character to be deleted
jz next ; if character is found jump to next
jnz below ; if not jump to below
below: mov [di],al ; copy character to destination string
inc di ; increment DI
next: inc si ; increment SI to skip character to be deleted
dec cl ; decrement count
jnz back ; jump to back
mov dx,offset str2 ; display commands

mov ah,09h
int 21h
int 03h ; interrupt
code ends
end start

Result:
4. e) Concatenation

Aim: To Concatenate the two strings


Requirements: PC with MASM of 6.11 version software.
Program:
data segment
str1 db „welcome$‟
str2 db „ECE$‟
data ends

assume cs:code,ds:data, es:data

code segment
start: mov ax,data ; intialize data segment and extra segment
mov ds,ax
mov es,ax
lea si,str2 ; load starting address of the string str2 into SI
lea di,str1 ; load starting address of the string str1 into DI
mov cl,0ah ; move count into CL
mov al,.‟$‟ ; move „$‟ into AL
repne scasb ; scan string1 to point the end of string
mov cl,05h ; move count into CL
dec di ; decrement DI
up: mov al,[si] ; copy string2 character into AL
mov [di],al ; move AL content into DI
inc di ; increment DI
inc si ; increment SI
loop up ; as count is not zero go to up to copy next character
mov dx,offset str2 ; display commands
mov ah,09h
int 21h
int 03h ; interrupt

code ends

end start

Result:
5. Interfacing ADC and DAC to 8086.

5. a) Interfacing ADC

Aim: To generate the digital value for the analog


input. Requirements: NVIS 86 kit, multi-meter
Program:
mov al,98 ; initialize 8255
out 76,al ; PA & PC upper as input & PB & PC lower as output
start: mov al,00 ; select channel 0
out 72,al ; out at port-B
mov al,00 ; give SOC and ALE as 0
out 74,al ; out at port-C
mov al,03 ; give SOC and ALE as 1
out 74,al ; out at port-C
mov al,00 ; give SOC and ALE as 0
out 74,al ; out at port-C
up: in al,74 ; read EOC from port-C
and al,10 ; check EOC at PC4 bit
jne up ; jump if EOC is not set
mov al,04 ; as EOC is set give output enable as 1
out 74,al ; out at port-C
in al,70 ; read ADC data from port-A
call F000:F07c ; clear LCD screen
mov ah,00 ; put 00 in AH
mov bl,80 ; selection of LCD location
call F000:F094 ; call display routine
mov cx,0f00 ; move count value into CX register
lp: loop lp ; for delay
jmp start ; jump to start label
int 03 ; interrupt
Result:
5. b) Interfacing DAC

Aim: To generate different analog waveforms (step, ramp, triangle and square) by using DAC
interface to 8086 processor with different periods.
Requirements: PC with MASM of 6.11 version software, 8086 microprocessor kit, CRO.
Program:

To generate square wave output:

mov al,80 ; initialize 8255 CWR


out 76,al ; PA,PB,PC as output port
start: mov al,00 ; move accumulator data 00
out 70,al ; out at PA
out 72,al ; out at PB
call delay1 ; call delay routine
mov al,ff ;move accumulator data ff
out 70,al ; out at PA
out 72,al ; out at PB
call delay1 ; call delay routine
jmp start ; jump to start
delay1: mov cx,0ff ; delay routine
dl1: dec cx
jnz dl1
ret

Program:
To generate Ramp wave at X-Out & Y-Out:

Port A - 70H
Port B - 72H
Port C - 74H
Control Word - 76H
mov al,80 ; initialize 8255 CWR
out 76,al ; PA,PB,PC as output port
mov al,00 ; move accumulator data 00
start: out 70,al ; out at PA
out 72,al ; out at PB
inc al ; increment accumulator data
jmp start ; jump to start
int 03 ; interrupt

Program:
To generate triangular wave at Xout and Yout:

Port A - 70H
Port B - 72H
Port C - 74H
Control Word - 76H

mov al,80 ; initialize 8255 CWR


out 76,al ; PA,PB,PC as output port
mov al,00 ; move accumulator data 00
start: out 70,al ; out at PA
up: out 72,al ; out at PB
inc al ; increment accumulator data
cmp al,ff ; compare with peak value
je down ; if equal start decrementing
jmp up ; if not continue incrementing
down: dec al ; decrement accumulator data
out 70,al ; out at PA
out 72,al ; out at PB
cmp al,00 ; compare with minimum value
je start ; if equal restart incrementing
jmp down ; if not continue decrementing
int 03 ; interrupt

Result:
6. Parallel communication between two microprocessors using 8255.

Aim: To communicate the data between two microprocessors using 8255 parallely.
Requirements: PC with MASM of 6.11 version software, Nvis 5586A Trainer kits.
Program:
Connect the 8255-1 of both trainers using 26 FRC cable.
For transmit data fill the program below in trainer given:
mov al,82 ; set 8255-1 for I/O
out 76,al ;
up: mov al,99 ; move data to be transferred into AL
out 70,al ; send data to 8255-1
call f000:f07c ; call the display function
mov ah,00 ; move 00 into AH
mov bl,80 ; move 80 into BL for setting position of LCD
call f000:f094 ; call the display function
jmp up ; jump to up label position
int 03 ; interrupt
For receiver fill the program given below in second trainer:
mov al,90 ; set 8255-1 for I/O
out 76,al
up: in al,70 ; read the port
call f000:f07c ; call the display function
mov ah,00 ; move 00 into AH
mov bl,00 ; move 00 into BL for setting position of LCD
call f000:f094 ; call the display function
jmp up ; jump to up label position
int 03 ; interrupt
When both program entered then data entered at transmit trainer is displayed on
receiving trainer. For above programs 99 are displayed on receiving trainer LCD.

Result:
7. Interfacing to 8086 and programming to control stepper motor.

Aim: To interface the stepper motor to 8086 and operate it in clockwise and anti-clockwise by
varying the different step-size.

Requirements: Nvis 5586A Trainer, Stepper motor interface kit with motor.
Circuit Diagram:

Switching Sequence:

Step Q4 Q2 Q3 Q1 Modes
1 0 0 1 0 1 PHASE
2 0 1 0 0 EXCITATION
3 0 0 0 1 W AVEDRIVE
4 1 0 0 0

1 1 0 1 0
2 0 1 1 0 2 PHASE
3 0 1 0 1 EXCITATION
4 1 0 0 1

1 1 0 1 0
2 0 0 1 0
3 0 1 1 0
4 0 1 0 0 HALF-STEP
5 0 1 0 1 EXCITATION
6 0 0 0 1
7 1 0 0 1
8 1 0 0 0
Program:
8255 Port Address
Port A - 70H
Port B - 72H
Port C - 74H
Control Word - 76H

Program -1

This program will move the motor in Anti-Clock wise direction. For Clockwise
direction, change F9,

F5, F6, and FA in place of FA, F6, F5, and F9.

mov al,80 ; initialize 8255 CWR

out 76,al ; set all ports as output

y: mov al,f9 ; set PA0 & PA3 coil high

out 70,al ; out at port-A

call abc ; call delay routine

mov al,f5 ; set PA0 & PA2 coil high

out 70,al ; out at port-A

call abc ; call delay routine

mov al,f6 ; set PA1 & PA2 coil high

out 70,al ; out at port-A

call abc ; call delay routine

mov al,fa ; set PA1 & PA3 coil high

out 70,al ; out at port-A

call abc ; call delay routine

jmp y
int 03 ; interrupt

abc: mov cx,00 ; delay routine

qz: dec cx

jnz qz

ret

Program -2

This program will move the motor in lock wise

mov al,80 ; initialize 8255 CWR

out 76,al ; set all ports as output

y: mov al,fa ; set PA1 & PA3 coil high

out 70,al ; out at port-A

call abc ; call delay routine

mov al,f6 ; set PA1 & PA2 coil high

out 70,al ; out at port-A

call abc ; call delay routine

mov al,f5 ; set PA0 & PA2 coil high

out 70,al ; out at port-A

call abc ; call delay routine

mov al,f9 ; set PA0 & PA3 coil high

out 70,al ; out at port-A

call abc ; call delay routine


jmp y

int 03 ; interrupt
abc: mov cx,00 ; delay routine

qz: dec cx

jnz qz

ret

Result:
8. Serial communication between two microprocessor kits using 8251

SERIAL COMMUNICATION

NV5586A has facility of Serial Interface with PC for any serial Transmission & Reception. Through this

facility one can upload & download data from / to PC. For Downloading &Uploading Windows Hyper

Terminal is required. Windows HYPER TERMINAL is a simple terminal emulator software for IBM-PC

compatible computers. It allows the user to communicate with the computer through serial port with the

facility of downloading & uploading of the data between the computer and the other serial devices. The

various communication parameters like baud rate (speed), number of data bits, stop bits, parity etc. can be

changed. The package communicates through COM1: as well as COM2: ports of the IBM-PC system.

Installation:

If your computer doesn‟t have Hyper Terminal software please follow the below procedure.

1. First go to Control Panel and Click Add/Remove Program.

2. Click Windows Setup.

3. Select Communication and Click Details.

4. Select Hyper Terminal then press OK and Click Apply.

5. Computer will ask for Window CD for Installing Hyper Terminal.

6. After Installing Hyper Terminal Click cursor on <Start> <Programs> <Accessories> <Communications>
<Hyper Terminal> then open it.

7. Click on <Hypertrm> icon give ABC in name Block and Click OK.

8. Select Communication Port either <Direct to COM1> or <Direct to COM2> and click OK.

9. For Trainer Kit select following COM1/COM2 properties:

Bits per second 4800

Data bits 8

Parity ODD

Stop bit 2

Flow Control XON/XOFF


10. Go on Menu Bar <Select FILE> <Properties> <Setting> <ASCII Setup> ASCII Sending

: Line Delay 20 Character Delay 20 ASCII Receiving:

Force Incoming ENABLE

Wrap lines that exceed terminal width ENABLE

11. Now one can upload / download data from / to PC.

NV5586A

NVIS Technologies 51

Uploading:

Hyper Terminal provides a feature by which the data stored in NV5586A can be stored in the
disk of PC. This can be achieved by following the instructions given as below:

Example

We are storing the program/data of NV5586A from 0000:0400 (Starting address) to 0000:04FF
(End address) as an example to demonstrate the UPLOADING features.

1. On NV5586A, execute from F000:F003 using G command as follows: Press Enter key and the
following will come on the display:

Press „F7‟ key to come in the OUT mode.

1st location indicates the starting address (F000:0400) and the 2nd location indicates the end
address (0400) of the memory area to be transmitted on to the Serial Port. Change this to

0000:0400 to 04FF as follows:

2. On Menu Bar Select <Transfer> <Capture Text>, Click on it.

3. Then give any name with extension .TXT and Click <Start>.

4. After that press <Enter> key of NV5586A Kit.

5. Now you will see Data on the PC Screen.

6. go in menu bar and select <transfer> <capture text> <stop>, click on it.

7. now your file is saved in the pc.


by this procedure one can upload data in pc.

downloading :

the following procedure is to be adopted for downloading the file from pc to nv5586a.

1. on nv5586a, execute from f000:f003 using g command as follows: press enter key and the
following will come on the display:

nv5586a

nvis technologies 52

change the location from f000:0400 to 0000:0400. this is the 1st ram location data will be
received from the pc and this address will keep on incrementing on receipt of each data byte.

2. press enter key

3. go to menu bar and click <transfer> <send text file>.

4. then type file to be downloaded i.e. abc.txt.

5. after that address field on nv5586a will go on incrementing will display till the last address

field at where user have saved abc.txt file.

the following example will transmit characters to pc and simultaneously display on

lcd. mov al,b7 ; control word format for 8253 out 03,al

mov al,13 ; count is given to set the baud rate at 4800

out 02,al

mov al,00

out 02,al

mov al,4e ; mode instruction format in asynchronous mode out

51,al

mov al,05 ; make transmit enable and receive enable high


out 51,al

f0 00 f0 l3: call f000:f07c

mov cx,0014

mov bl,80 ;delete the first line

call f000:f078

l2: push cx

call f000:f050 ; call for the read key in call

f000:f058 ; call the alphabetical key code and transfer into subprogram

call f000:f058 ; key in code enter into lcd modulator.

call f000:f048

push ax

l1: in al,51

and al,01 ; check for tx rdy signal

je 0434

pop ax

out 50,al ; transmit the character to crt terminal

pop cx

loop 0423

mov cx,0014

mov bl,80 ; delete the first line

call f000:f078

l5: push cx

call f000:f050 ; call for the read key in

call f000:f058 ; call the alphabetical key code & transfer into subprogram

call f000:f048 ; key in code enter into lcd modulator


push ax

l4: in al,51 ; check for tx rdy signal and al,01

je 045b

pop ax

out 50,al ; transmit the character to crt terminal pop cx

loop 044a j

mp 0414

Execute using „G‟ command from 0000:0400 and press any key of the NV5586A keyboard, the
same will be displayed on the LCD and on the screen of PC

Result:
9. Program for digital clock design using 8086.

AIM: To write an ALP program for displaying the system


clock. Requirements: PC with MASM of 6.11 version software
Program:
code segment
assume cs:code,ds:data
prog proc far
org 0400h
mov al,00h
mov dl,00h
mov si,0500h
mov [si],al
mov di,0500h
call clear
start:mov bl,80h
mov bl,80h
call atdat
call delay
inc ax
cmp al,03ch ;for second comparison
jnz start
mov al,00h
inc dl
mov al,dl
mov bl,85h
call atdat
mov al,00h
cmp dl,03ch ;for minute comparison
jnz start
mov dl,00
mov si,0500h
mov al,[si]
inc al
mov [si],al
mov bl,08ah
call atdat
cmp al,018h
jnz start
mov al,00h
mov [si],al
jnz start
prog endp
clear: db 9ah,7ch,0f0h,00h,0f0h ;call 0f000:f07c clear lcd screen
ret
atdat: mov ah,00h ;put 00 in ah
db 9ah,94h,0f0h,00h,0f0h;
ret
delay: mov cx,9999h ;delay of one second approx. change the cx value for changing the
;delay
lp1: dec cx
jne lp1
ret
code ends

Result:
10. Data Transfer from Peripheral to Memory through DMA controller 8237
/ 8257.

AIM: Write a program for data transfer from peripheral to memory through DMA
controller. Requirements: 8051 Trainer kit, DMA module, FRC cables, & Power Supply.
Program:
dmal = 00
dmah = 50
tcl = ff
tch = 47
mov ax,dmal
out 80,ax
mov ax,dmah
out 80,ax
mov al,tcl
out 81,al
mov al,tch
out 81,al
mov al,41
out 88,al
int 3

Result:
PART – B
EXPERIMENTS USING 8051 MICROCONTROLLER
INTRODUCTION TO KEIL IDE

KEIL IDE is basically an assembler and a compiler. You can write either an Assembly or C
language code and KEIL will take care of the rest for you. Furthermore, it supports many of the
8051 variants that you will face.

Steps for Using the Keil Software:

Create a new folder for project to avoid getting mixed up with files

Project > New µVision Project


Give some name and click save

When prompted, select proper device that you're using ( i-e ATMEL > AT89C51 )
When prompted, Select Yes

Click New and write your code (Assembly or C)

Save the file with proper extension as above


The code you have written gets highlighted

Right click the source group 1 and click the Add files to group Source group 1
Add the code you have written into the Project workspace

Go to options for the Target


Enable Hex file generation

Build the Target


Notice successful build. Ignore the warnings

Use this Hex file to program the IC.

Follow the above simple steps for programming the microcontroller using Keil IDE
1. Programming using arithmetic, logical and bit manipulation instructions
of 8051.

1. a) Addition

Aim: To write an 8051 ALP for addition of two numbers and verify its output using Keil
compiler.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

mov a, #40h ; load accumulator a with immediate value 40h

mov 40h, #28h ; copy the number 28h in data memory location 40h

add a, 40h ; add the contents of 40h and a, result will be in a

here: sjmp here ; halt the program/ wait here

end ; End of the program

Result:
1. b) Subtraction

Aim: To write an 8051 ALP for subtraction operation between two numbers and verify its output
using Keil compiler.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

mov a, #40h ; load accumulator a with the immediate value 40h

mov r1, #28h ; copy the number 28h in register r1

subb a, r1 ; subtract the contents of r1 from a, result will be in a

here: sjmp here ; halt the program/ wait here

end ; End of the program

Result:
1. c) Multiplication

Aim: To write an 8051 ALP for multiplying two numbers and verify its output using Keil
compiler.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

mov a, #0ah ; load accumulator a with immediate value 0ah

mov b, #02h ; load accumulator a with immediate value 02h

mul ab ; Multiply the contents of A with B, Lower and Higher

; bytes of the result will be in A and B respectively

here: sjmp here ; halt the program/ wait here

end ; End of the program

Result:
1. d) Division

Aim: To write an 8051 ALP for division operation between two numbers and verify its output
using Keil compiler.

Requirements:

1. Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

mov a, #0ch ; load accumulator a with immediate value 0ch

mov b, #05h ; load accumulator b with immediate value 05h

div ab ;Divide the contents of A with B. Quotient and ;remainder


will be available in A and B respectively.

here: sjmp here ; halt the program/ wait here

end ; End of the program

Result:
1. e) Logical AND Operation

Aim: To write an 8051 ALP for Logical AND operation between two numbers and verify its
output using Keil compiler.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location

mov a, #0ffh 0000h ; load accumulator a with immediate value ffh ;

mov r4, #0fh copy the number 0fh in register r4 ; perform a and r4,

anl a, r4 result will be in a ; halt the program/ wait here ; End

here: sjmp here of the program


end

Result:
1. f) Logical XOR Operation

Aim: To write an 8051 ALP for logical XOR operation between two numbers and verify its
output using Keil compiler.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location

mov a, #0ffh 0000h ; load accumulator a with immediate value ffh ;

mov r5, #0fh copy the number 0fh in register r5 ; perform a xor r5,

xrl a, r5 result will be in a ; halt the program/ wait here ; End

here: sjmp here of the program


end

Result:
1. g) Bit Manipulation

Aim: To write an 8051 ALP for bit manipulation operations and verify its output using Keil
compiler.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

clr p1.0 ; clear the bit 0 position of port 1

setb p1.0 ; set the bit 0 position of port 1

cpl p1.3 ; compliment the bit 3 position of port 1

here: sjmp here ; halt the program/ wait here

end ; End of the program

Result:
2. Program to verify Timer/Counter in 8051.

Aim: To write an 8051 ALP for complimenting all the bits of port 0 with some delay using
Timer 0.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

mov tmod, #01h ; timer 0 in mode 1

back: mov p0, #00h ; make all the bits of port 0 low

acall delay ; call delay subroutine

mov p0, #0ffh ; make all the bits of port 0 high

acall delay ; call delay subroutine

sjmp back ; repeat the operation

delay: setb tr0 ; start the timer

again: jnb tf0, again ; check the overflow flag

clr tr0 ; stop the timer when tf0 is set

clr tf0 ; clear the overflow flag

ret ; return from the subroutine

end ; end of the program

Result:
3. Program to verify Interrupt handling in 8051.
Aim: To write an 8051 ALP for complimenting all the bits of port 1 with some delay during
external interrupt.

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

ljmp main ; jump to the main program

org 0013h ; interrupt service routine for external interrupt 1

back: mov p1, #00h ; make all the bits of port 1 low

mov r2, #0ffh ; ****to generate some delay

mov r3, #0ffh ; these set of

here1: djnz r3, here1 ; instructions

here2: djnz r2, here2 ; are repetitively executed *****

mov p1, #0ffh ; make all the bits of port 1 high

mov r2, #0ffh ; ****to generate some delay

mov r3, #0ffh ; these set of

here3: djnz r3, here3 ; instructions

here4: djnz r2, here4 ; are repetitively executed *****

sjmp back ; repeat the toggling of port 1 bits

main: mov ie, #84h ; enable external interrupt 1

here: sjmp here ; wait for the interrupt to occur

end ; End of the program

Result:
4. UART operation in 8051.
Aim: To write an 8051 ALP for transmitting a character or number using UART operation

Requirements:

Keil Microvision Software

Program:

org 0000h ; start execution from program memory location 0000h

mov tmod, #20h ; timer 1, auto reload mode

mov th1, #-3 ; baud rate selection as 9600

mov scon, #50h ; uart mode selection

setb tr1 ; start the timer 1

again: mov sbuf, #‟a‟ ; transmit character a

here: jnb ti, here ; wait for transmission to complete

clr ti ; clear transmit interrupt flag

sjmp again ; repeat the transmission of a indefinitely

end ; End of the program

Result:
5. Interfacing Switches and LEDs to 8051
Aim: To write an 8051 ALP for interfacing switches and LEDs and verify its output using 8051
kit

Requirements:

1. Keil Microvision Software


2. Nvis 5001A kit
3. Nvis MC01 kit
4. Interfacing cable

Program:

Steps for Operation

;*Swith ON Nvis 5001A

;*Selsct PC mode and put toggle switch in PC mode

;*Burn Program "Switch Interface.hex" file in 8051/52 Microcontroller using Nvis 5001A

;* Connections:

;*Connect 20 Pin FRC cable in following manner:

;*Nvis 5001A Port P1 with "Switch Keypad interface block" Connector of MC01.

;*Put toggle switch in Run

;*Press Run button in software

;* OutPut:

;* whenever you will press any switch i.e. S1 or S2 or S3 or S4, corresponding LED will glow.

;*****************Pin discription****************************

sw1 equ p1.0

sw2 equ p1.1


sw3 equ p1.2

sw4 equ p1.3

l1 equ p1.4

l2 equ p1.5

l3 equ p1.6

l4 equ p1.7

org 0000h

;*****************main loop**********************************

main:

setb sw1

setb sw2

setb sw3

setb sw4

clr l1

clr l2

clr l3

clr l4

loop1: jnb sw1,loop1

setb l1

loop2: jnb sw2,loop2

setb l2
loop3: jnb sw3,loop3

setb l3

loop4: jnb sw4,loop4

setb l4

ajmp main

Result:
6. To communicate between 8051 kit and pc.
Aim: Interface an 8051 microcontroller trainer kit to pc and establish a communication
between them through RS 232

Requirements: PC with Keil software, 8051 kit

Program:

mov a,#36

mov dptr,#2043

movx @dptr,a

mov dptr,#2040

mov a,#0a

movx @dptr,a

mov a,#00

movx @dptr,a

mov r1,#3000

mov dptr,#0092

up: movx @dptr,a

movx @dptr,a

movx @dptr,a

movx @dptr,a

call delay

mov a,#40

movx @dptr,a

call delay

mov a,#0ce

movx @dptr,a
call delay

mov a,#27

movx @dptr,a

call delay

mov dptr,9000

mov dptr,#0092

movx @dptr,a

cmp a,1b

je up

mov dptr,#0090

movx @dptr,a

anl a,81

cjne b,a,down

mov dptr,#0092

movx @dptr,a

anl a,81

cjne al,81

up1 : mov a,b

mov dptr,#0090

movx @dptr,a

movx @dptr,a

mov r3,9700

mov r3,a

inc r3

jmp up
movx @dptr,a

inc r3

jmp up

int 03

down: mov cx,0002

delay:

here: loop here

ret

Result:
7. Interfacing Matrix Keypad and LCD to 8051
Aim: To write an 8051 ALP for interfacing matrix keypad and LCD and verify its output using
8051 kit

Requirements:

1. Keil Microvision Software


2. Nvis 5001A kit
3. Nvis MC01 kit
4. Interfacing cable

Program:

ORG 0000H

main:

lcall delay

lcall lcd_init ; lct init 1800h

lcall delay

lcall comp_name

lcall big_delay

lcall big_delay

lcall big_delay

lcall big_delay

lcall big_delay

lcall big_delay

lcall result

lcall big_delay

lcall big_delay

mov a,#255 ; moving value 255 to port 1

mov p1,a
;************************ key scan ****************************

scan:

lcall key1

lcall key2

lcall key3

lcall key4

ljmp scan

key1:

clr p1.4

mov a,p1

anl a,#0fh

mov r2,a

cjne r2,#14,n1

mov r7,#'f'

lcall datw1

n1:

cjne r2,#13,n2

mov r7,#'3'

lcall datw1

n2:

cjne r2,#11,n3

mov r7,#'2'

lcall datw1

n3:

cjne r2,#7,n4
mov r7,#'1'

lcall datw1

n4:

setb p1.4

ret

;** checking for key press on the second column of 4x4 matrix key2:

clr p1.5

mov a,p1

anl a,#0fh

mov r2,a

cjne r2,#14,q1

mov r7,#'e'

lcall datw1

q1:

cjne r2,#13,q2

mov r7,#'6'

lcall datw1

q2:

cjne r2,#11,q3

mov r7,#'5'

lcall datw1

q3:

cjne r2,#7,q4

mov r7,#'4'

lcall datw1
q4:

setb p1.5

ret

;;;checking for key press on the third column of 4x4 matrix */ key3:

clr p1.6

mov a,p1

anl a,#0fh

mov r2,a

cjne r2,#14,w1

mov r7,#'d'

lcall datw1

w1:

cjne r2,#13,w2

mov r7,#'9'

lcall datw1

w2:

cjne r2,#11,w3

mov r7,#'8'

lcall datw1

w3:

cjne r2,#7,w4

mov r7,#'7'

lcall datw1

w4:

setb p1.6
ret

;checking for key press on the fourth column of 4x4 matrix */ key4:

clr p1.7

mov a,p1

anl a,#0fh

mov r2,a

cjne r2,#14,e1

mov r7,#'c'

lcall datw1

e1:

cjne r2,#13,e2

mov r7,#'b'

lcall datw1

e2:

cjne r2,#11,e3

mov r7,#'a'

lcall datw1

e3:

cjne r2,#7,e4

mov r7,#'0'

lcall datw1

e4:

lcall delay

setb p1.7

ret
lcd_init:

mov a,#30h

acall commd

acall big_delay

mov a,#30h

acall commd

acall big_delay

mov a,#30h

acall commd

acall big_delay

mov a,#02h

acall commd

mov a,#028h

acall commd

mov a,#0ch

acall commd

mov a,#06h

acall commd

mov a,#01h

acall commd

ret

commd:

mov r5,a

anl a,#0f0h

mov p0,a ;p1 for lcd


clr p0.2 ;rs=0 command reg

setb p0.3 ;enable pin

acall delay

clr p0.3

mov a,r5

swap a

anl a,#0f0h

mov p0,a

clr p0.2

setb p0.3

acall delay

clr p0.3

ret

datawrt: ;1851h

mov r5,a

anl a,#0f0h

mov p0,a

setb p0.2 ;rs=1

setb p0.3

acall delay

clr p0.3

mov a,r5

swap a

anl a,#0f0h

mov p0,a
setb p0.2

setb p0.3

acall delay

clr p0.3

ret

;***************** key display subroutine ***********************/

datw1:

mov a,#0c7h ; setting ddram address on second line

lcall commd

mov a,r7

lcall datawrt

ret

/*******************************************************/

delay:

mov r1,#7fh

again:

mov r3,#0ffh

here:

djnz r3,here

djnz r1,again

ret

/**************** generating a bigger delay ********************/

big_delay: mov r1,#155

loop1: mov r3,#255

loop2: djnz r3,loop2


djnz r1,loop1

ret

mov a,#001h ;set lcd display clear

lcall commd

mov a,#82h ;set lcd display location

lcall commd

mov a,#'k'

lcall datawrt

mov a,#'e'

lcall datawrt

mov a,#'y'

lcall datawrt

mov a,#' '

lcall datawrt

mov a,#'p'

lcall datawrt

mov a,#'r'

lcall datawrt

mov a,#'e'

lcall datawrt

mov a,#'s'

lcall datawrt

mov a,#'s'

lcall datawrt

mov a,#'e'
lcall datawrt

mov a,#'d'

lcall datawrt

lcall delay

ret

;* checking for key press on the first column of 4x4 matrix comp_name:

lcall delay ; delay 1873h

mov a,#84h ; set lcd display location

lcall commd ;lcd_cmd 182fh

mov a,#'n'

lcall datawrt

mov a,#'v'

lcall datawrt

mov a,#'i'

lcall datawrt

mov a,#'s'

lcall datawrt

lcall delay

mov a, #0c0h ; set lcd display location

lcall commd ;lcd_cmd

mov a,#'t'

lcall datawrt

mov a,#'e'

lcall datawrt

mov a,#'c'
lcall datawrt

mov a,#'h'

lcall datawrt

mov a,#'n'

lcall datawrt

mov a,#'o'

lcall datawrt

mov a,#'l'

lcall datawrt

mov a,#'o'

lcall datawrt

mov a,#'g'

lcall datawrt

mov a,#'i'

lcall datawrt

mov a,#'e'

lcall datawrt

mov a,#'s'

lcall datawrt

ret

end

Result:
8. Data Transfer from Peripheral to Memory through DMA controller 8237
/ 8257
Aim: Write a program for data transfer from peripheral to memory through DMA controller.

Requirements: 8051 Trainer kit, DMA module, FRC cables, & Power Supply.

Program:

dmal = 00

dmah = 50

tcl = ff

tch = 47

mov ax,dmal

out 80,ax

mov ax,dmah

out 80,ax

mov al,tcl

out 81,al

mov al,tch

out 81,al

mov al,41

out 88,al

int 3

Result:
Viva Voce Questions
The questions along with the answers provided here are sample viva questions that
cover the entire experiments of the lab. Students are advised to refer other related material
for more viva questions.

1. What is Microprocessor?

Answer: It is a program controlled semiconductor device (IC}, which fetches, decodes and
executes instructions.

2. Define Assembler

Answer: An assembler is a program that takes basic computer instructions and converts them
into a pattern of bits that the computer's processor can use to perform its basic
operations.

3. What is Assembly level language?

Answer: An assembly language is a low-level programming language for microprocessors. It


implements a symbolic representation of the binary machine codes and other
constants needed to program a particular CPU architecture.

4. What are Mnemonics?

Answer: Mnemonics are instructions or commands to perform particular operation given by


user to microprocessor e.g MOV, ADD, SUB

5. What is a bus?

Answer: Information is transferred between units of the microcomputer by collections of


conductors called buses. There will be one conductor for each bit of information to
be passed.

6. What is a register?

Answer: In computer architecture, a processor register (or general purpose register) is a


small amount of storage available on the CPU whose contents can be accessed
more quickly than storage available elsewhere.

7. How many segment registers are there in 8086?

Answer: 4 different types of segments in 8086 CS (Code Segment) to hold code area SS
(Stack Segment) to run program DS (Data Segment) to hold data ES (Extra
Segment) to hold large data.
8. What is an instruction?

Answer: An instruction is an order given to a computer processor by a computer program. At


the lowest level, each instruction is a sequence of 0s and 1s that describes a physical
operation the computer is to perform (such as "Add")

9. What is MASM?

Answer: The Microsoft Macro Assembler (MASM) is an x86 assembler for MS-DOS and
Microsoft Windows.

10. What are addressing modes?

Answer: 1. Immediate addressing. 2. Register addressing. 3. Direct addressing. 4.


Indirect addressing.

11. What is the addressing mode used in the instruction MOV AX, [BX][SI]?

Answer: Based indexed addressing mode.

12. Give example of register relative addressing mode?

Answer: MOV AX, 50H [BX].

13. What is the logic level at MN/MX pin indicates?

Answer: The logic level at this pin decides whether the processor is to operate in either
minimum or maximum mode.

14. Distinguish between packed BCD and unpacked BCD.

Answer: Packed BCD numbers are stored two digits to a byte in 4 bit groups referred as
nibbles.

Ex: 86 in unpacked BCD there is only one digit per byte Ex: 08, 06

15. Describe about LOOP instructions?

Answer: The LOOP instruction is a combination of a decrement of CX and a conditional


jump. In the 8086, LOOP decrements CX and if CX is not equal to zero, it jumps
to the address indicated by the label. If CX becomes a 0, the next sequential
instruction executes.

16. What are flag manipulation instructions? Give examples.

Answer: Flag manipulation instructions. STC, CLC, CMC. Set, clear, complement carry flag.
STD, CLD. Set, clear direction flag.
17. What are Assembler directives?

Answer: Assembler directives are instructions to the assembler concerning the program
being assembled.

18. Define Procedure?

Answer: Procedures are a group of instructions stored as a separate program in memory and
it is called from the main program whenever required.

19. What is recursive procedure?

Answer: A recursive procedure is a procedure, which calls itself.

20. What is an interrupt? Explain.

Answer: An interrupt is a condition that causes the microprocessor to temporarily work on a


different task, and then later return to its previous task. Interrupts can be internal or
external.

21. What is instruction set?

Answer: It is the set of the instructions that microprocessor can execute and is usually
defined by the hardware manufacturer, and is based on mnemonics that symbolize
processing steps (instructions).

22. What is physical address?

Answer: Physical memory address pointed by SEGMENT:OFFSET pair is calculated as


Physical address = (<SEGMENT>*10)+<OFFSET>

23. What are the flags in 8086?

Answer: The flags in 8086 are carry flag, parity flag, auxiliary carry flag, zero flag, sign flag,
overflow flag, trap flag, interrupt flag and direction flag.

24. What is the maximum clock frequency of 8086

processor? Answer: 5MHz-10MHz

25. What are the different functional units of 8086 processor?

Answer: Bus interfacing unit and Execution unit.

26. What are machine control instructions?

Answer: NOP, HLT, WAIT and LOCK


27. What are flag manipulation instructions?

Answer: CLD, STD, CLI and STI

28. What are string instructions?

Answer: MOVSB, MOVSW, CMPS, SCAS, LODS and STOS.

29. What is an OPCODE?

Answer: The part of the instruction that specifies the operation to be performed is called the
operation code or OPCODE.

30. What is an Operand?

Answer: The data on which the operation to be performed is called operand.

31. What is data and address bus size in8086?

Answer: Data bus size is 16 bits and address bus size is 20 bits.

32. What is USART?

Answer: The device which can be programmed to perform synchronous or asynchronous


serial communication is called USART (Universal Synchronous Asynchronous
Receiver Transmitter)

33. What are the internal devices of 8255?

Answer: The internal devices of 8255 are PORT-A, PORT-B, PORT-C. The ports can be
programmed for either input or output functions in different operating modes.

34. The Instruction “ADDC A, source” places the result in ________

Answer: A, Accumulator

35. If Carry = 1, A = 95H and B = 4FH prior to the execution of “SUBB A, B”, what will be
the contents of A after the subtraction?

Answer: 45H

36. Is “DIV A, R1” a valid 8051 instruction? Explain your answer.

Answer: No, we must use registers A and B for division.

37. In unsigned multiplication, the product will be placed in ___________

registers Answer: A and B


38. XRLing an operand with itself results in ________

Answer: All zeros

39. How many timers do we have in the

8051? Answer: Two

40. Is TMOD register bit addressable?

41. In Mode 1, the counter rolls over when it goes from ______ to

________. Answer: FFFFH to 0000H

42. To get a 2 ms delay, what number should be loaded into TH, TL using mode 1? Assume
that XTAL = 11.0592 M Hz.

Answer: 2ms/1.085ms = 1843 = 0733H, where TH = 07H and TL = 33H

43. Besides reset, how many interrupts do we have in the

8051? Answer: 5

44. Which pin of the 8051 is assigned to the external hardware interrupt

INT1? Answer: P3.3, which is pin 13 on the 40-pin DIP package

45. What address in the interrupt vector table is assigned to Timer 0?

46. Which bit of IE belongs to the external hardware interrupts? Show how both are enabled.

Answer: Bits D0 and D2 and “MOV IE, #10000101B” will enable both the external
hardware interrupts.

47. What register keeps track of interrupt priority in the 8051? Is it a bit addressable

register? Answer: IP. Yes it is a bit addressable register.

48. The 8051 has a built in UART. (T/F)

49. Which Timer of the 8051 is used to set the baud rate?

Answer: T1
50. To transfer a byte of data serially, it must be placed in __________

register. Answer: SBUF

51. With XTAL = 11.0592 MHz, what value should be loaded into TH1 to have a 28,800
baud rate? Give the answer in both decimal and hexa-decimal.

Answer: -1, FFH

52. The RS pin is an ______________ (input/output) pin for the

LCD. Answer: Input

53. For the LCD to recognize information at the data pins as data, RS must be set

to______. Answer: High

54. Give the command codes for line1, first character and line2, first character.

Answer: 80H and C0H

55. In keypad interfacing, to identify the pressed key, one row at a time is grounded.

(T/F) Answer: True

Write a program to Data transfer from peripheral to memory through DMA

controller 8237/8257 .

*****End*****

S-ar putea să vă placă și