🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.lang.asm
Article #150

Re: looking for fast min()/max()

#150
From: Mark
Date: Wed, 06 Jan 1993 07:20
34 lines
1069 bytes
In article <1993Jan4.094755.9593@odin.diku.dk> terra@diku.dk (Morten Welinder) writes:
>; ax := unsigned-min(ax,dx)
>;
>	sub	ax,dx
>	sbb	cx,cx
>	and	ax,cx
>	add	ax,dx
>----------------------------------------------------------------------
>; ax := unsigned-max(ax,dx)
>;
>	sub	dx,ax
>	add	ax,dx
>	sbb	cx,cx
>	and	cx,dx
>	sub	ax,cx

Try this one:

AX, DX = max(AX, DX), min(AX, DX)

For unsigned integers:
sub AX, DX
sbb CX, CX
and CX, AX
add AX, DX
sub AX, CX
add DX, CX

For signed integers:
xor AH, 80h
xor DH, 80h
<The unsigned routine above>
xor AH, 80h
xor DH, 80h
Technical Details
Message-ID: <1ie172INN39r@uwm.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!uwm.edu!csd4.csd.uwm.edu!markh
References: <1992Dec30.152808.25311@netcom.com> <1993Jan4.094755.9593@odin.diku.dk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!uwm.edu!csd4.csd.uwm.edu!markh
From: markh@csd4.csd.uwm.edu (Mark)
Newsgroups: alt.lang.asm
Subject: Re: looking for fast min()/max()
Date: 6 Jan 1993 07:20:02 GMT
Organization: Computing Services Division, University of Wisconsin - Milwaukee
Lines: 34
Message-ID: <1ie172INN39r@uwm.edu>
References: <1992Dec30.152808.25311@netcom.com> <1993Jan4.094755.9593@odin.diku.dk>
NNTP-Posting-Host: 129.89.7.4
Keywords: speed min max