如何修复 Microsoft 16 位链接器上的错误 L2029?

How to fix error L2029 on microsoft 16-bit linker?

我正在尝试 assemble 调试。exe/com 来自 MS-DOS 2.0 source code,起初它没有用,但我一直在更改一些文件名并且我已经成功了要获取 .obj 文件,使用 link(16 位版本)在某些命令上出现错误(错误 L2029:未解析的外部),我不知道该怎么做,是否需要添加一些图书馆?

以下是失败的错误和命令:

batch
C:\Users\<my_username>\Desktop\Assembly>link16.exe

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

Object Modules [.obj]: debug.obj
Run File [debug.exe]: 
List File [nul.map]:
Libraries [.lib]:
Definitions File [nul.def]:
LINK : warning L4021: no stack segment

debug.obj(DEBUGGER) : error L2029: 'PARSERR' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'GO' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'REG' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'NAME' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'BYTEBUF' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'RELEASEPARITY' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DUMP' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'FILL' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DEFIO' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'LINEBUF' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'COMPARE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DSIZ' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'MOVE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'LOAD' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DEFDUMP' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'PARITYMES' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DISPB' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'TRACE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'TRAPPARITY' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'PERR' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'HEADSAVE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'BADVER' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DATAEND' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'ASSEM' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'LBUFSIZ' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'SPSAVE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'ENDMES' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'BACMES' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'ASMADD' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'SKIP_FILE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'PREPNAME' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'NEWEXEC' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'ZTRACE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DSSAVE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DISADD' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DWRITE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'DEBUG_FOUND' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'STACK' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'SEARCH' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'ENTER' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'QFLAG' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'INPUT' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'PARITYFLAG' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'UNASSEM' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'GETHEX' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'GETEOL' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'CSSAVE' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'CARRET' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'NOREGL' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'OUTPUT' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'USER_PROC_PDB' : unresolved external
debug.obj(DEBUGGER) : error L2029: 'IPSAVE' : unresolved external


There were 52 errors detected

我使用的代码、工具和其他依赖可以从here下载。

如何修复这些未解决的错误?

unresolved external linker 错误告诉您在您正在处理的目标文件中找不到它的符号。在您的情况下,您只是将 DEBUG.ASM 组装到 DEBUG.OBJ,然后将 link 组装到 DEBUG.EXE。粗略地看一下 MS-DOS 2.0 source code 表明许多缺失的符号在 DEBDATA.ASMDEBCONST.ASMDEBCOM2.ASM 中(也许是其他文件,但其中 3 个包含大部分这些符号).您需要将这些 ASM 文件 assemble 转换为目标文件,然后 link 它们与您的 DEBUG.OBJ 一起生成最终的 DEBUG.EXE 可执行文件。

当 linking 时,如果您有未解析的符号,您将需要找到定义这些符号的文件,然后以某种方式 assemble 和 link 将它们添加到您的程序中。

我为 assemble MS-DOS 2.00 的调试编写了一个脚本。这是脚本:https://hg.ulukai.org/ecm/msdos2/file/05669dfa5edd/v2.0/source/debug/makdebug.bat 完整引用:

@echo %DEBUG%off
masm debug debug debug;
masm debasm debasm debasm;
masm debcom1 debcom1 debcom1;
masm debcom2 debcom2 debcom2;
masm debconst debconst debconst;
masm debdata debdata debdata;
masm debmes debmes debmes;
masm debuasm debuasm debuasm;
link debug debasm debcom1 debcom2 debconst debdata debmes debuasm;
exe2bin debug
move /y debug.bin debug.com

在我的回购协议中,我还将所有文件移动到一个子目录中。