为什么 AT&T jmp *bar 组装成带有 SIB 字节的机器代码?指令中没有使用寄存器 [英] Why does AT&T jmp *bar assemble to machine code with a SIB byte? There's no register used in the instruction
问题描述
我在 x86 机器上有这个绝对间接跳转指令:
I have this absolute indirect jump instruction on x86 machine:
ff 24 25 30 10 60 00
产生于:
jmp *bar
但是我在解码它的第二个和第三个字节时遇到了麻烦.
but I've got trouble with decoding second and third byte of it.
第二个应该是 Mod R/M 字段.所以它转化为:
Second should be the Mod R/M field. So it translates to:
00 100 100
含义:
00
- 没有位移的内存(但它有常量地址,这不是位移"吗?)
00
- memory with no displacement (but it has the constant address, isn't this "displacement"?)
100
(dec. 4) - 扩展操作.代码 (FF/4 => JMP r/m32)
100
(dec. 4) - extended op. code (FF/4 => JMP r/m32)
100
- ??SIB?但是这个指令没有用到寄存器
100
- ?? SIB? but there is no register used in this instruction
附言一些背景:
Breakpoint 4, test () at test.s:13
13 jmp *bar
(gdb) disassemble /r
Dump of assembler code for function test:
0x000000000040051b <+0>: c7 04 25 30 10 60 00 2f 05 40 00 movl $0x40052f,0x601030
=> 0x0000000000400526 <+11>: ff 24 25 30 10 60 00 jmpq *0x601030
0x000000000040052d <+18>: 87 c0 xchg %eax,%eax
0x000000000040052f <+20>: c3 retq
End of assembler dump.
(gdb) list
8 bar: .word 0x0
9 .text
10 test:
11 .LFB0:
12 movl $label1, bar
13 jmp *bar
14 xchg %eax, %eax
15 label1:
16 ret
17 .LFE0:
(gdb)
推荐答案
操作数字节 24 25
表示具有 32 位位移的绝对寻址模式,即没有基址寄存器和索引寄存器.在 64 位模式下,这与 modr/m 字节 25
表示的 32 位位移的相对寻址模式不同(但在 32 位模式下不是).如果你想要后一种寻址方式,用AT&T语法写jmp *bar(%rip)
.
The operand bytes 24 25
indicate an absolute addressing mode with a 32 bit displacement, i.e. no base register and no index register. In 64 bit mode, this is distinct from the relative addressing mode with 32 bit displacement indicated by modr/m byte 25
(but in 32 bit mode it is not). If you want the latter addressing mode, write jmp *bar(%rip)
in AT&T syntax.
这篇关于为什么 AT&T jmp *bar 组装成带有 SIB 字节的机器代码?指令中没有使用寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!