#include #include #include #define PIO_SETUP2 0xffffea2a #define INT_PORT 0xbfa00000 .data save: .space 20*4 # Stringa di formato per la stampa nella ISR Format: .asciiz "Cause = 0x%x, EPC = 0x%x, Interrupt I/O = 0x%x\n" .text # Interrupt Service Routine # (chiamata dalla routine stub) .globl introutine .ent introutine .set noreorder .set noat introutine: .set noreorder .set noat # Salva i registri in area save # Preleva il Cause Register # Preleva l' EPC # Legge l'interrupt I/O port # Verifica se è alta l'INT3 # Verifica quale dispositivo è stato attivato # Fa l'INT ACK # Stampa le informazioni jr k1 # Salta a EPC rfe # Return from exception # Restores the status register .set reorder .end introutine .globl start # Inizio programma main .ent start .set at start: lh a0, PIO_SETUP2 # Abilita interrupt dal device andi a0, 0xbfff sh a0, PIO_SETUP2 sb zero,INT_PORT # INT Acknowledge (azzera registro) la a0, intstub jal install_normal_int mfc0 v0, $12 # Preleva lo Status Register li v1, ~SR_BEV # Setta il bit BEV dello SR and v0, v0, v1 # a 0 (Indirizzo eccezione non bootstrap) ori v0, v0, 1 # Abilitazione generale delle interruzioni ori v0, v0,EXT_INT3 # Abilita interrupt 3 (K1, K2, timer) mtc0 v0, C0_SR # Aggiorna lo status register Loop: b Loop # Wait for interrupt .end start .ent intstub .set noreorder intstub: j introutine nop .set reorder .end intstub