#LOOP ### ############## # This exercise will count the sum between 0..10 # Data segment .data # Create words ten: .word 10 one word 1 total: .word 0 #Text segment .text main: Iw $s0, ten loop: Iw $10, one move $s1, $s0 sub $50, $50, $10 add $s1, $s0, $s1 beqz $s0, done j loop done: sw $s1, total li $v0, 10 syscall # Load word into $50 from memory[ten] #Load word into $50 from memory[one] # Copy ($s0) to $s1 # ($50)=($50)-1 # ($s1)=($s0)+($s1) # The execution branch to 'done' if ($s0)=0 # The execution jump back to 'loops' # Store ($s1) into memory[total] #syscall number 10 will exit from program # actually exit the program
Solve the following questions by WRITING YOUR INSTRUCTION CODE in Assembly language. 1. Modify the Lab 4 Tutorial 1 to allow USERS TO ENTER the following parameter and displaythefinal result. You are also required to store the results in the memory named ‘output’. Findthesum of the last four numbers in the array. For example, assume the value of n is 10, the sumwill
be 10+9+8+7= 34 (in decimal). Your console should display the following:
Please enter the value of n: 10
The sum of the last four numbers is 34
Thank you. Before computing the difference of the numbers in the array, your code must performachecking; if n < 3, you should display a message ‘The value of n is less than 4’, and no operationwill be performed. In this case, your console should display the following: Please enter the value of n: 1
The entered n is less than 3. Thank you Type the instructions into your word editor and save it as ‘Lab2Q1.s
![#LOOP
###
##############
# This exercise will count the sum between 0..10
# Data segment
.data
# Create words
ten: .word 10
one word 1
total: .word 0
#Text segment
.text
main:
Iw $s0, ten
loop:
Iw $10, one
move $s1, $s0
sub $50, $50, $10
add $s1, $s0, $s1
beqz $s0, done
j loop
done: sw $s1, total
li $v0, 10
syscall
# Load word into $50 from memory[ten]
#Load word into $50 from memory[one]
# Copy ($s0) to $s1
# ($50)=($50)-1
# ($s1)=($s0)+($s1)
# The execution branch to 'done' if ($s0)=0
# The execution jump back to 'loops'
# Store ($s1) into memory[total]
#syscall number 10 will exit from program
# actually exit the program](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0c01e5ef-fbcb-4cb6-a6a1-b22540f375f3%2F1abba2b2-906c-478c-a546-ac96b0f118bd%2Fpm7pd9_processed.jpeg&w=3840&q=75)

Step by step
Solved in 2 steps









