Assembly SASM程序集IDE 64示例编译错误“;地址大小的不可能组合”;关于打印字符串msg
我使用的是64位Windows 7,我从这里下载了SASM程序集IDE: 其中包括几个hello world示例。NASM示例编译良好,但NASM 64位给出了一个编译错误 NASM 64位代码为:Assembly SASM程序集IDE 64示例编译错误“;地址大小的不可能组合”;关于打印字符串msg,assembly,x86,nasm,sasm,Assembly,X86,Nasm,Sasm,我使用的是64位Windows 7,我从这里下载了SASM程序集IDE: 其中包括几个hello world示例。NASM示例编译良好,但NASM 64位给出了一个编译错误 NASM 64位代码为: %include "io64.inc" section .data msg db 'Hello, world!', 0 section .text global CMAIN CMAIN: mov ebp, esp; for correct debug
%include "io64.inc"
section .data
msg db 'Hello, world!', 0
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
mov rbp, rsp
PRINT_STRING msg
NEWLINE
xor rax, rax
ret
编译错误是:
Build started...
Warning! Errors have occurred in the build:
C:\Temp\SASM\program.asm:11: error: impossible combination of address sizes
C:\Temp\SASM\program.asm:11: error: impossible combination of address sizes
C:\Temp\SASM\program.asm:11: error: impossible combination of address sizes
C:\Temp\SASM\program.asm:12: error: impossible combination of address sizes
C:\Temp\SASM\program.asm:12: error: impossible combination of address sizes
C:\Temp\SASM\program.asm:12: error: impossible combination of address sizes
gcc.exe: error: C:\Temp\SASM\program.o: No such file or directory
为什么我会出现这个错误/发生了什么,这样我才能理解,我该如何修复它?显然,您在标题中输入该消息的原因是NASM没有创建一个
.o
,因为它告诉了您一些错误消息。与构建脚本一样,第一个错误通常是最重要的,后面的错误通常只是结果。@PeterCordes我没有手动移植任何东西。安装时附带了示例代码。我的错误是,我只浏览了链接页面,看到了一个类似32位代码的屏幕截图,包括mov ebp,esp
。我假设SASM附带的任何示例(甚至在教程中的任何尝试)都不会使用mov ebp,esp
将堆栈指针的低32位零扩展到RBP,然后这次使用mov RBP,rsp
正确重试,因为这是一个糟糕的示例。(也没有保存/恢复RBP。)如果SASM附带了这个确切的代码,那么我希望实际的IDE比示例维护得更好。链接的文档说,PRINT\u STRING
应该与一个裸标签名(如msg
)一起使用,但也与地址表达式一起使用,因此可能值得尝试PRINT\u STRING[rel msg]
。就像我说的,要想真正弄清楚它为什么会断裂,你必须看一下宏定义。我找到了与你的代码相似的宏定义,只是它没有那条mov ebp,esp
行。这并不是问题所在,但很显然,实际的SASM示例并不疯狂。