I'm working on my very own compiler for Z80 I'm interested about how do your compiler deal with calls to BIOS that use registers as parameters and result values.
First of all. There is not BIOS in a basic PIC architecture. PIC are usually alone in the world, when they work; or you define your own BIOS.
PIC compilers don't use hardware stacks, because there is not hardware stack for registers in the basic PIC architecture. PicPas, like others PIC compilers, use global variables to pass parameters. However, to return a function result, PicPas use the W register (the only Work register PIC have), some flag, of the STATUS register, and if needed anothers, PicPas define some bytes in RAM, reserved to be used like "Work registers" [1].
It is too much code IMO. Doing some compiler magic:
FUNCTION GetStick (aId: __REGISTER_A): __REGISTER_A; BIOSDECL($00D5);
Yes. I think it's ok. It's some like external function definition. If you can do: the compiler make your life easy, well, do it. Maybe the problem here is, How to implement this in the best Pascalish way? I mean, without destroys the conventional and the spirit of the language. One detail, the identifier "__REGISTER" have some C-ish style, for me.
PicPas, have a way to use "Work Registers" like parameters:
procedure QuickParameterProc(REGISTER regvar: byte);
This will force the compiler to use the W register for pass the parameter. In PicPas, there is not need to specify the register, because there is only one (W). When use variables WORD, PicPas, would use W, and some other RAM "Work register".
All functions use the "Work registers" to return results, so there is no need to specify.
By the way, implementing calls to a BIOS, means to me, that the compiler will be restricted to compile only for that BIOS. I recomend to think the Z80 could work too, in other hardware enviroments, without change, too much, the convention for BIOS calls.
[1] Inside PicPas documentation "Work register" is a term to refers to a register always available, and used to make calculations and return operations results, something like A, B, C, D, in Z80. PicPas use the term "RAM register" to refer the other bytes in RAM used like common RAM.