Calling exported string functions - PB 4.2 beta 2
The tailbite function should change the 'Ret' line to:
Only when a string is returned. It should work then.
Code: Select all
RET X+4
Yes - it works!Fred wrote:The tailbite function should change the 'Ret' line to:
Only when a string is returned. It should work then.Code: Select all
RET X+4

Thanks Fred. Looking at it, the damn solution was obvious!!!
Can I ask why PB passes an extra parameter when calling compiled user lib functions?
I may look like a mule, but I'm not a complete ass.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
It seems to work yes (I only made a few tests).
1. only add 'RET X + 4' to the exported functions, not the private functions
2. don't use exported functions in the library
I have just updated the custom Tailbite for jaPBe V3 : http://freenet-homepage.de/gnozal/TailBite.zip
Source included, search for 'PB4.20 fix'. It seems to work.
Sorry, it's not the ABBKlaus source, but I am more confortable with the old ElChoni source
1. only add 'RET X + 4' to the exported functions, not the private functions
2. don't use exported functions in the library
I have just updated the custom Tailbite for jaPBe V3 : http://freenet-homepage.de/gnozal/TailBite.zip
Source included, search for 'PB4.20 fix'. It seems to work.
Sorry, it's not the ABBKlaus source, but I am more confortable with the old ElChoni source

Last edited by gnozal on Tue May 27, 2008 2:44 pm, edited 1 time in total.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
I made some tests, and it crashed.srod wrote:That should be fine Gnozal. I see no reason why that should be a problem.gnozal wrote:2. don't use exported functions in the library
I am probably doing something wrong, but imho the '+ 4' fix is only for the exported functions when called from the outside (PB), it's not right if the function is called from the library itself.
But then again, I am no asm guru.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Confirmed. Crashes if one exported string function calls another!gnozal wrote:I made some tests, and it crashed.srod wrote:That should be fine Gnozal. I see no reason why that should be a problem.gnozal wrote:2. don't use exported functions in the library
I am probably doing something wrong, but imho the '+ 4' fix is only for the exported functions when called from the outside (PB), it's not right if the function is called from the library itself.
But then again, I am no asm guru.

Mind you, in this case you'll just have to ensure that no function within a library calls a string function from the same library which is to be exported. Just add a 'dummy' function through which the exported string function operates.
I may look like a mule, but I'm not a complete ass.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Yes, that's what I did for one test library.srod wrote:Mind you, in this case you'll just have to ensure that no function within a library calls a string function from the same library which is to be exported. Just add a 'dummy' function through which the exported string function operates.
I will check all my libs for this before recompiling them with PB4.20 final.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB could need to reuse this parameter value, after the function call. Before VC8, the parameter value was never changed by the called function (as it was pushed on the stack which is not in the function scope), so we could use a trick to get it back if needed. With VC8, this trick didn't work anymore (the function can modify the user-parameter stack), so we have to duplicate the push, to be able to get it back if needed.srod wrote:Can I ask why PB passes an extra parameter when calling compiled user lib functions?
Is there an inconsistency somewhere that prevents us from calling an exported function that returns a string from within the same library? I'm assuming that the ASM output is different between a Procedure and ProcedureDLL.
Would it be possible to keep the ASM the same so that we can call these functions again with TailBite?
Would it be possible to keep the ASM the same so that we can call these functions again with TailBite?