<div dir="ltr">Thank you very much Karol, I completly missed this point during the development of my kernel (Or maybe I had in mind sometime ago but I forgot it)<div>It was only when I decided to play with -02 that all these issues arrised. </div><div><br></div><div>Matias</div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-10 17:34 GMT+01:00 Karoly Balogh (Charlie/SGR) <span dir="ltr"><<a href="mailto:charlie@scenergy.dfmk.hu" target="_blank">charlie@scenergy.dfmk.hu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Hi,<br>
<br>
On Wed, 10 Jan 2018, Matias Vara wrote:<br>
<br>
</span><span class="">> Hi Karol and thanks you very much! I got confused with the function<br>
</span>> names, I feel very sorry.As I said in my previous email, I fixed by<br>
<span class="">> rewriting the assembler function. However, I don't why it worked. <br>
<br>
</span>By accident. Simply the register/stack/memory layout being different upon<br>
entry, and it worked by pure luck.<br>
<span class=""><br>
> So I understand you correctly, if I use assembler in my procedures there<br>
> could be a risk that I trash a variable that the compiler is using.<br>
<br>
</span>Yes. All operating systems and CPU architectures define a so called ABI or<br>
calling convention, which functions must respect. This details which<br>
registers are the parameters to be passed on, and which registers are free<br>
to destroy in a function and which ones *MUST* be saved/preserved (usually<br>
on the stack). There's no way around this. The compiler will expect that<br>
your assembly subfunctions play by the rules.<br>
<br>
See here, for example, for x86:<br>
<a href="https://en.wikipedia.org/wiki/X86_calling_conventions" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/<wbr>X86_calling_conventions</a><br>
<span class=""><br>
> Is the compiler warning me about this? <br>
<br>
</span>No. Assembly is quite a minefield in this regard. If you use assembler,<br>
the compiler assumes you know what you're doing, and doesn't analyze the<br>
assembler function. You have to respect the ABI of your CPU *AND* target<br>
platform by hand, and save the nonvolatile registers.<br>
<br>
(This is BTW, not Free Pascal specific. Delphi does the same, or more or<br>
less any other language which supports inline assembly.)<br>
<span class="HOEnZb"><font color="#888888"><br>
Charlie<br>
</font></span><br>______________________________<wbr>_________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.<wbr>org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" rel="noreferrer" target="_blank">http://lists.freepascal.org/<wbr>cgi-bin/mailman/listinfo/fpc-<wbr>pascal</a><br></blockquote></div><br></div>