I'm rewriting my library in asm, but still offering an API to be called from C.
cc65 implements arguments passing to function with a stack in $500 - $5FF, but I figured out a faster (I think) way to do that without the stack.
I declare some zero page variables which will be used to simulate the arguments, let's say _byte_arg_0, etc.
Then I defined a macro function with arguments, which is what the user really calls in his code, which in turn sets those zero page vars with the values of the arguments, and then calls the real .proc
The .proc reads the arguments from the zero page vars and does what it has to do, with faster zero page vars instead of a stack.
With this method, of course a routine like this cannot call itself recursively or call another routine that uses the same zero page vars. Anyway, no routine of my library will do any of both.
Also, if one of this routines, gets interrupted by an interrupt which in turn calls another of this routines, and both use the same zero page vars, there's a problem there too. I'l have to look over that.
Besides what I mentioned, does anyone think this method is good?
Does anyone detect any other problem?
Would you use this method? or is the stack method better?
( One of the reasons I don't use cc65's stack, appart from zp being faster, is that I don't fully understand it yet )
cc65 implements arguments passing to function with a stack in $500 - $5FF, but I figured out a faster (I think) way to do that without the stack.
I declare some zero page variables which will be used to simulate the arguments, let's say _byte_arg_0, etc.
Then I defined a macro function with arguments, which is what the user really calls in his code, which in turn sets those zero page vars with the values of the arguments, and then calls the real .proc
The .proc reads the arguments from the zero page vars and does what it has to do, with faster zero page vars instead of a stack.
With this method, of course a routine like this cannot call itself recursively or call another routine that uses the same zero page vars. Anyway, no routine of my library will do any of both.
Also, if one of this routines, gets interrupted by an interrupt which in turn calls another of this routines, and both use the same zero page vars, there's a problem there too. I'l have to look over that.
Besides what I mentioned, does anyone think this method is good?
Does anyone detect any other problem?
Would you use this method? or is the stack method better?
( One of the reasons I don't use cc65's stack, appart from zp being faster, is that I don't fully understand it yet )