Re: [cc65] possible bug?

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2002-02-24 20:06:03


Good evening and sorry for the delay, I've been out of town.

On Sat, Feb 23, 2002 at 04:25:23PM +0100, groepaz wrote:
> in other words, if a (asm-) function that is declared "signed char" is
> called and the value casted to an int, shouldnt the COMPILER generate
> necessary code to do the required sign-extension?

The compiler expects the default promotions to be applied when the value is
loaded into the primary register. This means that an assembler function
returning a character must always return a widened value in a/x.

The reason for this is simple: There are no operators defined on characters.
The C standard defines that the following expression will be evaluated using
integer types yielding a correct result (20000):

	unsigned char a = 100;
	unsigned char b = 200;
	int c = a * b;

As usual, the "as if" rule does also hold, so the compiler is free to evaluate
an expression using smaller types, provided that this does not change the
result of the expression. cc65 does this in some, but not all cases.

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 : 2002-02-24 20:06:12 CET