Professional Documents
Culture Documents
20L412 - MPMC Ex No 2
20L412 - MPMC Ex No 2
MICROCONTROLLERS LABORATORY
(AUTONOMOUS INSTITUTION)
PREPARED BY,
SAKTHIVEL R
20L412
EX NO: 2 MULTIPLICATION AND DIVISION OF SINGLE
AIM:
SOFTWARE REQUIREMENT:
THEORY:
Multiplication Instruction:
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.
ORG 0000H
MOV A, 21H
MOV B, 22H
MUL AB
MOV 23H, A
MOV 24H, B
L1: SJMP L1
END
Result:
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.
ORG 0000H
MOV A, 21H
MOV B, 22H
DIV AB
MOV 23H, A
MOV 24H, B
L1: SJMP L1
Result:
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: