Re: [cc65] Problem with 16/32-bit variables and conditions

From: Carlos Sánchez de La Lama <csanchez1sidsa.es>
Date: 2005-03-11 13:34:36
>CSdLL> As long as I understand, this will only test the last byte of
>CSdLL> "a" for a zero value, because the Zero flag will be set in the
>CSdLL> last (8-bit) load instruction in the ldeax0sp subroutine. If I
>CSdLL> call the test function with a=0xff00 the condition would be
>CSdLL> (incorrectly) found to be false.
>
>CSdLL> Am I right?
>
>Looks like it:
>
>  #include <stdio.h>
>
>  int test(unsigned long a) {
>    if (a) {
>      return(1);
>    }
>    return(0);
>  }
>
>  int main (void) {
>    printf("test(0) == %s\n", test(0) ? "true" : "false");
>    printf("test(1) == %s\n", test(1) ? "true" : "false");
>    printf("test(0xff00) == %s\n", test(0xff00) ? "true" : "false");
>    return(0);
>  }
>
>gives:
>
>  test(0) == false
>  test(1) == true
>  test(0xff00) == false
>
>  
>
Yes, it is the same problem. Is it already reported?
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Mar 11 13:35:20 2005

This archive was generated by hypermail 2.1.8 : 2005-03-11 13:35:26 CET