Changed the implementation of g_leavariadic.

Generate calls to the additional decax functions.


git-svn-id: svn://svn.cc65.org/cc65/trunk@676 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2001-03-26 20:49:54 +00:00
parent c6c752ef8b
commit c3e37a287a

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2000 Ullrich von Bassewitz */ /* (C) 1998-2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -844,7 +844,7 @@ void g_getlocal (unsigned flags, int offs)
} else { } else {
AddCodeLine ("\tjsr\tldeax0sp"); AddCodeLine ("\tjsr\tldeax0sp");
} }
break; break;
default: default:
typeerror (flags); typeerror (flags);
@@ -887,7 +887,7 @@ void g_getind (unsigned flags, unsigned offs)
AddCodeLine ("\tjsr\tldaui"); AddCodeLine ("\tjsr\tldaui");
} }
} else { } else {
AddCodeLine ("\tjsr\tldai"); AddCodeLine ("\tjsr\tldai");
} }
} }
break; break;
@@ -938,30 +938,30 @@ void g_leasp (int offs)
/* For value 0 we do direct code */ /* For value 0 we do direct code */
if (offs == 0) { if (offs == 0) {
AddCodeLine ("\tlda\tsp"); AddCodeLine ("\tlda\tsp");
AddCodeLine ("\tldx\tsp+1"); AddCodeLine ("\tldx\tsp+1");
} else { } else {
if (CodeSizeFactor < 300) { if (CodeSizeFactor < 300) {
ldaconst (offs); /* Load A with offset value */ ldaconst (offs); /* Load A with offset value */
AddCodeLine ("\tjsr\tleaasp"); /* Load effective address */ AddCodeLine ("\tjsr\tleaasp"); /* Load effective address */
} else { } else {
if (CPU == CPU_65C02 && offs == 1) { if (CPU == CPU_65C02 && offs == 1) {
AddCodeLine ("\tlda\tsp"); AddCodeLine ("\tlda\tsp");
AddCodeLine ("\tldx\tsp+1"); AddCodeLine ("\tldx\tsp+1");
AddCodeLine ("\tina"); AddCodeLine ("\tina");
AddCodeLine ("\tbne\t*+3"); AddCodeLine ("\tbne\t*+3");
AddCodeLine ("\tinx"); AddCodeLine ("\tinx");
AddCodeHint ("x:!"); /* Invalidate X */ AddCodeHint ("x:!"); /* Invalidate X */
} else { } else {
ldaconst (offs); ldaconst (offs);
AddCodeLine ("\tclc"); AddCodeLine ("\tclc");
AddCodeLine ("\tldx\tsp+1"); AddCodeLine ("\tldx\tsp+1");
AddCodeLine ("\tadc\tsp"); AddCodeLine ("\tadc\tsp");
AddCodeLine ("\tbcc\t*+3"); AddCodeLine ("\tbcc\t*+3");
AddCodeLine ("\tinx"); AddCodeLine ("\tinx");
AddCodeHint ("x:!"); /* Invalidate X */ AddCodeHint ("x:!"); /* Invalidate X */
} }
} }
} }
} }
@@ -984,61 +984,32 @@ void g_leavariadic (int Offs)
ArgSizeOffs = -oursp; ArgSizeOffs = -oursp;
CheckLocalOffs (ArgSizeOffs); CheckLocalOffs (ArgSizeOffs);
/* Get the stack pointer plus offset. Clear the carry as the result of /* Get the size of all parameters. */
* this sequence. if (ArgSizeOffs == 0 && CPU == CPU_65C02) {
*/ AddCodeLine ("\tlda\t(sp)");
if (Offs > 0) {
AddCodeLine ("\tclc");
AddCodeLine ("\tlda\tsp");
AddCodeLine ("\tadc\t#$%02X", Offs & 0xFF);
if (Offs >= 256) {
AddCodeLine ("\tpha");
AddCodeLine ("\tlda\tsp+1");
AddCodeLine ("\tadc\t#$%02X", (Offs >> 8) & 0xFF);
AddCodeLine ("\ttax");
AddCodeLine ("\tpla");
AddCodeLine ("\tclc");
} else {
AddCodeLine ("\tldx\tsp+1");
AddCodeLine ("\tbcc\t*+4"); /* Jump over the clc */
AddCodeLine ("\tinx");
AddCodeHint ("x:!"); /* Invalidate X */
AddCodeLine ("\tclc");
}
} else if (Offs < 0) {
Offs = -Offs;
AddCodeLine ("\tsec");
AddCodeLine ("\tlda\tsp");
AddCodeLine ("\tsbc\t#$%02X", Offs & 0xFF);
if (Offs >= 256) {
AddCodeLine ("\tpha");
AddCodeLine ("\tlda\tsp+1");
AddCodeLine ("\tsbc\t#$%02X", (Offs >> 8) & 0xFF);
AddCodeLine ("\ttax");
AddCodeLine ("\tpla");
} else {
AddCodeLine ("\tldx\tsp+1");
AddCodeLine ("\tbcs\t*+3");
AddCodeLine ("\tdex");
AddCodeHint ("x:!"); /* Invalidate X */
}
AddCodeLine ("\tclc");
} else { } else {
AddCodeLine ("\tlda\tsp"); ldyconst (ArgSizeOffs);
AddCodeLine ("\tldx\tsp+1"); AddCodeLine ("\tlda\t(sp),y");
AddCodeLine ("\tclc");
} }
/* Add the size of all parameters. Carry is clear on entry. */ /* Add the value of the stackpointer */
if (ArgSizeOffs == 0 && CPU == CPU_65C02) { if (CodeSizeFactor > 250) {
AddCodeLine ("\tadc\t(sp)"); AddCodeLine ("\tldx\tsp+1");
AddCodeLine ("\tclc");
AddCodeLine ("\tadc\tsp");
AddCodeLine ("\tbcc\t*+3");
AddCodeLine ("\tinx");
AddCodeHint ("x:!"); /* Invalidate X */
} else { } else {
ldyconst (ArgSizeOffs); AddCodeLine ("\tjsr\tleaasp");
AddCodeLine ("\tadc\t(sp),y"); }
/* Add the offset to the primary */
if (Offs > 0) {
g_inc (CF_INT | CF_CONST, Offs);
} else if (Offs < 0) {
g_dec (CF_INT | CF_CONST, -Offs);
} }
AddCodeLine ("\tbcc\t*+3");
AddCodeLine ("\tinx");
AddCodeHint ("x:!"); /* Invalidate X */
} }
@@ -3396,7 +3367,7 @@ void g_dec (unsigned flags, unsigned long val)
/* FALLTHROUGH */ /* FALLTHROUGH */
case CF_INT: case CF_INT:
if (val <= 2) { if (val <= 8) {
AddCodeLine ("\tjsr\tdecax%d", (int) val); AddCodeLine ("\tjsr\tdecax%d", (int) val);
} else if (val <= 255) { } else if (val <= 255) {
ldyconst (val); ldyconst (val);