Re-added register variables.

Changed/added several optimizer steps to detect register variables correctly
or to handle them in a special way.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1636 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2002-11-25 15:05:15 +00:00
parent 1d94d18fa5
commit 70755921a9
18 changed files with 407 additions and 295 deletions

View File

@@ -132,9 +132,9 @@ static const char* GetLabelName (unsigned Flags, unsigned long Label, long Offs)
break;
default:
Internal ("Invalid address flags");
Internal ("Invalid address flags: %04X", Flags);
}
/* Return a pointer to the static buffer */
return Buf;
}
@@ -485,11 +485,51 @@ void g_leave (void)
/*****************************************************************************/
/* Register variables */
/* Register variables */
/*****************************************************************************/
void g_swap_regvars (int StackOffs, int RegOffs, unsigned Bytes)
/* Swap a register variable with a location on the stack */
{
/* Calculate the actual stack offset and check it */
StackOffs -= oursp;
CheckLocalOffs (StackOffs);
/* Generate code */
if (Bytes == 1) {
if (CodeSizeFactor < 165) {
ldyconst (StackOffs);
ldxconst (RegOffs);
AddCodeLine ("jsr regswap1");
} else {
ldyconst (StackOffs);
AddCodeLine ("lda (sp),y");
AddCodeLine ("ldx regbank%+d", RegOffs);
AddCodeLine ("sta regbank%+d", RegOffs);
AddCodeLine ("txa");
AddCodeLine ("sta (sp),y");
}
} else if (Bytes == 2) {
ldyconst (StackOffs);
ldxconst (RegOffs);
AddCodeLine ("jsr regswap2");
} else {
ldyconst (StackOffs);
ldxconst (RegOffs);
ldaconst (Bytes);
AddCodeLine ("jsr regswap");
}
}
void g_save_regvars (int RegOffs, unsigned Bytes)
/* Save register variables */
{