2014-05-09 67 views
1

我正在編寫一箇中斷處理程序,它接收鍵盤中斷並將它們輸入到程序中的某個函數中以進行作業分配。我目前的步驟是:檢查中斷級別Mips

檢查中斷級別。 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 

在這一點上,我需要檢查中斷級別,但我不確定這是如何實際代碼實現。誰能幫我?謝謝!

回答

2

如果$ 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 
+0

工作正常!謝謝一堆! –

+0

你打賭。你對於它的工作原理有很好的把握嗎? –

+1

哦,去年我從未看過你的評論,但是當時我明白了。從這個任務開始就沒有使用過MIPS,所以現在有點模糊了,但得到了一般的想法! –