Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / [ DLL ] Inline Assemble In Making DLL

Author
Message
puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 28th Jul 2010 06:53 Edited at: 28th Jul 2010 06:56
Hi , I have made my dll about windows application. I used that the way was like inline assemble because I needed speed up for enhancing applications specification when I was making my dll. however , when I was compiled the dll and I ran a test source code for the dll.
it was made a happening that the happening was application error about appcore.h of dbpro. hmm... I don't know really how I do that.
I show up source code of problem with some pictures.
If I ignored the error , The test program was run very well...







Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Jul 2010 15:32
Assembly itself has no effect on the DLL or DBPro, so what else did you do in the plug-in? Can you provide the whole function.

puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 29th Jul 2010 17:58
Sorry for posting lately.
Does assembly affact to dbpro or dlls really?
Umm... The problem of that sendmessage function used for finding specific strings was guessed by me.

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Jul 2010 00:54
It doesn't affect it at all (unless you get it wrong).

My function pointer plug-in uses assembly code for preparing the stack, copying parameters, calling function pointers and cleaning everything up afterwards - basically, it's the centre of the plug-in and doesn't have any known problems.

Provide something for me to look at and I'll try and tell you if anything is wrong with it - send it to me directly if you don't want to post it here.

puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 30th Jul 2010 09:38 Edited at: 31st Jul 2010 04:35
Oh! I appreciate you that you find the reason of problem directly and you tell me that!
I just upload source code with project ( VC++ 6.0 )!
[EDIT] "I sent the source code to your email"

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Aug 2010 15:49
Ok, I've looked at it, and the very first thing you should do is to fix the other bugs in your code first - it's those bugs that are causing the crashes, not the assembly.

This function does NOT initialise the arrays correctly - it doesn't initialise the array at all:


As this is an MFC DLL (which I know almost nothing about), make sure that the function calls you have in DllMain are correct for this kind of DLL - if they are not correct, this too could cause the crash (or a deadlock too if they cause other DLL's to be loaded, such as the MFC DLL). Move them to an exported 'void Constructor(void)' or 'void ReceiveCoreDataPtr(LPVOID)' so that DBPro will initialise then at the correct point.

Finally, there's no checking to ensure that you don't overflow your arrays.

Why is the assembly there anyway? You are using assembly code to increment a variable, which is no faster than letting the compiler do it with ++, but in addition, removes any chance that the compiler might have for optimising access to that variable. In summary, your assembly will at best be as fast as the C++ compiler produces, and at worst, slower.

Also, I have to comment on the style of things like this:

Pointers are set to NULL, integers should be set to 0. My personal preference is to get run of NULL from my programs entirely, but you may not want to go that far.

puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 1st Aug 2010 18:10
Oh ! You're BEST ~ !
Thanks! I really appreciate you because I learn a number of things from you!

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 2nd Aug 2010 03:11
Just a note, assembly does not make things faster, it merely gives you more functionality. In some cases this extra functionality can allow you to implement an algorithm more efficiently, but not always. In most cases the compiler will know better (MSVC++ is actually very good at optimising code!)

[b]
puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 2nd Aug 2010 04:46 Edited at: 2nd Aug 2010 05:03
Thanks Diggsey!
Now , I use assembly for function of low level!
I learn from you more!

Offtopic?.. " Assembly is also funny ! "

[EDIT]
Oh I saw rendering section in the john carmak's source code in quake2 engine. It was assembly code only. In this case , Is the code makes a increasing speed of engine?

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Aug 2010 23:19
Quake 2 was written to run on a 90 mhz processor (Intel Pentium 1, AMD K6-2) in 1997 by a world-class expert in assembly programming.

You are not that good

Besides, processors have moved on since then - the majority of instructions run in a single clock cycle, there are parallel lines of execution within the processor (giving multiple instructions per clock cycle), and compilers/optimisers have improved massively to take advantage of that.

Quote: "Now , I use assembly for function of low level!"

You missed Diggsey's point, and mine.

You will get faster code by not using assembly language.

Every time you use assembly, you slow down the code that the compiler produces, and you don't take advantage of the parallel pipe-lining of the processor.

YOUR CODE WILL RUN SLOWER!

puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 5th Aug 2010 15:36 Edited at: 5th Aug 2010 15:36
Oh Sorry my bad expressing...
I mean that I use assembly language for detailed functions in cumputer processor. not speed.

Anyway, Thank you for your advice , knowledge!

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.

Login to post a reply

Server time is: 2024-04-18 03:02:54
Your offset time is: 2024-04-18 03:02:54