1

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

4

1 回答 1

2

我建议仅使用 DosBox 来运行最终的可执行文件。你不需要 DosBox 来生成这个可执行文件,因为 Masm32 在 64 位 Windows 下运行。但是lib.exeMasm32 附带的没有生成适合link16.exe. 所以你必须得到一个lib.exe“说话”的OMF,例如lib.exeDigitalMars(http://www.digitalmars.com/ctg/lib.html)。

例子:

主.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

函数.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

构建.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 的控制台中构建它并main.exe在 DosBox 中运行。

于 2014-05-10T09:03:56.353 回答