Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

19L511 MICROPROCESSORS AND

MICROCONTROLLERS LABORATORY

DEPT. OF ELECTRONICS AND COMMUNICATION ENGINEERING,

PSG COLLEGE OF TECHNOLOGY,

(AUTONOMOUS INSTITUTION)

PEELAMEDU, COIMBATORE - 641004

PREPARED BY,

SAKTHIVEL R

20L412
EX NO: 2 MULTIPLICATION AND DIVISION OF SINGLE

DATE: 26/09/2021 AND MULTI-BYTE DATA

AIM:

To become familiar with data transfer instructions and to write an assembly


language program for single byte and multi byte Multiplication and Division.

SOFTWARE REQUIREMENT:

Keil µVision IDE

THEORY:
Multiplication Instruction:

The MUL instruction is used to perform multiplication of two 8 bit


numbers. Both the operands should be placed in registers A and B to perform
multiplication operation. The result from the multiplication operation is also
stored in A (Lower 8 bits) and B (Upper 8 bits).

MUL AB - Multiplies the values in registers A and B


The A Register contains the Lower Nibble and the B register contains the
Upper Nibble.
Division Instruction:
During the DIV operation, the numerator is stored in the accumulator, and
the denominator is stored in register B. Once the operation is performed, the
quotient is placed in A, and the remainder is stored in B.

DIV AB - Divides the values in registers A by B


The A register contains the Quotient and the B register Contains the
Remainder.
MULTIPLICATION OF 8-BIT NUMBERS:

Algorithm:
 Initialize the A register and B register with immediate operands (Numeric
Constants).
 Multiply the A and B registers.
 The A register contains the Lower Nibble and the B register contains the
Upper nibble.

Program:

Memory Machine
Label: Mnemonic: Operands: Comments:
Address: Code:
0x0000 7412 MOV A,#0x21 Move the
Immediate
Constant
(#0x12) to the
Accumulator
A.
0x0002 75F012 MOV B(0xF0),#0X22 Move the
Immediate
Constant
(#0x12) to the
B register.
0x0005 A4 MUL AB Multiply both
the registers A
and B. The
lower nibble
is stored in the
A register and
upper nibble
is stored in the
B register.
0x0006 FA MOV 23H,A Move the
contents of
the
accumulator A
to the Register
R2.
0x0007 ABF0 MOV 24H,B(0XF0) Move the
contents of
the B register
to the register
R3.

Assembly Language Program:

ORG 0000H

MOV A, 21H

MOV B, 22H

MUL AB

MOV 23H, A

MOV 24H, B

L1: SJMP L1

END

Result:

Input Details: Result:


Memory Memory
Expected Obtained
Location/ Data: Location/
Output: Output:
Registers: Registers:

A #0x21 A C0 C0

B #0x22 B 20 20

23H 00 00

24H 18 18
DIVISION OF 8-BIT NUMBERS:

Algorithm:
 Initialize the A register and B register with the Memory Locations.
 Divide the A register by B register.
 The A register contains Quotient and the B register contains the
Remainder.

Program:
Memory Machine
Label: Mnemonic: Operands: Comments:
Address: Code:
0x0000 E520 MOV A,0x21 Move the
contents of the
Memory
Location
(0x20) to the
Accumulator
A.
0x0002 8521F0 MOV B(0XF0),0x22 Move the
contents of the
Memory
Location
(0x21) to the B
register.
0x0005 84 DIV AB Divide the A
register by B
register. The
Quotient is
stored in the
Accumulator A
and the
Remainder is
stored in the B
register.
0x0006 F522 MOV 0x23H,A The contents
of the
Accumulator is
stored in the
Memory
location
(0x22)
0x0008 85F023 MOV 0x24H,B The contents
(0XF0) of the B
register is
stored in the
Memory
Location
(0x23).
0x000B 80FE L1: SJMP L1 Halting the
program.

Assembly Language Program:

ORG 0000H

MOV A, 21H

MOV B, 22H

DIV AB

MOV 23H, A

MOV 24H, B

L1: SJMP L1
Result:

Input Details: Result:


Memory Memory
Expected Obtained
Location/ Data: Location/
Output: Output:
Registers: Registers:

0x20 21H 0x23H 40H 40H

0x21 22H 0X24H 0EH 0EH

MULTIPLICATION OF 16-BIT NUMBERS:

Algorithm:
 Initialize the A register and B register with immediate operands (Numeric
Constants).
 Multiply the A and B registers.
 The A register contains the Lower Nibble and the B register contains the
Upper nibble.
Program:

Memory Machine
Label: Mnemonic: Operands: Comments:
Address: Code:
0x0000 7412 MOV A,#0x21 Move the
Immediate
Constant
(#0x12) to the
Accumulator
A.
0x0002 75F012 MOV B(0xF0),#0X22 Move the
Immediate
Constant
(#0x12) to the
B register.
0x0005 A4 MUL AB Multiply both
the registers A
and B. The
lower nibble
is stored in the
A register and
upper nibble
is stored in the
B register.
0x0006 FA MOV 23H,A Move the
contents of
the
accumulator A
to the Register
R2.
0x0007 ABF0 MOV 24H,B(0XF0) Move the
contents of
the B register
to the register
R3.
0x0000 7412 MOV A,#0x21 Move the
Immediate
Constant
(#0x12) to the
Accumulator
A.
0x0002 75F012 MOV B(0xF0),#0X22 Move the
Immediate
Constant
(#0x12) to the
B register.
0x0005 A4 MUL AB Multiply both
the registers A
and B. The
lower nibble
is stored in the
A register and
upper nibble
is stored in the
B register.
0x0005 A4 MUL AB Multiply both
the registers A
and B. The
lower nibble
is stored in the
A register and
upper nibble
is stored in the
B register.
0x0006 FA MOV 23H,A Move the
contents of
the
accumulator A
to the Register
R2.
0x0007 ABF0 MOV 24H,B(0XF0) Move the
contents of
the B register
to the register
R3.
0x0008 85F023 MOV 0x24H,B The contents
(0XF0) of the B
register is
stored in the
Memory
Location
(0x23).
0x000B 80FE L1: SJMP L1 Halting the
program.
Assembly Language Program:

ORG 0000H
MOV A, 20H
MOV B, 22H
MUL AB
MOV 23H, A
MOV R0, B
MOV A, 21H
MOV B, 22H
MUL AB
ADD A, R0
MOV 24H, A
MOV 25H, B
H: SJMP H
END

INFERENCE:
 In Multiplication of 2 8-bit numbers Lower nibble is stored in the
Accumulator A and the upper Nibble is stored in the B register.
 In Division of 2 8-bit numbers the Quotient is stored in the Accumulator
and the Remainder is stored in the B register.
RESULT:

Thus we have done the Division and Multiplication of 2 8-bit data.

You might also like