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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:41:47+00:00 2026-06-13T18:41:47+00:00

Some of the MIPS instructions have immediate offsets. For example, while moving lw command

  • 0

Some of the MIPS instructions have immediate offsets.
For example, while moving lw command to fill the branch delay slot below the beq, its immediate offset changes from 100 to 96.

PC     Loop: lw $2, 100($3)
PC+4         addi $3, $3, 4
PC+8         beq  $3, $4, Loop

transformed into

PC   Loop: addi $3, $3, 4
PC+4       beq $3, $4, Loop
PC+8       lw $2, 96($3) # branch delay slot

Is it because PC is always PC+4, so it goes as 100 – 8 + 4 = 96 ?
What happens if instruction is moving up?
For example,

PC       Loop: xxxxxxxxxxxxx
PC+4           addi $5, 4($5)

Will this be correct?

PC       Loop: addi $5, 4($5)
PC+4           xxxxxxxxxxxxx
  • 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-13T18:41:48+00:00Added an answer on June 13, 2026 at 6:41 pm

    The change in the immediate has nothing to do with the PC.

    Loop: lw $2, 100($3)
          addi $3, $3, 4
          beq  $3, $4, Loop
    

    In the original you are loading from address ($3 + 100), then adding 4 to $3.

    Loop: addi $3, $3, 4
          beq $3, $4, Loop
          lw $2, 96($3) # branch delay slot
    

    In the transformed one, you are adding 4 to $3, then loading from address ($3 + 96) = (original_$3 + 4 + 96) = (original_$3 + 100). It’s the reordering between lw and addi which affects the immediate (addi cannot be moved to the delay slot because the branch depends on the new value of $3).

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

Sidebar

Related Questions

I am working on a little mini compiler while trying to learn some MIPS
I have been asked recently to produced the MIPS (million of instructions per second)
At school we have been programming in MIPS assembly language for some time. I'm
Is there some instruction in MIPS that will determine the parity of a certain
Some background info: I am currently writing a bootloader in protected mode while learning
Some setup background first: I have a cronjob which runs a PHP file called
I have some very heavy code to develop and want to make some calculations
I have designed a MIPS I simulator using Verilator which allows me to wrap
I have some code that I am porting from an SGI system using the
Some of the users of our Ruby on Rails app have complained that page

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.