I was wondering if anyone has though of porting or writing something like the MASM32LIB?

I don't mean having it all precompiled just that you could:


.code
include '%include%\fasmlib\stringfunctions.asm'


and would then have strcat, strlen type functions available.


Or macro could be done.
Posted on 2003-01-24 14:11:43 by jInuQ
I think this idea (implemented with macro from my reply) would be helpul:
http://www.asmcommunity.net/board/index.php?topic=10134.msg75980
Posted on 2003-01-24 14:57:32 by Tomasz Grysztar
Are you talking of the post by Vortex?
Posted on 2003-01-24 15:31:22 by jInuQ
Yes (this link points exactly to that post), and my macros in second post below it.
Posted on 2003-01-24 15:41:39 by Tomasz Grysztar
So if I had:


;---------------------------------------------------------------
; Based upon the function in the MASM32LIB
; Translated by James Majrie`
;---------------------------------------------------------------
macro StrLen szString
{

push ebx

xor eax,eax
xor edx, edx
mov eax, szString
lea edx, [eax+3]

@@:
mov ebx, [eax]
add eax, 4
lea ecx, [ebx-01010101h]
not ebx
and ecx,ebx
and ecx, 80808080h
jz @B
test ecx,00008080h
jnz @F
shr ecx,16
add eax,2
@@:
shl cl,1
sbb eax,edx


pop ebx
}

macro szStrCat lpszSource, lpszAdd
{

StrLen lpszSource

mov edx, lpszSource
mov ecx, lpszAdd
add edx, eax

@@:
mov al, [ecx]
mov [edx], al
inc ecx
inc edx
test al, al
jne @B

}

How would I do that then?
Posted on 2003-01-24 16:41:32 by jInuQ
I've noticed that fasm was too strict in some aspects to correctly resolve inherited dependencies. I've corrected it in the 1.45 beta, but anyway it needs more passes to assemble correctly the attached code (currently fasm has 256 passes limit, should be enough for most purposes, but I've reserved some fields in revised fasm 1.45 structures to hold 16-bit pass number, if there's such need).
The attachment will assemble with fasm 1.45 only, it contains two samples, one using simple asm routines with arguments in registers, one using the stdcall convention.
Posted on 2003-01-25 08:41:22 by Tomasz Grysztar
So you would prefer functions instead of macros?
Posted on 2003-01-25 15:41:56 by jInuQ
This makes your code smaller.
Posted on 2003-01-25 16:44:51 by Tomasz Grysztar
True :grin: , Then again I don't need to use it more then a handful of times.
Posted on 2003-01-25 16:54:18 by jInuQ
Privalov,

I think your "lib2.inc" example is the best for creating libraries for FASM
Nice example!:alright:

Regards,

Vortex
Posted on 2003-01-26 04:55:23 by Vortex

Privalov,

I think your "lib2.inc" example is the best for creating libraries for FASM
Nice example!:alright:

Regards,

Vortex


Including all these macros may seem great when you've got a small library
and the assembler is fast. Now consider what happens when you've got
a library that has in excess of 50,000 lines of code in it (e.g., the HLA
Standard Library). Combine that with the 20-30,000 lines lines of definitions
needed for a decent set of Windows include files and you find yourself
assembling 75,000 lines of code or so, just to get "Hello World" running
Now, all of a sudden, gross includes of the entire library become impractical.
The macro idea doesn't scale up well at all.

Some might argue that the user should choose only those include files
that they actually need; however, this is cumbersome for advanced
programmers and very challenging for beginners. Much better to just
include one header file (that includes everything) and be done with it.
Randy Hyde
Posted on 2003-02-01 02:24:22 by rhyde
Dear Randall,

As you pointed,huge libraries based on macros can demonstrate serious problems
since the same library code has to be re-assembled everytime.For the moment,
the only solution for the library problem is to define our macros.As we know,the
best solution is to have a special linker for the Flast Assembler.Yet,I am satisfied with
the "lproc-endlp" macros defined by Privalov.A linker for Fasm will support much
the development of big libraries.(+ a librarian)

Thanks,

Regards,

Vortex
Posted on 2003-02-01 03:09:21 by Vortex
Could you use something like the "if used" syntax to implement a function based library?



if used
proc strcat args


I am sure my syntax is off but hopfully you guy get what I am mean. Too tired to think straight right now.
Posted on 2003-02-01 04:01:58 by jInuQ
jInuQ: Take a look inside the .INC files from the package above.
Posted on 2003-02-01 04:46:50 by Tomasz Grysztar
So if I write/convert the non-ms windows specific stuff first from the masm32lib and then go on and do the MS Windows specific stuff. Would that be a good idea?

After that was done work could be done on some linux/gnome/kde/etcetra specific stuff.

Would this be worth setting up a side project?

I think it would be nice to have a library full of little jewels ready to go. :grin:

Any thoughts?


Forgot to ask how to be able to use different file bassed on a define.

i.e
#define p2
include "%includes%\fasmlib.inc"

Could I then do #ifdef p2
include "%includes%\fasmlib\ix86\p2\lib.inc"

This is just an outline.
Posted on 2003-02-01 19:41:30 by jInuQ
Okay some more thoughts. I was thinking of porting libASM from linux. It looks to have small libc also.
I've got the directory layout done. If anyone has any thoughts just let me know. At some time in the future non 486 code could be
written for the Win32 and Linux stuff.


usage:


#define k6 ; Comment this line out to get 386 code.
#define winnt4 ; Comment this out for no os specific functions.
include "%include%/fasmlib/lib.inc'



Directory Layout


fasmlib\
ix86\
386\
k6\
k7\
p1\
p2\
p3\
p4\
xp\
win32\
win95\
win98\
winME\
winNT4\
win2k\
winXP\
linux\
X\
console\
gnome\
kde\
Posted on 2003-02-03 16:02:01 by jInuQ
Okay just as a side note I will be going away on vaction so it will be a couple of days until I get settled in, after that I will get a alpha library up soon.
Posted on 2003-02-04 17:02:32 by jInuQ
UPDATE: I have got most of MASMLIB string functions converted to the new lproc...endlp macros. I am writing tests and making corrections to get the code to compile and work.
Posted on 2003-02-08 14:48:58 by jInuQ
Okay, I think that I am going to put this into a sf project. I already have a project that I never did anything with. I think that I will set it up with cvs if I can figure that out.



Okay I think I am finally getting a hang of the whole CVS thing. I've set up my own CVS server to test out on. One I get the directory layout set-up and a few core file I will test load my own cvs repoistory. After that I will work on getting the sf project converted to the new discription and all.

The project is call pattod. It still has all the old info, but that should be cleaned out in the next couple of days.

Also I almost forgot is that I am going to scrap everything that I have converted from MASMLIB and do it all from scratch so this project can be placed under a different licence. For the same reason I wont be converting anything from libAsm.
Posted on 2003-02-12 17:01:23 by jInuQ
jInuQ,

When will you post the converted Masm32 library?

Regards,

Vortex
Posted on 2003-02-24 03:47:40 by Vortex