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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:57:44+00:00 2026-05-23T10:57:44+00:00

This is probably a simple, obvious thing I’m just not seeing, but how do

  • 0

This is probably a simple, obvious thing I’m just not seeing, but how do I load an address in a MIPS64 processor? In a MIPS32 processor the following assembler pseudo-instruction:

la $at, LabelAddr

Expands into:

lui $at, LabelAddr[31:16]
ori $at,$at, LabelAddr[15:0]

Looking at the MIPS64 instruction set, I see that lui still loads a 16-bit immediate into the upper half of a 32-bit word. There doesn’t appear to be any kind of expanded instruction that loads an immediate anywhere into the upper area of a 64-bit word. This seems, then, that to do the equivalent of an la pseudo-instruction I’d need to expand into code something like:

lui $at, LabelAddr[63:48]
ori $at, $at, LabelAddr[47:32]
sll $at, 16
ori $at, $at, LabelAddr[31:16]
sll $at, 16
ori $at, $at, LabelAddr[15:0]

This strikes me as a bit … convoluted for something as basic as loading an address so it leaves me convinced that I’ve overlooked something.

What is it I’ve overlooked (if anything)?

  • 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-23T10:57:44+00:00Added an answer on May 23, 2026 at 10:57 am

    I think if you need to load a lot of constants, you should put it in a constant pool (A.K.A “literal pool”) near the current code and then load it by an ld instruction.

    For example: $s0 contains the pool’s base address, and the constant you want to load is at offset 48, you can load it to $t1 by the instruction ld $t1, 48($s0)

    This technique is very common in ARM, where instructions could only load a 12-bit immediate (only later versions of ARM can load 16-bit immediates with some restrictions). And it is used in Java too.

    However somehow MIPS compilers still always generate multiple instructions to load a 64-bit immediate. For example to load 0xfedcba0987654321 on MIPS gcc uses

        li      $2,-9568256       # 0xffffffffff6e0000
        daddiu  $2,$2,23813
        dsll    $2,$2,17
        daddiu  $2,$2,-30875
        dsll    $2,$2,16
        daddiu  $2,$2,17185
    

    Many other RISC architectures have more efficient ways to load an immediate so they need less instructions, but still at least 4. Maybe the instruction cache cost is lower than data cache cost in those cases, or maybe someone just don’t like that idea

    Here’s an example of handwritten constant pool on MIPS

    # load pool base address
        dla $s0, pool
    foo:
    # just some placeholder
        addu $t0, $t0, $t1
    bar:
    # load from pool
        ld $a0, pool_foo($s0)
        ld $a1, pool_bar($s0)
    
    .section pool
    # macro helper to define a pool entry
    .macro ENTRY label
    pool_entry_\label\(): .quad \label
    .equ pool_\label\(), pool_entry_\label - pool
    .endm
    ENTRY foo
    ENTRY bar
    

    I failed to persuade any MIPS compilers to emit a literal pool but here’s a compiler-generated example on ARM

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

Sidebar

Related Questions

I know this probably really simple but Im not sure what im doing wrong...
This probably has a simple answer, but I must not have had enough coffee
This is probably a simple question but I am not an ASP.NET developer and
This is probably really simple, and the answer is probably really obvious, but I'm
This is probably really obvious and simple - but it isn't to me with
This is probably a question that has an easy/simple/obvious answer, but I've found myself
The solution is probably obvious, but I do not see it. I have this
This is probably simple but I do not seem to get it to work.
This is probably a simple answer but I can't find it. I have a
This is probably a simple question, and I'm slightly embarrassed to ask it, but

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.