Era*_*lpB 3 assembly forward-reference x86-16 a86
我正在尝试使用 A86 为 8086 汇编一些代码。我将问题缩小到 4 行代码。
MOV BX, testz
ADD AL, [testz]
INT 20h
testz:
~ ^
#ERROR 16: Definition Conflicts With Forward Reference @@@@#
db ?
Run Code Online (Sandbox Code Playgroud)
你认为这段代码有什么问题?我将地址本身移动到 BX 寄存器并将 testz 地址中的字节值添加到 AL。
在一个更大的程序中,我也得到了#ERROR 13: Byte/Word Combination Not Allowed.
但是label是一个字 where[label]是一个字节。为什么我的编译器不能区分这些?
ADD BL, [second]
MOV BX, second
~ ^
#ERROR 13: Byte/Word Combination Not Allowed
second:
~ ^
#ERROR 16: Definition Conflicts With Forward Reference @@@@#
db ?
Run Code Online (Sandbox Code Playgroud)
因为我看不到任何字节/字冲突。
我的编译器同等地解释 offset testz 和 testz 。我查看了字节码,看不出任何区别。
MOV BX, testz
ADD AL, [BX]
Run Code Online (Sandbox Code Playgroud)
上面的代码有效,但是有没有其他方法可以在一行中执行此操作,例如
ADD AL, [testz]
Run Code Online (Sandbox Code Playgroud)
每当我在 [] 中放置标签名称时,根据我的编译器 a86,这是不可接受的。但我觉得他们在语言中是允许的。
我怀疑你想要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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
982 次 |
| 最近记录: |