MPMC Lab Manual
MPMC Lab Manual
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
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
Cycle of Experiments
1. Personnel Computer
2. 8086 microprocessor kits
3. 8051 microcontroller kits
4. Interfacing Modules
5. Cathode Ray Oscilloscope (30MHz)
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
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.
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
1. a) Addition
Aim: To perform addition of two 16-bit numbers for 8086 using direct addressing mode in ALP.
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
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.
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
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
Result:
2. b) Descending Order
Result:
3. Program for searching for a number or character in a string for 8086.
Result:
3. b) Searching for a character
Result:
4. b) Reversing a String
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
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
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
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 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:
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
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,
jmp y
int 03 ; interrupt
qz: dec cx
jnz qz
ret
Program -2
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.
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.
Data bits 8
Parity ODD
Stop bit 2
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:
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
3. Then give any name with extension .TXT and Click <Start>.
6. go in menu bar and select <transfer> <capture text> <stop>, click on it.
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.
5. after that address field on nv5586a will go on incrementing will display till the last address
lcd. mov al,b7 ; control word format for 8253 out 03,al
out 02,al
mov al,00
out 02,al
51,al
mov cx,0014
call f000:f078
l2: push cx
f000:f058 ; call the alphabetical key code and transfer into subprogram
call f000:f048
push ax
l1: in al,51
je 0434
pop ax
pop cx
loop 0423
mov cx,0014
call f000:f078
l5: push cx
call f000:f058 ; call the alphabetical key code & transfer into subprogram
je 045b
pop ax
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.
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.
Create a new folder for project to avoid getting mixed up with files
When prompted, select proper device that you're using ( i-e ATMEL > AT89C51 )
When prompted, Select Yes
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
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:
Program:
mov 40h, #28h ; copy the number 28h in data memory location 40h
Result:
1. b) Subtraction
Aim: To write an 8051 ALP for subtraction operation between two numbers and verify its output
using Keil compiler.
Requirements:
Program:
Result:
1. c) Multiplication
Aim: To write an 8051 ALP for multiplying two numbers and verify its output using Keil
compiler.
Requirements:
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:
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:
Program:
mov r4, #0fh copy the number 0fh in register r4 ; perform a and r4,
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:
Program:
mov r5, #0fh copy the number 0fh in register r5 ; perform a xor r5,
Result:
1. g) Bit Manipulation
Aim: To write an 8051 ALP for bit manipulation operations and verify its output using Keil
compiler.
Requirements:
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:
Program:
back: mov p0, #00h ; make all the bits of port 0 low
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:
Program:
back: mov p1, #00h ; make all the bits of port 1 low
Result:
4. UART operation in 8051.
Aim: To write an 8051 ALP for transmitting a character or number using UART operation
Requirements:
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:
Program:
;*Burn Program "Switch Interface.hex" file in 8051/52 Microcontroller using Nvis 5001A
;* Connections:
;*Nvis 5001A Port P1 with "Switch Keypad interface block" Connector of MC01.
;* OutPut:
;* whenever you will press any switch i.e. S1 or S2 or S3 or S4, corresponding LED will glow.
;*****************Pin discription****************************
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
setb l1
setb l2
loop3: jnb sw3,loop3
setb l3
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
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
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
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
delay:
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:
Program:
ORG 0000H
main:
lcall delay
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 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
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.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
datw1:
lcall commd
mov a,r7
lcall datawrt
ret
/*******************************************************/
delay:
mov r1,#7fh
again:
mov r3,#0ffh
here:
djnz r3,here
djnz r1,again
ret
ret
lcall commd
lcall commd
mov a,#'k'
lcall datawrt
mov a,#'e'
lcall datawrt
mov a,#'y'
lcall datawrt
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:
mov a,#'n'
lcall datawrt
mov a,#'v'
lcall datawrt
mov a,#'i'
lcall datawrt
mov a,#'s'
lcall datawrt
lcall delay
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.
5. What is a bus?
6. What is a register?
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?
9. What is MASM?
Answer: The Microsoft Macro Assembler (MASM) is an x86 assembler for MS-DOS and
Microsoft Windows.
11. What is the addressing mode used in the instruction MOV AX, [BX][SI]?
Answer: The logic level at this pin decides whether the processor is to operate in either
minimum or maximum mode.
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
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.
Answer: Procedures are a group of instructions stored as a separate program in memory and
it is called from the main program whenever required.
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).
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.
Answer: The part of the instruction that specifies the operation to be performed is called the
operation code or OPCODE.
Answer: Data bus size is 16 bits and address bus size is 20 bits.
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.
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
41. In Mode 1, the counter rolls over when it goes from ______ to
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.
8051? Answer: 5
44. Which pin of the 8051 is assigned to the external hardware interrupt
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
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 __________
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.
53. For the LCD to recognize information at the data pins as data, RS must be set
54. Give the command codes for line1, first character and line2, first character.
55. In keypad interfacing, to identify the pressed key, one row at a time is grounded.
controller 8237/8257 .
*****End*****