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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:15:41+00:00 2026-06-11T05:15:41+00:00

Consider the following MIPS assembly (I’m using MIPS because that is what my Computer

  • 0

Consider the following MIPS assembly (I’m using MIPS because that is what my Computer Organization and Design book uses):

beq   $s0, $s1, L1
add   $t0, $t1, $t2
...
L1: ...

Because MIPS only uses 16 bits for the PC-relative address in the beq instruction, if L1 is sufficiently far away from the beq, the assembler must replace it with two instructions (a jump has 26 bits for the address) and a new label:

bne   $s0, $s1, L2
j     L1
L2:   add $t0, $t1, $t2
...
L1: ...

If even this isn’t enough, it may need multiple jumps.

The assembler doesn’t know whether it needs to make this replacement until it knows the location of L1. Since it doesn’t initially know the size of the beq (1 instruction or 2), how can it keep the location counter up-to-date during the first pass?

  • 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-11T05:15:43+00:00Added an answer on June 11, 2026 at 5:15 am

    There are multiple approaches:

    • Reserve space only for one instruction and if it’s found not enough, expand it.
    • Reserve enough space for the two instructions and then either fill the unused space with nop(s) or compact the code.

    In either case you don’t have to generate (semi-)final machine code immediately, nor do you need to rescan the source code and reassemble it, though it’s possible. You can generate “intermediate” code or its representation at first and then fix it up, pretty much what the linker does.

    Speaking of which [the linker], there’s also another option:

    • Leave this piece for the linker to handle. It’s not very hard. Nowadays compilers (e.g. Microsoft Visual C++) can do link-time code optimization.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider following string Some string with quotes and \pre-slashed\ quotes Using regex, I want
Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider following tables: How to skip and take groups from the table? Tried using
Consider following XML document fragment: <Book> <Title>Example</Title> <Content> Some line </Content> <TOC> Again some
How to get the underlying type of an Observable collection using reflection? Consider following
I am a bit stuck up with the following question, Consider the following MIPS
Consider following source files 1.cpp #include <iostream> using namespace std; struct X { X()
Please consider following example: The source image consists of 6 areas that need to
Consider following MySQL table: CREATE TABLE `log` ( `what` enum('add', 'edit', 'remove') CHARACTER SET
Consider following code: ArrayList<Integer> aList = new ArrayList<Integer>(); aList.add(2134); aList.add(3423); aList.add(4234); aList.add(343); String tmpString

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.