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: 3634544 • 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

.globl main .data Data: .word 8, 127, 16000, 65537 Value: .byte 255,128,64,32,5 Dataout: .asciiz " Data sum: " Valueout: .asciiz " Value sum: " byte: .space 1 new: .asciiz " Value sum after storing: " .text main: li $v0,4 #Output String la $a0,Dataout syscall la $s0,Data #sequentially load and add words in Data lw $s1,($s0) lw $t1,4($s0) add $s1,$s1,$t1 lw $t1,8($s0) add $s1,$s1,$t1 lw $t1,12($s0) add $s1,$s1,$t1 li $v0,1 move $a0,$s1 syscall li $v0,4 #Output String la $a0,Valueout syscall li $v0,1 #sequentially load and add bytes in Value la $s0,Value lbu $s1,($s0) #If you dont load unsigned then you may end up with negative values lbu $t0,1($s0) #because the leading bit may be 1 add $s1,$s1,$t0 lbu $t0,2($s0) add $s1,$s1,$t0 lbu $t0,3($s0) add $s1,$s1,$t0 lbu $t0,4($s0) add $s1,$s1,$t0 move $a0,$s1 syscall li $v0,4 #Output String la $a0,new syscall li $v0,1 la $s3,byte #after storing the wrong value is returned because the sb $s1,($s3) #summed quantity of value is 484 which is bigger than a byte lbu $s1,0($s3) #can hold move $a0,$s1 syscall j $ra #Bytes could have the decimal answer resulting from adding the numbers unsigned,adding #the numbers signed or,the asciiz character value.

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