【问题标题】:nasm "error: comma, colon, decorator or end of line expected after operand"nasm“错误:操作数后应有逗号、冒号、装饰符或行尾”
【发布时间】:2017-08-05 10:06:07
【问题描述】:

我使用的是 Debian 9。这些是错误:

andrea@debian:~/Assembly/sandbox$ nasm -f elf -g -F stabs sandbox.asm
sandbox.asm:8: error: comma, colon, decorator or end of line expected after operand
sandbox.asm:9: error: comma, colon, decorator or end of line expected after operand
sandbox.asm:11: error: comma, colon, decorator or end of line expected after operand
sandbox.asm:12: error: comma, colon, decorator or end of line expected after operand

这是代码:

section .data
section .text

global _start

_start:
    nop
    mov eax 10
    mov ebx 12

    mov eax 1
    mov ebx 0
    int 80H
    nop

section .bss

导致这些错误的问题是什么,我该如何解决?

如果我使用以下代码修复操作数之间的逗号,我会得到一个不同的错误:

section .data
section .text

    global_start

_start:
    nop
    mov eax,10
    mov ebx,12

    mov eax,1
    mov ebx,0
    int 80H
    nop

section .bss

我得到的错误是:

sandbox.asm:4: warning: label alone on a line without a colon might be in error

为什么会出现此错误,我该如何解决?

【问题讨论】:

  • 在您描述为“正确”的代码中,有global_start,看起来不正确。正如我在回答中所写,它应该是global _start。在此更正之后,您在尝试编译代码时是否遇到相同的错误集?

标签: linux assembly x86 nasm


【解决方案1】:

我想有一个空格丢失,应该是:

global _start

在第 4 行。

我还怀疑十六进制常量可能格式不正确,因为缺少 0 前缀,但只要数字以数字开头就应该没问题,正如 Michael Petch 提到的在 cmets 中(并根据此处提供的 NASM 文档:http://www.nasm.us/doc/nasmdoc3.html)。

【讨论】:

  • 我的错误,我发布了新代码,旧代码在 mnemonics.sorry.global _start 后缺少逗号也是错误的。
  • 没有必要在int 080h前面多加一个零。 int 80h 很好。如果第一个数字不在 0 和 9 之间,您只需将前导零放在开头。如果数字是 A0 十六进制,则必须是 0A0h,因为十六进制数字 A 不在 0 和 9 之间。
  • @Andrea 然后请编辑问题,以便显示您的实际代码!使用复制/粘贴复制您尝试组装的实际代码,不要给我们任何其他内容。
猜你喜欢
  • 2018-04-14
  • 2015-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-12
  • 2011-12-21
相关资源
最近更新 更多