1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-22 12:29:06 +00:00

Check for shift count zero

git-svn-id: svn://svn.cc65.org/cc65/trunk@1055 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-10-17 21:46:27 +00:00
parent 03229b3253
commit 43530d1604

View File

@ -2785,7 +2785,7 @@ void g_and (unsigned flags, unsigned long val)
AddCodeLine ("tax"); AddCodeLine ("tax");
AddCodeLine ("tya"); AddCodeLine ("tya");
if ((val & 0x00FF) != 0x00FF) { if ((val & 0x00FF) != 0x00FF) {
AddCodeLine ("and #$%02X", (unsigned char)val); AddCodeLine ("and #$%02X", (unsigned char)val);
} }
} }
} }
@ -2829,10 +2829,10 @@ void g_asr (unsigned flags, unsigned long val)
/* Primary = TOS >> Primary */ /* Primary = TOS >> Primary */
{ {
static char* ops [12] = { static char* ops [12] = {
0, "tosasra0", "tosasrax", 0, "tosasra0", "tosasrax",
0, "tosshra0", "tosshrax", 0, "tosshra0", "tosshrax",
0, 0, "tosasreax", 0, 0, "tosasreax",
0, 0, "tosshreax", 0, 0, "tosshreax",
}; };
/* If the right hand side is const, the lhs is not on stack but still /* If the right hand side is const, the lhs is not on stack but still
@ -2848,12 +2848,11 @@ void g_asr (unsigned flags, unsigned long val)
AddCodeLine ("txa"); AddCodeLine ("txa");
ldxconst (0); ldxconst (0);
val -= 8; val -= 8;
if (val == 0) {
/* Done */
return;
}
} }
if (val >= 1 && val <= 4) { if (val == 0) {
/* Done */
return;
} else if (val >= 1 && val <= 4) {
if (flags & CF_UNSIGNED) { if (flags & CF_UNSIGNED) {
AddCodeLine ("jsr shrax%ld", val); AddCodeLine ("jsr shrax%ld", val);
} else { } else {
@ -2864,7 +2863,10 @@ void g_asr (unsigned flags, unsigned long val)
break; break;
case CF_LONG: case CF_LONG:
if (val >= 1 && val <= 4) { if (val == 0) {
/* Nothing to do */
return;
} else if (val >= 1 && val <= 4) {
if (flags & CF_UNSIGNED) { if (flags & CF_UNSIGNED) {
AddCodeLine ("jsr shreax%ld", val); AddCodeLine ("jsr shreax%ld", val);
} else { } else {
@ -2883,10 +2885,10 @@ void g_asr (unsigned flags, unsigned long val)
AddCodeLine ("ldy #$00"); AddCodeLine ("ldy #$00");
AddCodeLine ("ldx sreg+1"); AddCodeLine ("ldx sreg+1");
if ((flags & CF_UNSIGNED) == 0) { if ((flags & CF_UNSIGNED) == 0) {
unsigned L = GetLocalLabel(); unsigned L = GetLocalLabel();
AddCodeLine ("bpl %s", LocalLabelName (L)); AddCodeLine ("bpl %s", LocalLabelName (L));
AddCodeLine ("dey"); AddCodeLine ("dey");
g_defcodelabel (L); g_defcodelabel (L);
} }
AddCodeLine ("lda sreg"); AddCodeLine ("lda sreg");
AddCodeLine ("sty sreg+1"); AddCodeLine ("sty sreg+1");
@ -2901,8 +2903,8 @@ void g_asr (unsigned flags, unsigned long val)
/* If we go here, we didn't emit code. Push the lhs on stack and fall /* If we go here, we didn't emit code. Push the lhs on stack and fall
* into the normal, non-optimized stuff. * into the normal, non-optimized stuff.
*/ */
g_push (flags & ~CF_CONST, 0); g_push (flags & ~CF_CONST, 0);
} }
@ -2916,10 +2918,10 @@ void g_asl (unsigned flags, unsigned long val)
/* Primary = TOS << Primary */ /* Primary = TOS << Primary */
{ {
static char* ops [12] = { static char* ops [12] = {
0, "tosasla0", "tosaslax", 0, "tosasla0", "tosaslax",
0, "tosshla0", "tosshlax", 0, "tosshla0", "tosshlax",
0, 0, "tosasleax", 0, 0, "tosasleax",
0, 0, "tosshleax", 0, 0, "tosshleax",
}; };
@ -2936,23 +2938,25 @@ void g_asl (unsigned flags, unsigned long val)
AddCodeLine ("tax"); AddCodeLine ("tax");
AddCodeLine ("lda #$00"); AddCodeLine ("lda #$00");
val -= 8; val -= 8;
if (val == 0) {
/* Done */
return;
}
} }
if (val >= 1 && val <= 4) { if (val == 0) {
/* Done */
return;
} else if (val >= 1 && val <= 4) {
if (flags & CF_UNSIGNED) { if (flags & CF_UNSIGNED) {
AddCodeLine ("jsr shlax%ld", val); AddCodeLine ("jsr shlax%ld", val);
} else { } else {
AddCodeLine ("jsr aslax%ld", val); AddCodeLine ("jsr aslax%ld", val);
} }
return; return;
} }
break; break;
case CF_LONG: case CF_LONG:
if (val >= 1 && val <= 4) { if (val == 0) {
/* Nothing to do */
return;
} else if (val >= 1 && val <= 4) {
if (flags & CF_UNSIGNED) { if (flags & CF_UNSIGNED) {
AddCodeLine ("jsr shleax%ld", val); AddCodeLine ("jsr shleax%ld", val);
} else { } else {