cancel
Showing results for 
Search instead for 
Did you mean: 

critical question

li_lou
Associate
Posted on April 20, 2015 at 09:21

hello, I define the critical like this:

*********************************************

    #define define_critical()           uint8 cpu_sr

    #define enter_critical()            cpu_sr=EnterCritical()

    #define exit_critical()             ExitCritical(cpu_sr)

    uint8 EnterCritical(void)

   {

        #asm

        push cc

        sim

        pop a

        #endasm

    }

    void ExitCritical(uint8 sr)

    {

        #asm

        push a

        pop cc

        #endasm

    }

*******************************

I use the critical like this:

Templet fun(Templet)

{

    define_critical();

    enter_critical();

    // do something

    exit_critical();

}

But I think that, there are some hidden problems! so, what it will happen?
1 REPLY 1
paulrbryson
Associate III
Posted on April 24, 2015 at 21:30

Not sure what is intended with the push and pop instructions but I am pretty sure they are not doing what you intend.

Why do you need more than SIM in the ''enter'' and RIM in the ''exit''?