Re: [cc65] Code generation of "jsr enter"

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2007-03-12 14:55:20
On Mon, Mar 12, 2007 at 05:29:50AM -0800, Mike Harris wrote:
> I'm using cc65 to compile some simple C code, and I'm a bit confused as to
> some of the assembly it's generating.
>
> I see "jsr enter", "jsr pusha", and "jsr leavey" in the generated assembly,
> but I don't see them defined anywhere. This assembles fine though, so I'm not
> sure whats going on or what those subs do.
>
> Can someone shed some light on this?

These functions are part of the runtime library. They're linked in by the -
you guessed it - linker. There are hundreds of these functions and most of
them are really short. If you're interested in the details, you may want to
download the source archive and have a look into the libsrc/runtime/
directory.

Hint: If your routines call "enter" and "leavey", they're probably declared
with an empty parameter list like this:

        void foo ()
        {
        }

An empty parameter list means "this function accepts any number of
parameters". The compiler inserts special code to make this possible. If what
you really want is a function that accepts *no* parameters, using

        void foo (void)
        {
        }

generates better code.

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 Mar 12 14:55:32 2007

This archive was generated by hypermail 2.1.8 : 2007-03-12 14:55:34 CET