Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sub Fastcall behaviour
#1
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)
    Asm
        ld (40000),a
    End Asm
    Print n
        Print Peek (40000)
End Sub

test (16)

I expected this code to print 16 twice, but it outputs:

Code:
0
16

This is, the value of "n" is 0. In other scenarios, I get other values, not just 0.
Reply
#2
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.
Reply
#3
Nice to know. It would be nice to mention this in the docs, as it is not, and may mislead people (i.e. me :lolSmile
Reply
#4
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 :lolSmile
It would be nice to use only registers, but Z80 has so few registers, I couldn't manage to do it. :oops:
Reply
#5
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.
Reply
#6
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" :?:
Reply
#7
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)