#Registers #g1 primary use is for the Product also used for a zero test before the Product #g4 used for the input value and as a counter for the Product function #g5 used for a comparison store and for a zero value Main #Start of Program GETPORT IN0, $g4 #Pulls Value of Input Port 0 (The Value to be Multiplied) SUB $g5, $g5 #Zeroes $g5 and $g1 SUB $g1, $g1 PreInt #Loops Until second interupt is set to value other than 0 SETPORT OUT0, $g4 #Displays the value input by the user GETPORT IN1, $g5 #Pulls value from Input Port 1 (Product Trigger) BEQ $g1, $g5, PreInt #performs check for Second Interrupt set to nonzero SUB $g5, $g5 #Zeroes $g5 and $g1(result reg) SUB $g1, $g1 BNE $g4, $g5, Finish #If $g4 is zero it goes straight to the end Product #Contains the Multiply algorithm ADDI $g1, 255 #Adds 255 to the result register SUBI $g4, 1 #Deincrements Input SUB $g5, $g5 #Zeroes $g5 BNE $g4, $g5, Product #Checks for #g4 being 0(done) ADDI $g5, 65535 #Sets #g5 to 65535 SLT $g1, $g5, $g5 #Checks for result less than 65535 SUB $g4, $g4 #zeroes #g4 BEQ $g4, $g5, Finish #If result is less than 65535 goes to finish SUB $g1, $g1 #else result is replaced with zero Finish SETPORT OUT0, $g1 #outputs result