2

SDCC 的汇编器源自 ASxxxx,其中手册在此处描述了 .define 命令:http: //shop-pdp.net/ashtml/asxs02.htm#define

由于它是派生的,因此可能并非所有内容都以相同的方式工作,但是由于命令行参数 help 谈论 .define ("-b Display .define substitions in Listing") 我假设它们在那里。

但是,当我这样做时:

.define ay /-1/

我得到错误:

g.s:1: Error: <o> .org in REL area or directive / mnemonic error

我尝试过的其他形式包括:

.define ay ^/-1/
.define ay "-1"
.define kword /foo/

所有这些都导致了同样的错误。如果我尝试

.define

错误变为:

g.s:1: Error: <q> missing or improper operators, terminators, or delimiters

虽然我得到了同样.blarg的错误,所以关键字可能已被删除(为什么?)

我做错了什么,还是 sdasz80 刚刚坏了?

4

3 回答 3

2

废话,似乎这是他们出于某种原因删除的功能。搜索 SDCC 源的 github 镜像(这里的 sdas 源:https ://github.com/svn2github/sdcc/tree/master/sdcc/sdas )SDCC 的 asxxxx.h(上次编辑 6 年前)有这个块:

/*
 *      The def structure is used by the .define assembler
 *      directive to define a substitution string for a
 *      single word.  The def structure contains the
 *      string being defined, the string to substitute
 *      for the defined string, and a link to the next
 *      def structure.  The defined string is a sequence
 *      of characters not containing any white space
 *      (i.e. NO SPACEs or TABs).  The substitution string
 *      may contain SPACES and/or TABs.
 */
struct def
{
        struct def      *d_dp;          /* link to next define */
        char            *d_id;          /* defined string */
        char            *d_define;      /* string to substitute for defined string     */
        int             d_dflag;        /* (1) .defined / (0) .undefined */
};

但据我所知,该结构并未在任何地方使用。

于 2018-12-04T09:19:51.710 回答
1

还要考虑到与 SDCC 一起提供的 sdasz80 是旧版本的 ASxxxx。事实上,他们的 sdasz80 随附的文档是针对更新版本的 ASxxxx 的,并且某些功能实际上在随附的版本中不存在。

如果您想要这些功能和更新的功能,您可以从其网站下载更新版本的 ASxxxx。有许多更新的版本,包括新的有趣功能的文档。最新版本从 2019 年 1 月开始:http: //shop-pdp.net/ashtml/asxxxx.php

于 2019-03-08T20:52:27.290 回答
1

出于多种目的,您可以使用变量。这将适用于 sdasz80(SDCC 修订版)

SOME_IO_ADDRESS = 0x32
[...]
LD A, #0xAA
OUT (#SOME_IO_ADDRESS), A
于 2019-06-03T13:04:13.190 回答