将 %substr 与 NASM 汇编程序一起使用

Using %substr with NASM assembler

我从 NASM 文档 pdf 第 46 页复制粘贴了以下代码:

%substr mychar ’xyzw’ 1 ; equivalent to %define mychar ’x’

组装后出现以下错误:

`%substr` requires string as second parameter

但是在我将“xyzw”更改为 'xyzw' 或 "xyzw" 后它工作正常。那么我在这里缺少什么?

online documentation

中显示了正确的语法
%substr mychar 'xyzw' 1       ; equivalent to %define mychar 'x' 

一般来说,对于预处理器字符串函数,它会讨论字符串和字符串字面量,这些内容有解释 here 并且可以用单引号、双引号和反引号括起来:

String constants are character strings used in the context of some pseudo-instructions, namely the DB family and INCBIN (where it represents a filename.) They are also used in certain preprocessor directives.

A string constant looks like a character constant, only longer.

以及关于character constants(实际解释分隔符的地方):

A character string consists of up to eight characters enclosed in either single quotes ('...'), double quotes ("...") or backquotes (`...`). Single or double quotes are equivalent to NASM (except of course that surrounding the constant with single quotes allows double quotes to appear within it and vice versa); the contents of those are represented verbatim. Strings enclosed in backquotes support C-style -escapes for special characters.

如评论中所述,很可能 PDF 被文字处理器弄乱了,太急于排版漂亮的字符而不是正确的字符。