C85 Exp5 MP
C85 Exp5 MP
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.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)
.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
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
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
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)
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.
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)
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)
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
num db ?
fact dw 1
.code
main proc
mov ds, ax
int 21h
int 21h
mov num, al
; calculate factorial
mov ax, 1
PART B
calculate_fact:
mul cx
loop calculate_fact
mov fact, ax
; display result
int 21h
call display_number
; exit program
int 21h
main endp
display_number proc
; display number in ax
mov dx, ax
int 21h
ret
display_number endp
end main