GetMinimumEx function
The GetMinimumEx function returns the minimum of two numbers passed through the stack. The function automatically aligns the stack to 4 bytes.
Parameters (stack): 1. First number. 2. Second number.
Return value: AX - the minimum number.
Flag state: The function does not modify the flags.
Program source code
Intel 8086 assembly program example demonstrating the use of the GetMinimumEx function to find the minimum of two numbers passed through the stack.
title .286C .model small .stack 100h data segment public fmtout db "The minimum value between %d and %d = %d.\0" data ends code segment public assume ds:data, cs:code include Handyfar.inc ; Include the file with functions include Handymac.inc ; Include the file with macros main proc call SetDataSegment ; Call the SetDataSegment procedure push 13 ; 2nd: Push the number 13 onto the top of the stack push 15 ; 1st: Push the number 15 onto the top of the stack call GetMinimumEx ; Call the GetMinimumEx(15, 13) procedure := AX push ax ; 4th: Push the return value of GetMinimumEx onto the top of the stack push 13 ; 3rd: Push the number 13 onto the top of the stack push 15 ; 2nd: Push the number 15 onto the top of the stack leaax ds:[fmtout] ; 1st: Load the address of the fmtout format string into the ds:ax register call PrintFormatString ; Call the PrintFormatString(ax:fmtout, 15, 13, ax) procedure add sp, 6 ; Align the stack push 0 ; Push the byte return code onto the top of the stack call ExitProcessEx ; Call the ExitProcessEx(0) procedure main endp code ends end main
The minimum value between 15 and 13 = 13.
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".