0% found this document useful (0 votes)
6 views10 pages

MPMC Lab-2

The document outlines several lab tasks for an 8086 Assembly language course, including programs for summing and averaging 'N' 8-bit numbers, calculating factorials, and converting Celsius to Fahrenheit. Each task includes a detailed algorithm and corresponding assembly code with comments explaining the purpose of each instruction. The document serves as a guide for students to implement these tasks in a microprocessor lab setting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

MPMC Lab-2

The document outlines several lab tasks for an 8086 Assembly language course, including programs for summing and averaging 'N' 8-bit numbers, calculating factorials, and converting Celsius to Fahrenheit. Each task includes a detailed algorithm and corresponding assembly code with comments explaining the purpose of each instruction. The document serves as a guide for students to implement these tasks in a microprocessor lab setting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

BECE204P-Microprocessors & Microcontrollers

Lab
LAB-2
SUM & AVERAGE OF “N” 8-BIT
NUMBERS, FACTORIAL, CELSIUS TO
FAHRENHEIT
INSTRUCTION REQUIRED

OPCOD
E OPERAND EXPLANATION EXAMPLE

ADC D, S D = D + S + CF ADD AX, BX

INC D D=D+1 INC AX

DEC D D=D-1 DEC [0500H]

JNZ Address Jump if not zero JNZ 1020

Compare D with S (S-D). Doesn’t


store result but it affect ONLY flag
CMPCF standsD,
Here forSCarry Flag, D stands for
register CMP
destination and S stands for AX, BX
source.
D and S can either be register, data or memory address.
LAB -3 BECE204P - MP & MC LAB 1
LAB TASK-1
SUM OF “N” NUMBERS
 Write 8086 Assembly language program to perform sum of “N” 8-bit numbers stored
in array of memory locations

Algorithm:
1. Initialize SI with memory location 0500H as a starting a address to hold the value of the
count “N” and store array of numbers to be added in the consecutive memory locations
2. Initialize DI with 0600H as a starting a address to hold the result of sum of “N” numbers
3. Initialize AX register 0000H to eliminate error in the result by adding previous value of AX
4. Assign CL register with the value of the count “N” by loading it from 0500h memory
location using SI
5. Increment the content of SI to point the first element of the array
6. Perform addition on the value of AL and first element of the array (Result will be stored
again in AL)
7. Perform addition of AH+00+C bit to hold result when Lower byte addition resulted any
carry
8. Increment the content of SI to point the next element of the array
9. Decrement CL value by 1 and check whether count is reached 0
10. If not zero, repeat steps 6 to 9
11. Otherwise store the final result of sum of all numbers in the array held by AX into the
LAB -3 BECE204P - MP & MC LAB 1
LAB TASK-1
SUM OF “N” NUMBERS

ADDRES MEMONICS COMMENTS


S Input:
ADDRESS
1000 MOV SI, 0500H Load 0500H into Source Index Register
VALUE
MOV DI, 0600H Load 0600H into Destination Index Register 0500H 05H
MOV AX, 0000 Clear AX register 0501H 04H
0502H 02H
MOV CL, [SI] Load the block size (Value of N) 0503H 09H
INC SI Increment SI to point next memory location 0504H 01H
BACK: ADD AL, [SI] Add AL and data pointed by SI register 0505H 05H

ADC AH, 00 Add AH and 00H along with Carry


Output:
INC SI Increment SI to point next memory location
ADDRESS
DEC CL Decrement CL value by 1 VALUE
JNZ BACK If Z=0, jump to BACK label 0600H 15H
0601H 00H
MOV [DI], AX Store the result of the division into memory location
pointed by DI
HLT Stop the execution
LAB -3 BECE204P - MP & MC LAB 1
LAB TASK-2
AVERAGE OF “N” NUMBERS
 Write 8086 Assembly language program to perform sum of “N” 8-bit numbers stored
in array of memory locations
Algorithm:
1. Initialize SI with memory location 0500H as a starting a address to hold the value of the
count “N” and store array of numbers to be added in the consecutive memory locations
2. Initialize DI with 0600H as a starting a address to hold the result of sum of “N” numbers
3. Initialize AX register 0000H to eliminate error in the result by adding previous value of AX
4. Assign CL register with the value of the count “N” by loading it from 0500h memory
location using SI
5. Also copy the count “N” value into BL register to act as devisor in the division operation
6. Increment the content of SI to point the first element of the array
7. Perform addition on the value of AL and first element of the array (Result will be stored
again in AL)
8. Perform addition of AH+00+C bit to hold result when Lower byte addition resulted any
carry
9. Increment the content of SI to point the next element of the array
10. Decrement CL value by 1 and check whether count is reached 0
11. If not zero, repeat steps 6 to 9
12. Otherwise perform division operation on the final result of sum of all numbers in the array
LAB -3 held by AX by BL register count BECE204P - MP & MC LAB 1
LAB TASK-2
AVERAGE OF “N” NUMBERS
ADDRESS MEMONICS COMMENTS
1000 MOV SI, 0500H Load 0500H into Source Index Register Input:
MOV DI, 0600H Load 0600H into Destination Index Register ADDRESS
VALUE
MOV AX, 0000H Clear AX register 0500H 05H
MOV CL, [SI] Load the block size (Value of N) 0501H 04H
MOV BL, CL Also store N into BL 0502H 02H
0503H 09H
INC SI Increment SI to point next memory location 0504H 01H
BACK ADD AL, [SI] Add AL and data pointed by SI register 0505H 05H
ADC AH, 00H Add AH and 00H along with Carry
INC SI Increment SI to point next memory location Output:
ADDRESS
DEC CL Decrement CL value by 1 VALUE
JNZ BACK If Z=0, jump to BACK label 0600H 04H
DIV BL Store the result of the division into memory location (Q)
pointed by DI 0601H 01H (R)

MOV [DI], AX Otherwise divide it with BL


HLT Stop the execution
LAB -3 BECE204P - MP & MC LAB 1
LAB TASK-3
FACTORIAL
 Write 8086 Assembly language program to calculate factorial of given number

Algorithm:
1. Input the Number whose factorial is to be find and Store that Number in CX
Register
2. Insert 0001 in AX(Condition for MUL Instruction) and copy AX to BX register
3. Increment BX by 1
4. Multiply AX and BX (Results stored in AX)
5. Repeat step 3 and 4 until BX repeated for CX number using CMP and JNZ
instructions
6. Use CMP and JNZ instruction to CX with AX until CX become Zero(0) using LOOP
Instruction
LAB -3 7. Copy the final content of AXBECE204P
to memory location
- MP & MC LAB 4000H 1
LAB TASK-3
FACTORIAL

ADDRE MEMONICS COMMENTS


SS
1000 MOV CX, 04H Load Number whose factorial is to be find Input:
in CX CX =04H

MOV AX, 0001H Load AX with 0001H


Output:
MOV BX,AX COPY AX into BX ADDRESS
BACK: INC BX Increment BX value by 1 VALUE
4000H 18H
MUL BX Multiply AX*BX = DX:AX 4001H 00H
CMP BX,CX Compare BX with CX i.e BX-CX
JNZ BACK If Z is not Zero, jump to BACK label
MOV [4000H], AX Store AX register content to memory
location 4000H
LAB -3 BECE204P - MP & MC LAB 1
LAB TASK-4
CONVERT CELSIUS TO FAHRENHEIT (Exercise)
 Write 8086 Assembly language program to Convert the given temperature in Celsius
(C) scale to Fahrenheit (F) scale. Assume the value of temperature in Celsius as 25°C
(19H).
F = (9C/5)+32
Algorithm:
1. Input the Celsius (C) value in CL Register
2. Store AL with constant value 09H
3. Perform 09 * C using MUL instruction
4. Store DL with constant value 05H
5. Perform (09 * C)/5 using DIV instruction
6. Add 20H (32) with the Quotient result from previous operation
7. Copy the final content of AL to memory location 2000H
8. Stop Execution
LAB -3 BECE204P - MP & MC LAB 1
LAB TASK-4
CONVERT CELSIUS TO FAHRENHEIT (Exercise)

ADDRES MEMONICS COMMENTS


S
1000 MOV CL, 19H Load 25°C (19H) Celsius value into CL register
Input:
MOV AL, 09H Load AL with 09H
CL =19H
MUL CL Multiply AL with 25°C Celsius value and store the
result in AX
Output:
MOV DL, 05H Move 05H to DL register ADDRESS
VALUE
DIV DL Divide AX by DL. Quotient in AL and Reminder in
2000H 4DH
AH.
ADD AL, 20H Add 32 (20H) along with AL (Quotient)
MOV [2000H], Store the final result available in AL into memory
AL location 2000H
HLT Stop the execution
LAB -3 BECE204P - MP & MC LAB 1

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