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 9318951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:15:44+00:00 2026-06-19T03:15:44+00:00

I’m trying to create an array of pointers to strings, but it’s not behaving

  • 0

I’m trying to create an array of pointers to strings, but it’s not behaving as expected. The array has the contents of the strings, not the addresses. Here’s the source code:

    showhelp:
        .data
    help1:  .asciiz "\nHELP FOR HW4_2b\n"
    help2:  .asciiz "Purpose: Displays the output from a one-bit full adder with inputs provided on the command line.\n"
    help3:  .asciiz "HW4_2b c a b\n"
    help4:  .asciiz "c\t\tThe carry in bit: 0|1\n"
    help5:  .asciiz "a\t\tOne of the bits to be added: 0|1\n"
    help6:  .asciiz "c\t\tThe other bit to be added: 0|1\n"
    helpar: .word help1, help2, help3, help4, help6
    helpsiz:.word 6
            .text
            lw          $t0, helpsiz    # load size of help array
            lw          $t1, helpar     # load address of address of first help string
    nxthlp: la          $a0, ($t1)      # specify string to print
            li          $v0, 4          # specify print string 
            syscall                     # print it
            addi        $t1, $t1, 4     # increment pointer to next string
            subi        $t0, $t0, 1     # decrement counter
            bgtz        $t0, nxthlp     # if not last string loop

            jr $ra          # return

When this runs, this is the output:

    HELP FOR HW4_2b
    P FOR HW4_2b
    R HW4_2b
    4_2b

    rpose: Displays the output from a one-bit full adder with inputs provided on the command line.

As you can see, the helpar: contains all the strings concatenated, rather than the addresses. Also, the indirect addressing in the “la $a0, ($t1)” is loading the contents of $t1, rather than the contents at the address contained in $t1.

What am I misunderstanding?

Thanks,
Kevin

  • 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-06-19T03:15:45+00:00Added an answer on June 19, 2026 at 3:15 am

    Here’s the problem:

            lw          $t0, helpsiz
            lw          $t1, helpar     # load address of 1st string
    nxthlp: la          $a0, ($t1)      # NOT SURE IF THIS IS EVEN VALID
            li          $v0, 4
            syscall
            addi        $t1, $t1, 4     # skip 4 chars in string; must be unsigned add!
            subi        $t0, $t0, 1
            bgtz        $t0, nxthlp
    

    Here’s what you should do instead:

        lw      $t0, helpsiz
        la      $t1, helpar # t1 points to element 0 of helpar
    nxthlp:
        lw      $a0, 0($t1) # fetch element of helpar that t1 points to
        li      $v0, 4
        syscall
        addu    $t1, $t1, 4 # t1 points to next element of helpar
        subi    $t0, $t0, 1
        bgtz    $t0, nxthlp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

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.