mirror of
https://github.com/cc65/cc65.git
synced 2025-01-19 02:33:19 +00:00
Removed special-casing code for scaling up. Now it uses the normal multiplying code.
This commit is contained in:
parent
75dc234988
commit
ea7336591c
@ -1496,54 +1496,14 @@ void g_scale (unsigned flags, long val)
|
|||||||
** pointer points to.
|
** pointer points to.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int p2;
|
|
||||||
|
|
||||||
/* Value may not be zero */
|
/* Value may not be zero */
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
Internal ("Data type has no size");
|
Internal ("Data type has no size");
|
||||||
} else if (val > 0) {
|
} else if (val > 0) {
|
||||||
|
|
||||||
/* Scale up */
|
/* Use a multiplication instead */
|
||||||
if ((p2 = PowerOf2 (val)) > 0 && p2 <= 4) {
|
if (val != 1) {
|
||||||
|
|
||||||
/* Factor is 2, 4, 8 and 16, use special function */
|
|
||||||
switch (flags & CF_TYPEMASK) {
|
|
||||||
|
|
||||||
case CF_CHAR:
|
|
||||||
if (flags & CF_FORCECHAR) {
|
|
||||||
while (p2--) {
|
|
||||||
AddCodeLine ("asl a");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* FALLTHROUGH */
|
|
||||||
|
|
||||||
case CF_INT:
|
|
||||||
if (flags & CF_UNSIGNED) {
|
|
||||||
AddCodeLine ("jsr shlax%d", p2);
|
|
||||||
} else {
|
|
||||||
AddCodeLine ("jsr aslax%d", p2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CF_LONG:
|
|
||||||
if (flags & CF_UNSIGNED) {
|
|
||||||
AddCodeLine ("jsr shleax%d", p2);
|
|
||||||
} else {
|
|
||||||
AddCodeLine ("jsr asleax%d", p2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
typeerror (flags);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (val != 1) {
|
|
||||||
|
|
||||||
/* Use a multiplication instead */
|
|
||||||
g_mul (flags | CF_CONST, val);
|
g_mul (flags | CF_CONST, val);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -3224,7 +3184,6 @@ void g_asl (unsigned flags, unsigned long val)
|
|||||||
"tosaslax", "tosshlax", "tosasleax", "tosshleax"
|
"tosaslax", "tosshlax", "tosasleax", "tosshleax"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* 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
|
||||||
** in the primary register.
|
** in the primary register.
|
||||||
*/
|
*/
|
||||||
@ -3233,6 +3192,14 @@ void g_asl (unsigned flags, unsigned long val)
|
|||||||
switch (flags & CF_TYPEMASK) {
|
switch (flags & CF_TYPEMASK) {
|
||||||
|
|
||||||
case CF_CHAR:
|
case CF_CHAR:
|
||||||
|
if ((flags & CF_FORCECHAR) != 0 && val <= 4) {
|
||||||
|
while (val--) {
|
||||||
|
AddCodeLine ("asl a");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
case CF_INT:
|
case CF_INT:
|
||||||
val &= 0x0F;
|
val &= 0x0F;
|
||||||
if (val >= 8) {
|
if (val >= 8) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user