我一直在尝试编译一个在Windows XP上运行tasm的asm文件。
Tasm32版本 - Turbo Assembler Version 5.0 Copyright (c) 1988, 1996 Borland International
Turbo Link Version 1.6.71.0 Copyright (c) 1993,1996 Borland International
将我当前的目录设置为tasm\bin
我已经能够执行以下操作 -
TASM32 /m29A /ml filename.asm
这会生成正常的.Obj文件。到现在为止还挺好。然后我尝试使用 -
进行链接TLINK32 -Tpe -aa -x filename.obj,,,"kernel32.lib"
我正在使用kernel32.lib的适当路径
但它引发了以下错误 -
Fatal: Unable to open file 'filename.obj,,,C:\Program Files\Microsoft SDKs\Windo
ws\v6.0A\Lib\Kernel32.lib'
我对asm知之甚少,谷歌也在寻找解决方案,但我似乎无法找到解决方案。似乎链接器将所有内容都作为一个文件。
任何帮助都将受到赞赏,因为我完全在海上如何解决这个问题。
谢谢。
答案 0 :(得分:1)
我安装了Borland C ++ Builder 5,其中包括tasm32和tlink32。 TASM32的命令行选项打印如下:
Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise Corporation
Syntax: TASM [options] source [,object] [,listing] [,xref]
/a,/s Alphabetic or Source-code segment ordering
/c Generate cross-reference in listing
/dSYM[=VAL] Define symbol SYM = 0, or = value VAL
/e,/r Emulated or Real floating-point instructions
/h,/? Display this help screen
/iPATH Search PATH for include files
/jCMD Jam in an assembler directive CMD (eg. /jIDEAL)
/kh# Hash table capacity # symbols
/l,/la Generate listing: l=normal listing, la=expanded listing
/ml,/mx,/mu Case sensitivity on symbols: ml=all, mx=globals, mu=none
/mv# Set maximum valid length for symbols
/m# Allow # multiple passes to resolve forward references
/n Suppress symbol tables in listing
/os,/o,/op,/oi Object code: standard, standard w/overlays, Phar Lap, IBM
/p Check for code segment overrides in protected mode
/q Suppress OBJ records not needed for linking
/t Suppress messages if successful assembly
/uxxxx Set version emulation, version xxxx
/w0,/w1,/w2 Set warning level: w0=none, w1=w2=warnings on
/w-xxx,/w+xxx Disable (-) or enable (+) warning xxx
/x Include false conditionals in listing
/z Display source line with error message
/zi,/zd,/zn Debug info: zi=full, zd=line numbers only, zn=none
TLINK32的命令行选项打印如下:
Turbo Link Version 2.5.0.0 Copyright (c) 1993,1998 Borland International
Syntax: TLINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
@xxxx indicates use response file xxxx
-m Map file with publics -x No map
-s Detailed segment map -L Specify library search paths
-M Map with mangled names -j Specify object search paths
-c Case sensitive link -v Full symbolic debug information
-Enn Max number of errors -n No default libraries
-P- Disable code packing -H:xxxx Specify app heap reserve size
-OS Do smart linking
-B:xxxx Specify image base addr -Hc:xxxx Specify app heap commit size
-wxxx Warning control -S:xxxx Specify app stack reserve size
-Txx Specify output file type -Sc:xxxx Specify app stack commit size
-Tpx PE image -Af:nnnn Specify file alignment
(x: e=EXE, d=DLL) -Ao:nnnn Specify object alignment
-ax Specify application type -o Import by ordinals
-ap Windowing Compatible -Vd.d Specify Windows version
-aa Uses Windowing API -r Verbose link
所以你的链接器命令行
TLINK32 -Tpe -aa -x filename.obj,,,"kernel32.lib"
有以下选项:-Tpe表示输出文件类型PE exe, -aa表示应用程序类型“使用Windowing API”, -x表示没有地图。 由于未指定-n选项,因此将包含默认运行时库。
然后有六个文件名列表。列表以逗号分隔。如果我没记错的话,文件名用空格分隔。
目前你有objfiles = filename.obj,resfiles = kernel32.lib,其他四个文件名列表都是空的。我认为你的意思是将kernel32.lib放在libfiles列表中。试试这个:
TLINK32 -Tpe -aa -x filename.obj, , , kernel32.lib, ,
如果您创建一个makefile,这个项目将更容易构建和维护,因为只需要一个额外的逗号来使链接器阶段失败。您已经体验过尝试调试神秘构建收件人的挫败感。
# makefile for Borland make
# *** not tested yet! no source code.
# Not compatible with nmake.
# May be compatible with gnu make.
#
# Borland Turbo Assembler
$(TASM32)=TASM32.exe
$(TASM32FLAGS)=/m29A /ml
#
# Borland Turbo Link
$(TLINK32)=TLINK32.exe
$(TLINK32FLAGS)=-Tpe -aa -x
#
# objfiles
$(OBJ)=filename.obj
#
# exefile
$(BIN)=filename.exe
#
# mapfile
$(MAP)=
#
# libfiles
$(LIBS)=kernel32.lib
#
# deffile
$(DEF)=
#
# resfiles
$(RES)=
all: all-before $(BIN) all-after
$(BIN): filename.asm
# Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise Corporation
# Syntax: TASM [options] source [,object] [,listing] [,xref]
.asm.o:
$(TASM32) $(TASM32FLAGS) $<
# Turbo Link Version 2.5.0.0 Copyright (c) 1993,1998 Borland International
# Syntax: TLINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
# Note the commas separate the lists of filenames, not the filenames themselves
$(BIN): $(OBJ)
$(TLINK32) $(TLINK32FLAGS) $(OBJ), $(BIN), $(MAP), $(LIBS), $(DEF), $(RES)
对不起,就这个问题而言,这是我可以得到的,这里我没有太多可以实际测试。希望这足以让您的构建在正确的轨道上。祝你好运!