MASM32错误A2006,错误A2074和警告A4023

时间:2013-06-15 17:55:42

标签: assembly masm32

我很新闻。我从学习形式的书中得到以下代码。我下载了MASM32。我的电脑是Win7 64bit。我尝试构建以下代码:

.model small
.stack 100h

.data
a dw 2
b dw 5
sum dw ?

.code
main proc
mov ax, @data
mov ds, ax

mov ax, a
add ax, b
mov sum, ax

mov ax, 4c00h
int 21h

main endp
 end main

不幸的是,我收到以下错误:

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: C:\masm32\test.asm
C:\masm32\test.asm(11) : error A2006: undefined symbol : DGROUP
C:\masm32\test.asm(14) : error A2074: cannot access label through segment registers
C:\masm32\test.asm(15) : error A2074: cannot access label through segment registers
C:\masm32\test.asm(16) : error A2074: cannot access label through segment registers
C:\masm32\test.asm(22) : warning A4023: with /coff switch, leading underscore required for start address : main
_
Assembly Error
Press any key to continue . . .

我搜索了解决方案。我可以在error A2074:行之前添加ASSUME DS:_DATA来解决.data。我从这篇文章中接过它:Cannot access label through segment registers, error in assembly但不幸的是,解决方案没有解释为什么和这是什么?

为什么会出现这些错误以及如何解决这些错误?我是一个新手,需要一些细节,并在一开始就一步一步。

1 个答案:

答案 0 :(得分:1)

您需要使用16位Microsoft分段链接器链接16位DOS代码,而不是MASM32附带的增量链接器,从MS下载: 16 bit Microsoft Segmented Linker 5.60

解压缩到一个目录,然后将link.exe重命名为link16.exe,并将其放入/ masm32 / bin目录。您现在可以将link16用于16位DOS应用程序并链接32位应用程序。

您还需要使用正确的命令行参数来汇编16位代码,例如:assembly fatal error LNK1190: invalid fixup found, type 0x0001 当您使用64位操作系统时,您无法再本地运行16位DOS应用程序,您需要使用模拟器。我使用D-Fend Reloaded