相对VS绝对JMP在大会 [英] Relative vs Absolute jmp in Assembly

查看:228
本文介绍了相对VS绝对JMP在大会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道以下。我已经编写汇编语言,IA32被设计以这样一种方式,以促进使用相对跳跃即跳字节的位移量VS在存储器使用绝对跳转即变化EIP的一个特定的地址时,注意到了。这是什么逻辑背后?

I was wondering about the following. I've noticed when writing assembly language that IA32 is designed in such a way as to promote the use of relative jumps i.e. jump a displacement amount of bytes vs the use of absolute jumps i.e. change eip to a specific address in memory. What is the logic behind this?

推荐答案

大多数跳跃是目标不远处跳转指令。由于设置跳转指令是取一个符号的16位值,它们可以比所需的绝对跳转(通常为4个字节加上该指令本身)。

Most jumps are to targets not far away from the jump instruction. Since jump instructions are provided that take a signed 16-bit value, they can be fewer bytes than needed for an absolute jump (usually 4 bytes plus the instruction itself).

相对的一个分支小的额外好处是,他们并不需要在连接器是固定的,或者,对于这个问题,通过在PIC所需的额外间接(位置无关code)。

One small additional advantage of relative branches is that they don't need to be fixed up in the linker, or, for that matter, go through the extra indirection needed in PIC (position independent code).

这篇关于相对VS绝对JMP在大会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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