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

#pragma ASM/ENDASM inside a #define (???)

Hello,

I'm having trouble using #pragma ASM/ENDASM inside a #define statement. This is what I want to do inside the #define:

- push ACC (assembly)
- push IE (assembly)
- EA = 0 (C)

This is the code I'm *trying* to use:

#define portENTER_CRITICAL() \ 
{ \ 
#pragma ASM \ 
push  ACC \ 
push  IE  \ 
#pragma ENDASM \ 
EA = 0; \ 
}

But I always get an error, no matter what I change... also, it seems that #pragma ASM/ENDASM can't be used inside header files (who knows why...), is there any workaround for that, without repeating the same #defines inside all .c files that uses it?

Best regards,
Carlos.

PS: any one answering this thread, nevermind the "that's a bad practice! use separate asm and c source files! blah blah!..." comments... I really need this, so don't bother with those kind of comments...

Parents
  • "SDCC manuals says _bp is the stack frame pointer and keil doesn't allow compiling of the same"

    Keil doesn't use a "stack frame" in the conventional sense!

    Anyhow, "_bp" is an internal symbol of SDCC - you should never expect any compiler to understand the internal symbols of another compiler!

    "What could be the alternative?"

    I think you're going to have to do this in assembler.

    "Free RTOS for 8051 SDCC ... how to port?"

    First, you're going to need to gain a very thorough, in-depth understanding of how this "Free RTOS" works, and how it relies upon the specific implementation details of SDCC (this, of course, implies an in-depth understanding of the specific implementation details of SDCC itself);
    Next, you're going to need to gain a very thorough, in-depth understanding of Keil's implementation details;
    Then - and only then - you will be in a position to understand how to adapt "Free RTOS for SDCC" to Keil.

    Again, this so-called "free" RTOS may have a zero price tag to obtain, but it certainly has a non-zero cost to implement!

    Would it not be simpler just to use SDCC?

    Or, if you must use Keil, why not use an RTOS supplied & supported by Keil?

Reply
  • "SDCC manuals says _bp is the stack frame pointer and keil doesn't allow compiling of the same"

    Keil doesn't use a "stack frame" in the conventional sense!

    Anyhow, "_bp" is an internal symbol of SDCC - you should never expect any compiler to understand the internal symbols of another compiler!

    "What could be the alternative?"

    I think you're going to have to do this in assembler.

    "Free RTOS for 8051 SDCC ... how to port?"

    First, you're going to need to gain a very thorough, in-depth understanding of how this "Free RTOS" works, and how it relies upon the specific implementation details of SDCC (this, of course, implies an in-depth understanding of the specific implementation details of SDCC itself);
    Next, you're going to need to gain a very thorough, in-depth understanding of Keil's implementation details;
    Then - and only then - you will be in a position to understand how to adapt "Free RTOS for SDCC" to Keil.

    Again, this so-called "free" RTOS may have a zero price tag to obtain, but it certainly has a non-zero cost to implement!

    Would it not be simpler just to use SDCC?

    Or, if you must use Keil, why not use an RTOS supplied & supported by Keil?

Children
No data