[fpc-pascal] (no subject)

2014-03-08 Thread Barracuda
Hello, guys!
Firstly, thank you for such a great project! It's very nice to use it in a 
study process in a school/university.
And now a question :)
I have some trouble working on one of my projects, it's code is here:
https://github.com/Barracuda72/PT
The problem is with function "SentenceSample" in "PT4LibIFace.pas"; there are 
two ways - my stupidness or mysterious behavior of FPC compiler.
Code:
-
function SentenceSample(N: integer): string; stdcall;
begin
  //writeln('N = ', N);
  //SentenceSample := RuGetSentence(N);
  inc(N);
end;
-
Of course, inc(N); added just to simplify disassembling. And there is disasm:
-
sentencesample  proc near
  pushebp
  mov ebp, esp
  inc [ebp+0Ch]
  leave
  retn8
-
As you can see, procedure has only one parameter, but FPC generates code as if 
there are two 
parameters; and the main problem is that it trying to work with wrong variable 
(N is in ebp+08, 
not 0C; it's obvious and proved by debugging). The result is bad =)
So, can you say, there am I wrong?
Ah, I'm using Lazarus 1.0.14 with FPC 2.6.2, Win32 build
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] (no subject)

2014-03-08 Thread Barracuda
OK, thanks. I've really figured that out - function should return PChar, not 
string.
I'm writing an replacement for closed-source component (also written in 
Pascal), and using disassembler because of that. This component 
intercommunicate with two others, loadable library (on one side) written in 
Pascal and application (on other side) written in C#, both are closed-source.
Anyway, thanks for help!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal