This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to place assembler function in ram

a function could be placed in ram by assigning the
__ram switch.
How to do this for assembler functions?

//*********************************************************************
// 32*32 bit signed/unsigned multiply in ARM Assembler
// Returns 64 bit result in R0,R1
//*********************************************************************
AREA ?C?bla, CODE, READONLY, ALIGN=2

PUBLIC S_MUL32x32?A
S_MUL32x32?A            PROC CODE32

                SMULL   R2,R0,R1,R0                     ; R0,R2 := R1*R0
                mov     R1,R2
                bx      lr
                ENDP

PUBLIC U_MUL32x32?A
U_MUL32x32?A            PROC CODE32

                UMULL   R2,R0,R1,R0                     ; R0,R2 := R1*R0
                mov     R1,R2
                bx      lr
                ENDP

                END
//*********************************************************************

maybe there is a chance in the red line.
i'm not sure i just copied this line from an example-programm...

Parents
  • Your Assembler functions as they exist (as I have seen in previous postings), are fully relocatable.

    You may copy them to as section of RAM and call them by function pointer. I think they would be 12 bytes long each (if the UMULL/SMULL fit in 32 bits)

    u32 UMULL_EXT[3];
    u32 SMULL_EXT[3];

    typedef unsigned long long (*RAM_MULL_CALL)(u32 a, u32 b);

    for (i = 0; i < 3; i++)
    { UMULL_EXT[i] = ((u32 *) &UMULL_32x32)[i]; SMULL_EXT[i] = ((u32 *) &SMULL_32x32)[i];
    }

    to call

    zz = ((RAM_MULL_CALL) &UMULL_EXT)(number1, number2); zz = ((RAM_MULL_CALL) &SMULL_EXT)(number1, number2);

Reply
  • Your Assembler functions as they exist (as I have seen in previous postings), are fully relocatable.

    You may copy them to as section of RAM and call them by function pointer. I think they would be 12 bytes long each (if the UMULL/SMULL fit in 32 bits)

    u32 UMULL_EXT[3];
    u32 SMULL_EXT[3];

    typedef unsigned long long (*RAM_MULL_CALL)(u32 a, u32 b);

    for (i = 0; i < 3; i++)
    { UMULL_EXT[i] = ((u32 *) &UMULL_32x32)[i]; SMULL_EXT[i] = ((u32 *) &SMULL_32x32)[i];
    }

    to call

    zz = ((RAM_MULL_CALL) &UMULL_EXT)(number1, number2); zz = ((RAM_MULL_CALL) &SMULL_EXT)(number1, number2);

Children
No data