X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fcoptcmp.h;h=dbfd74dd57629411d821103059869d963b6b9089;hb=4185caf8558690ae4720d4a83d829ed3ed087ae9;hp=39a79121f3f529da8f90bf5cdf41c16cfc9ca602;hpb=3692fd40dab79f0464a9a3da33baa5932f29b90d;p=cc65 diff --git a/src/cc65/coptcmp.h b/src/cc65/coptcmp.h index 39a79121f..dbfd74dd5 100644 --- a/src/cc65/coptcmp.h +++ b/src/cc65/coptcmp.h @@ -1,15 +1,15 @@ /*****************************************************************************/ /* */ -/* 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 */ @@ -44,7 +44,7 @@ /*****************************************************************************/ -/* Remove calls to the bool transformer subroutines */ +/* Remove calls to the bool transformer subroutines */ /*****************************************************************************/ @@ -57,7 +57,7 @@ unsigned OptBoolTrans (CodeSeg* S); /*****************************************************************************/ -/* Optimizations for compares */ +/* Optimizations for compares */ /*****************************************************************************/ @@ -65,38 +65,38 @@ unsigned OptBoolTrans (CodeSeg* S); 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. */ @@ -104,19 +104,19 @@ unsigned OptCmp3 (CodeSeg* S); 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. @@ -132,7 +132,7 @@ unsigned OptCmp5 (CodeSeg* S); * lda (sp),y * cpx #a * bne L1 - * cmp #b + * cmp #b * jne/jeq L2 */ @@ -153,11 +153,21 @@ unsigned OptCmp8 (CodeSeg* S); * 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 - - -