0% found this document useful (0 votes)
39 views15 pages

Faculty of Engineering Mahsa University

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 15

Faculty of Engineering

MAHSA UNIVERSITY

BEE 3013

Microprocessor and Microcontroller Lab

LAB MANUAL

Year 3

Semester 1

1|Page
Doc No:
MAHSA/ENG/FM/

ASSIGNMENT COVER SHEET Rev No:

Date:

Faculty of Engineering & IT


Department of Electrical and Electronics Engineering
Module Code Module Name
MPCL Microprocessor and Microcontroller Lab

Name of the student Kanakri Mohammad


Student ID
BEEE20046465
(MAHSA/ARU)
Email [email protected]
Mobile Phone +60 182737922
Batch/Intake
Academic Session
Year/Level 3 Semester 1

2|Page
EXPERIMENT 3: ARITHMETIC OPERATION OF TWO 16-BIT NUMBERS USING
8086 MICROPROCESSORS
Experiment 3.1 for 8086 Microprocessor
Objective: To understand how arithmetic operations are performed in assembly language
using 8086 simulators.
Equipment required: PC with 8086 Microprocessor Simulator
Procedure:
1. RUN THE FOLLOWING ASSEMBLY CODE
LABEL MNEMONICS
START: MOV AX, 4343H

MOV BX, 1111H

SUB AX, BX

Manual Calculation: 4343H – 1111H = 3232H

LABEL MNEMONICS
START: MOV AX, 0043H

MOV BX, 0011H

MUL BX

Manual Calculation: 0043H × 0011H = 0473H

LABEL MNEMONICS
START: MOV AX, 0043H

MOV BX, 0011H

DIV BX

Manual Calculation: 0043H ÷ 0011H = 0003H

1|Page
2. CAPTURE AND DISCUSS THE RESULT IN THE LAB REPORT.

THE FIRST TABLE

Figure (1) Initiate the program.

Figure (2) Store the first value at AX.

Figure (3) Store the second value at BX.

2|Page
Figure (4) Subtract the first number from the second and store it at AX.

THE SECOND TABLE

Figure (1) Initiate the program.

Figure (2) Store the first value at AX.

3|Page
Figure (3) Store the second value at BX.

Figure (4) Multiply the first number and the second and store at AX.

THE THIRD TABLE

Figure (1) Initiate the program.

4|Page
Figure (2) Store the first value at AX.

Figure (3) Store the second value at BX.

Figure (4) Divide the first number by the second and store at AX.

5|Page
3. DISCUSSION:
In this experiment, to understand how arithmetic operations are performed in
assembly language using 8086 simulators, the program is to perform several arithmetic
operations, subtract, multiply, addition, and division operations.

THE FIRST TABLE

The code is an assembly code used to subtract two numbers, the first step, the
assembly code, and the emulation window indicating the start of the program. And then by
moving the value (4343H) to AX using (MOV) command, the H will be assigned to (43) and
the L will be assigned to (43), then by moving the value (1111H) to Bx using (MOV)
command, the H will be assigned to (11) and the L will be assigned to (11).

So, to subtract both values in AX and Bx, by using the (SUB) command, then the
resulted value will always be stored at the accumulator, and in the case of 8086, the
accumulator is AX, (4343H – 1111H = 3232H), 32 stored at L, and 32 stored at H.

THE SECOND TABLE

The code is an assembly code used to multiply two numbers, the first step, the
assembly code, and the emulation window indicating the start of the program. And then by
moving the value (0043H) to AX using (MOV) command, the H will be assigned to (00) and
the L will be assigned to (43), then by moving the value (0011H) to Bx using (MOV)
command, the H will be assigned to (00) and the L will be assigned to (11).

So, to multiply both values in AX and Bx, by using the (MUL) command, then the
resulted value will always be stored at the accumulator, and in the case of 8086, the
accumulator is AX, (0043H × 0011H = 0473H), 04 stored at L, and 73 stored at H.

THE THIRD TABLE

The code is an assembly code used to divide two numbers, first step, the assembly
code and the emulation window indicating the start for the program. And then by moving the
value (0043H) to AX using (MOV) command, the H will be assigned to (00) and the L will
be assigned to (43), then by moving the value (0011H) to Bx using (MOV) command, the H
will be assigned to (00) and the L will be assigned to (11).

6|Page
So, to divide both values in AX and Bx, by using the (DIV) command, then the
resulted value will always be stored at the accumulator, and in the case of 8086, the
accumulator is AX, (0043H ÷ 0011H = 0003H), 00 stored at L, and 03 stored at H.

7|Page
Experiment 3.2 for 8086 Microprocessor
Objective: To write an assembly language to solve arithmetic operations of (6 * 5) – (12 / 4)
and store the result in the CX register in 8086 microprocessors.
Equipment required: PC with 8086 Microprocessor Simulator
Procedure:
1. DRAW A FLOWCHART BASED ON THE QUESTIONS.

START

Store the value 12H at AX.

Store the value 2H at Bx.

Divide 12H over 2H and store the value at AX.

Move the value stored at AX to CX.

Store the value 6H at AX.

Store the value 5H at Bx.

Multiply 12H over 2H and store the value at AX.

Subtract the value at AX from the value of CX.

Move the new value from AX to CX.

END

8|Page
2. WRITE THE ASSEMBLY CODE TO SOLVE THE ARITHMETIC
OPERATIONS.
LABEL MNEMONICS FUNCTION

Start: MOV AX, 12H Store the value 12H at AX

MOV BX, 2H Store the value 2H at Bx

DIV BX Divide 12H over 2H and store the value at AX

MOV CX, AX Move the value stored at AX to CX

MOV AX, 6H Store the value 6H at AX

MOV BX, 5H Store the value 5H at Bx

MUL BX Multiply 6H over 5H and store the value at AX

SUB AX, CX Subtract the value at AX from the value of CX

MOV AX, CX Move the new value from AX to CX and halt the
program.

3. CALCULATIONS:

Hexadecimal Values:

Manual Calculation: (6H × 5H) – (12H ÷ 2H) = 15H

Decimal Values:

Manual Calculation: (6 × 5) – (18 ÷ 2) = 21

9|Page
4. CAPTURE AND DISCUSS THE RESULT IN THE LAB REPORT.

Figure (1) Start the program

Figure (2) Store 12H at AX.

Figure (3) Store 02H at Bx.

10 | P a g e
Figure (4) Divide AX by Bx and store the value at AX.

Figure (5) Move the value from AX to CX.

Figure (6) Store 06H at AX.

11 | P a g e
Figure (7) Store 05H at Bx.

Figure (8) Multiply AX and Bx together and store the value at AX.

Figure (9) Subtract AX from Bx and store the value at CX.

12 | P a g e
5. DISCUSSION:
In this experiment, to write an assembly language to solve arithmetic operations for
the given problem (6 × 5) – (18 ÷ 4) and store the result in CX register in 8086
microprocessors.
The code is assembly code used with a compound of three arithmetic operations
subtraction, multiplication, and division to solve several numbers, first step, the assembly
code and the emulation window indicating the start for the program, move the value of 12 (18
in decimal) to AX using (MOV) command, the H will be (00) and the L will be (12), and
move the value of 02 to Bx using (MOV) command, the H will be (00) and the L will be (02),
then divide AX value (12) by Bx value (02) using (DIV) command, and store the value at AX
(12H ÷ 02H = 09H), 00 is assigned to (H) and 09 is assigned to (L), then move the value to
CX.
Then, Move the value of 06 to AX using the (MOV) command, the H will be (00) and
the L will be (06), and move the value of 05 to Bx using (MOV) command, the H will be (00)
and the L will be (05), then multiply AX value (06) with Bx value (05) using (MUL)
command, and store the value at AX (06H × 05H = 1EH), 00 is assigned to (H) and 1E is
assigned to (L).
Then, subtract the value stored at AX (1E) from the value stored at CX (09) using the
(SUB) command, the manual calculation is as follow (1EH – 09H = 15H), the value stored at
AX, (00) is assigned to (H) and (15) is assigned to L, then move the value stored at AX back
to CX and halt the program.

6. CONCLUSION:
In summary, the objective of those experiments 3.1 and 3.2, to understand
how arithmetic operations are performed in assembly language using 8086 simulators, and to
write an assembly language to solve arithmetic operations of (6 * 5) – (12 / 4).
The 8086 microprocessor is used to copy the data and perform arithmetic operations,
the results are always stored at the accumulator register, and in 8086 microprocessors, the
accumulator is AX register, for experiment 3.1 is used to perform an individual operand, and
obtain the output stored at Ax, but in experiment 3.2 is used to perform several operands and
obtain the output stored at AX register.

13 | P a g e

You might also like