无法通过段寄存器访问标签,汇编错误
INCLUDE Irvine16.inc
.data
byteArray BYTE 6 DUP(?)
listSize = ($ - byteArray)
aSum WORD 0
soffset = 0
.code
main PROC
mov ax, @data
mov ds, ax
mov cx, listSize
Loop1:
mov ax, 0
movzx ax, [byteArray + soffset]
add aSum, ax
soffset = soffset + 1
loop Loop1
exit
main ENDP
END main
我收到的错误是错误“A2074:无法通过段寄存器访问标签”
我试图使用 soffset 循环访问 byteArray。
INCLUDE Irvine16.inc
.data
byteArray BYTE 6 DUP(?)
listSize = ($ - byteArray)
aSum WORD 0
soffset = 0
.code
main PROC
mov ax, @data
mov ds, ax
mov cx, listSize
Loop1:
mov ax, 0
movzx ax, [byteArray + soffset]
add aSum, ax
soffset = soffset + 1
loop Loop1
exit
main ENDP
END main
The error I'm getting is error "A2074:cannot access label through segment registers"
I'm trying to use the soffset to loop through the byteArray.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此错误是由于尝试将 DOS 程序 (
.model
!= flat) 汇编为COFF
.obj 文件而引起的。此外,ML.EXE 会引发错误 A2006:未定义符号:DGROUP
。源代码应组装成旧式的OMF
文件。使用以下命令行构建文件:ml.exe
是 Visual Studio 安装的一部分。link16.exe
是 Irvine 库套件 的一部分( “示例程序和链接库源代码...”)。This error is caused by trying to assemble a DOS program (
.model
!= flat) to aCOFF
.obj file. Additionally ML.EXE throwserror A2006:undefined symbol : DGROUP
. The source should be assembled to an old fashionOMF
file. Build the file with following command lines:ml.exe
is part of the Visual Studio installation.link16.exe
is part of Irvine's library suite (" Example programs and link library source code...").我不确定 Irvine16.inc 中的内容,但我敢打赌它在某个时候会说
.modelsmall,...
。如果您添加,
那么您的错误消息将会消失,尽管我怀疑这是否足以使程序运行。
好吧,我有一个主意。我认为你应该切换到 32 位示例。这是一个平面模型,其中段寄存器由操作系统设置,而不由程序使用。我刚刚下载了 irvine 示例和示例项目,它恰好是 32 位的,已编译并运行。
在 x86 机器代码这个奇怪而扭曲的世界中,16 位模型比 32 位模型复杂得多,至少从用户程序的角度来看是这样。
I'm not sure what's in Irvine16.inc, but I bet it is saying
.model small,...
at some point.If you add
then your error messages will go away, although I doubt if that's enough to make the program run.
Ok, I've got an idea. I think you should switch to the 32-bit examples. That's a flat model where the segment registers are set up by the OS and not used by programs. I just downloaded the irvine examples and the sample project, which happens to be 32-bits did assemble and run.
In the wierd and twisted world that is x86 machine code, the 16-bit model is quite a bit more complex than the 32-bit model, at least from the point of view of a user program.