0% found this document useful (0 votes)
17 views8 pages

C85 Exp5 MP

The document outlines an assembly programming experiment aimed at finding the minimum and maximum numbers from a given array using BIOS/DOS interrupts. It includes prerequisites, expected outcomes, a detailed algorithm, and a sample code implementation for the Intel 8086 processor. Additionally, it discusses observations, conclusions, and provides examples of various jump instructions in assembly language.

Uploaded by

YOU NEED TO ALL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views8 pages

C85 Exp5 MP

The document outlines an assembly programming experiment aimed at finding the minimum and maximum numbers from a given array using BIOS/DOS interrupts. It includes prerequisites, expected outcomes, a detailed algorithm, and a sample code implementation for the Intel 8086 processor. Additionally, it discusses observations, conclusions, and provides examples of various jump instructions in assembly language.

Uploaded by

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

PART A

(PART A : TO BE REFFERED BY STUDENTS)


Experiment No.05

A.1 Aim: Write assembly program to find minimum and maximum no. from a given array.
[Use BIOS/DOS interrupts to read input and display results.]

A.2 Prerequisite: Basic knowledge of 8086 instruction set and interrupts

A.3 Outcome:
After successful completion of this experiment students will be able to
1. Use appropriate instructions to program microprocessor to perform various
task.
2. Develop the program in assembly/ mixed language for Intel 8086 processor
3. Demonstrate the execution and debugging of assembly/ mixed language program
A.4 Theory:
Theory: Finding maximum and minimum number from a given array of n numbers or list
elements according to a comparison operator on the elements. The comparison operator helps
in deciding whether the number taken in registers is small or large. In the given diagram
shows the example finding largest number from a given array. A random set of numbers are
given in an array and is stored in memory location from 2000:500 to memory location
2000:504.The largest among the given array is stored in memory location 2000:600.

A.5 Algorithm:
1. Start, Define memory model
2. Initialize data segment.
3. Initialize the code segment
4. set the counter
5. Initialize the array base pointer.
6. Get the numbers on MAX and MIN.
7. Compare the numbers
8. If num in AL> MAX, Max = num in AL & increment pointer.
If num in AL< MIN, Min = num in AL & increment pointer
9. Decrement the counter.
10. If count = 0 stop or else repeat steps 6, 7, 8, 9.
11. Store maximum and minimum number.
12. Stop.
PART B
(PART B : TO BE COMPLETED BY STUDENTS)

(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded at the end of the practical)

Roll. No: C85 Name: Tanmay Pralhad Hirnak


Class: SE-C Batch: C4
Date of Experiment: 17/03/25 Date of Submission: 17/03/25
Grade:

B.1 Software Code written by student:

.model small
.stack 100h

.data
msg1 db 'Enter 5 numbers: $'
msg2 db 'Minimum number: $'
msg3 db 'Maximum number: $'
arr db 5 dup(?)
min db ?
max db ?
newline db 0Ah, 0Dh, '$'

.code
main proc
mov ax, @data
mov ds, ax

lea dx, msg1


mov ah, 09h
int 21h
lea dx, newline
mov ah, 09h
int 21h

mov cx, 5
mov si, offset arr
read_num:
mov ah, 01h
int 21h
sub al, 30h
mov [si], al
inc si
loop read_num

mov al, [arr]


mov min, al
mov max, al
PART B
mov cx, 5
mov si, offset arr
find_min_max:
mov al, [si]
cmp al, min
jge check_max
mov min, al
check_max:
cmp al, max
jle next
mov max, al
next:
inc si
loop find_min_max

lea dx, msg2


mov ah, 09h
int 21h
lea dx, newline
mov ah, 09h
int 21h
mov dl, min
add dl, 30h
mov ah, 02h
int 21h
lea dx, newline
mov ah, 09h
int 21h

lea dx, msg3


mov ah, 09h
int 21h
lea dx, newline
mov ah, 09h
int 21h
mov dl, max
add dl, 30h
mov ah, 02h
int 21h
lea dx, newline
mov ah, 09h
int 21h

mov ax, 4C00h


int 21h
main endp
end main
PART B
B.2 Input and Output:

B.3 Observations and learning:

Observing the program, it's clear that it demonstrates how to perform operations on an array,
such as reading and storing values, and finding the minimum and maximum values. The
program utilizes various registers, including AX, BX, CX, DX, SI, and DI, to perform
different operations. Additionally, the program employs looping constructs, such as the LOOP
instruction, to iterate through the array, and conditional statements, like JGE and JLE, to
compare values and make decisions.

From a learning perspective, this program provides valuable insights into array indexing,
register management, looping and conditional statements, and input/output operations. The
program demonstrates how to use array indexing to access and manipulate elements in an
array, and how to manage registers effectively to perform different operations. Furthermore,
the program shows how to use looping constructs and conditional statements to perform
repetitive tasks and make decisions. Finally, the program illustrates how to use BIOS
interrupts to perform input/output operations, such as reading from the keyboard and
displaying output on the screen.

Overall, this program offers several key takeaways, including understanding array operations,
effective register management, and the use of looping constructs and conditional statements.

B.4 Conclusion:
In conclusion, the assembly language program demonstrated how to find the minimum and
maximum numbers in an array. The program utilized array operations, register management,
looping constructs, and conditional statements to achieve this task. By employing BIOS
interrupts, the program also performed input/output operations, such as reading from the
keyboard and displaying output on the screen. This program serves as a valuable example of
assembly language programming concepts and techniques, providing a solid foundation for
further learning and exploration.
PART B
B.5 Question of Curiosity

Q1. List out and explain any 5 different type of JMP instruction with example

Here are 5 different types of JMP instructions with examples:

1. JMP (Unconditional Jump)

The JMP instruction transfers control to a label or address without any


conditions.

Example:

assembly
MOV AX, 5
JMP LABEL
MOV AX, 10
LABEL:
MOV BX, AX

In this example, the program will jump to the label "LABEL" and execute the
instruction "MOV BX, AX" with AX = 5.

2. JE (Jump if Equal)

The JE instruction transfers control to a label or address if the result of a


comparison is equal.

Example:

assembly
MOV AX, 5
CMP AX, 5
JE LABEL
MOV AX, 10
LABEL:
MOV BX, AX

In this example, the program will jump to the label "LABEL" and execute the
instruction "MOV BX, AX" with AX = 5 because the comparison AX = 5 is
true.

3. JNE (Jump if Not Equal)

The JNE instruction transfers control to a label or address if the result of a


comparison is not equal.

Example:

assembly
MOV AX, 5
CMP AX, 10
PART B
JNE LABEL
MOV AX, 10
LABEL:
MOV BX, AX

In this example, the program will jump to the label "LABEL" and execute the
instruction "MOV BX, AX" with AX = 5 because the comparison AX = 10 is
false.

4. JG (Jump if Greater)

The JG instruction transfers control to a label or address if the result of a


comparison is greater.

Example:

assembly
MOV AX, 10
CMP AX, 5
JG LABEL
MOV AX, 5
LABEL:
MOV BX, AX

In this example, the program will jump to the label "LABEL" and execute the
instruction "MOV BX, AX" with AX = 10 because the comparison AX > 5 is
true.

5. JL (Jump if Less)

The JL instruction transfers control to a label or address if the result of a


comparison is less.

Example:

assembly
MOV AX, 5
CMP AX, 10
JL LABEL
MOV AX, 10
LABEL:
MOV BX, AX

In this example, the program will jump to the label "LABEL" and execute the
instruction "MOV BX, AX" with AX = 5 because the comparison AX < 10 is
true.
PART B
Q2. Write an assembly language program to find factorial of a number

.model small

.stack 100h

.data

msg1 db 'Enter a number: $'

msg2 db 'Factorial: $'

num db ?

fact dw 1

.code

main proc

mov ax, @data

mov ds, ax

; display message to enter number

lea dx, msg1

mov ah, 09h

int 21h

; read number from user

mov ah, 01h

int 21h

sub al, 30h

mov num, al

; calculate factorial

mov cx, num

mov ax, 1
PART B
calculate_fact:

mul cx

loop calculate_fact

; store result in fact variable

mov fact, ax

; display result

lea dx, msg2

mov ah, 09h

int 21h

mov ax, fact

call display_number

; exit program

mov ax, 4C00h

int 21h

main endp

display_number proc

; display number in ax

add ax, 3030h

mov dx, ax

mov ah, 02h

int 21h

ret

display_number endp

end main

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