The ArrayGetMinimum function
The ArrayGetMinimum function finds the minimum value in a given array of numbers.
Parameters: AX: pointer to the array; BX: array length.
Return value: AX: minimum value in the array.
Flag state: The function does not modify the flags.
Program source code
An example program for the Intel 8086 assembler demonstrating the use of the ArrayGetMinimum function to find the minimum value in an array.
title .model small .stack 100h data segment public array dw 4, 7, 3, 67, 5, 22, 5, 66, 8, 5 arrlen equ ($-array) / 2 fmtout db "Minimum number in the array: %d\0" data ends code segment public ; Start of the code segment assume ds:data, cs:code include Handyfar.inc ; Include the file with functions main proc ; Start of the main procedure call SetDataSegment ; Call the SetDataSegment procedure mov bx, arrlen ; Copy the array length into the bx register lea ax, ds:[array] ; Load the address of the variable array into the ds:ax register call ArrayGetMinimum ; Call the ArrayGetMinimum procedure (ds:ax, bx) := AX push ax ; 2nd: save the ax register value on the stack lea ax, ds:[fmtout] ; 1st: Load the address of the fmtout format string into the ds:ax register call PrintFormatString ; Call the PrintFormatString procedure (ax:fmtout, ax) add sp, 2 ; Align the stack xor al, al ; Clear the al register call ExitProcess ; Call the ExitProcess procedure main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Minimum number in the array: 3
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".