The GetMinimum function
The GetMinimum function returns the smallest of the two given values.
Parameters: AX: the first number; BX: the second number.
Return value: DX: the smallest of the two values.
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 GetMinimum function to find the smallest of two numbers.
title .model small .stack 100h data segment public fmtout db "Minimum value between %d and %d = %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, 13 ; Copy the value 13 into the bx register mov ax, 15 ; Copy the value 15 into the ax register call GetMinimum ; Call the GetMinimum procedure (ax, bx) := DX push dx ; 4th: Save the dx register value on the stack push bx ; 3rd: Save the bx register value on the stack 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, bx, dx) add sp, 6 ; 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 value between 15 and 13 = 13.
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".