yasm:预期的 `,' 具有立即值
yasm: Expected `,' with immediate value
给定以下汇编程序:
BITS 64
mov rax, 0b111
Yasm 输出:
error: expected `,'
为什么这里需要逗号? NASM 愉快地组装了这个。
来自 YASM 手册:
3.5.1. Numeric Constants
A numeric constant is simply a number. NASM allows you to specify numbers in a variety of number bases, in a variety of ways: you can suffix H, Q or O, and B for hex, octal, and binary, or you can prefix 0x for hex in the style of C, or you can prefix $ for hex in the style of Borland Pascal.
Some examples:
mov ax,10010011b ; binary
NASM手册增加:
In addition, current versions of NASM accept the prefix 0h for hexadecimal, 0d or 0t for decimal, 0o or 0q for octal, and 0b or 0y for binary.
TL;DR:虽然 NASM 支持二进制文字的 b
后缀和 0b
前缀,但 YASM 仅支持后缀变体。所以0b111
需要写成111b
.
给定以下汇编程序:
BITS 64
mov rax, 0b111
Yasm 输出:
error: expected `,'
为什么这里需要逗号? NASM 愉快地组装了这个。
来自 YASM 手册:
3.5.1. Numeric Constants
A numeric constant is simply a number. NASM allows you to specify numbers in a variety of number bases, in a variety of ways: you can suffix H, Q or O, and B for hex, octal, and binary, or you can prefix 0x for hex in the style of C, or you can prefix $ for hex in the style of Borland Pascal.
Some examples:
mov ax,10010011b ; binary
NASM手册增加:
In addition, current versions of NASM accept the prefix 0h for hexadecimal, 0d or 0t for decimal, 0o or 0q for octal, and 0b or 0y for binary.
TL;DR:虽然 NASM 支持二进制文字的 b
后缀和 0b
前缀,但 YASM 仅支持后缀变体。所以0b111
需要写成111b
.