MIN AX, loc16
6-153
MIN AX, loc16 Find the Minimum
SYNTAX OPTIONS OPCODE OBJMODE RPT CYC
MIN AX, loc16 0101 0110 0111 010A
0000 0000 LLLL LLLL
1 Y N+1
Operands AX Accumulator high (AH) or accumulator low (AL) register
loc16 Addressing modes (see Chapter 5)
Description Compare the signed content of the specified AX register (AH or AL) with the
content of the signed location pointed to by the “loc16” addressing mode and
load the AX register with the smaller of these two values:
if(AX > [loc16]), AX = [loc16];
if(AX <= [loc16]), AX = unchanged;
Flags and
Modes
N If AX is less then the contents of the addressed location (AX < [loc16]) then
the negative flag bit will be set; otherwise, it will be cleared.
Z If AX and the contents of the addressed location are equal (AX = [loc16]) then
the zero flag bit will be set; otherwise, it will be cleared.
V If AX is greater then the contents of the addressed location (AX > [loc16])
then the overflow flag bit will be set. This instruction cannot clear the V flag.
Repeat If the operation is follows a RPT instruction, the instruction will be executed
N+1 times. The state of the N, Z and V flags will reflect the final result.
Example
; Saturate VarA as follows:
; if(VarA > 2000) VarA = 2000;
; if(VarA < −2000) VarA = −2000;
MOV AL,@VarA ; Load AL with contents of VarA
MOV @AH,#2000 ; Load AH with the value 2000
MIN AL,@AH ; if(AL > AH) AL = AH
NEG AH ; AH = −2000
MAX AL,@AH ; if(AL < AH) AL = AH
MOV @VarA,AL ; Store result into VarA