Hi,

tested my code with CRITICAL macro. The macro works (tested that)
but it did not solve my issue, but I'll make an other post about that.

BTW there is a small typo in the macro you sketched, you cannot
have a non const initializer for the static var, so I modified it as
follows:

#define CRITICAL(CODE) do { \
   static unsigned char __sdcc_iflags; \
   __sdcc_iflags = (INTCON & 0xC0);  \
   INTCON &= ~0xC0; \
   do { CODE; } while (0); \
   INTCON |= __sdcc_iflags; \
} while(0)

Speaking of which __sdcc_iflags, why do you make it static? Local would
do,
wouldn't it or is it so that it will in any case end up using same
amout of
memory or performance point?

>>>>>> rnei...@web.de 20.1.2009 16:29 >>>
>>>Hi Kusti,
>>>
>>>> I'll test this later today.
>>>>
>>>> You wrote: "partially emulate"
>>>>
>>>> What do you mean by that, what __critical -functionality would
>>>> disabling all interrupt not emulate?
>>>
>>>Well, you cannot emulate
>>>
>>>void func(void) __critical
>>>{
>>>// something
>>>}
>>>
>>>using
>>>
>>>void func(void)
>>>{
>>>   CRITICAL(
>>>   //something
>>>   )
>>>}
>>>
>>>as this would not protect the prologue and epilogue. You *could*
use
Do we need to protect the prologue/epilogue?

>>>
>>>void func(void)
>>>{
>>>   CRITICAL(real_func());
>>>}
>>>
>>>and implement // something in real_func instead to solve that, but
>>>it is more costly and less convenient.
Ok, see that point now.

>>>
>>>With partly I meant that __critical (if implemented) adds value
>>>that cannot completely be obtained using standard stuff such as
>>>macros. In other words, __critical is not mere syntactic sugar.
Agree.

>>>
>>>> Or are you talking abou things like using a 'return/break'
statement
>>>> inside disabled section in which case of course the re-enabling
of
>>>> interrupts would not happen?
>>>
>>>This is another good point. Yes, I meant such things.
>>>
>>>Best wishes,
>>>Raphael

br Kusti

PS A compiler warning for non implemented __critical would be nice....

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword 
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/sdcc-user

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to