GetMaximumEx function
The GetMaximumEx function returns the maximum 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 maximum number.
Flag state: The function does not modify the flags.
Program source code
Intel 8086 assembly program example demonstrating the use of the GetMaximumEx function to find the maximum of two numbers passed through the stack.
title .286C .model small .stack 100h data segment public fmtout db "The maximum 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 GetMaximumEx ; Call the GetMaximumEx(15, 13) procedure := AX push ax ; 4th: Push the return value of GetMaximumEx 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 maximum value between 15 and 13 = 15.
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".