java - 程序怎么可能超过 2^16 字节?

标签 java c assembly memory-address

在汇编 (MIPS) 中,立即指令具有以下格式:

+----------+------+------+-------+
|  opcode  |  rs  |  rt  |  IMM  |
+----------+------+------+-------+

在哪里,

Opcode = 6 bits
Source register (rs) = 5 bits
Destination register (rt) = 5 bits
Immediate value (IMM) = 16 bits

也就是说,您可以跳转到远离当前指令(分支指令)的另一条指令 2^16 字节 = 64 kb 代码。程序(C、Java 等)怎么可能超过 2^16 字节的代码?

编辑:

正如@trashgod 所指出的,编译器可以使用 J instructions反而。但它仍然限于 26 位 地址,这意味着程序不能跨越 256MB。那么,这怎么可能呢?

最佳答案

我不是MIPS专家,但相对跳转的最大偏移与程序本身的大小无关。

跳转可以由编译器序列化或在汇编代码中手动序列化。这样一来,人们就可以毫无问题地向上或向下跳跃任何距离。

;it is pseudo code, not mips
start:
        jmp  to_the_limit
        .....
        .... 256MB bloated code
        ....
to_the_limit:
        jmp  even_further
        ....
        .... another 256MB of even more bloated code.
        ....
even_further:
        jmp  this_code

关于java - 程序怎么可能超过 2^16 字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19439926/

相关文章:

assembly - 重定位被截断以适合 : 16 against `.text'

assembly - 16 位端口地址的 32 位分配

java - Weka:Src 和 Dest 的属性数量不同:使用 java

c - 高斯消除期间段错误(核心转储)

c - 将有符号的 char 数组传递给需要 const char 指针的函数会导致数组值出现乱码

使用 libCURL 在 C 中创建 Azure Blob 存储

assembly - 避免固件意外覆盖

java - Android OpenCV - CameraBridgeViewBase 拍照?

java - 阅读日历日期

java - 使用 Apache Camel 和 spring-ws 组件调用基于 SOAP 的服务