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) It was only when I decided to play with -02 that all these issues arrised.
Matias 2018-01-10 17:34 GMT+01:00 Karoly Balogh (Charlie/SGR) < char...@scenergy.dfmk.hu>: > Hi, > > On Wed, 10 Jan 2018, Matias Vara wrote: > > > Hi Karol and thanks you very much! I got confused with the function > > names, I feel very sorry.As I said in my previous email, I fixed by > > rewriting the assembler function. However, I don't why it worked. > > By accident. Simply the register/stack/memory layout being different upon > entry, and it worked by pure luck. > > > So I understand you correctly, if I use assembler in my procedures there > > could be a risk that I trash a variable that the compiler is using. > > Yes. All operating systems and CPU architectures define a so called ABI or > calling convention, which functions must respect. This details which > registers are the parameters to be passed on, and which registers are free > to destroy in a function and which ones *MUST* be saved/preserved (usually > on the stack). There's no way around this. The compiler will expect that > your assembly subfunctions play by the rules. > > See here, for example, for x86: > https://en.wikipedia.org/wiki/X86_calling_conventions > > > Is the compiler warning me about this? > > No. Assembly is quite a minefield in this regard. If you use assembler, > the compiler assumes you know what you're doing, and doesn't analyze the > assembler function. You have to respect the ABI of your CPU *AND* target > platform by hand, and save the nonvolatile registers. > > (This is BTW, not Free Pascal specific. Delphi does the same, or more or > less any other language which supports inline assembly.) > > Charlie > > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal