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

Write an MIPS assembly program which contains the following data statements. .da

ID: 3623673 • Letter: W

Question

Write an MIPS assembly program which contains the following data statements.

.data
Data: .word 8, 127, 983, 16000, 65537
Value: .byte 255, 128, 64, 32, 5

Your program should read the 5 words labeled “ Data” from memory and sum them. Likewise, read the five bytes labeled “Value” from memory and display their sum also. Comment on the sum of the five byte values. (HINT: did you use signed or unsigned load?) What happens if the byte sum is stored in memory then retrieved and displayed?

There are at least 3 different answers for the sum of bytes and each may be correct. Discuss the conditions under which each result is correct and document your results in your program's comments section

Explanation / Answer

please rate- thanks

2 different versions one loads the byte but the high order bit propagates to make it negative, the othe the high order bit doesn't even load, the 3rd would be where you get the actual number


    .text
    .globl main

main:    la    $s0,Data    #intialize the array pointers
           
         lw    $s5,size    #get size
         li     $s2,0        #init count
         lw    $t0,0($s0)    #get array 1 element
loop:
        beq    $s2,$s5,cnt    #while(count<size)
        addiu    $s0,$s0,4    #point to next array elements
        lw   $t1,0($s0)
        add $t0,$t0,$t1
        addi $s2,1
    j    loop       #end pair loop

cnt:
     la $a0, m6       
    li $v0 4
     syscall
    li $v0, 1
   move $a0, $t0
   syscall
##output 1
la    $s0,Value    #intialize the array pointers
           
         lw    $s5,size    #get size
         li     $s2,0        #init count
         lb   $t0,0($s0)    #get array 1 element
loop2:
        beq    $s2,$s5,cnt2    #while(count<size)
        addiu    $s0,$s0,1    #point to next array elements
        lb   $t1,0($s0)
        add $t0,$t0,$t1
        addi $s2,1
    j    loop2      #end pair loop

cnt2:
     la $a0, m7  
      li $v0 4
       syscall
    li $v0, 1
   move $a0, $t0
   syscall
##output 2
la    $s0,Value    #intialize the array pointers
           
         lw    $s5,size    #get size
         li     $s2,0        #init count
         lb   $t0,0($s0)    #get array 1 element
loop3:
        beq    $s2,$s5,cnt3    #while(count<size)
        addiu    $s0,$s0,1    #point to next array elements
        lbu   $t1,0($s0)
        add $t0,$t0,$t1
        addi $s2,1
    j    loop3      #end pair loop

cnt3:
     la $a0, m7  
      li $v0 4
       syscall
    li $v0, 1
   move $a0, $t0
   syscall
    .data
size:        .word   4
Data: .word 8, 127, 983, 16000, 65537
Value: .byte 255, 128, 64, 32, 5
m6:    .asciiz "The word sum is: "   
m7:    .asciiz " The byte sum is:   "   

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