Is there an easy way or macro to load a 64-bit address into mips64 GPR

I want to load a 64-bit address into the MIPS64 General Purpose Register (GPR). I can do it with

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] 

But is there any other way to do this?

I received information from this

But I want to know what a "permanent pool" is and how to create it and how to get it?

0
assembly mips
source share
1 answer

A β€œsimple” way is to let the assembler process it using the dla pseudo- dla . It will expand approximately to your code:

 lui $dst, LabelAddr[63:48] lui $at, LabelAddr[31:16] daddiu $dst, $dst, LabelAddr[47:32] daddiu $at, $at, LabelAddr[15:0] dsll32 $dst, $dst, 0 daddu $dst, $dst, $at 

A persistent pool is a memory area in which you store your constants that can be solved efficiently. Some assemblers and architectures have special support for this; on others, you must do something manually. As indicated in the answer to your question, you can set the pointer to your permanent pool (using the above method) and use more efficient access for subsequent operations.

 # 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 
+2
source share

All Articles