[cc65] Function returns (was: ATARI Multijoy Joystickdriver)

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-01-02 22:45:46


On Thu, Jan 02, 2003 at 10:20:52PM +0100, Christian Groessler wrote:
> I think this is something which should be documented (sorry, if it
> already is.). It's quite vital information for people writing
> subroutines in assembler.

The "internal.doc" file says that functions return values in A/X. I admit that
this is not very explicit. On the other side, the whole process of writing
subroutines in assembler is not documented anywhere, so I do not even have a
place where this additional information could go:-)

> If I understand it correctly the compiler assumes return values from
> functions to be already "int promoted". This is quite different from
> the (obvious?) assumption that a function returning char will only
> return a char.

It does not only expect this on a function call, but also when loading a value
or evaluating an expression. This is common C knowledge: While there is a
"char" type, it is never used in expressions. And even character literals have
type int. BTW: This is one of the (few) differences in the common language
subset of C and C++. The code snippet

        printf ("The size of a character literal is %u\n", sizeof ('a'));

will always print

        The size of a character literal is 1

when compiled with a C++ compiler, and something else when compiled with a C
compiler.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-01-02 22:45:53 CET