Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:37:32+00:00 2026-05-30T20:37:32+00:00

This is my code: .data .ascii r, o, r, y, \n key: .word 2

  • 0

This is my code:

.data  
.ascii "r", "o", "r", "y", "\n"
key: .word 2
.text
.globl main

main:   la  $t0, string
        move    $t5, $t0         # preserve original data
        la  $t1, key            # load cypher into t1 reg
        lw  $a1, 0($t1)      # key loaded into a1 reg   

Loop:   lb  $a0, 0($t5)      # ith element of array loaded into a0    
        beq $a0, 10, exit_all   # if ith character is \n, get out of loop
        jal sub1               # otherwise, call sub  

        addi    $t5, $t5,      # increment index of array   
        j   Loop

exit_all: syscall 

sub1:   
    some code
    move $v0, $t0              # what i want to return to main
    jr  $ra                 # exit iteration

I have a loop with a sub-routine in it. The sub returns (in the $v0 reg) an output i want to save every time the ‘jr $ra’ command returns the flow to my main function. I need to save these outputs directly after my inputs in the data segment. How do i do this? If it was just one output, i could say:

sb $v0, 4($t1)

and it would be saved directly after. But there are multiple outputs, so how do i do this in a general way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:37:34+00:00Added an answer on May 30, 2026 at 8:37 pm

    You need to reserve space in your data section for all of your output values, so for example for 32 output values add:

    results: .byte 32
    

    to your data section. Then set a register to the address of results, and increment the register each time around the loop:

            la  $t7, result
    ...
    Loop:   ...
            jal sub1
            sb  $v0,0($t7)
            addiu $t7,1
            j loop
    

    The above code is untested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: $.getJSON(Featured/getEvents, function(data){ $.each(data.events, function(i,event){ var title = event.title.substr(0,20); $(#title-+i).text(Text); if
Which is preferable? Assume this code before each: byte[] data = Encoding.ASCII.GetBytes(Test Packet Message);
In Python 2.5 I stored data using this code: def GLWriter(file_name, string): import cPickle
How does this code concatenate the data from the string buffer? What is the
This code correctly fetches data, and displays it; however, the sort is completely ignroed.
I use this code to update data in database table. Can reuse same code
Will this code ever wait on the mutex inside the producer's void push(data) ?
I have this code to update users data, but I can't write the for
I have a data.frame from this code: my_df = data.frame(read_time = c(2010-02-15, 2010-02-15, 2010-02-16,
I have this code: ... request data = new request(); data.username = formNick; xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.