Creating a library in MASM while using dosbox

烈酒焚心 提交于 2019-12-12 01:45:20

问题


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.



来源:https://stackoverflow.com/questions/23571335/creating-a-library-in-masm-while-using-dosbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!