News:

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

Linking Object Files

Started by ic2, May 30, 2007, 05:40:14 PM

Previous topic - Next topic

ic2

Is it possible to link two object files together.  One is a real program and the other is just a big 500k buffer in the un-initialized data section that has no other coding for it at all..

I want to try it this because i have a 140000 byte buffer in my program and i need another one, but when i add an extra one it take forever to comply which is expected, so i want to test with another way.  I know how to use alloc functions but i need these buffers build-in.

Could someone show me an example of how to do this.  I think i got a way of how to use the big buffer from the program once it's in there.  I'll place a one byte buffer at the end of the data file in the main program and make it touch the big one and call the one byte buffer to get an auto connection to the big one.  ... Do you think this should work?

Vortex

Create a separate module containing the uninitialized data section :

.386
.model flat,stdcall
option casemap:none

PUBLIC uninitialized

.data?

uninitialized db 500000 dup(?)

END


Assemble it only once :

ml /c /coff bss.asm

Link it with your main object module :

link mainmodule.obj bss.obj

You should put an EXTERN statement to your main module to present the uninitialized data block.

EXTERN uninitialized:BYTE

ic2

This is amazing...  Not only did it work but looking at Mem Usage and Peak Mem Usage i was using between 3,192 3,208k at all times.

Now with a near extra 1 meg module it now read 3,628k.  I remember a long time ago f0dder said that Windows automatically allocates at lease one meg of memory for every running process weather we use it or not.  Maybe that's where my other 436k is accumulated somehow ...  If so WoW if not, I'll worry about that latter... for now... it WORKS,,,, with  No hesitation at all doing start up.  It writes fast, It even pop up the message box with NO noticeable delay.  This is much more than i expected out of Windows using build-in large buffers.


Thanks Vortex

3,628
3,192
______
436k
This seems to prove f0dder right or something in relations to it ... Now i can figure my memory  usage more accurately.

Now it's reading 3,224... XP is really strange...
Now it went up to  3,232... same open window...
I wonder why do it just leave thing ALONG ....

Tedd

Is there any particular reason you're not just allocating this memory at run time??
That's what the functions are for, and it would save you this trouble :wink
No snowflake in an avalanche feels responsible.

Vortex

Hi ic2,

You are welcome. I am glad to see that the method works for you.

Vortex

GoAsm assembles very fast asm modules containing large uninitialized data blocks :

.data
buffer db 500000 dup ?


\goasm\goasm test.asm

ic2

QuoteIs there any particular reason you're not just allocating this memory at run time?? That's  what the functions are for, and it would save you this trouble

Hello Tedd,

I'm just beginning to use and understand Heap and VirtualAlloc.  What i really want to do is run code that is only going to be used once (such as getting my fonts, color etc into dwords than Free that memory so that all of that never-again-to-be-reused code is no longer in memory doing the life of the program while running.
:
I have a tons of string in the .data section that will only be used once during start up.  I have to figure out how to use Heap or  VirtualAlloc to use those strings with the running code that i speak of above than FREE that memory so there is no trace of wasted code and strings in Windows memory while the rest of the program runs as usually.
:
The reason I want to keep a big block of memory in the program is for re-use and not having to call ALLOC function every time i need something.... I now will only have to call it if i need more memory than the built-in big buffers supply.
:
Another thing is i don't know if i can re-use allocated memory like i can do with my build-in big buffers. I don't know if i can really call ALLOC and save up to 5 buffers for re-used thru out the life of the program, than free them all before the program is close.  I think you have to keep calling ReAlloc or something.
:
So, i guest my answer is I don't know what the heck I'm doing and had too many dumb questions about it back to back that would cause others to say... Oh Heck, ... I'm just too embarrass to ask all of that.  So I ask about big buffers...
:
Todays computer has lots of memory.  I just want to use it as efficiently as possible so i can't never say, i did not know that was still over there, i thought it should be over here or not at all...
:
Plus i'm getting close to an answer of what happing with Mem Usage and Peak Mem Usage in TASKMAN.  I would have never been concern until now...  MichaelW recently help to explore TASKMAN with the use of ALLOC functions.  I could not do the test because my masm32 is missing something.  He already told me i need to re-install updated verion.  I have not done that yet... but will by morning..

I'm wasting a lot of time on an simple project, worrying about this and that, but I'm picking up a lot of facts for future projects and for cleaning up the mess i already done.


QuoteGoAsm assembles very fast asm modules containing large uninitialized data blocks :

What's up Vortex,

Masm does too ,thru the code you posted.  I even tried it with a 2meg object file fixed to work in my program ... than i dumped about 500k worth of buffers in my uninitialized data section and it compiled like lighting just struck.

I know GoAsm got to be great. If donkey like it you know it got to be really something special about it.

I like POASM because it keep aside with MASM, and i think it is very special also.  It got some tricks that even masm can't see.  I found two and been meaning to post about it.  I will do that in a few days before i forget.  Could be seen as an mistake but it's very usable with no flaws... I'll post soon.. at POASM..

Tedd

Quote from: ic2 on June 01, 2007, 01:46:26 AM
I'm just beginning to use and understand Heap and VirtualAlloc.  What i really want to do is run code that is only going to be used once (such as getting my fonts, color etc into dwords than Free that memory so that all of that never-again-to-be-reused code is no longer in memory doing the life of the program while running.
I understand your idea, but the truth is that you don't need to worry about this. The sections of your program are paged in and out of memory as they're required and to make space for other required pages - any section that's paged out and not required again will not be paged back in again, so it wouldn't take up memory if it's not used anyway. The second thing is that it's only 'taking up space' if that space is needed for something else, if the space isn't needed then it doesn't matter whether that section there or not (and when the space is needed, that section will be removed anyway.)

Quote
I have a tons of string in the .data section that will only be used once during start up.  I have to figure out how to use Heap or  VirtualAlloc to use those strings with the running code that i speak of above than FREE that memory so there is no trace of wasted code and strings in Windows memory while the rest of the program runs as usually.
Same reason as above - just leave the strings in the data section (or you could look into building a string-table - which appears in the resource section.)

Quote
The reason I want to keep a big block of memory in the program is for re-use and not having to call ALLOC function every time i need something.... I now will only have to call it if i need more memory than the built-in big buffers supply.
:
Another thing is i don't know if i can re-use allocated memory like i can do with my build-in big buffers. I don't know if i can really call ALLOC and save up to 5 buffers for re-used thru out the life of the program, than free them all before the program is close.  I think you have to keep calling ReAlloc or something.
Well you can equally just allocate a big block and keep hold it - re-use it over and over again, in exactly the same way - there's nothing special about it. ReAlloc is used for re-sizing a block of memory, you don't need to call it just to use the same block of memory - once you have it, it's yours and you can use it as you wish. You can also allocate as many buffers as you like (as long as there's enough memory) - this is no problem.
This 'built-in' block is actually allocated in exactly the same way, but it's done for you when the program is loaded so you don't have to worry about doing that, but otherwise there's nothing special about it.

Quote
So, i guest my answer is I don't know what the heck I'm doing and had too many dumb questions about it back to back that would cause others to say... Oh Heck, ... I'm just too embarrass to ask all of that.  So I ask about big buffers...
Nothing to be embarrassed about, you're still learning (we all are - yes, still!!) and every one of us had to start at the beginning :wink

Quote
I'm wasting a lot of time on an simple project, worrying about this and that, but I'm picking up a lot of facts for future projects and for cleaning up the mess i already done.
It's not wasting time if you're learning :wink The best way to learn (and remember) is make lots of mistakes and then learn how to fix them.
No snowflake in an avalanche feels responsible.

Vortex

Hi ic2,

PoAsm is another great tool compatible With Masm. You will enjoy using it.

ic2

I been WAY off the mark for a long time.  This is a total SHOCK... I'm going to look up and read seriously into Paging and such.  Give me a day or two (at lease by Tuesday) to come back and clear up a few things. .

Thanks a bunch

You guys actually put it all in a nut-shell.  I'm just going back to understand what i been skipping.  I don't think I'll come up with much after this but terminology. :)