Re: [cc65] assembler/C stack issue

From: Oliver Schmidt <ol.sc1web.de>
Date: 2011-02-12 12:38:25
Hi,

> The compiler/linker will know that the function returns a char and not an
> int, and it shouldn't just use whatever is in A+X when promoting to int, but
> rather "know" that it should stick a zero in X first. ???  Seems broken if
> that is so?

Again, maybe I'm totally wrong...but here are my two cents:

Certainly what you say is the normal/theoretical/native approach. What
I describe is an optimization. Functions are supposed to be reused.
Therefore it is desirable to place as much as possible stuff into the
function instead at the call site. Exactly the same as with parameter
stack handling: Theoretically the caller pushes and pops - with the
practical benefit of having no issues with varargs etc. But for
optimization reasons one might want to have the function pop the
arguments.

Btw: Again done in other invironments too. Both 16-bit and 32-bit
Windows API functions pop their arguments themselves (see "pascal" /
"stdcall" calling convention).

Regards,
Oliver
----------------------------------------------------------------------
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 Feb 12 12:38:42 2011

This archive was generated by hypermail 2.1.8 : 2011-02-12 12:38:45 CET