MIPSASSEMBLY coding Get five numbers from the user one at a

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

Solution

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

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site