[英]Converting AT&T syntax program to intel syntax
原始代碼產生以下輸出:處理器供應商ID為'GenuineIntel'。此處為原始代碼:
1. .section .data
2. output:
3. .ascii “The processor Vendor ID is ‘xxxxxxxxxxxx’\n”
4. .section .text
5. .globl _start
6. _start:
7. movl $0, %eax
8. cpuid
9. movl $output, %edi
11. movl %ebx, 28(%edi)
12. movl %edx, 32(%edi)
13. movl %ecx, 36(%edi)
14 movl $4, %eax
15. movl $1, %ebx
16. movl $output, %ecx
17. movl $42, %edx
18. int $0x80
19. movl $1, %eax
20. movl $0, %ebx
21. int $0x80
我執行的轉換為intel可以執行,但是在匯編代碼后屏幕上不會顯示任何輸出:
1. .intel_syntax noprefix
2. .section .data
3. output:
4. .ascii "The processor Vendor ID is 'xxxxxxxxxxxx'\n"
5. .section .text
6. .globl _start
7. _start:
8. mov eax, 0
9. cpuid
10. mov edi, OFFSET output
11. mov [edi+28], ebx
12. mov [edi+32], edx
13. mov [edi+36], ecx
14. mov eax, 4
15. mov ebx, 1
16. mov ecx, output
17. mov edx, 42
18. int 0x80
19. mov eax, 1
20. mov ebx, 0
21. int 0x80
如果您的代碼中沒有注釋,則可以先進行匯編,然后再使用其他語法進行匯編,以此作為一個良好的開端。
如果有的話,將注釋移到其他位置可能會更容易/不太容易/不太容易出錯。 這樣做可能會不方便保留全局符號名稱,但是某些反匯編程序可以使用符號表。
即使您決定手動執行此操作,也可以通過組裝AT&T和NASM版本來確定是否出錯。 如果這些二進制文件反匯編成相同的代碼,那就太好了 。 如果沒有,您應該迅速找出它們不同的地方。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.