了解 Arduino 内联汇编中的 SBI 和 CBI

Understanding SBI and CBI in Arduino Inline Assembly

我正在尝试使用内联汇编在 Arduino 中编写一个小的闪烁程序。第一个标签 (start:) 下的代码有效,LED 亮起;但是,问题在于跳停。从理论上讲,这似乎是正确的——我将该位设置到寄存器 5 的第 5 位,然后清除该位,但这不起作用。

void setup(){
    asm("sbi 0x05, 5");
}

void loop(){
    asm("start:");
    asm("sbi 0x05, 5");
    asm("jmp stop");

    asm("stop:");
    asm("cbi 0x05, 5");
    asm("jmp start");
}

我是 Arduino 内联汇编的新手,如有任何帮助,我们将不胜感激

根据GCC

"asm statements may not perform jumps into other asm statements. GCC does not know about these jumps, and therefore cannot take account of them when deciding how to optimize. Jumps from asm to C labels are only supported in extended asm."

考虑到文档,我认为如果您在一个 asm 调用中包含 all 程序集,您的运气会更好。这使我能够获得您在问题中描述的所需功能。