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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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).
Example:
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 ;
Build it in a console of Windows and run main.exe
in DosBox.