[A86-定义与前向引用冲突

问题描述 投票:3回答:3

我正在尝试使用A86为8086汇编一些代码。我将问题缩小为4行代码。

MOV BX, testz
ADD AL, [testz]

INT 20h
testz:
~     ^
#ERROR 16: Definition Conflicts With Forward Reference                    @@@@#
db ?

您认为此代码有什么问题?我将地址本身移至BX寄存器,并将testz地址中的字节值添加至AL。

在更大的程序中,我也得到#ERROR 13: Byte/Word Combination Not Allowed

但是label是一个单词,其中[label]是一个字节。为什么我的编译器不能区分这些?

ADD BL, [second]
MOV BX, second
~             ^
#ERROR 13: Byte/Word Combination Not Allowed   
second:
~      ^
#ERROR 16: Definition Conflicts With Forward Reference                    @@@@#
db ?

因为我看不到任何字节/字冲突。


我的编译器对偏移量testz和testz的解释相同。我查看了字节码,看不出任何区别。

MOV BX, testz
ADD AL, [BX]

上面的代码可以用,但是还有其他方法可以像这样一行吗?

ADD AL, [testz]

[每当我在[]中放置标签名称时,根据我的编译器a86,这都是不可接受的。但是我认为他们可以使用该语言。

assembly x86-16 forward-reference a86
3个回答
5
投票

我怀疑您想要MOV BX, offset testz。看来您的汇编器将[testz]testz解释为同一意思。

您可以尝试改用等价的LEA BX, testz来确认这一点>

编辑:(来自http://www.csn.ul.ie/~darkstar/assembler/manual/a14.txt):

ERROR 16: Definition Conflicts With Forward Reference

   This error occurs when the assembler has previously guessed
   the type of a forward-referenced symbol in order to determine
   what kind of instruction to generate, and the guess turned out
   to be wrong.  The error is reported at the time the symbol is
   defined.  For example, when A86 sees MOV AX,FOO, it will
   assume FOO is an immediate value.  This error is reported if
   FOO turns out to be a word variable: FOO DW 0.  You need to
   search backwards from the error message, to references of FOO,
   and specify the type you intend to be used: MOV AX,FOO W.  If
   you really did intend to load the offset of FOO and not the
   memory contents, you can code MOV AX,OFFSET FOO to make the
   error message go away.

3
投票

您遇到的问题源于A86是单遍汇编程序的事实。在定义符号之前使用testzsecond之类的符号时,A86必须猜测它们是什么。它假定它们将是立即值,但后来发现它们实际上是标签。多阶段汇编器可能会返回并更改先前做出的决定,但是A86不会这样做。它只是提出一个错误(#16)。这就是错误在定义附近的源文件中显示的原因:这是A86发现问题的所在。


1
投票

DOS手册为这样的处理程序指示了指针:

© www.soinside.com 2019 - 2024. All rights reserved.