2017-02-18 93 views
0

我复制粘贴在NASM文档PDF页面46下面的代码:与NASM汇编中使用%SUBSTR

`%substr` requires string as second parameter 

但atfer:

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

而且组装它,我收到以下错误后我把'xyzw'改为'xyzw'或者'xyzw',它的效果很好。那么我在这里错过了什么?

+1

最可能的是他们搞砸PDF - 可能还有一些文字处理器试图有点太聪明引号。 –

回答

1

正确的语法示于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是由文字处理器急于排版漂亮的字符,而不是正确的人搞砸了。

+0

谢谢,但它的方式不适用于反引号?是否有任何已知的情况(说明),其中一种字符串被接受而不是其他字符? –

+0

它与我相信的反引号合作。您的代码不工作时使用某种非常引号的,不是从他们'”,”,\''组。您'''。 – Ped7g

+0

@MaykelJakson它与反引号工作'\''但与性格,你剪切和粘贴'''。 –