本文介绍了如何使用MASM以上比较特别一个的.lib文件的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Visual Studio 2010做了一个文件,.LIB,现在我想在MASM使用它。我该怎么办呢?需要帮助。我试图寻找它在互联网上,但无法找到如何做到这一点的任何precise答案。

I have made a .lib file using visual studio 2010 and now I want to use it in masm. How can I do that? need help. I tried to look it on the internet but couldn't find any precise answer on how to do this.

下面是.LIB我使用Visual C ++ 2010中创建文件的链接。

here is the link to .lib file that I created using Visual C++ 2010.https://www.dropbox.com/s/pzdd35ktolfl48x/MathFuncsLib.lib

此文件只包含一个函数,它有两个整型参数并返回它们的总和。我需要在我使用MASM写的Intel汇编程序的一个使用此功能。

This file contains only a function that takes two integers as arguments and returns their sum. I need to use this function in one of my program written in intel assembly using masm.

需要在这个问题的帮助。

Need help in this problem.

推荐答案

我是过于乐观说有在净MASM-C组合的例子很多。在这里,一步一步的指示为Visual Studio防爆preSS 2010(无MASM32):

I was too optimistic saying that there are many examples for a MASM-C-combination in the net. Here a step-by-step instruction for Visual Studio Express 2010 (no Masm32):

MathFuncsLib.cpp:

extern "C" {
    int Addition (int a, int b) { return a + b; }
    int Subtraction (int a, int b) { return a - b; }
    int Multiplication (int a, int b) { return a * b; }
    int Division (int a, int b) { return a / b; }
} // end of extern "C"

MathFuncsLib.asm:

.MODEL flat, stdcall

includelib kernel32.lib
ExitProcess PROTO STDCALL, :DWORD

includelib msvcrt.lib
printf PROTO C, :VARARG

includelib MathFuncsLib.lib
Addition PROTO C, :SDWORD, :SDWORD
Subtraction PROTO C, :SDWORD, :SDWORD
Multiplication PROTO C, :SDWORD, :SDWORD
Division PROTO C, :SDWORD, :SDWORD

.data
    arg1 SDWORD 100
    arg2 SDWORD 10
    result SDWORD ?

    fmt1 db "Addition: %u",10,0
    fmt2 db "Subtraction: %u",10,0
    fmt3 db "Multiplication: %u",10,0
    fmt4 db "Division: %u",10,0

.code
main PROC

    invoke Addition, arg1, arg2
    mov result, eax
    invoke printf, ADDR fmt1, result        ; printf (fmt1,result)

    invoke Subtraction, arg1, arg2
    mov result, eax
    invoke printf, ADDR fmt2, result

    invoke Multiplication, arg1, arg2
    mov result, eax
    invoke printf, ADDR fmt3, result

    invoke Division, arg1, arg2
    mov result, eax
    invoke printf, ADDR fmt4, result

    invoke ExitProcess, 0

main ENDP

END main

MathFuncsLib.cmd:

@ECHO OFF
call "C:\Compiler\Visual Studio Express 2010\VC\vcvarsall.bat"
rem Adapt it with path to your 'vcvarsall.bat'

cl.exe MathFuncsLib.cpp /c
lib.exe MathFuncsLib.obj
ml.exe MathFuncsLib.asm /link /subsystem:console

MathFuncslib.exe

祝你好运!

这篇关于如何使用MASM以上比较特别一个的.lib文件的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 16:11