Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Fixed point support for GCC cross compiler

    Hello everyone,

    I am involved with the porting of GCC for a new arm processor.
    The trouble is that I have to add a feature which is not supported by GCC - Fixed point support.
    You know adding a new support along with porting is going to be tough.

    Someone told me that one can add support in two ways.
    1. Include the support through the compiler (change the internals).
    2. Outside the compiler, through a library. (library support)

    I am not sure which one to pursue.
    The processor has a dedicated hardware support for fixed point operations.
    Providing the support through a library is a good option when this is so?

    Could anyone tell me which will be the best approach?
    and why it is so?

    or better could anyone give me an example so that I can use it as a reference
    while porting?

    Thanks in advance.

    Mohamed Shafi.

  2. #2
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Maryland, USA
    I use fixed point math on the Atmel AVR processors, but I don't need any support--I just do it all explicitely.

    But if the ARM has hardware support, I would just write macros that take advantage of them and put them in a header file. For example, look at /usr/include/bits/mathinline.h as a random example of a macro using assembly code on Linux. Of course this is floating point stuff, but it illustrates how assembly opcodes can be called inline from C.

    #define isgreater(x, y) \
         ({ register char __result;                                       \
    	__asm__ ("fucomip %%st(1), %%st; seta %%al"                   \
    		 : "=a" (__result) : "u" (y), "t" (x) : "cc", "st");  \
    	__result; })
    Also, /usr/include/bits/string.h has lots of examples unrelated to math.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts