#program to multiply an unsigned 8-bit number with 0xFF. #Install the Interrupt Handler main: 0x0040: 01001 1 00 00000000 li 1, $d0, a(i_handler) 0x0042: 01001 0 00 10111100 li 0, $d0, a(i_handler) 0x0044: 01011 1100 0000 000 sw $d0, $0, 0 #Do nothing until an interrupt comes spin: 0x0046: 01001 1 00 00000000 li 1, $d0, a(spin) 0x0048: 01001 0 00 01000110 li 0, $d0, a(spin) 0x004A: 00101 0 00 0000 0000 btj 0, $d0, $0, 0 #display the output value. output: 0x004C: 01011 0001 0000 110 sw $g0, $0, 6 0x004E: 01011 0000 0000 101 sw $0, $0, 5 0x0050: 01110 00001010 000 latch 0xA 0x0052: 01001 1 00 00000000 li 1, $d0, a(spin) 0x0054: 01001 0 00 01000110 li 0, $d0, a(spin) 0x0056: 00101 0 00 0000 0000 btj 0, $d0, $0, 0 #Calculates the product of $g1 and 0xFF #and stores the result in $d0 product: 0x0058: 01000 0 00 0010 1000 s 0, $d0, $g1, 8 0x005A: 00100 1 01 0010 0000 not 1, $d1, $g1, 0 0x005C: 00000 0 00 1100 1101 add 0, $d0, $d0, $d1 0x005E: 01100 0001 1100 000 copy $g0, $d0, 0 #return 0x0060: 01100 1110 1010 000 copy $d0, $ra, 0 0x0062: 00101 0 00 0000 0000 btj 0, $d0, $0, 0 #called by i_handler when the go signal is received do_product: 0x0064: 01001 1 00 00000000 li 1, $d0, a(product) 0x0066: 01001 0 00 01011000 li 0, $d0, a(product) 0x0068: 00110 0 00 0000 0000 btl 0, $d0, $0, 0 0x006A: 01001 1 00 00000000 li 1, $d0, a(output) 0x006C: 01001 0 00 01001100 li 0, $d0, a(output) 0x006E: 00101 0 00 0000 0000 btj 0, $d0, $0, 0 #magically skip a bunch of bytes. i_handler: 0xbc 01010 1101 0000 011 lw $g3, $0, 3 # load interrupt control register 0xbe 00111 0 00 0100 1111 bs 0, $d0, $g3, 15 # set global disable 0xc0 01011 1100 0000 011 sw $d0, $0, 3 # disable interrupts 0xc2 01010 0100 0000 010 lw $g3, $0, 2 # load interrupt condition register 0xc4 01001 1 10 00000000 li 1, $d2, 0x00 0xc6 01001 0 10 11011100 li 0, $d2, a(input) 0xc8 00101 1 10 0100 1110 btj 1, $d2, $g3, 14 # if input interrupt # happened, jump 0xca 01001 1 10 00000000 li 1, $d2, 0x00 0xcc 01001 0 10 11110000 li 0, $d2, a(go) 0xce 00101 1 10 0100 1101 btj 1 ,$d2, $g3, 13 # if go interrupt happened, jump 0xd0 01010 1101 0000 011 lw $g3, $0, 3 # load interrupt control register 0xd2 00111 1 00 0100 1111 bs 1, $d0, $g3, 15 # set global enable 0xd4 01011 1100 0000 011 sw $d0, $0, 3 # enable interrupts 0xd6 01001 1 10 00000000 li 1, $d2, a(spin) 0xd8 01001 0 10 01000110 li 0, $d2, a(spin) 0xda 00101 0 10 0000 0000 btj 0, $d2, $0, 0 # start spinning again input: 0xdc 01010 0010 0000 0100 lw $g1, $0, 4 # load the input into $g1 0xde 01010 0100 0000 0010 lw $g3, $0, 2 # load the interrupt # condition register 0xe0 00111 1 00 0100 1110 bs 0, $d0, $g3, 14 # we have serviced the # interrupt, set the bit to 0 0xe2 01011 1100 0000 010 sw $d0, $0, 2 0xe4 01010 1101 0000 011 lw $g3, $0, 3 # load interrupt control register 0xe6 00111 1 00 0100 1111 bs 1, $d0, $g3, 15 # set global enable 0xe8 01011 1100 0000 011 sw $d0, $0, 3 # enable interrupts 0xea 01001 1 10 00000000 li 1, $d2, 0x00 0xec 01001 0 10 01000110 li 0, $d2, a(spin) 0xee 00101 0 10 0000 0000 btj 0, $d2, $0, 0 # start spinning again go: 0xf0 01010 0100 0000 0010 lw $g3, $0, 2 0xf2 00111 1 00 0100 1101 bs 0, $d0, $g3, 13 0xf4 01011 1100 0000 010 sw $d0, $0, 2 0xf6 01010 1101 0000 011 lw $g3, $0, 3 # load interrupt control register 0xf8 00111 1 00 0100 1111 bs 1, $d0, $g3, 15 # set global enable 0xfa 01011 1100 0000 011 sw $d0, $0, 3 # enable interrupts 0xfc 01001 1 10 00000000 li 1, $d2, a(do_product) 0xfe 01001 0 10 01100100 li 0, $d2, a(do_product) 0x100 00101 0 10 0000 0000 btj 0, $d2, $0, 0 # start executing program