嗯,这是手册中定义的PDP 11/40汇编语言。
让我们逐行分解:
.globl _idle # define a global symbol called idle
_idle: # this is the label for the global symbol
mov PS,-(sp) # push processor state onto stack
bic $340,PS # clear priority level bits - effectively enable all interrupts
wait # wait for an interrupt
mov (sp)+,PS # pop processor state from stack
rts pc # return from function
-(sp)
and应该被(sp)+
理解为等价于C/C++
运算符--sp
and sp++
。
因此,它有效地保存状态,清除优先级位,然后等待中断。一旦中断到达,它就会恢复状态并重新开始工作。
PS寄存器内容的定义请参见手册中的【2.3.2处理器状态字】部分。
现在,由于wait
各种原因,操作会被中断,其中最重要的是实时时钟中断,所以它会定期唤醒以做更多的工作。
当您查看源代码时,有两个地方idle()
调用了例程 - 一个来自恐慌处理程序,在无限循环中,另一个在swtch
.闲置的例行公事。