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

Place assembly within C Code

Hi
I searched all over the keil software but never found how to access the assembly code of my project. The help itself tells that you can use #pragma SRC to instruct compiler to create an SRC file that contains all assembly codes of your project. This looks so intresting, But obviously, It seems that Keil won't let us know about translating C code to assembly!
Anyhow, I searched all over the help, But did not find any way to place assembly code into my C function. I used to place a #asm instruction anywere in my functions in Codevision, but it doesn't work in keil.
So any idea to mix assembly with C in keil Real View 3.0?

  • I searched all over the keil software but never found how to access the assembly code of my project. The help itself tells that you can use #pragma SRC to instruct compiler to create an SRC file that contains all assembly codes of your project. This looks so intresting, But obviously, It seems that Keil won't let us know about translating C code to assembly!

    There is no conspiracy to try and hide assembly code from you. I find that the easiest way to inspect the generated code is to load the binary image into the simulator and use the debugger's disassembler. You can also instruct the compiler to generate output in assembly for you:
    www.keil.com/.../armccref_cihbebei.htm
    As for pragma ASM, it's not supported by the RealView compiler. I know that this pragma exists in Keil's C166 compiler and maybe in other compilers too. But Keil MDK for ARM ships with the RealView compilation tools written by ARM, so perhaps you were looking for information in the wrong place.

    Anyhow, I searched all over the help, But did not find any way to place assembly code into my C function. I used to place a #asm instruction anywere in my functions in Codevision, but it doesn't work in keil.
    So any idea to mix assembly with C in keil Real View 3.0?

    See here:
    http://www.keil.com/support/man/docs/armcc/armcc_cihffbgf.htm
    Basically, there are the inline and embedded assemblers. They are substantially different. Be careful when using the embedded assembler: it might not behave the way you would expect. Read the manual for details.

  • If using the IDE, why not just turn on the list files?

  • I think that the OP was looking for assembler listings, rather than
    using assembler with C code.

    > Basically, there are the inline and embedded assemblers. They are
    > substantially different. Be careful when using the embedded
    > assembler: it might not behave the way you would expect. Read the
    > manual for details.

    Actually, it is the inline assembler that might not behave as expected
    -- depends on what you expect, of course :-) Inline assembler is
    applied before instruction level optimization. The code you end
    up with might look very different from what you originally wrote.

    Inline assembler works only for ARM code (as opposed to Thumb). With
    newer cores providing only Thumb-2 (Cortex-M0/1/3/?), this would leave
    us with embedded assembler only. Inline assembler has been deprecated
    for ARM architectures v7 and later.

    infocenter.arm.com/.../armcc_bcfjdiaa.htm

    Regards
    Marcus
    http://www.doulos.com/arm/