Question

is tion II (SPIM Code Segment Problems: solve the problems as directed. Each problem worth 15 points. Use the data declaration on the first page of this Problem 2 Review the SPIM program on the right. Then answer the following questions: text main: la St1 str next Ib St0,0St1) 2.1 What does the program do and how does it accomplish its goal? beqz Sto, off sub Ssp,Ssp,4 sw St0,0Ssp) addi St1,St1,1 addi St2,St2,1 j next off sub St1,St1,1. cap iw St00,0Ssp) addi Ssp,Ssp,4 2.2 is the last operation the program performs before bit St0,0x61,getlet bgt St0,0x7a,getlet sub St0,St0,0x20 getlet: sb St0,0(St1) sub St1,St1,1 sub St2,St2,1 2.3 Write down the exact console output. beqz St2,over j cap over: la Sao,str li Sv0,4 syscall. Note ASCII Codes li Sv0,10 syscall 0x30 0 0x41 A .data str .asciiz hello worldn 0x5a 0x61 a 0x7a z 0x30 0 0x39 9 0x 0a ln (carriage return/line feed).
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution: 1. The program converts the lower case letters given in string to upper case and displays it. It definesa procedure

#Add instruction addi Şsp, $sp, 4 #Branch If less than blt Şt0, 0x61,getlet #Branch if greater than bgt $t0,0x7a, getlet #sub

#Data data #Display string str: .asciiz hello world \n Sample Output: HELLO WORLD -program is finished running --

Code:

#Define text section

.text

#Define main method

main: la $t1, str

#Define next method

next: lb $t0,($t1)

#Check if equal

beqz $t0,off

  

#Sub

sub $sp,$sp,4

  

#Store value

sw $t0,($sp)

  

#Add instruction

addi $t1,$t1,1

  

#Add instruction

addi $t2,$t2,1

  

#Jump to label

j next

   

#Define off procedure

off: sub $t1,$t1,1

   

#Define cap procedure

cap: lw $t0,($sp)

    

#Add instruction

addi $sp,$sp,4

    

#Branch if less than

blt $t0,0x61,getlet

     

#Branch if greater than

bgt $t0,0x7a,getlet

      

#sub instruction

sub $t0,$t0,0x20

      

   #Define getlet procedure

    getlet: sb $t0,0($t1)

      

    #Sub instruction

    sub $t1,$t1,1

      

    #Sub instruction

    sub $t2,$t2,1

    

    #Branch if matches

    beqz $t2,over

       

    #Jump to label

    j cap

       

     #Define procedure over

     over: la $a0,str

       

     #Load

     li $v0,4

       

     #Syscall

     syscall

       

     #Load

     li $v0,10

        

      #System call

      syscall

        

      #Data

      .data

      

       #Display string

        str: .asciiz "hello world \n"

       

Add a comment
Know the answer?
Add Answer to:
Solve the problems as directed. Each problem worth 15 points. Use the data declaration on the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT