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.

How to write the ASM code in the C code function with the parameter transportation?

Other Parts Discussed in Thread: AM1808

Hi all,

How to write the ASM code in the C code function with the parameter transportation? for example, with the gcc,you can write you code as following

static inline void mmu_set_trans_tbl(uint32_t val)
{
    asm volatile ("mcr 15, 0, %0, cr2, cr0, 0\n" : :"r" (val));
}

static inline uint32_t mmu_get_domain_ctrl(void)
{
    uint32_t val;
    asm volatile ("msr 15, 0, %0, cr3, cr0\n" : "=r" (val));
    return val;
}

with the CCS , how to do it?

thanks!

  • It has been said said:

    The great thing about C is its portability, and

    The bad thing about C is its non-portability.

    The answer to your question may depend on which TI device you are using. Since your function names and assembly mnemonics are unfamiliar to me, they may be from a CPU that I do not know well. Someone else may, so please reply back with more information such as TI Device number, compiler tools version, and even your CCS version in case it might be helpful.

    Regards,
    RandyP

  • hi Randyp,

    thank you for youre reply.

    my device number is AM1808 ,the compiler is TMS470 compiler ,my CCS version is 4.1.2.00027.

     

  • Please search for "Intrinsics" in your TI TMS470 C Compiler User's Guide.

    These provide the mechanism to pass C-based parameters to assembly instructions that may not be routinely used in the compiler's output.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • i search for "Intrinsics" in TI TMS470 C Compiler User's Guide, i can not find any useful information for me. i just want to know how use the operator from c code and return the register value  to c code when i embeded the assembly code in C code.

    thanks.

  • The Compiler User's Guide has a lot of useful information for you. If the intrinsics do not meet your needs, then please continue looking for other features of the tools that will work. There are table showing GCC extensions that are supported and those that are not supported, there are a variety of compiler switches that control compiler compatibility conditions. There are examples of the asm() operator and how it is used, but it does not appear to be what you seek.

    The clear option, in my opinion, would be to write a simple assembly function that you can call from C to implement what you want. You can name that function with a meaningful name to help self-document the code. You could call that function with standard C expressions and get the exact result that you want. This assumes that I understand what you want.

    The Compiler User's Guide has a section that describes how to interface C with Assembly, if you choose to do this.

    Does any of this help?

    Regards,
    RandyP