assembly - 如何使用 nasm 编译 x86 汇编代码?我收到一个错误
问题描述
我一直在尝试在 Linux 上学习 x86 汇编,这是我的代码:
.386
.model flat
.code
start PROC
mov eax, 100
add eax, 200
ret
start endp
end start
每当我尝试用 nasm 编译它时,就像这样:
nasm -f elf32 -o <filename>.o <filename>.asm
ld -m elf_i386 -o <filename> <filename>.o
我收到此错误:
simple.asm:1: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
simple.asm:1: error: attempt to define a local label before any non-local labels
simple.asm:2: error: attempt to define a local label before any non-local labels
simple.asm:2: error: parser: instruction expected
simple.asm:3: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
simple.asm:3: error: attempt to define a local label before any non-local labels
simple.asm:4: error: parser: instruction expected
simple.asm:9: error: symbol `start' redefined
simple.asm:9: error: parser: instruction expected
simple.asm:10: error: parser: instruction expected
为什么我会收到这个错误?是编译器还是代码?以及如何解决?
解决方案
推荐阅读
- python-3.x - 如何展平列表中的两个或多个数组?
- java - arg4j 选项但没有参数
- github-actions - 带有 ESP-IDF 编译的 GitHub Actions
- python - 我怎样才能得到之间的文字使用 Selenium 导入 webdriver?
- .net - 如何从 NLOG 中的模板动态添加连接字符串“凭据”
- java - 如何使用 GZipOutputStream 获得中间压缩大小?
- java - Spring Cloud Stream 3.0.7 测试逻辑
- amazon-web-services - Terraform aws:[WARN] 可重试错误:拨打 tcp:在 127.0.0.53:53 上查找 self.public_ip:没有这样的主机
- python - 如何从pdf文件中提取几行?
- c# - 如何按比例拍摄图片框的屏幕截图