使用dosbox时在MASM中创建库 [英] Creating a library in MASM while using dosbox
问题描述
我有一个问题,我被分配去用汇编语言(即MASM)制作一个静态库,但我在互联网上找到的所有教程都不完整或太难理解.我使用dosbox,因为我有64位窗口. 请逐步帮助 拜托了,谢谢你
I have a question, i have been given an assignment to make a static library in assembly language i.e. MASM, but all the tutorials i find on the internet are either incomplete or too hard for me to understand. I am using dosbox since i have a 64 bit windows. Please help step by step Please and thank you
推荐答案
我建议仅使用DosBox来运行最终的可执行文件.您不需要DosBox来生成此可执行文件,因为Masm32在64位Windows下运行.但是Masm32随附的lib.exe
不会产生适用于link16.exe
的OMF库.因此,您必须得到一个说" OMF的lib.exe
,例如由DigitalMars( http://www.digitalmars.com/ctg/lib.html ).
I suggest using DosBox only for running the final executable. You don't need DosBox to produce this executable, since Masm32 runs under 64 bit Windows. But the lib.exe
shipped with Masm32 doesn't produce a OMF-Library suitable for link16.exe
. So you have to get a lib.exe
which "speaks" OMF, e.g. the lib.exe
by DigitalMars (http://www.digitalmars.com/ctg/lib.html).
示例:
main.asm:
.MODEL small
.code
EXTERN sub1:NEAR
main PROC
mov ax, @data
mov ds, ax
call sub1
mov ax, 4C00h
int 21h
main ENDP
.stack 1000h
END main
function.asm:
.MODEL small
.data
text db "This is sub1.",13,10,"$"
.code
sub1 PROC
push ax
push dx
mov ah, 09h
mov dx, OFFSET text
int 21h
pop dx
pop ax
ret
sub1 ENDP
END
build.cmd:
@ECHO OFF
SET PATH=C:\masm32\bin
ml.exe /c function.asm
ml.exe /c main.asm
<Path to DigitalMars>\dm\bin\lib.exe -c main.lib main.obj function.obj
link16.exe main.lib ;
在Windows控制台中进行构建,然后在DosBox中运行main.exe
.
Build it in a console of Windows and run main.exe
in DosBox.
这篇关于使用dosbox时在MASM中创建库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!