Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MIPS/ASSEMBLY coding Get five numbers from the user, one at a time, and print th

ID: 3785568 • Letter: M

Question

MIPS/ASSEMBLY coding

Get five numbers from the user, one at a time, and print the difference of all the negative numbers in the end. For example, for a sequence in input equal to: -3, 0, -7, -2, 1 the result should be computed as follows: (-3)-(-7)-(-2)=6

.text

li $v0,5
syscall
move $t0,$v0

li $v0,5
syscall
move $t1,$v0

li $v0,5
syscall
move $t2,$v0

li $v0,5
syscall
move $t3,$v0

li $v0,5
syscall
move $t4,$v0

sub $t5,$t0,$t1,$t2,$t3,$t4


li $v0,1
li $a0,$t5
syscall

This is what i have done so far but im having a where i bolded it (subtraction of the numbers). I cant figure out what im doing wrong

Says theres an error and it wont do the subtraction of the 5 numbers

Explanation / Answer

Assembly language programming does not support subtracting 5 integers at the same time.This can be done by subtracting first two integers and then storing the result in a register temporarily and then using it again for further computation.Example

sub $t0,$t0,$t1

sub $t0,$t0,$t2

sub $t0,$t0,$t3

sub $t5,$t0,$t4