This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Cortex-M4 DSP operations with nRF52

The ARM Cortex-M4 supports many assembly-level DSP instructions and we would like to use them (not just the packaged ones in the CMSIS DSP libraries).

For example the set of signed multiply-accumulate halfword operations (SMLABB, for example) is very useful.  

How can we use these valuable M4 assembly instructions, which require several qualifiers (references to variables in the C program)?  Is there a good example of inline C for the nRF52?

Thanks,

Jackson  

Parents
  • Are you asking how to write inline assembly?  Or are you looking for pre-written wrappers for those instructions, like a library?  If the former, it's just something like:

    int32_t signed_mult_accum( int16_t m, int16_t n, int32_t a )
    {
        int32_t ret;
        __asm__( "SMLABB %%r0, %%r2, %%r1, %%r10;"
                    : "=r" (ret)
                    : "m" (m), "n" (n), "a" (a) );
        return ret;
    }

    or something very much like it.  Then just repeat for the other instructions you want.  There aren't really that many of them to do.

    (Warning: I'm not an assembly developer and I didn't test that, I'm on a phone. This is from what I remember of assembly.)

    **EDIT** And actually, here is a not too bad-looking tutorial: www.codeproject.com/.../Using-Inline-Assembly-in-C-C

Reply
  • Are you asking how to write inline assembly?  Or are you looking for pre-written wrappers for those instructions, like a library?  If the former, it's just something like:

    int32_t signed_mult_accum( int16_t m, int16_t n, int32_t a )
    {
        int32_t ret;
        __asm__( "SMLABB %%r0, %%r2, %%r1, %%r10;"
                    : "=r" (ret)
                    : "m" (m), "n" (n), "a" (a) );
        return ret;
    }

    or something very much like it.  Then just repeat for the other instructions you want.  There aren't really that many of them to do.

    (Warning: I'm not an assembly developer and I didn't test that, I'm on a phone. This is from what I remember of assembly.)

    **EDIT** And actually, here is a not too bad-looking tutorial: www.codeproject.com/.../Using-Inline-Assembly-in-C-C

Children
Related