[cc65] optimizer or me?

From: Shawn Jefferson <jefferson_shawn_a8bit1yahoo.com>
Date: 2004-07-15 05:33:10
Well, a possible bug or my expectations are wrong?  In
one of my projects I am testing for the existance of
hardware at a particular address.  The listing is a
little wierd.  I guess it's optimizing out the compare
and first case, but should it do that?

version: 2.10.1
compiled with: cl65 -Osir -t atari --listing -T test.c

---
test.c:

int main(void)
{
  char a;

  *(unsigned char *) 0xD104 = 1;
  if (*(unsigned char *) 0xD104 == 1)
    a = 1;
  else
    a = 2;

  return(1);
}

---
test.lst

000000r 1               ;
000000r 1               ; File generated by cc65 v
2.10.1
000000r 1               ;
000000r 1               	.fopt		compiler,"cc65 v
2.10.1"
000000r 1               	.setcpu		"6502"
000000r 1               	.smart		on
000000r 1               	.autoimport	on
000000r 1               	.case		on
000000r 1               	.debuginfo	off
000000r 1               	.importzp	sp, sreg, regsave,
regbank, tmp1, ptr1, ptr2
000000r 1               	.macpack	longbranch
000000r 1               	.export		_main
000000r 1               
000000r 1               ;
---------------------------------------------------------------
000000r 1               ; int __near__ main (void)
000000r 1               ;
---------------------------------------------------------------
000000r 1               
000000r 1               .segment	"CODE"
000000r 1               
000000r 1               .proc	_main: near
000000r 1               
000000r 1               .segment	"CODE"
000000r 1               
000000r 1               ;
000000r 1               ; *(unsigned char *) 0xD104 =
1;
000000r 1               ;
000000r 1  20 rr rr     	jsr     decsp1
000003r 1  A9 01        	lda     #$01
000005r 1  8D 04 D1     	sta     $D104
000008r 1               ;
000008r 1               ; a = 2;
000008r 1               ;
000008r 1  A0 00        	ldy     #$00
00000Ar 1  91 rr        	sta     (sp),y
00000Cr 1               ;
00000Cr 1               ; return(1);
00000Cr 1               ;
00000Cr 1  A2 00        	ldx     #$00
00000Er 1               ;
00000Er 1               ; }
00000Er 1               ;
00000Er 1  4C rr rr     	jmp     incsp1
000011r 1               
000011r 1               .endproc
000011r 1               
000011r 1               



	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 
----------------------------------------------------------------------
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 05:33:14 2004

This archive was generated by hypermail 2.1.8 : 2004-07-15 05:33:23 CEST