News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Building a library?

Started by lib, May 18, 2005, 09:59:46 AM

Previous topic - Next topic

lib

Hello all.

I want to build a library of my function How Do I Do That??? (What words should I use?)

I use MASM 6.14
The code is 16 bit

notice that I don's want to use the INVOKE command but CALL xyz

Thanx in advance

Vortex

If I am not wrong, you need the 16-bit librarian to create static libraries.


MichaelW

Hi lib,

Since I already provided you with a link to answer your question, I'm assuming you had problems understanding the answer. The attachment contains an example that I think will show you how to create and use a library. You will still need a 16-bit library manager (LIB.EXE), available here:

http://www.cs.fit.edu/~mmahoney/cse3101/examples/Lib16/




[attachment deleted by admin]
eschew obfuscation

lib

Thanx I will give it a look
:U

yodacool

Since I know what a library is, and how to make one, yet I still do not understand how to use a library manager, I will explain this to you, in case you dont know how to use it. I am thinking that you must understand the library managers syntax in order to use it, and if I ever want or need to use a lib manager, I will have to learn the syntax. I make my libraries by hand, since my programs require different procedures and .obj's to link depending on the program.
There are two types of what i call libraries:
Regular libraries: These contain public procedures that can be used by your main module.
They usually have the extension .obj, and are basically modules.
If you build a math library, put all your math procedures in the .asm file, and assemble this into something like math.obj, and you have your math library.
Macro libraries: These are just macros, placed into a file like liba.mac
Macros just replace your macro lable you typed into your .asm file with whatever is in your macro.
Parameters can be used with macros.
-----
Now I know when most people think of a library, they are including multiple modules in a file that tells your linker to link them to your main module every time you link an .obj. This isnt what I do. I make my math procedures in ONE .asm file (one procedure per file, unless a procedure absoutly REQUIRES another proc.). Then later when I think I have enough, I copy and paste ALL of these procedures into ONE .asm file, then I assemble it into an .obj file, and that is my math library. I still have all those seperate math procedures in seperate .asm files if I need only one. This way I have mini-modules I can link to my main module if I dont need the whole math library.
Here is an example of a mini-module that I have in my screen library, and yes, you can assemble and link it to your main program seperate and use it, you dont need the whole dang library.
--------
mydata segment public
extrn LRXY:WORD
mydata ends
mycode segment public
public clearscr
assume CS:mycode,DS:mydata
clearscr proc
mov cx,0 ; upper left coords of the screen
mov dx,LRXY ;lower right coords of screen =184Fh
mov al,0 ;specifies clear entire screen, and not just scroll a few lines
mov bh,07h ; specify normal attribute for blanked lines
mov ah,06h ; subfunction 06h of int 10h -Video service 6 (scroll, clear screen)
int 10h
ret
clearscr endp ; end of proc. clearscr
mycode ends   ;end of code segment
end
-----
And here is a macro file I made that works with some of my libraries, and some just stand alone:

comdef MACRO
CRLF db 0dh,0ah,'$'
LRXY dw 184Fh
ENDM
gotoxy MACRO newx,newy
mov dh,newy
mov dl,newx
mov ah,02h  ; VIDEO service 02h (position Cursor)
mov bh,0    ; Display page 0 (normal)
int 10h     ; Make it so
ENDM
writeln MACRO show,showlen
;show is the string to be displayed, showlen is the length of that string
mov bx,1        ; Selects dos file handle1: standard output
mov cx, showlen  ; Length of the string to be displayed
lea dx, show     ; Offset address of the string to be displayed
mov ah,40h       ; Subfunction 40h of INT 21h: Print string
int 21h          ; Make it so
ENDM
printCR MACRO
; Now to place a carraige return and line feed
lea dx, CRLF     ; Place offset of CRLF into DX
mov ah, 09h      ; Subfunction 09h of INT 21h: Display a string
int 21h          ; Make it so
ENDM
--------
the library for clearing the screen is called cls.asm (if assembled, cls.obj), and needs LRXY defined in your data segment. This is achieved in conjunction with the macro library, by typing 'comdef' into your data segment. 'comdef' is where I put data needed by my libraries, and is really handy.
So again, if I need my math procs for a program calc.asm, I assemble math.asm into math.obj, then calc.asm into calc.obj, then (for turbo assembler) tlink calc.obj math.obj, and thats all it takes.
My library is FAR from being finished. It is just started actually. Once I have my standart input/output routines, and some other stuff related, I will put my math procedures into it, and compile a full library. So it is nice to have it like this [Your FULL standard library]------>[Standard library parts grouped by function types]--->[Single function]. All this is built starting with single functions.
If you are unfamiliar on how to declare your procedures as external in your main module, so your assembler doesnt throw a fit, let me know. It is a good idea to make all your data/code segments have the same label, and use assume statements the same way through your modules.

lib