# ----------------------------------- # INITALIZATION PROCEDURE # ----------------------------------- cli # Initialize interrupt handlers. # IRQ0 is the data input line. IRQ1 is the button press. lir inputhandler1 xor $at, $at or $at, $ir lir 1 shl $at, $ir lir i0 sw $at, $ir # Initialize IRQ1. lir inputhandler2 xor $at, $at or $at, $ir lir 1 shl $at, $ir lir i1 sw $at, $ir # Jump to wait state. lir wait j $ir # ----------------------------------- # DATA INPUT INTERRUPT HANDLER # ----------------------------------- inputhandler1: # Disable interrupts in this interrupt handler. cli # Load data from input port zero into $a0. lir pi0 xor $a0, $a0 lw $a0, $ir #Shifts the data in the display register over 4. lir po0 lw $t1, $ir shl $t1, 4 or $t1, $a0 lw $t1, $ir # Load the starting number into $a1. lir startN # Pseudoinstruction expansion of "lw $a1, startN" xor $at,$at or $at,$ir lir 1 lw $a1, $at # Display the input number on the output port. lir po0 sw $a0, $ir # Go back to wait state. lir wait j $ir # ----------------------------------- # BUTTON PRESS INTERRUPT HANDLER # ----------------------------------- inputhandler2: # Clear interrupts in this interrupt handler. cli # Go to main procedure. lir main j $ir