Forums

Sign-extension on ADSP SHARC 21469 ??

Started by Mauritz Jameson August 11, 2012
Hi,

I have some 24bit audio data (stored in an unsigned int). I have to
sign extend it to 32 bit.
From what I understand, I just look at bit 23 (counting from bit0)
which is the sign-bit. If it
is 1 then I place 1's in bit23 to bit31. If it is zero then I don't
need to do anything.

Now...is there a fast way of doing that on SHARC ADSP 21469 ? A built-
in function or something?

I haven't been able to find anything in the manuals (maybe I am
overlooking something).

Thanks
"Mauritz Jameson" <mjames2393@gmail.com> wrote in message 
news:2ea9ca25-7c1e-4ce3-92bb-97a49cf6bbae@u7g2000yqj.googlegroups.com...
> Hi, > > I have some 24bit audio data (stored in an unsigned int). I have to > sign extend it to 32 bit. > From what I understand, I just look at bit 23 (counting from bit0) > which is the sign-bit. If it > is 1 then I place 1's in bit23 to bit31. If it is zero then I don't > need to do anything. > > Now...is there a fast way of doing that on SHARC ADSP 21469 ? A built- > in function or something? > I haven't been able to find anything in the manuals (maybe I am > overlooking something).
s32 y = (u32)(s24) x - (s32)0x800000 Duh. Vladimir Vassilevsky DSP and Mixed Signal Consultant www.abvolt.com
"Vladimir Vassilevsky" <nospam@nowhere.com> wrote in message 
news:dpednUa-xrCuDrvNnZ2dnUVZ5r-dnZ2d@giganews.com...
> > "Mauritz Jameson" <mjames2393@gmail.com> wrote in message > news:2ea9ca25-7c1e-4ce3-92bb-97a49cf6bbae@u7g2000yqj.googlegroups.com... >> Hi, >> >> I have some 24bit audio data (stored in an unsigned int). I have to >> sign extend it to 32 bit. >> From what I understand, I just look at bit 23 (counting from bit0) >> which is the sign-bit. If it >> is 1 then I place 1's in bit23 to bit31. If it is zero then I don't >> need to do anything. >> >> Now...is there a fast way of doing that on SHARC ADSP 21469 ? A built- >> in function or something? >> I haven't been able to find anything in the manuals (maybe I am >> overlooking something). > > s32 y = (u32)(s24) x - (s32)0x800000 > > Duh. >
Oops. s32 y = (x ^ 0x800000) - 0x800000 Vladimir Vassilevsky DSP and Mixed Signal Consultant www.abvolt.com
Thanks Vlad :-)
On Sat, 11 Aug 2012 09:32:55 -0700 (PDT), Mauritz Jameson
<mjames2393@gmail.com> wrote:

>Hi, > >I have some 24bit audio data (stored in an unsigned int). I have to >sign extend it to 32 bit. >From what I understand, I just look at bit 23 (counting from bit0) >which is the sign-bit. If it >is 1 then I place 1's in bit23 to bit31. If it is zero then I don't >need to do anything. > >Now...is there a fast way of doing that on SHARC ADSP 21469 ? A built- >in function or something? > >I haven't been able to find anything in the manuals (maybe I am >overlooking something). > >Thanks
See Processor Manual page 11-79 Rn = FEXT Rx BY Ry (SE) Mark DeArman