DSPRelated.com
Forums

40 bit subtraction in 16 bit processor.

Started by mahtab alam May 20, 2005
hi every one,
I am a design engineer and doing voice compression in ADSP 218x series.This is basically a 16 bit processor. Actually i am porting C-code in Assembly and I am using its IDE ( Analog Devices Visual DSP ++).
Now i am facing a problem in handling 40 bit arithmatic. complete description of my quary is below.

" A 40 bit variable ' L40_sum ' , this variable is declered DOUBLE in C, is subtracted from a 32 bit variable ' MAX_32 ' the problem i am facing is when i subtract last ( msb ) 8 bits of the following instruction .

if (L40_sum < = MAX_32). MAX_32 = 0x7fff ffff.

this instruction always remains true the reason is ' L40_sum ' is actually with in 32 bit range most of the times and its MSB 8 bits are zeros so when these subtracted from MAX_32.
( ax0 - 0 + c -1 ) where ax0 is a register, its result always becomes -ve (0xffff) and i am taking decision on MSB bits.

If some one have any idea how it can tackle so do reply me. Or if any one did 40 bit subtraction in assembly do reply me. Espacially waiting positive reply from Analog Devices.

thanks. regards.
mahtab alam.
Design Engineer.



On Fri, 20 May 2005, mahtab alam wrote:

> hi every one,
> I am a design engineer and doing voice compression in ADSP 218x series.This is basically a 16 bit processor. Actually i am porting C-code in Assembly and I am using its IDE ( Analog Devices Visual DSP ++).
> Now i am facing a problem in handling 40 bit arithmatic. complete description of my quary is below.
>
> " A 40 bit variable ' L40_sum ' , this variable is declered DOUBLE in C, is subtracted from a 32 bit variable ' MAX_32 ' the problem i am facing is when i subtract last ( msb ) 8 bits of the following instruction .
>
> if (L40_sum < = MAX_32). MAX_32 = 0x7fff ffff.
>
> this instruction always remains true the reason is ' L40_sum ' is actually with in 32 bit range most of the times and its MSB 8 bits are zeros so when these subtracted from MAX_32.
> ( ax0 - 0 + c -1 ) where ax0 is a register, its result always becomes -ve (0xffff) and i am taking decision on MSB bits.
>
> If some one have any idea how it can tackle so do reply me. Or if any one did 40 bit subtraction in assembly do reply me. Espacially waiting positive reply from Analog Devices.

Howdy Mahtab,

This is confusing to me. If you have a 16 bit processor, a 32 bit
variable and a 40 bit variable (which is a float??) how can you possibly
compare them with one instruction?
check the upper 8 bits first to see if they are zero or 0xff. If not,
then you have an overflow and can set the sum to max (positive or
negative). No reason to check all the other bits.

Patience, persistence, truth,
Dr. mike