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

About function call

Is there any "naked" attribute function for Keil C?

This is because I would like to have complete control over the push/pop of the registers during function call.
If not, is that necessary for me to write the code in pure Asm? And is that possible to call the C macros inside the ASM?


Thank you~

Parents Reply Children
  • I think the OP is using the term "naked function" to mean the block of code that is the body of the function, minus the call and return sequence, the prolog and epilog.

    C preprocessor macros do not exist as a separate piece of object code. The text is inlined into the source at the point where the macro is used. The compiler then sees that complete text and compiles the code. There is, for example, no single "entry point" for a macro. It's a macro, not a subroutine.

    An assembler could not make use of a C macro, in C syntax, unless it could similarly expand the macro according to the preprocessor rules, and also compile the C syntax.

    If you want to use a macro in assembler, use the assembler syntax for defining a macro. If you want to call a subroutine, you could write in either in C or assembler, but either way, you're going to have a CALL / RET sequence, whether generated by you or the compiler.

  • This is because I would like to have complete control over the push/pop of the registers during function call.
    ..
    I would like the stack for my context switching task.


    The '51 is not a "mini PC", variables do not go on the stack and the chip is singularily not suited for task switching.

    Erik