Re: [cc65] Stack adressing

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-01-19 19:32:14
Good evening!

On Mon, Jan 19, 2009 at 04:14:26PM +0100, Jonathan MASUR wrote:
> Is there a way to change the way CC65 adress stack so instead of doing
> indirect adressing :
> "lda [StackPtr],Y"
>
> It would use some direct adressing to produce faster code :
> "lda Stack,Y"

No, there is no easy way to do that. The compiler generated code will contain
stack accesses as well as the libraries. Without using tricks (like sp still
pointing to the stack so the library routines don't have to be changed), you
will have to change the compiler and use separate, rewritten C and runtime
libraries.

> Of course the stack would be limited to 256 bytes, but at least it would
> be much faster, and fixing the stack pointer would also be faster as it
> would only involve some "iny" or "dey".

It's not that easy, because you need to store the current stack top somewhere.
If the stack is fixed and of a limited size, you do still need a way to tell a
subroutine where it can start to store variables and temporaries. Besides
that, I doubt that resulting programs are really much faster, since variable
access is just a small part of a program. Reducing the cycle count of these
instructions from 5 to 3 or 4 will probably have a measurable effect but not a
noticeable one.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Jan 19 19:34:38 2009

This archive was generated by hypermail 2.1.8 : 2009-01-19 19:34:39 CET