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

  • Home
  • SEARCH
  • 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 6861615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:33:27+00:00 2026-05-27T02:33:27+00:00

I am running the following MIPS code in MARS simulator: add $t0, $zero, $zero

  • 0

I am running the following MIPS code in MARS simulator:

add $t0, $zero, $zero        # i = 0
        add $t4, $zero, $zero        # initialize the sum to zero
        add $t5, $zero, $zero        # initialize temporary register to zero

        la $a0, array                 # load address of array
        la $a1, array_size            # load address of array_size
        lw $a1, 0($a1)                # load value of array_size variable

loop:
        sll  $t1, $t0, 2              # t1 = (i * 4)
        add $t2, $a0, $t1             # t2 contains address of array[i]
        sw $t0, 0($t2)                # array[i] = i

        addi $t0, $t0, 1              # i = i+1
        add $t4, $t4, $t0             # sum($t4) = ($t4 + array[i])

        slt $t3, $t0, $a1             # $t3 = ( i < array_size)
        bne $t3, $zero, loop          # if ( i < array_size ) then loop

        add $t5, $a0, $zero           # save contents of $a0 in temporary reg $t5
        nop                           # done.

In machine code, the bne instruction is the following: 00010101011000001111111111111001. In this case, the immediate is: 1111111111111001 which equals to: 0xFFF9. MIPS will take that, bit shift it to the left by 2 (multiplies it by 4) and takes its program counter to that number. However, 0xFFF9 multiplied by 4 is 0x3FFE4. How is that possible? The program counter at SLL should be 0x18 and not 0x3FFE4. What am I missing here?

Thank you,

  • 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-27T02:33:27+00:00Added an answer on May 27, 2026 at 2:33 am

    There are 2 things to note here:

    1. The immediate is in 2’s complement; since the sign bit is 1, this is a NEGATIVE value
    2. On the MIPS, the target of the branch is expressed as an offset (which squares w/ the value being negative, since loop comes before the bne). The value gets multiplied by 4 b/c the instructions are all 4-bytes in size
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running the following code to add an association enters multiple entries each time the
while running following code : def v1=[]; def p=[]; v.as('x') .except(v1).sideEffect{v1.add(it)} // step 1
I am running following PHP code to interact with a MS Access database. $odbc_con
Running the following code, I get a StackOverflowError at the getPackage() line. How can
When running the following code it leaves out one row. When I do a
When running the following Java code, I get very accurate and consistent results in
When running the following python code: >>> f = open(rmyfile.txt, a+) >>> f.seek(-1,2) >>>
When running the following code I get no output but I cannot work out
I am running following code, getAccount() is a static function, $ac_info = AccountClass::getAccount($ac_code); print_r($ac_info);
Running the following JavaScript code shows 63 in both cases: alert( 0xff >> 2

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.