Message-ID: From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: !!Absolute value with inline ASM!! Date: Tue, 17 Feb 1998 10:26:57 -0000 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk Henri Ossi writes: > I need to get the absolute value of a registers (bx) > > How is this done in asm. > (in one command, not using cmp) I don't know of any such method. I think a test followed by conditional negation is probably the best you can do: that is what gcc produces for the abs() function. > Is there a way to turn off the signed flag somehow or something like > that? The sign of a number isn't just a separate flag. The Intel architecture uses 2's compliment arithmetic, where the highest order bit is given a negative weighting, eg. the bits in a signed byte represent 1, 2, 4, 8, 16, 32, 64, and -128 respectively. There are many advantages to this format, but the negate operation works as a toggle rather than an on/off switch so you will need to know the existing sign before you can get an absolute value. Shawn Hargreaves.