[cc65] discarded if statement

From: carlos <carlosofcascade1gmx.net>
Date: 2004-07-15 19:16:51
Hello Shawn,

this is a test i made with your code.

000000r 1  20 rr rr      jsr     decsp1
000003r 1  A9 01         lda     #$01
000005r 1  8D 04 D1      sta     $D104
000008r 1  A0 00         ldy     #$00
00000Ar 1  91 rr         sta     (sp),y
  *(unsigned char *) 0xD104 = 1;
  if (*(unsigned char *) 0xD104 == 1){a = 1;}
  else{a = 2;}
//the whole if statement gets deleted by the optimizer. A real Mr. Proper, eh?


00000Cr 1  8D 04 D1      sta     $D104
00000Fr 1  20 rr rr      jsr     push1
000012r 1  AD 04 D1      lda     $D104
000015r 1  20 rr rr      jsr     tosicmp
000018r 1  D0 05         bne     L000E
00001Ar 1  A9 01         lda     #$01
00001Cr 1  4C rr rr      jmp     L001A; Here opcode $2c(bit absolute) could be usedby the compiler
00001Fr 1  A9 02        L000E: lda     #$02
000021r 1  A0 00        L001A: ldy     #$00
000023r 1  91 rr         sta     (sp),y
000025r 1  A2 00         ldx     #$00
000027r 1  A9 01         lda     #$01
000029r 1  4C rr rr      jmp     incsp1

 *(unsigned char *) 0xD104 = 1;
  if (1 == *(unsigned char *) 0xD104){a = 1;}
  else{a = 2;}
// Just changing the order of right and left hand value, produces completely different code.
// In this case, the if doesn't get deleted. 

Greetings 

Monte Carlos



----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Jul 15 22:50:30 2004

This archive was generated by hypermail 2.1.8 : 2004-07-15 22:50:38 CEST