This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

c2000 pass c variable to inline assembly

Other Parts Discussed in Thread: TMS320F28335

Hello, i have found a jump function on these forums that i have implemented on a TMS320F28335 for a bootloader project and all works fine

 void AsmJump (Uint32 address){


      __asm(" SETC INTM\n"
            " ZAPA\n"
            " MOV @SP,#0\n"
            " PUSH ACC\n"
            " PUSH AL\n"
            " MOV AL, #0x0a08\n"
            " PUSH AL\n"
            " MOVL XAR7, #0x330000\n"           //jump to 0x330000 in flash memory
            " PUSH XAR7\n"
            " POP RPC\n"
            " POP ST1\n"
            " POP ST0\n"
            " POP IER\n"
            " POP DBGIER\n"
            " LRETR\n");
}

however where the address is hard coded i would like to be able to call the function with an address parameter and pass this into the inline assembly and get the same results. I have found that the C variable cannot be directly referenced. How else can i do this?

Thanks

Michael

  • Rather than writing inline assembly, which could potentially disrupt the C environment and produce unexpected results, especially when using optimization, a better practice would be to implement the entire function in assembly code, and call the assembly function from the C code. Details on interfacing C and assembly can be found in the C2000 Compiler Users Guide, section 7.4.