【问题标题】:Check Interrupt Level Mips检查中断级别 Mip
【发布时间】:2014-05-10 04:22:48
【问题描述】:

我正在编写一个中断处理程序,它接受键盘中断并将它们输入到程序中的一个函数中以进行家庭作业。我目前的步骤是:

检查中断级别。 MMIO 接收器控制中断是一个硬件 级别 1 的中断,这是图 B.7 中中断掩码中的最低(最右边)位。{1,2}, 这是位 8 = 0x0100。对于这个硬件,我们不关心任何其他中断级别,所以如果它 不匹配这个,什么都不做,退出。

我想知道我是怎么做的。到目前为止我的中断是这样的:

.ktext 0x80000180

Interrupt: 
sw $at, saveat
sw $a0, save0
sw $a1, save1
mfc0 $k0, $13       #$k0 = Cause
mfc0 $k1, $14       #$k1 = EPC
andi $k0, $k0, 0x003c   # $k0 = Exception Code
bnez $k0, done      # If its not equal 0, its not a keyboard interrupt, done

此时我需要检查中断级别,但我不确定这实际上是如何在代码中完成的。谁能帮我?谢谢!

【问题讨论】:

    标签: mips interrupt


    【解决方案1】:

    如果 $k0 是您的原因,我会假设也存储级别。做这样的事情怎么样?

      andi $t0, $k0, 0x003c # $t0 = Exception code, $k0 is preserved
      bnez $t0, done        #If its not equal 0, its not a keyboard interrupt, done
      andi $t0, $k0, 0x0100 #Check to see if this bit is set in $k0
      bnez $t0, done        #If it is set, service the interrupt
                            #otherwise, go to done
    
      #service the interrupt
    
    done:
      #clean up and exit
    

    【讨论】:

    • 哦,我去年没看到你的评论后记,但在我理解的时候是的。自从这次作业后就没有使用过 MIPS,所以现在有点模糊,但大致了解一下吧!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-07
    • 1970-01-01
    相关资源
    最近更新 更多