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

C runtime environment setup by "#pragma asm"

I am checking some terrible C source code; I haven't got any idea about how to maintain it or cooperate with it. But I found a very fundamental problem. It does NOT have a startup.asm; it has a startup.c using the powerful C extension "#pragma". So, the C runtime environment is setup by "#pragma section", "#pragma intvect", "#pragma asm". I quite worry about such a startup.c; so I contacted the FAE of our local distributor. The FAE is an experienced good engineer, but he told me that, this is not their standard way to setup C runtime environment; they definitely provided the startup.s from Day 1.

What will be the side-effect, when the C runtime environment is setup by the C extension "#pragma"?

Parents Reply Children
  • I am not sure if that (inclusion of assembler instructions in a C file) makes a big difference. end of the day, they produce the same result.<i/>

    This is a very generic statement; it can be asserted about programming in C vs. assembly or even almost any other programming language. The bit stream (might) yield the same result, but as mentioned the intricacies of start-up are very different and impose a different discipline.
    Also, generally speaking inline assembly greatly reduces the freedom of the compiler to apply all soft of optimizations. Will you then get the same result? I don't think so.

  • Things can get really nasty when one bypasses the default initialization of the C library, and that creates problems with some hardware start-up timing, because of some rare "living on the edge" condition that suddenly becomes relevant...