# Implementation of Homework 1, Problem 8 in MIPS # prints a + b if a < b, b - a if a > b and b * a if a = b .data nl: .asciiz "\n" .text .globl main main: # Set a and b for testing li $t0, 4 # a li $t1, 4 # b # go to branch1 if a < b blt $t0, $t1, branch1 # go to branch2 if a > b bgt $t0, $t1, branch2 # Otherwise they're equal mul $t2, $t0, $t1 j end branch1: add $t2, $t0, $t1 j end branch2: sub $t2, $t1, $t0 end: # Print Solution li $v0, 1 move $a0, $t2 syscall # Print Newline li $v0, 4 la $a0, nl syscall jr $ra