Re: [cc65] "software" stack?

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-10-30 22:31:39
On Sat, Oct 30, 2010 at 09:49:16AM +0200, Gábor Lénárt wrote:
> Ahaa, thanks a lot, it was useful for me! I was thought on replace RTS, JSR
> and other opcodes on the generated asm source by cc65 into my own solutions,
> which uses the "parameter stack" as well, so I would have a single stack,
> not the "return" (6502 hw) and the "parameter".  Then I would no need to
> save/restore the 6502 hw stack on context switching at all.  Thanks for the
> information!

You can do that, but it is really slow and generates big code. As a
comparison,

        pha             (push on hardware stack)

is 3 cycles, while

        jsr     pusha   (push on software stack)

is 31 cycles when called and 19/22 (best/worst) when inlined. Please note that
it uses "jsr" to place the return address on the hardware stack, so if you
don't want to inline, you have another penalty to avoid the "jsr".

The hardwired stack makes multithreading on the 6502 really slow. You can
speedup things by either limiting the stack and the number of threads as
suggested by Oliver (e.g. 4 threads can use 64 bytes stack each), or by adding
hardware support. A commodore REU allows fast stack swapping. The C128 can
switch the stack page. Some other platforms may offer other hardware support.

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 Sat Oct 30 22:31:46 2010

This archive was generated by hypermail 2.1.8 : 2010-10-30 22:31:50 CEST