1
原代码产生以下输出:处理器供应商ID是“GenuineIntel” 赫雷什原来的代码:转换AT&T语法程序Intel语法
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
我转化为英特尔执行,但不显示任何代码后在屏幕上输出组合:
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
在哪里以及如何定义输出?您将第9行movl $ output,%edi转换为mov edi,OFFSET输出,但另一方面,您将第16行movl $ output,%ecx转换为mov ecx,output。只有一个选择是正确的,但没有定义,哪一个是不确定的。 – zx485
nvm我刚添加OFFSET到第16行的intel代码。 – Yeezus
只是注意到我忽略了'输出'被定义为一个标签。但另一件令我想知道的事情是:原始代码中的第10行在哪里?它从9直到11。是否缺少一条线? – zx485