MP&MC Lab PDF
MP&MC Lab PDF
MP&MC Lab PDF
COIMBATORE -641659
LABORATORY RECORD
NAME
CLASS
BRANCH
SUBJECT
This is to certify that this is a bonafide record of work done by the above student for the
Laboratory________________________________________ during the academic year / semester
_________________________
2 BLOCK TRANSFER
4 SORTING
5 FIBONACCI SERIES
6 LOGICAL OPERATIONS
7 MATRIX ADDITTION
8 CODE CONVERSION
9 MASM
14 CODE CONVERSION
20 DIGITAL CLOCK
21 PRINTER STATUS
EXPT NO: 01 DATE:
AIM:
To write an Assembly Language Program (ALP) for performing the Arithmetic
operation of two byte numbers and to execute it using 8086 microprocessor kit.
APPARATUS REQUIRED:
ALGORITHM:
(iii) Multiplication of 16-bit
(i) 16-bit addition numbers:
Initialize the MSBs of sum to 0
Get the multiplier.
Get the first number.
Get the multiplicand
Initialize the product to 0.
Add the second number to the first
number.
Product = product + multiplicand
If there is any carry,
increment
MSBs of sum by 1. Decrement the multiplier by 1
Store LSBs of sum.
If multiplicand is not equal to
Store MSBs of sum. 0,repeat from step (d) otherwise
store the product.
(ii) 16-bit subtraction (iv) Division of 16-bit numbers.
Get the dividend
Initialize the MSBs of difference to
0 Get the divisor
Initialize the quotient to 0.
Get the first number
Dividend = dividend – divisor
Subtract
the second number from the first
number.
If the divisor is greater, store the
quotient. Go to step g.
If there is any
borrow, increment MSBs of
difference by 1.
Store LSBs of difference
If dividend is greater, quotient
= quotient + 1. Repeat from
Store MSBs of difference. step (d)Store the dividend
value as remainder.
ADDITION
1004 8B, 06,00,12 MOV AX, [1200] Get the first data in AX reg
1008 8B, 1E, 02,12 MOV BX, [1202] Get the second data in BX reg
SUBTRACTION
ADDRESS OPCODES PROGRAM COMMENTS
1004 8B, 06,00,12 MOV AX,[1200] Get the first data in AX reg
1008 8B, 1E, 02,12 MOV BX, [1202] Get the second data in BX reg
ADDITION
MEMORY
DATA
SUBTRACTION
MEMORY
DATA
MANUAL CALCULATION:
MULTIPLICATION
DIVISION
MULTIPLICATION
MEMORY
DATA
DIVISON
MEMORY
DATA
MANUAL CALCULATION
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the assembly language program to perform arithmetic operation of two byte
numbers are written and executed using 8086 microprocessor kit and output is verified .
EXP.NO: 02 DATE:
BLOCK TRANSFER
AIM:
To write an Assembly Language Program (ALP) to transfer a block of data
from one part of memory location to another set of location and to execute it using
8086 microprocessor
APPARATUS REQUIRED:
.
ALGORITHM:
1. Start the program
2. Lead the count CL
3. Initialize BX with source address
4. Initialize SI with destination address
5. Move the content of memory location pointed by BX to AL
6. Move contents of AL to memory location
7. Increment BX by SI
8. Decrement CL register.
PROGRAM:
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the assembly language program to Move a data block without overlap is
written and executed using 8086 microprocessor kit and output is verified.
EXP.NO: 03 DATE:
AIM:
To write an Assembly Language Program (ALP) to find an average of ‘N’
numbers in an array and to execute it using 8086 microprocessor
APPARATUS REQUIRED:
ALGORITHM:
2001
2002
2003
2004
3000
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the assembly language program to find an average of ‘N’ numbers in an array is
written and executed using 8086 microprocessor kit and output is verified.
EXP.NO: 04 DATE:
SORTING OF AN ARRAY
AIM:
APPARATUS:
ALGORITHM:
1. Start
2. Load the array count in two registers C1 and C2.
3. Get the first two numbers.
4. Compare the numbers and exchange if necessary so that the two numbers are
in ascending order.
5. Decrement C2.
6. Get the third number from the array and repeat the process until C2 is 0.
7. Decrement C1 and repeat the process until C1 is 0.
8. Stop
SORTING IN DESCENDING ORDER:
1. Start
2. Load the array count in two registers C1 and C2.
3. Get the first two numbers.
4. Compare the numbers and exchange if necessary so that the two numbers are
in descending order.
5. Decrement C2.
6. Get the third number from the array and repeat the process until C2 is 0.
7. Decrement C1 and repeat the process until C1 is 0.
8. Stop
ASCENDING ORDER
OUTPUT
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2000
2001 2001
2002 2002
2003 2003
2004 2004
2005 2005
DESCENDING ORDER:
OUTPUT
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2000
2001 2001
2002 2002
2003 2003
2004 2004
2005 2005
Exp setup 30
Program 40
Output 20
Viva 10
RESULT:
Total 100
AIM
ALGORITHUM:
PROGRAM:
OUTPUT:
INPUT 2000
OUTPUT
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the assembly language program for generation of Fibonacci series is written and
executed using 8086 microprocessor kit and output is verified.
EXP.NO:06 DATE:
AIM:
To write and execute an assembly language program for performing logical OR, AND,
NAND operation in 8086 kit.
APPARATUS:
1. 8086 microprocessor kit
2. Power card
3. Keyboard
ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BL-register.
3. Logically OR the content of AL with BL-register.
4. Store the result in memory location
5. Stop the program
PROGRAM:
register
INPUT OUTPUT
AL 85H 1200H 9D
BL 95H
22
ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BL-register.
3. Logically AND the content of AL with BL-register.
4. Store the result in memory location
5. Stop the program
register
INPUT OUTPUT
BL 95H
ALGORITHM:
PROGRAM
register
register
INPUT OUTPUT
BL 95H
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus an assembly language program for performing logical OR, AND, NAND
operation is written and executed using 8086 kit output is verified.
EX. NO: 07 DATE:
AIM:
To write and execute an assembly language program for performing addition of two
matrices using 8086 k
APPARATUS:
ALGORITHM:
PROGRAM:
INPUT OUTPUT
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT
CODE CONVERSION
AIM:
To write and execute an assembly language program for converting BCD to Binary
and Hexadecimal to binary using 8086 kit.
APPARATUS:
BCD TO BINARY
register
Mask lower
100B AND AL,0F0 nibble
register
AL register
Stop the
101D HLT program
OUTPUT:
INPUT OUTPUT
HEXADECIMAL TO BINARY
register
Move
1008 MOV BL,01 BL
Rotate AL and
100B LOOP 2 RCR AL,BL BL
Stop the
1023 HLT program
OUTPUT:
INPUT OUTPUT
OUTPUT
ADDRESS INPUT DATA ADDRESS DATA
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus an assembly language program for converting BCD to Binary data and
Hexadecimal to Binary using 8086 overlap is written and executed using 8086
microprocessor kit output is verified
EX. NO: 09 DATE:
MASM
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:
2. We can extend 8-bit register to 16-bit register which the help of extended register option.
5. 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. With the help of dump we can view register contents.
6. We can trace the program step by step with the help of F7.
COMMAND SYNTAX
Assemble A [address]
Dump D [range]
Go G [=address] [addresses]
Hex H value1 value2
Input I port
Quit Q
Register R[register]
Unassembled U [range]
MS-MASM:
Procedure:
3. In that window change the directory [Where you paste the masm software]
4. n the command window type the directory name after that change the directory to
8086(masm) after that type edit
5. After changing directory type edit then you get one window in that window you can write a
program
6. After writing a program click: file->save->exit [again we enter the command window
8. Type: link filename,,; [This will create a list file you can see this inside the
masm(8086)software]
Note: Here we no need to use stack segment so no need to worry about stack error
9. Type: debug filename.exe [to create exe file]
14. Type: e 1200 [see output in corresponding address] use space bar to see next output value
15. Type: q [terminate a line]
Mov ah, 4ch [These commands are used to see the results system itself] Int 21h
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the procedure to execute an assembly language program for 8086 microprocessor by
using MASM is studied and sample programs are executed.
8051 EXPERIMENTS
EX .NO:10 DATE:
AIM:
To write an assembly language program to perform an arithmetic operations like
addition and subtraction of two 16 bit numbers, multiplication and division of two 8 bit
numbers and to execute it using 8051 µc.
APPARATUS REQUIRED:
1. 8051 microcontroller
2. Power supply
ALGORITHM:
OUTPUT:
8504
SUM 8505
OUTPUT
8506
CARRY
ALGORITHM:
PROGRAM:
ALGORITHM:
1. Initialize DPTR and get multiplicand form memory location into accumulator.
3. Accumulator content of multiplicand is moved to B register.
4. Increment the pointer to get the multiplier into accumulator.
5. Multiply the content of A & B. The lower byte of the product in the accumulator and
higher byte in B register.
6. Store the product into memory location by incrementing the pointer.
7. Stop the execution.
PROGRAM:
OUTPUT:
MULTIPLIER 8701
DIVISOR 8701
OUTPUT 8702
QUOTIENT
8703
REMAINDER
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the assembly language programs to perform arithmetic operations like addition,
subtraction, multiplication and division are written and executed using 8051microcontroller
and output is verified.
EXP.NO: 11 DATE:
NUMBER
AIM:
To write an assembly language program to count the number of one’s & zero’s in a
given number and to execute it using 8051 microcontroller.
APPARATUS REQUIRED:
1. 8051 microcontroller kit
2. Power supply
ALGORITHM:
1. Start the program.
2. Initialize the memory pointer for input and outputs data
3. Initialize two registers R0 and R1 for counting zero’s & one’s.
4. Give the count value that is number of bits in data as 08 in R2.
5. Get the input data into accumulator.
6. Rotate right the accumulator through carry.
7. If CF=0, go to step9, else continue.
8. Increment one’s count in R1 then go to step10
9. Increment zero’s count in R0.
10. Decrement count in R2 and repeat the steps from 5 till count becomes zero.
11. Stop the program.
PROGRAM: COUNTING NUMBER OF ONE’S AND ZERO’S IN A
NUMBER
ADDRESS OPCODE LABEL MNEMONICS OPERANDS COMMENTS
8700 78 00 MOV R0,#00 Clear R0 register(count for 0’)
8702 79 00 MOV R1,#00 Clear R2 register(count for 1’s)
8704 7A 08 MOV R2, #08 Load the count value
8706 90 88 00 MOV DPTR, #8800 Initialize the data pointer
8709 E0 MOVX A,@DPTR Move the contents of data pointer
into accumulator
870A 13 LOOP 2 RRC A Rotate right through carry the
accumulator
870B 40 03 JC LOOP If cy=1 jump to loop
870D 09 INC R1 Increment R1
870E E1 03 AJMP LOOP 1 Absolute jump to loop 1
8710 08 LOOP INC R0 Increment count for zero’s
8711 DA F7 LOOP 1 DJNZ R2,LOOP 2 Decrement jump on no zero to
loop 2
8713 E9 MOV A,R1 Move the count of one’s in R1
to accumulator
8714 A3 INC DPTR Increment memory pointer
8715 E0 MOVX @DPTR,A Move the content of
accumulator to memory pointer
8716 E8 MOV A,R0 Move the count of 0’s in R0
into accumulator
8717 A3 INC DPTR Increment memory pointer
8718 F0 MOVX @DPTR,A Move the content of
accumulator to memory
8719 80 FE SJMP 8719 Stop the execution
OUTPUT:
8802 (0’S)
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT: Thus the assembly language program to count the number of one’s and zero’s
in a given number is written and executed using 8051 Microcontroller kit and output is
verified.
EXP.NO: 12 DATE:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM:
OUTPUT:
8300
OUTPUT 8301
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the assembly language program to search a given byte in an array is written
and executed using 8051µc kit and output is verified.
EXP.NO:13 DATE:
AIM:
APPARATUS:
ALGORITHM:
address 4500H
OUTPUT:
INPUT OUTPUT
R0-Register 14 4500 10
A-Register 12
LOGICAL OR OPERATION
address 4500H
OUTPUT:
INPUT OUTPUT
R0-Register 14 4500 16
A-Register 12
address 4500H
OUTPUT:
INPUT OUTPUT
R0-Register 14 4500 06
A-Register 12
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus an assembly language program for logical operations is written and executed
using 8051µc kit and output is verified.
EXP.NO: 14 DATE:
CODE CONVERSION
AIM:
To write and execute an assembly language program to perform code conversion and to
execute it using 8051 microcontroller kit.
APPARATUS REQUIRED:
ALGORITHUM:
BINARY TO GRAY:
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
AIM:
APPARATUS REQUIRED:
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position
is a stepper motor. The rotary motion occurs in a step-wise manner from one equilibrium
position to the next. Stepper Motors are used very wisely in position control systems like
printers, disk drives, process control machine tools, etc. The basic two-phase stepper motor
consists of two pairs of stator poles. Each of the four poles has its own winding. The excitation
of any one winding generates a North Pole. A South Pole gets induced at the diametrically
opposite side. The rotor magnetic system has two end faces. It is a permanent magnet with
one face as South Pole and the other as North Pole. The Stepper Motor windings A1, A2, B1,
B2 are cyclically excited with a DC current to run the motor in clockwise direction. By
reversing the phase sequence as A1, B2, A2, B1, anticlockwise stepping can be obtained.
ANTICLOCKWISE CLOCKWISE
STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA
1 1 0 0 1 9h 1 1 0 1 0 Ah
2 0 1 0 1 5h 2 0 1 1 0 6h
3 0 1 1 0 6h 3 0 1 0 1 5h
4 1 0 1 0 Ah 4 1 0 0 1 9h
ADDRESS MNEMONICS
OPCODDE LABEL COMMEND
ORG 4100h
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus an assembly program to interface stepper motor with 8051 µc and to rotate it
on forward/reverse direction operations is written and executed using 8051µc kit and output
is verified.
EXP.NO: 16 DATE:
AIM:
To interface analog to digital convertor with 8051 µc and to display the equivalent
digital (hexa value) value by saving it on memory location is written and to execute using
8051µc kit
APPARATUS REQUIRED:
2. Power Supply
THEORY:
An ADC usually has two additional control lines: the SOC input to tell the ADC when
to start the conversion and the EOC output to announce when the conversion is complete. The
following program initiates the conversion process, checks the EOC pin of ADC 0809 as to
whether the conversion is over and then inputs the data to the processor. It also instructs the
processor to store the converted digital data at RAM location.
ALGORITHM:
PROCEDURE:
1. Place the jumper J2 in A position.
2. Place the jumper J5 in A position.
3. Enter and execute the program.
4. Vary the analog input (using trimpot) and verify the digital data displayed with that data
stored in memory location 4105H
PROGRAM
ADDRESS OPCODE MNEMONICS COMMENTS
4100 90,FFC8 MOV DPTR,#FFC8
OSERVATION:
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus an assembly program to interface analog to digital convertor with 8051 µc and
to display the equivalent digital (hexa value) value by saving it on memory location is written
and executed using 8051µc kit and output is verified.
EXP.NO: 17 DATE:
AIM :
To interface DAC with 8086 microprocessor and to write an assembly language
program to generate square, sawtooth and triangular waveform and to execute it.
APPARATUS REQUIRED:
1. 8051 MICROCONTROLLER
2. Power Supply
3. DAC Interface board
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is between –5v and
+5v. The output voltage varies in steps of 10/256 = 0.04 (approximately). The digital data
input and the corresponding output voltages are presented in the table. The basic idea behind
the generation of waveforms is the continuous generation of analog output of DAC. With 00
(Hex) as input to DAC2 the analog output is –5v. Similarly with FF H as input, the output is
+5v. Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square wave
of amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to DAC2. Repeat
this sequence again and again. As a result a saw-tooth wave will be generated at DAC2
output.Output digital data from 00 to FF in constant steps of 01 to DAC2.Output digital data
from FF to 00 in constant steps of 01 to DAC2. Repeat this sequence again and again. As a
result a triangular wave will be generated at DAC2 output.
ALGORITHM:
Square Waveform:
Square wave
PROGRAM TABLE: SAW TOOTH WAVEFORM.
OBSERVATION:
WAVEFORM AMPLITUDE TIME PERIOD FREQUENCY
SAW TOOTH
PROGRAM TABLE: TRIANGULAR WAVE
MOV BL,00 Move immediate data to BL register
OBSERVATION:
WAVEFORM AMPLITUDE TIME PERIOD FREQUENCY
Triangular wave
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
AIM:
Keyboard and display is configured in the encoded mode. In the encoded mode, a
binary count sequence is put on the scan lines SL0-SL3. These lines must be externally
decoded to provide the scan lines for keyboard and display. A 3 to 8 decoder 74LS138 is
provided for this purpose. The S0-S1 output lines of this decoder are connected to the two
rows of the keyboard. And QA0 to QA7 is connected to 7 Segment Display
8086 MICRO PROCESSOR ON BOARD I/O DECODING ADDRESS
CONTROL ADDRESS
Control REG C2
Control Data CC
DISPLAY DATA "A":
APPARATUS REQUIRED:
i. 8051 microcontroller
ii. Power cable
PROGRAM:
CHARACTER d c b a dp g f e HEXA
VALUE
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
AIM:
To write and execute an assembly language Program for interfacing the Traffic
Light Controller in 8086 kit.
APPARATUS:
output port.
1004 BB 6B 10 REPEAT: MOV BX, LOOKUP Copy the lookup data value
to BX-register
value to SI-reg.
to Al-register
PORTA
to Al-register
PORTB
101D E8 3E 00 CALL DELAY1 Call Delay program
to Al-register
PORTC
to Al-register
PORTC
to Al-register
78
PORTC
AL-register
PORTC
AL-register
AL-register
PORTA
105D C3 RET
106A C3 RET
1073 84 48 2E 84 84H,48H,2EH,84H
107C END
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus the traffic light controller is interfaced with 8086 microprocessor and assembly
language program to display a specified sequence is written and executed and output is
verified.
EXP.NO: 20 DATE:
DIGITAL CLOCK
AIM:
To write and execute an assembly language Program for digital clock in 8086 kit.
APPARATUS:
1.8086microprocessorkit/MAM ----1
2. Traffic Light Controller Interface boar- 1
3. Power card -- 1
4. Keyboard1---
5. PC with Intel/AMD
Processor---- 1
PROGRAM:
DL-reg.
reg
83
Reg
reg
reg
reg
84
reg
reg
OUTPUT:
1500- 00 SECONDS
1501- 00 MINUTES
1502- 09 HOURS
Exp setup 30
Program 40
Output 20
Viva 10
Total 100
RESULT:
Thus an assembly language Program for 8086 microprocessor to verify the operation
of digital clock kit is written and executed and output is verified.
EXP.NO:21 DATE:
PRINTER STATUS
AIM:
To write and execute an assembly language program for printer interface with
microprocessor 8086 kit and to print a single character “A”.
APPARATUS REQUIRED:
CONTL
register.
with 20H
Program 40
Output 20
Viva 10
Total 100
RESULT: