irqs.c

来自「arm ads1.2 with crack.rar」· C语言 代码 · 共 40 行

C
40
字号
/* Example 4-2 */

/* Enabling and disabling interrupts */

/*
Interrupts are enabled or disabled by reading the cpsr flags and updating bit 7. 
This example shows how this can be done by using small functions that can be inlined. 
These functions work only in a privileged mode, because the control bits of the 
cpsr and spsr cannot be changed while in User mode.
*/

__inline void enable_IRQ(void)
{
    int tmp;
    __asm
    {
        MRS tmp, CPSR
        BIC tmp, tmp, #0x80
        MSR CPSR_c, tmp
    }
}

__inline void disable_IRQ(void)
{
    int tmp;
    __asm
    {
        MRS tmp, CPSR
        ORR tmp, tmp, #0x80
        MSR CPSR_c, tmp
    }
}

int main(void)
{
    disable_IRQ();
    enable_IRQ();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?