Technical discussions related to Analog Devices DSPs (including Blackfin, TigerSHARC, SHARC and ADSP-21xx DSPs).
|
Hi, For the first time, I am trying to write C-programs for the ADSP-218x, but it seems that the C-compiler wants to do all math in integer mode. As result of any multiplication z = x*y it uses MR0 as result instead of MR1. How do I get around this? Can I declare a 32-bit variable for the result (MR), or is it not possible to use fractional math mode with the C-compiler? Thanks, Jesper |
|
|
|
Hi!, Jesper Bennedbæk Kristensen wrote: > For the first time, I am trying to write C-programs for the ADSP-218x, but > it seems that the C-compiler wants to do all math in integer mode. As result > of any multiplication z = x*y it uses MR0 as result instead of MR1. How do I > get around this? Can I declare a 32-bit variable for the result (MR), or is > it not possible to use fractional math mode with the C-compiler? Yes, AFAIK the C environment hides all such DSP relative things from you, so (among others) you can't use fractional mode in C programs. It uses either integer or (software emulated) floating point math for integer and floating point data types, respectively. L. |
|
If you are using VisualDSP++ 2.0 for the 218x, you'll see in the file fract.h a couple of macros to do fractional multiplications. Using those as a guide you should use those to write your own c-callable function (in asm) to perform the fractional multiplications. Unfortunately the macros supplied don't perform well when code optimization is turned on when you compile. Hope this helps... Jesper Bennedbæk Kristensen <> on 03/21/2002 01:01:55 To: cc: (bcc: Chuck Petras/SEL) Subject: [adsp] ADSP-218x C programming examples |
|
Hi, For the first time, I am trying to write C-programs for the ADSP-218x, but it seems that the C-compiler wants to do all math in integer mode. As result of any multiplication z = x*y it uses MR0 as result instead of MR1. How do I get around this? Can I declare a 32-bit variable for the result (MR), or is it not possible to use fractional math mode with the C-compiler? Thanks, Jesper _____________________________________ /groups.php3 This e-mail may contain SEL confidential information. The opinions expressed are not necessarily those of SEL. Any unauthorized disclosure, distribution or other use is prohibited. If you received this e-mail in error, please notify the sender, permanently delete it, and destroy any printout. Thank you. |