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
  • Hi Andrew,

    Many thanks for your help.

    I have already reported this to my supervisor, when I got the response from the FAE.

    My supervisor told me that, this amazing startup.c was provided by our client. Our client purchased a software solution from third party and deliver this solution to us.

    So they definitely knew this, they just didn't understand what this means.

    Based on your help, I read some more articles.

    I suspect that, C runtime environment is being setup/fiddled more than once, or it is never being well setup.

  • Either they didn't understand, or they did understand and were trying to be "clever".

    Both of these are major risks to you / your project / your company - I'm not sure which is worse!

    Do you have the option to go back to the client and/or the original supplier to get an explanation?

  • Do you have the option to go back to the client and/or the original supplier to get an explanation?

    Most likely, I would not have such an option.

    Amazing and fantastic.

  • This is the most fundamental problem, but there are also other critical problems within this project.

    What kind of developer would create such a startup.c solution for C runtime environment setup?