2012-09-29 42 views
5

考慮這個64 NASM語法組件:爲什麼此機器代碼爲「inc qword [rsp]」生成?

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。我明顯錯過了更高層次的東西。

回答

7

沒有[RSP] ModR/M字節。所以它使用[sib] ModR/M。 sib表示有sib byte,而0x24是RSP的同胞字節。

+0

完美,謝謝! – jli

相關問題