[cc65] Missed Optimization with | 0

Date view Thread view Subject view

From: Geoffrey Wossum (geoffrey_at_pager.net)
Date: 2003-11-05 16:29:33


Hi,

Just noticed an optimization that cc65 2.9.3 misses:

947      0000F0r 1               ;
948      0000F0r 1               ; lcd_write(LCD_COL_ADDR_LSB | (x & 0x0f));
949      0000F0r 1               ;
951 82f5 0000F0r 1  B1 rr               lda     (sp),y
952 82f7 0000F2r 1  29 0F               and     #$0F
953 82f9 0000F4r 1  09 00               ora     #$00
954 82fb 0000F6r 1  85 16               sta     $0016

Here's the relavent macros from the C source:

#define lcd_write(_val)  CS2 = (_val)
#define CS2         __REG8(0x16)
#define __REG8(_addr)   (*((uint8_t *)(_addr)))
#define LCD_COL_ADDR_LSB         0x00

LCD_COL_ADDR_LSB is 0x00, so of course the OR operation has no effect.  
Interestingly, if a change the '|' to a '+', cc65 recognizes the no effect 
operation and optimizes it out.

---
Geoffrey Wossum
Software Engineer
Long Range Systems - http://www.pager.net


----------------------------------------------------------------------
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-11-05 16:37:06 CET