/*****************************************************************************/
/* */
-/* coptcmp.h */
+/* coptcmp.h */
/* */
-/* Optimize compares */
+/* Optimize compares */
/* */
/* */
/* */
-/* (C) 2001-2004 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2001-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/*****************************************************************************/
-/* Remove calls to the bool transformer subroutines */
+/* Remove calls to the bool transformer subroutines */
/*****************************************************************************/
/*****************************************************************************/
-/* Optimizations for compares */
+/* Optimizations for compares */
/*****************************************************************************/
unsigned OptCmp1 (CodeSeg* S);
/* Search for the sequence
*
- * ldx xx
- * stx tmp1
- * ora tmp1
+ * ldx xx
+ * stx tmp1
+ * ora tmp1
*
* and replace it by
*
- * ora xx
+ * ora xx
*/
unsigned OptCmp2 (CodeSeg* S);
/* Search for the sequence
*
- * stx xx
- * stx tmp1
- * ora tmp1
+ * stx xx
+ * stx tmp1
+ * ora tmp1
*
* and replace it by
*
- * stx xx
- * ora xx
+ * stx xx
+ * ora xx
*/
unsigned OptCmp3 (CodeSeg* S);
/* Search for
*
- * lda/and/ora/eor ...
- * cmp #$00
- * jeq/jne
+ * lda/and/ora/eor ...
+ * cmp #$00
+ * jeq/jne
* or
- * lda/and/ora/eor ...
- * cmp #$00
- * jsr boolxx
+ * lda/and/ora/eor ...
+ * cmp #$00
+ * jsr boolxx
*
* and remove the cmp.
*/
unsigned OptCmp4 (CodeSeg* S);
/* Search for
*
- * lda x
- * ldx y
- * cpx #a
- * bne L1
- * cmp #b
- * jne/jeq L2
+ * lda x
+ * ldx y
+ * cpx #a
+ * bne L1
+ * cmp #b
+ * jne/jeq L2
*
* If a is zero, we may remove the compare. If a and b are both zero, we may
* replace it by the sequence
*
- * lda x
- * ora x+1
- * jne/jeq ...
+ * lda x
+ * ora x+1
+ * jne/jeq ...
*
* L1 may be either the label at the branch instruction, or the target label
* of this instruction.
* lda (sp),y
* cpx #a
* bne L1
- * cmp #b
+ * cmp #b
* jne/jeq L2
*/
* the result of the compare is known.
*/
+unsigned OptCmp9 (CodeSeg* S);
+/* Search for the sequence
+ *
+ * sbc xx
+ * bvs/bvc L
+ * eor #$80
+ * L: asl a
+ * bcc/bcs somewhere
+ *
+ * If A is not used later (which should be the case), we can branch on the N
+ * flag instead of the carry flag and remove the asl.
+ */
+
/* End of coptcmp.h */
#endif
-
-
-