0% found this document useful (0 votes)
8 views20 pages

MC Lab Manual

The document outlines a series of experiments involving Assembly Language Programs executed on an 8051 microcontroller kit, including multi-byte addition, multiplication, division, sorting an array, ASCII to binary conversion, and parity bit generation. Each experiment includes the aim, required components, procedures, manual calculations, program codes, and actual outputs, demonstrating the functionality and verification of the programs. The results confirm that the programs were successfully entered and verified against manual calculations.

Uploaded by

Hariram S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views20 pages

MC Lab Manual

The document outlines a series of experiments involving Assembly Language Programs executed on an 8051 microcontroller kit, including multi-byte addition, multiplication, division, sorting an array, ASCII to binary conversion, and parity bit generation. Each experiment includes the aim, required components, procedures, manual calculations, program codes, and actual outputs, demonstrating the functionality and verification of the programs. The results confirm that the programs were successfully entered and verified against manual calculations.

Uploaded by

Hariram S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Expt. No.

1 Multi byte Addition

Aim:
To write an Assembly Language Program for multi byte addition and execute the same using 8051
microcontroller kit

Component Required:
1. 8051 Microcontroller Kit - 1
2. Power Supply & Connecting wires - As required

Procedure:
● Switch ON the Power supply
● Follow the General procedures to operate the 8051 microcontroller kit
● Enter the corresponding opcodes of the instruction in the program
● Execute the program
● Verify the outputs from the microcontroller kit with manual calculations

Manual Calculation:
Let us take two 16 bit (2 byte) numbers and add it manually.

83A0 - 1000 0011 1010 0000


3F95 - 0011 1111 1001 0101
______________________
0 1100 0011 0011 0101
C 3 3 5
Program:
Address Label Mnemonics Opcode Comments

CLRC Good practice to clear the


carry flag before any
arithmetic operations

MOV A, # A0H Add the two LSB numbers


and store the result in A
ADD A, # 95H register itself

MOV DPTR, # 8450 H Make to point the DPTR to


external RAM at 8450
address location

MOVX @DPTR, A Move the A (i.e.) added


result to 8450 memory
location

INC DPTR Make the DPTR to point the


next location for storing the
MSB added result

MOV A, #83 H Add the two MSB numbers


and store the result in A
ADDC A, 3FH register itself

MOVX DPTR, A Move the MSB result in


DPTR pointed memory
locations

MOV R0, # 00H Assume to store CARRY


Flag value in R0 register

JNC LOOP Jump if no carry to LOOP

INC R0 Set the carry flag if carry


occurs

LOOP MOV A, R0 Move the carry contents


from RO to A register

INC DPTR Make to point the DPTR to


next location to store
CARRY Value

MOVX@ DPTR, A Move the CARRY value,


which is in Accumulator to
DPTR pointed memory
location

HERE SJMP HERE Make a endless loop


Actual Output:

Addend 83 A0

Adder 3F 95

Added Result

Output Address 8452 ( Carry ) 8451 H ( MSB ) 8450 H ( LSB )

Result:
The Multi byte addition program was entered in 8051 Microcontroller kit and output was verified with
manual calculations.
Expt. No.2 Multiplication & Division

Aim:
To write an Assembly Language Program for multiplication and division and execute the same using an
8051 microcontroller kit.

Component Required:
1. 8051 Microcontroller Kit - 1
2. Power Supply & Connecting wires - As required

Procedure:
● Switch ON the Power supply
● Follow the General procedures to operate the 8051 microcontroller kit
● Enter the corresponding opcodes of the instruction in the program
● Execute the program
● Verify the outputs from the microcontroller kit with manual calculations

Manual Calculation:
Let us take two 8 bit (2 bytes) numbers and multiply it manually.

5 X 4 = 20
5 - Multiplicand (8 bits)
4 - Multiplier (8 bits)
20 - Multiplied result (16 bits)

Let us take two 8 bit (2 bytes) numbers and Divide it manually.

21 / 4 = 5
21 - Dividend
4 - Divisor
5 - Quotient
1 - Remainder
Multiplication Program:
Address Label Mnemonics Opcode Comments

MOV A, # 05 H Move the multiplicand to A


register

MOV B, # 04 H Move the multiplier to B


register

MUL AB Multiplies A & B and stores


the result, LSB part in A and
MSB part in B registers
respectively

MOV DPTR, # 8450 H Make the data pointer to


point is such a way that to
store the result LSB and
MSB part in successive
memory locations

MOVX @DPTR, A Move the LSB result from A


register to data pointer
pointed memory location
8450 H

INC DPTR Make the Data pointer to


point next memory location

MOV A, B Move the MSB result from B


to A register

MOVX @DPTR, A Now move MSB result from


A register to Data pointed
memory location 8451 H

HERE SJMP HERE Makes a endless loop


Division Program:
Address Label Mnemonics Opcode Comments

MOV A, # 21 H Move the Dividend to A


register

MOV B, # 04 H Move the Divisor to B


register

DIV AB Divide A by B and stores the


result, Quotient part in A
and Remainder part in B
registers respectively

MOV DPTR, # 8450 H Make the data pointer to


point is such a way that to
store the results both
Quotient and Remainder
part in successive memory
locations

MOVX @DPTR, A Move the Quotient result


from A register to data
pointer pointed memory
location 8450 H

INC DPTR Make the Data pointer to


point next memory location

MOV A, B Move the Remainder result


from B to A register

MOVX @DPTR, A Move Remainder result from


A register to Data pointed
memory location 8451 H

HERE SJMP HERE Make a endless loop


Actual Output: Multiplication
A register
(Multiplicand)

B register
(Multiplier)

Multiplied Result

Output Address 8451 H ( MSB ) 8450 H ( LSB )

Actual Output: Division


A register
(Dividend)

B register
(Divisor)

Division Result

Output Address 8451 H ( Remainder ) 8450 H ( Quotient )

Result:
Thus the Multiplication & Division program was entered in 8051 Microcontroller kit and output was
verified with manual calculations.
Expt. No.3 Sorting an Array in Ascending order

Aim:
To write an Assembly Language Program for sorting operation in ascending order for a given array of
data and execute the same using an 8051 microcontroller kit.

Component Required:
1. 8051 Microcontroller Kit - 1
2. Power Supply & Connecting wires - As required

Procedure:
● Switch ON the Power supply
● Follow the General procedures to operate the 8051 microcontroller kit
● Enter the corresponding opcodes of the instruction in the program
● Execute the program
● Verify the outputs from the microcontroller kit with manual calculations
Flowchart:
Start

Place unsorted 5 data in memory


locations starting from 9200H

Initialize registers R0 & R1 for outer and inner loop


operations and DPTR to the unsorted memory
locations

Push the DPTR address to


Stack

Hold the first Data in B register and the second data


in A register respectively

Compare A & B
and Check for

NO
YE
POP the DPTR address from
STACK

Interchange the values such


that it stores in ascending order

Decrement R1 & make Inner Loop Untill R1 becomes


Zero

Decrement R0 & make outer Loop Untill R0 becomes


Zero

Stop
Program:
Address Label Mnemonics Opcode Comments

MOV R0, #05H Length of the array stored in


R0 & R1
AGAIN MOV A, R0

MOV R1, A

MOV DPTR, #9200H Data pointer made to point


first memory location

DPTR ← 9200

FIRST PUSH DPH (83) Move the Memory Location


to the stack
PUSH DPL (82)

MOVX A, @ DPTR Data present inside Data


pointer address will be
moved to accumulator

MOV B , A B register holds the A


register value

INC DPTR DPTR ← DPTR +1

MOVX A, @DPTR A ← [ DPTR ]

CJNE A, B, NEXT Compare A & B and Jump


if not equal to NEXT
pointed memory location

NEXT JNC LOOP Jump on NO Carry to LOOP


pointed memory Location

POP DPL Retrieve the data from stack


for interchanging
POP DPH

MOVX@ DPTR, A Interchanging the values in


ascending order
INC DPTR

MOV A,B

MOVX @DPTR, A

LOOP DJNZ R1, FIRST Decrement R1 and Jump if


non zero to FIRST pointed
memory location

Inner Loop
DJNZ R0, AGAIN Decrement R0 and Jump if
non zero to AGAIN pointed
memory location

Outer Loop

HERE SJMP HERE

Actual output
:
INPUT OUTPUT

Memory Address Data Memory Address Data

9200 45 9200

9201 58 9201

9202 8A 9202

9203 12 9203

9204 93 9204

Result:
Thus the 8051 microcontroller program for ascending order sorting was entered in the microcontroller
kit and the output was tabulated and verified.
Expt. No.4 ASCII to Binary Conversion

Aim:
To write an Assembly Language Program for ASCII to Binary Conversion and execute the same using
an 8051 microcontroller kit

Component Required:
1. 8051 Microcontroller Kit - 1
2. Power Supply & Connecting wires - As required

Procedure:
● Switch ON the Power supply
● Follow the General procedures to operate the 8051 microcontroller kit
● Enter the corresponding opcodes of the instruction in the program
● Execute the program
● Verify the outputs from the microcontroller kit with manual calculations
ASCII to Binary Conversion
Flow chart
Start

Place data in memory locations


9100H

Move the data from 9100 to A


register

Compare A & 40H


and Check for

NO

YE
CARR
Y?
NO
Clear CARRY
Flag

Subtract A with 07H

Clear CARRY
Flag

Subtract A with 30H

Increment DPTR

Move the result contents from A to


DPTR pointed memory location

Stop
Program:
Address Label Mnemonics Opcode Comments

MOV DPTR, # 9100H 9100 ← 45 [Assumed]

MOVX A, @DPTR A ← 45

CJNE A, #40 H, LOOP Compare 45 with 40, if it’s


not equal jump to label
LOOP

LOOP JC NEXT Jump on CARRY to NEXT


location

CLRC CF ← 0

SUBB A, # 07 H A ← 3E

NEXT CLRC Clear CARRY Flag


CF ← 0

SUBB A, # 30 H Subtract with borrow


A ← 3E - 30
A←E

INC DPTR DPTR ← 9101

MOVX @DPTR, A 9101 ← E

HERE SJMP HERE

Actual output:
INPUT OUTPUT

Memory Address ASCII Data Memory Address Binary Data

9100 9101

Result:
Thus the 8051 microcontroller program for ASCII to Binary Conversion was entered in the kit and the
output was tabulated and verified.
Expt. No.5 Parity Bit Generator

Aim:
To write an Assembly Language Program for parity bit generation and execute the same using an 8051
microcontroller kit.

Component Required:
1. 8051 Microcontroller Kit - 1
2. Power Supply & Connecting wires - As required

Procedure:
● Switch ON the Power supply
● Follow the General procedures to operate the 8051 microcontroller kit
● Enter the corresponding opcodes of the instruction in the program
● Execute the program
● Verify the outputs from the microcontroller kit with manual calculations
Parity Bit [Even] Generation
Flow chart
Start

Place data in memory locations


8500H

As shifting process to be carried based on bit size, and


we have 8 bits in total in a register, Initialize R0 looping
register with 08H

Initialize register R1 with 00H, to store the number of 1’s


occurance

Move the contents from Data pointed memory location to


Accumulator

Rotate with CARRY instruction for 8 times will make all


the eight bits in A register to pass through the CARRY
Flag

NO
CARRY
FLAG

YE
Increment register R1 by
1

After the above process we have total 1’s occurrences


count in R1 Register, divide it by 2 by using DIV AB
instruction, We get the result in B register the
remainder value

Increment DPTR and Move the contents from B to


DPTR pointed memory through A register

Stop
Program:
Address Label Mnemonics Opcode Comments

MOV R0, #08 H R0 ← 8 LOOP SIZE

MOV DPTR, # 8500H DPTR ← 8500

MOV R1, # 00H R1  00 H

MOVX A, @DPTR A  [DPTR]

NEXT RRC A Rotate right with carry storing


the 1’s in carry bit

JNC LOOP Jump instruction for checking


CARRY bit

INC R1 R1 ← holds the number of


1’s

LOOP DJNZ R0, NEXT Loop for 8 times

MOV A, R1 Move the number of 1’s in A


register from R1 register

MOV B, # 02 H B←2

DIV AB Divide by 2 to check even or


not

MOV A, B Move the Remainder in A

INC DPTR Increment DPTR

MOVX @DPTR, A Store the result in DPTR


memory

HERE SJMP HERE

Actual output:
INPUT OUTPUT

Memory Address Data Memory Address Parity Bit

8500 8501

Result:
Thus the 8051 microcontroller program for parity bit generation was entered in the kit and the output
was tabulated and verified.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy