我怎么知道MASM是使用相对偏移还是绝对偏移对我的JMP指令进行编码? [英] How do I know whether MASM encodes my JMP instruction using a relative or absolute offset?

查看:122
本文介绍了我怎么知道MASM是使用相对偏移还是绝对偏移对我的JMP指令进行编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么知道MASM是使用相对偏移还是绝对偏移对我的JMP指令进行编码?

How do I know whether MASM encodes my JMP instruction using a relative or absolute offset?

我知道x86提供了相对和绝对偏移量的JMP操作码.

I know that x86 provides JMP opcodes for relative and absolute offsets.

我想确定我的跳跃是相对的,但是我找不到任何合适的MASM文档来告诉我JMP @label是否实际上转换为相对跳跃.

I want to be certain that my jumps are relative, however I cannot find any proper MASM documentation telling me whether JMP @label actually translates into a relative jump.

请尽可能在答案中提供指向文档的链接.

Please, if possible, give a link to documentation in the answer.

对于相反的问题: 参见如何编码远为绝对的JMP/CALL如果您要尝试使MASM发出直接绝对远距离jmp

For the opposite issue: See How to code a far absolute JMP/CALL instruction in MASM? if you're trying to get MASM to emit a direct absolute far jmp

推荐答案

唯一的机器编码直接在jmp附近使用相对位移,而不是绝对位移.另请参阅标签Wiki的问题,以获取指向文档的更多链接/手册,包括MASM官方手册.不过,对于这个问题,我认为毫无意义.

The only machine encodings for direct near jmps use relative displacements, not absolute. See also the x86 tag wiki for more links to docs / manuals, including the official MASM manual. I don't think there's any point wading through it for this issue, though.

没有Near- jmp会立即进行绝对位移,因此没有汇编程序会意外地使用非PIC分支的风险.

There is no near-jmp that takes an immediate absolute displacement, so there's no risk of an assembler ever using a non-PIC branch unexpectedly.

绝对近跳转需要寄存器或内存操作数中的地址,因此MASM不能仅将jmp target组装为

An absolute near jump would require the address in a register or memory operand, so MASM can't just assemble jmp target into

section .rodata
pointer_to_target dq target          ; or dd for a 32bit pointer

section .text
jmp    [pointer_to_target]

因为那太荒谬了.如果您找到IDK来说明这种特定的精神错乱是绝对不可能的,则可以使用IDK.

because that would be ridiculous. IDK if you'd ever find documentation stating that this specific piece of insanity is specifically impossible.

我想像的唯一方法是,如果有某种巨大的代码模型",所有跳转目标都使用64位指针而不是32位相对位移来引用,那么汇编程序会为您做这样的事情.

The only way I could imagine an assembler doing anything like this for you is if there was some kind of "Huge code model" where all jump targets were referenced with 64 bit pointers instead of 32 bit relative displacements.

但是AFAIK,如果要执行此操作,则必须在所有现有的汇编程序中自行执行.

But AFAIK, if you want to do that, you have to do it yourself in all existing assemblers.

文档变得很without肿,而没有提到程序没有做的所有奇怪的事情,所以我不希望找到关于此的任何具体信息.这可能是被认为很明显并且不用说的事情之一. (或者语法与英特尔在其指令参考手册中使用的语法匹配.)

Documentation gets bloated enough without mentioning every weird thing that a program doesn't do, so I wouldn't expect to find anything specific about this. This is probably one of those things that's assumed to be obvious and goes without saying. (Or that the syntax matches what Intel uses in their instruction reference manual.)

正如Jester所说的,不要求就不会得到far跳转,因此,对于普通的jmp,没有任何汇编程序使用JMP ptr16:32编码(EA imm16(segment) imm32(offset))的风险.

As Jester says, you won't get a far jump without asking for it, so there's no risk of any assembler using the JMP ptr16:32 encoding (EA imm16(segment) imm32(offset)) for a normal jmp.

这篇关于我怎么知道MASM是使用相对偏移还是绝对偏移对我的JMP指令进行编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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