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
  • I don't think this can be a generic question? You must specify the particular toolset!

    In C51, #pragma asm means that the compiler just creates an assembler source file, and this is passed to the Assembler for translation to object.

    There is nothing magic or special about this generated assembler file - it just uses the normal A51 assembler syntax.

    Therefore, in principle, it's possible to write your startup code this way.

    "this is not their standard way to setup C runtime environment"

    Absolutely!

    "What will be the side-effect"

    Key side effec is that, because the 'C' source is all converted to assembler, the rest of the toolchain loses all sight of the 'C' source - it has no idea that 'C' was ever involved.

    This has 2 important results:

    1. The standard 'C' support cannot be automatically provided - you must do it all manually.
    There is plenty of documentation on this in the Knowledgebase; eg,
    http://www.keil.com/support/docs/1646.htm

    2. You lose all 'C' source level debugging capability.

    You are right to be concerned about this - you should flag it as a major risk to your boss/client!

Reply
  • I don't think this can be a generic question? You must specify the particular toolset!

    In C51, #pragma asm means that the compiler just creates an assembler source file, and this is passed to the Assembler for translation to object.

    There is nothing magic or special about this generated assembler file - it just uses the normal A51 assembler syntax.

    Therefore, in principle, it's possible to write your startup code this way.

    "this is not their standard way to setup C runtime environment"

    Absolutely!

    "What will be the side-effect"

    Key side effec is that, because the 'C' source is all converted to assembler, the rest of the toolchain loses all sight of the 'C' source - it has no idea that 'C' was ever involved.

    This has 2 important results:

    1. The standard 'C' support cannot be automatically provided - you must do it all manually.
    There is plenty of documentation on this in the Knowledgebase; eg,
    http://www.keil.com/support/docs/1646.htm

    2. You lose all 'C' source level debugging capability.

    You are right to be concerned about this - you should flag it as a major risk to your boss/client!

Children