Assembly language program to find maximum and minimum number in the array

Can a large array be stored in memory?

If the array is very large and memory is limited
Storing the entire array in memory may not be feasible
Which could require a more complex solution such as :
Sorting the array in smaller parts. Rearrange an array in order - smallest

  1. Largest
  2. 2nd smallest
  3. 2nd largest
.. A Computer Science portal for geeks.

How do I get a maximum value from an array?

Have your function store and return the maximum in al. Use ah to fetch values from the array
And zero it at the end. As a bonus
Ax could also be considered the return value. (If the array is intended to hold signed data
Then use cbw to sign extend al into ax instead of zeroing ah .)

How do I traverse an array if an element is bigger than DL?

Similarly each time I find an element that is bigger than the current maximum in DL
I set that element as the new current maximum. You can traverse the array going from first to last element or from last to first element. I chose the latter because it saves me from writing an extra cmp instruction.

Signed Comparison

Does your array of values represent unsigned bytes, or signed bytes? If your array contains 0FFh, is that the largest possible value, or one smaller than zero? If the data is supposed to be signed, you're good. If it was supposed to be unsigned bytes, you again should change the jle to jbe.

Signed Length

If n happens to be between 128 and 255, the jge will treat the comparison as if it was a signed comparison, and since 0 is not greater than or equal to any value between -128 and -1, inclusive, immediately jump to the end, again leaving chas an undefined value. You should use jae instead, so you can have up to 255 values in array.

Undefined Behaviour

If you execute this code with n DB 0, it returns without setting chto any value, leaving the result as undefined.

Unnecessary Register Usage

You execute mov cx,0h, but nowhere do you use cl, so are unnecessarily destroying cl. You execute mov ah,[bx+si] and use mov ax,0h to clean-up at the end. Again, nowhere have you used al, so you've unnecessarily destroyed al. If you used cl instead of ah, you wouldn't need to destroy axat all. Use of siappears unnecessary. Instead of based-index ad.

What is a n array?

It is a common operation used in many algorithms and applications
Such as :
Finding the maximum value in a data set or determining the winner of a game. It is a fast operation that can be completed in O (n) time complexityWhere n is the number of elements in the array.

How do I get a maximum value from an array?

Have your function store and return the maximum in al. Use ah to fetch values from the array, and zero it at the end. As a bonus, ax could also be considered the return value. (If the array is intended to hold signed data, then use cbw to sign extend al into ax instead of zeroing ah .)

How do I traverse an array if an element is bigger than DL?

Similarly each time I find an element that is bigger than the current maximum in DL, I set that element as the new current maximum. You can traverse the array going from first to last element or from last to first element. I chose the latter because it saves me from writing an extra cmp instruction.

\nIn computer software and hardware

find first set (ffs) or find first one is a bit operation that

Given an unsigned machine word

Designates the index or position of the least significant bit set to one in the word counting from the least significant bit position.A nearly equivalent operation is count trailing zeros (ctz) or number of trailing zeros (ntz)

Which counts the number of zero bits following the least significant one bit.The complementary operation that finds the index or position of the most significant set bit is log base 2

So called because it computes the binary logarithm texhtml >⌊log2(x)⌋.This is closely related to count leading zeros (clz) or number of leading zeros (nlz)

Which counts the number of zero bits preceding the most significant one bit.\nThere are two common variants of find first set

The POSIX definition which starts indexing of bits at 1

Herein labelled ffs

And the variant which starts indexing of bits at zero

Which is equivalent to ctz and so will be called by that name.


Categories

Nasa assembly programming language
Name the assembly programming language
Assembly language program for palindrome
Raspberry pi assembly language programming pdf
Raspberry pi assembly language programming arm processor coding
The art of assembly language programming by randall hyde
Is assembly language and machine language the same
Assembly language tasm program
Assembly language program to take input from user
Assembly language program for multiplication table in 8086
Assembleur 8086
Assembly language course
Assembler language programming for ibm z system
Assembly language programming and organization of ibm pc
Assembly language programming and organization of the ibm pc pdf free download
Assembly language programming and organization of the ibm pc pdf download
Assembly language programming and organization of the ibm pc by ytha yu
Assembly language programming and organization of the ibm pc by charles marut
8086 assembly language programming code for beginners
Assembly language book