为什么这个机器代码是为“inc qword [rsp]”生成的?

时间:2012-09-29 19:50:07

标签: assembly 64-bit nasm machine-code

考虑这个x64 NASM语法程序集:

inc qword [rax]
inc qword [rcx]
inc qword [rdx]
inc qword [rbx]
inc qword [rsp]
inc qword [rbp]
inc qword [rsi]
inc qword [rdi]

使用nasm进行汇编(并与gnu ld链接)后,objdump -d会报告以下内容:

4000b0:       48 ff 00                incq   (%rax)
4000b3:       48 ff 01                incq   (%rcx)
4000b6:       48 ff 02                incq   (%rdx)
4000b9:       48 ff 03                incq   (%rbx)
4000bc:       48 ff 04 24             incq   (%rsp)
4000c0:       48 ff 45 00             incq   0x0(%rbp)
4000c4:       48 ff 06                incq   (%rsi)
4000c7:       48 ff 07                incq   (%rdi)

inc qword [rbp]生成的代码有意义,因为设置了mod字段。但是,在汇编24时,我无法确定inc qword [rsp]来自哪里。我一直在关注coder64 #xFF并且没有任何迹象告诉我应该生成24。我显然错过了更高层次的东西。

1 个答案:

答案 0 :(得分:7)

没有[RSP] ModR / M字节。所以它使用[sib] ModR / M. sib表示有sib byte,0x24是RSP的sib字节。