Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!batcomputer!cornell!uw-beaver!uw-entropy!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c Subject: Re: iAPX86 code for ABS (using Microsoft C?) Message-ID: <2083@dataio.Data-IO.COM> Date: 2 Aug 89 18:05:06 GMT References: <1202@draken.nada.kth.se> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 22 In article <1202@draken.nada.kth.se> d88-eli@nada.kth.se (Erik Liljencrantz) writes: >The function to convert an integer >to a positive integer was performed without a conditional jump (i.e. JS or >something). I'm very interested in this piece of code, This is a well-known trick: ;;;;;;;;;;;;;;;;;;;;;;;;; ; Take absolute value of integer. c_public abs func abs push BP mov BP,SP mov AX,P[BP] cwd xor AX,DX ;look, ma, no jumps! sub AX,DX pop BP ret c_endp abs