是否有任何简单的方法或宏可以将64位地址加载到mips64 GPR中 [英] Is there any simple way or macro to load 64bit address into mips64 GPR

查看:302
本文介绍了是否有任何简单的方法或宏可以将64位地址加载到mips64 GPR中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将64位地址加载到MIPS64通用寄存器(GPR)中.我可以做到

I want to load 64 bit address into MIPS64 General Purpose Register(GPR). I can do it by

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 it?

我从

但是我想知道什么是常量池",如何创建它以及如何访问它?

But i want to know what is "constant pool" and how to create it and how to access it?

推荐答案

简单"的方法是让汇编器使用dla伪指令对其进行处理.它将扩展为类似于您的代码的内容:

The "simple" way is to let the assembler handle it using the dla pseudoinstruction. It will expand to something like 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 constant pool is an area of memory where you store your constants that can be addressed efficiently. Some assemblers and architectures have special support for this, on others you have to do things manually. As outlined in the answer to the question you linked, you can set up a pointer to your constant 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

这篇关于是否有任何简单的方法或宏可以将64位地址加载到mips64 GPR中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆