mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 02:30:44 +00:00
Get rid of ldaconst/ldxconst/ldyconst in many places.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4338 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
3be976189b
commit
2ae20c3b61
@ -411,14 +411,6 @@ void g_importmainargs (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ldaconst (unsigned val)
|
|
||||||
/* Load a with a constant */
|
|
||||||
{
|
|
||||||
AddCodeLine ("lda #$%02X", val & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ldxconst (unsigned val)
|
static void ldxconst (unsigned val)
|
||||||
/* Load x with a constant */
|
/* Load x with a constant */
|
||||||
{
|
{
|
||||||
@ -493,7 +485,7 @@ void g_leave (void)
|
|||||||
} else {
|
} else {
|
||||||
/* We've a stack frame to drop */
|
/* We've a stack frame to drop */
|
||||||
while (k > 255) {
|
while (k > 255) {
|
||||||
ldyconst (255);
|
AddCodeLine ("ldy #$FF");
|
||||||
AddCodeLine ("jsr addysp");
|
AddCodeLine ("jsr addysp");
|
||||||
k -= 255;
|
k -= 255;
|
||||||
}
|
}
|
||||||
@ -522,14 +514,13 @@ void g_swap_regvars (int StackOffs, int RegOffs, unsigned Bytes)
|
|||||||
CheckLocalOffs (StackOffs);
|
CheckLocalOffs (StackOffs);
|
||||||
|
|
||||||
/* Generate code */
|
/* Generate code */
|
||||||
|
AddCodeLine ("ldy #$%02X", StackOffs & 0xFF);
|
||||||
if (Bytes == 1) {
|
if (Bytes == 1) {
|
||||||
|
|
||||||
if (IS_Get (&CodeSizeFactor) < 165) {
|
if (IS_Get (&CodeSizeFactor) < 165) {
|
||||||
ldyconst (StackOffs);
|
AddCodeLine ("ldx #$%02X", RegOffs & 0xFF);
|
||||||
ldxconst (RegOffs);
|
|
||||||
AddCodeLine ("jsr regswap1");
|
AddCodeLine ("jsr regswap1");
|
||||||
} else {
|
} else {
|
||||||
ldyconst (StackOffs);
|
|
||||||
AddCodeLine ("lda (sp),y");
|
AddCodeLine ("lda (sp),y");
|
||||||
AddCodeLine ("ldx regbank%+d", RegOffs);
|
AddCodeLine ("ldx regbank%+d", RegOffs);
|
||||||
AddCodeLine ("sta regbank%+d", RegOffs);
|
AddCodeLine ("sta regbank%+d", RegOffs);
|
||||||
@ -539,15 +530,13 @@ void g_swap_regvars (int StackOffs, int RegOffs, unsigned Bytes)
|
|||||||
|
|
||||||
} else if (Bytes == 2) {
|
} else if (Bytes == 2) {
|
||||||
|
|
||||||
ldyconst (StackOffs);
|
AddCodeLine ("ldx #$%02X", RegOffs & 0xFF);
|
||||||
ldxconst (RegOffs);
|
|
||||||
AddCodeLine ("jsr regswap2");
|
AddCodeLine ("jsr regswap2");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ldyconst (StackOffs);
|
AddCodeLine ("ldx #$%02X", RegOffs & 0xFF);
|
||||||
ldxconst (RegOffs);
|
AddCodeLine ("lda #$%02X", Bytes & 0xFF);
|
||||||
ldaconst (Bytes);
|
|
||||||
AddCodeLine ("jsr regswap");
|
AddCodeLine ("jsr regswap");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -683,13 +672,13 @@ void g_getimmed (unsigned Flags, unsigned long Val, long Offs)
|
|||||||
|
|
||||||
case CF_CHAR:
|
case CF_CHAR:
|
||||||
if ((Flags & CF_FORCECHAR) != 0) {
|
if ((Flags & CF_FORCECHAR) != 0) {
|
||||||
ldaconst (Val);
|
AddCodeLine ("lda #$%02X", (unsigned char) Val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case CF_INT:
|
case CF_INT:
|
||||||
ldxconst ((Val >> 8) & 0xFF);
|
AddCodeLine ("ldx #$%02X", (unsigned char) (Val >> 8));
|
||||||
ldaconst (Val & 0xFF);
|
AddCodeLine ("lda #$%02X", (unsigned char) Val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CF_LONG:
|
case CF_LONG:
|
||||||
@ -1334,7 +1323,7 @@ void g_reglong (unsigned Flags)
|
|||||||
case CF_INT:
|
case CF_INT:
|
||||||
if (Flags & CF_UNSIGNED) {
|
if (Flags & CF_UNSIGNED) {
|
||||||
if (IS_Get (&CodeSizeFactor) >= 200) {
|
if (IS_Get (&CodeSizeFactor) >= 200) {
|
||||||
ldyconst (0);
|
AddCodeLine ("ldy #$00");
|
||||||
AddCodeLine ("sty sreg");
|
AddCodeLine ("sty sreg");
|
||||||
AddCodeLine ("sty sreg+1");
|
AddCodeLine ("sty sreg+1");
|
||||||
} else {
|
} else {
|
||||||
@ -2351,7 +2340,7 @@ void g_push (unsigned flags, unsigned long val)
|
|||||||
if ((flags & CF_TYPE) == CF_CHAR && (flags & CF_FORCECHAR)) {
|
if ((flags & CF_TYPE) == CF_CHAR && (flags & CF_FORCECHAR)) {
|
||||||
|
|
||||||
/* Handle as 8 bit value */
|
/* Handle as 8 bit value */
|
||||||
ldaconst (val);
|
AddCodeLine ("lda #$%02X", (unsigned char) val);
|
||||||
AddCodeLine ("jsr pusha");
|
AddCodeLine ("jsr pusha");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -2930,7 +2919,7 @@ void g_and (unsigned Flags, unsigned long Val)
|
|||||||
|
|
||||||
case CF_LONG:
|
case CF_LONG:
|
||||||
if (Val <= 0xFF) {
|
if (Val <= 0xFF) {
|
||||||
ldxconst (0);
|
AddCodeLine ("ldx #$00");
|
||||||
AddCodeLine ("stx sreg+1");
|
AddCodeLine ("stx sreg+1");
|
||||||
AddCodeLine ("stx sreg");
|
AddCodeLine ("stx sreg");
|
||||||
if ((Val & 0xFF) != 0xFF) {
|
if ((Val & 0xFF) != 0xFF) {
|
||||||
@ -2938,7 +2927,7 @@ void g_and (unsigned Flags, unsigned long Val)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (Val == 0xFF00) {
|
} else if (Val == 0xFF00) {
|
||||||
ldaconst (0);
|
AddCodeLine ("lda #$00");
|
||||||
AddCodeLine ("sta sreg+1");
|
AddCodeLine ("sta sreg+1");
|
||||||
AddCodeLine ("sta sreg");
|
AddCodeLine ("sta sreg");
|
||||||
return;
|
return;
|
||||||
@ -3311,7 +3300,7 @@ void g_inc (unsigned flags, unsigned long val)
|
|||||||
if (val <= 8) {
|
if (val <= 8) {
|
||||||
AddCodeLine ("jsr incax%lu", val);
|
AddCodeLine ("jsr incax%lu", val);
|
||||||
} else if (val <= 255) {
|
} else if (val <= 255) {
|
||||||
ldyconst (val);
|
AddCodeLine ("ldy #$%02X", (unsigned char) val);
|
||||||
AddCodeLine ("jsr incaxy");
|
AddCodeLine ("jsr incaxy");
|
||||||
} else {
|
} else {
|
||||||
g_add (flags | CF_CONST, val);
|
g_add (flags | CF_CONST, val);
|
||||||
@ -3357,7 +3346,7 @@ void g_inc (unsigned flags, unsigned long val)
|
|||||||
|
|
||||||
case CF_LONG:
|
case CF_LONG:
|
||||||
if (val <= 255) {
|
if (val <= 255) {
|
||||||
ldyconst (val);
|
AddCodeLine ("ldy #$%02X", (unsigned char) val);
|
||||||
AddCodeLine ("jsr inceaxy");
|
AddCodeLine ("jsr inceaxy");
|
||||||
} else {
|
} else {
|
||||||
g_add (flags | CF_CONST, val);
|
g_add (flags | CF_CONST, val);
|
||||||
@ -3404,7 +3393,7 @@ void g_dec (unsigned flags, unsigned long val)
|
|||||||
if (val <= 8) {
|
if (val <= 8) {
|
||||||
AddCodeLine ("jsr decax%d", (int) val);
|
AddCodeLine ("jsr decax%d", (int) val);
|
||||||
} else if (val <= 255) {
|
} else if (val <= 255) {
|
||||||
ldyconst (val);
|
AddCodeLine ("ldy #$%02X", (unsigned char) val);
|
||||||
AddCodeLine ("jsr decaxy");
|
AddCodeLine ("jsr decaxy");
|
||||||
} else {
|
} else {
|
||||||
g_sub (flags | CF_CONST, val);
|
g_sub (flags | CF_CONST, val);
|
||||||
@ -3449,7 +3438,7 @@ void g_dec (unsigned flags, unsigned long val)
|
|||||||
|
|
||||||
case CF_LONG:
|
case CF_LONG:
|
||||||
if (val <= 255) {
|
if (val <= 255) {
|
||||||
ldyconst (val);
|
AddCodeLine ("ldy #$%02X", (unsigned char) val);
|
||||||
AddCodeLine ("jsr deceaxy");
|
AddCodeLine ("jsr deceaxy");
|
||||||
} else {
|
} else {
|
||||||
g_sub (flags | CF_CONST, val);
|
g_sub (flags | CF_CONST, val);
|
||||||
@ -4274,7 +4263,7 @@ void g_initauto (unsigned Label, unsigned Size)
|
|||||||
AddCodeLine ("dey");
|
AddCodeLine ("dey");
|
||||||
AddCodeLine ("bpl %s", LocalLabelName (CodeLabel));
|
AddCodeLine ("bpl %s", LocalLabelName (CodeLabel));
|
||||||
} else if (Size <= 256) {
|
} else if (Size <= 256) {
|
||||||
ldyconst (0);
|
AddCodeLine ("ldy #$00");
|
||||||
g_defcodelabel (CodeLabel);
|
g_defcodelabel (CodeLabel);
|
||||||
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0));
|
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0));
|
||||||
AddCodeLine ("sta (sp),y");
|
AddCodeLine ("sta (sp),y");
|
||||||
@ -4299,7 +4288,7 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size)
|
|||||||
AddCodeLine ("bpl %s", LocalLabelName (CodeLabel));
|
AddCodeLine ("bpl %s", LocalLabelName (CodeLabel));
|
||||||
} else if (Size <= 256) {
|
} else if (Size <= 256) {
|
||||||
unsigned CodeLabel = GetLocalLabel ();
|
unsigned CodeLabel = GetLocalLabel ();
|
||||||
ldyconst (0);
|
AddCodeLine ("ldy #$00");
|
||||||
g_defcodelabel (CodeLabel);
|
g_defcodelabel (CodeLabel);
|
||||||
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, InitLabel, 0));
|
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, InitLabel, 0));
|
||||||
AddCodeLine ("sta %s,y", GetLabelName (CF_STATIC, VarLabel, 0));
|
AddCodeLine ("sta %s,y", GetLabelName (CF_STATIC, VarLabel, 0));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user