![]() |
Sub Fastcall behaviour - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15) +---- Thread: Sub Fastcall behaviour (/showthread.php?tid=480) |
Sub Fastcall behaviour - na_th_an - 07-27-2012 I understand that if, for example, you pass an uByte parameter, it's put into the A register... But it seems that the parameter itself is not usable from BASIC. I don't know if this is intended, there's nothing about this in the doc. Code: Sub Fastcall test (n as uByte) I expected this code to print 16 twice, but it outputs: Code: 0 This is, the value of "n" is 0. In other scenarios, I get other values, not just 0. Re: Sub Fastcall behaviour - boriel - 07-27-2012 This is not possible. FASTCALL is used for registers. I could manage to use the A register for "N var", but the content will be lost. FASCTALL is used for ASM functions basically, or for SUB/Functions with no parameters. In the future, functions with no parameters will be all fast-called. Re: Sub Fastcall behaviour - na_th_an - 07-30-2012 Nice to know. It would be nice to mention this in the docs, as it is not, and may mislead people (i.e. me :lol ![]() Re: Sub Fastcall behaviour - boriel - 07-30-2012 na_th_an Wrote:Nice to know. It would be nice to mention this in the docs, as it is not, and may mislead people (i.e. me :lolIt would be nice to use only registers, but Z80 has so few registers, I couldn't manage to do it. :oops: Re: Sub Fastcall behaviour - na_th_an - 07-30-2012 No, it's incredibly useful. What I meant is that the behaviour "you can't really use the variables" should be documented. I mean, if the fastcall sub has a byte parameter "X", that parameter goes into the A register, but that's it, there's no "X" local variable you can use. Well, there is, but the value is not. Re: Sub Fastcall behaviour - boriel - 07-30-2012 na_th_an Wrote:No, it's incredibly useful. What I meant is that the behaviour "you can't really use the variables" should be documented. I mean, if the fastcall sub has a byte parameter "X", that parameter goes into the A register, but that's it, there's no "X" local variable you can use. Well, there is, but the value is not.Hmmm. Maybe the compiler can issue a Warning like "Warning: Fastcalled var is not accesible" :?: Re: Sub Fastcall behaviour - na_th_an - 08-02-2012 boriel Wrote:na_th_an Wrote:No, it's incredibly useful. What I meant is that the behaviour "you can't really use the variables" should be documented. I mean, if the fastcall sub has a byte parameter "X", that parameter goes into the A register, but that's it, there's no "X" local variable you can use. Well, there is, but the value is not.Hmmm. Maybe the compiler can issue a Warning like "Warning: Fastcalled var is not accesible" :?: It would be useful, but just mentioning it in the wiki (that's the docs I always read) would suffice. The wiki explains how to use the fastcall parameters and stuff, but doesn't mention this issue. |