Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

library in masm

Status
Not open for further replies.

djdeath

MIS
Oct 18, 2003
4
0
0
GR
Hi, I have an assignment which is to build a library of some routines in assembly. Does anybody know how the main program (that calls the routines) and the program (library
file) which includes the routines sould be?I mean their syntax. I use masm611 and i made a library file with the ms-lib utility, but when i use ML to assemble the main programm the linker finds problems in the lib file. When i assemble the routines .asm file there are no errors.Also when i make the library with lib there are no error messages. I just wonder if there are some directives which ignore.Please i need help !!!
 
When i try to compile the main program that calls routines from the libray i get an "error A2206: missing operator in expression" for the programm line of the call instruction. The lib file is put in the lib directory of masm611. I used the public directive with no results at both modules. Can anybody show me a working example of two programms, one for the library and one for the main programm that calls routines from the library? Please help.
 
djdeath,

I hope this will work with MASM611.

This is a LIB example. Name the file as "msgbox.asm"

.386
.model flat, stdcall
option casemap :none ; case sensitive

include \masm32\include\windows.inc
include \masm32\include\user32.inc

includelib \masm32\lib\user32.lib

.CODE
MBox proc MB_Message:LPSTR, MB_Title:LPSTR
invoke MessageBox, NULL, MB_Message, MB_Title, MB_ICONINFORMATION
ret
MBox endp
END

Build it using this command (change the masm32 path to your masm folder) :
c:\masm32\bin\ml /c /coff MsgBox.asm
c:\masm32\bin\link -lib *.obj /out:MsgBox.lib


Main program ( call_MBox.asm ):

.386
.model flat, stdcall
option casemap :none ; case sensitive

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

includelib MSGBOX.LIB ; This is our library

; Declare the function prototype from our library
MBox PROTO :LPSTR, :LPSTR

.DATA
cMsg db 'My Message',0
cTitle db 'My Title',0

.CODE
Start:
invoke MBox, Addr cMsg, Addr cTitle
invoke ExitProcess, 0
END Start

Build:
\masm32\bin\ml /c /coff Call_MBox.asm
\masm32\bin\Link /nologo /SUBSYSTEM:WINDOWS Call_MBox.obj


Hope it helps


-- AirCon --
 
Thank you very much aircon for your help i shall try it tomorrow.
 
Unfortunately it doesn't work in masm611 at "c:\masm32\bin\link -lib *.obj /out:MsgBox.lib" command there is a "/out : unrecognised option name ; option ignored. I'll try to tweak it in order to get it work. But does anybody has another example for masm611.
 
Try to build with this:

LIB *.obj /out:msgbox.lib


-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top