Re: Saturation
- From: "Wolfgang Kern" <nowhere@xxxxxxxx>
- Date: Mon, 23 Feb 2009 18:27:29 +0100
Tim Frink wrote:
My DSP has this instruction:
sat_abs DATAREG_A, DATAREG_B, DATAREG_C
(with DATAREG_X beeing 32bit data registers).
The manual says to this instruction:
Compute the absolute value between DATAREG_B and DATAREG_C
and store the result in DATAREG_A. The registers are treated as
signed, 32-bit integers, and saturation is performed on signed
overflow. What I don't understand is why saturation makes
sense here since in my option an overflow can never happen.
Or am I wrong?
how can an ABSolute value be signed ?
OK, if the result must fit into 31 bits then it can overflow:
b= 7fff_ffff 2^31 -1 2147483647
c= 8000_0000 -2^31 -2147483648
b-c= ffff_ffff +4294967295
is true even carryover truncated and unsigned yet
or is it - 1 ?
if abs(a)=abs(b)-abs(c) shoudn't it be +1 then ?
NEG (2's complement) of 8000_0000h wont work without using more
than 32 bits. But NEG of ffff_ffffh will produce a +1.
mov eax,ebx
sub eax,ecx
jns done ;if difference is positive
neg eax
done:
__
wolfgang
.
- Follow-Ups:
- Re: Saturation
- From: Phil Carmody
- Re: Saturation
- References:
- Saturation
- From: Tim Frink
- Saturation
- Prev by Date: Re: move this Forum somewhere else?
- Next by Date: Re: Saturation
- Previous by thread: Re: Saturation
- Next by thread: Re: Saturation
- Index(es):
Relevant Pages
|