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

Create anassembly program that display following series and iterate it for15 tim

ID: 3608623 • Letter: C

Question

Create anassembly program that display following series and iterate it for15 times.

Series will be 3, 5, 6, 10,9, 15, 12, 20, 15, 25....

Initialize thefirst register as 3 and 5. Keep two register as a counter for eachsub part of the series.

Emphasis shouldbe put on efficient register usage.

I'm obviouslynot 'fluent' with this language and could use some explainationwith what is going on..


Thanks in advance!


I have come upwith the following code (not sure how much of it isright)

.data
.text
main:

addi $s2, $0, 3 #initialization
addi $s1, $0, 5 #initialization

addi    $t2, $0,15              # $t2=0+15=15 (initialization)

LOOP: addi    $s2, $s2,3                #
            addi    $s1, $s1, 5
            addi    $t2, $t2,-1        #
            bne $t2, $0, LOOP



li $v0,1
syscall














Explanation / Answer

I figured it out. If there is a more efficient way of doing thisplease let me know. .data comma: .asciiz "," .text main:   li $s0,1                      # $s0 = loop counter         li $s1,15             # $s1 = upper bound of loop         li $s2, 3         li $s3, 5 loop:   move $a0,$s2          #         li $v0, 1         syscall         li $v0,4                      # print “,”         la $a0,comma           #comma: .asciiz “,”         syscall         move $a0, $s3         li $v0, 1         syscall         li $v0,4                      # print “,”         la $a0,comma           #comma: .asciiz “,”         syscall         addi $s2, $s2,3        # increase counter by3         addi $s3, $s3,5        #increase by 5         addi $s0, $s0, 1         ble $s0, $s1,loop             # if ($s0
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote