.data
base: .word 0
ht: .word 0
area: .word 0
msg: .asciiz "\n"
msgadd: .word msg
msg2: .asciiz "Please enter a value for base: "
msgadd2:.word msg2
msg3: .asciiz "Please enter a value for height: "
msgadd3:.word msg3
msg4: .asciiz "Area is: "
msgadd4:.word msg4
msg5: .asciiz "Finished "
msgadd5:.word msg5
.text
main: lw $a0, msgadd2 #display input message for base
ori $v0, $0, 4
syscall
addi $v0, $0, 5 #read base
syscall
add $t0, $0, $v0 #put base into $t0
slti $t3, $t0, 0 #if base is less than 0 then print
bne $t3, $0, prin
sw $t0, base #store value in $t0 into base in memory
height: lw $a0, msgadd3 #display input message for height
ori $v0, $0, 4
syscall
addi $v0, $0, 5 #read integer
syscall
add $t1, $0, $v0 #put ht into $t1
slti $t4, $t1, 0 #if height is less than 0 then print
bne $t4, $0, prin
sw $t1, ht #store value in $t1 into height in memory
j main #jump to main
prin: lw $t0, base #load base from memory
lw $t1, ht #load height from memory
lw $a0, msgadd #print new line
ori $v0, $0, 4
syscall
lw $a0, msgadd4 #display area is message
ori $v0, $0, 4
syscall
mult $t0, $t1 #base * height
mflo $t2
addi $t5, $0, 2 #put 2 into $t5
div $t2, $t5 #bh / 2, store result back into $t2
mflo $t2
sw $t2, area #store result in $t2 into area in memory
addi $v0, $0, 1 #print final result
add $a0, $0, $t2
syscall
j end #jump to end
end: lw $a0, msgadd #print new line
ori $v0, $0, 4
syscall
lw $a0, msgadd5 #display finished message
ori $v0, $0, 4
syscall