mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Implemented large offsets for g_putind
git-svn-id: svn://svn.cc65.org/cc65/trunk@483 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
f6768466be
commit
5be5b3763b
@ -1039,48 +1039,81 @@ void g_putlocal (unsigned flags, int offs)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void g_putind (unsigned flags, unsigned offs)
|
void g_putind (unsigned Flags, unsigned Offs)
|
||||||
/* Store the specified object type in the primary register at the address
|
/* Store the specified object type in the primary register at the address
|
||||||
* on the top of the stack
|
* on the top of the stack
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* We cannot currently handle more than byte sized offsets */
|
/* We can handle offsets below $100 directly, larger offsets must be added
|
||||||
if (offs > 256 - sizeofarg (flags)) {
|
* to the address. Since a/x is in use, best code is achieved by adding
|
||||||
Internal ("g_putind: Large offsets not implemented");
|
* just the high byte. Be sure to check if the low byte will overflow while
|
||||||
|
* while storing.
|
||||||
|
*/
|
||||||
|
if ((Offs & 0xFF) > 256 - sizeofarg (Flags | CF_FORCECHAR)) {
|
||||||
|
|
||||||
|
/* Overflow - we need to add the low byte also */
|
||||||
|
AddCodeLine ("\tldy\t#$00");
|
||||||
|
AddCodeLine ("\tclc");
|
||||||
|
AddCodeLine ("\tpha");
|
||||||
|
AddCodeLine ("\tlda\t#$%02X", Offs & 0xFF);
|
||||||
|
AddCodeLine ("\tadc\t(sp),y");
|
||||||
|
AddCodeLine ("\tsta\t(sp),y");
|
||||||
|
AddCodeLine ("\tiny");
|
||||||
|
AddCodeLine ("\tlda\t#$%02X", (Offs >> 8) & 0xFF);
|
||||||
|
AddCodeLine ("\tadc\t(sp),y");
|
||||||
|
AddCodeLine ("\tsta\t(sp),y");
|
||||||
|
AddCodeLine ("\tpla");
|
||||||
|
|
||||||
|
/* Complete address is on stack, new offset is zero */
|
||||||
|
Offs = 0;
|
||||||
|
|
||||||
|
} else if ((Offs & 0xFF00) != 0) {
|
||||||
|
|
||||||
|
/* We can just add the high byte */
|
||||||
|
AddCodeLine ("\tldy\t#$01");
|
||||||
|
AddCodeLine ("\tclc");
|
||||||
|
AddCodeLine ("\tpha");
|
||||||
|
AddCodeLine ("\tlda\t#$%02X", (Offs >> 8) & 0xFF);
|
||||||
|
AddCodeLine ("\tadc\t(sp),y");
|
||||||
|
AddCodeLine ("\tsta\t(sp),y");
|
||||||
|
AddCodeLine ("\tpla");
|
||||||
|
|
||||||
|
/* Offset is now just the low byte */
|
||||||
|
Offs &= 0x00FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the size and determine operation */
|
/* Check the size and determine operation */
|
||||||
switch (flags & CF_TYPE) {
|
switch (Flags & CF_TYPE) {
|
||||||
|
|
||||||
case CF_CHAR:
|
case CF_CHAR:
|
||||||
if (offs) {
|
if (Offs) {
|
||||||
ldyconst (offs);
|
ldyconst (Offs);
|
||||||
AddCodeLine ("\tjsr\tstaspidx");
|
AddCodeLine ("\tjsr\tstaspidx");
|
||||||
} else {
|
} else {
|
||||||
AddCodeLine ("\tjsr\tstaspp");
|
AddCodeLine ("\tjsr\tstaspp");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CF_INT:
|
case CF_INT:
|
||||||
if (offs) {
|
if (Offs) {
|
||||||
ldyconst (offs);
|
ldyconst (Offs);
|
||||||
AddCodeLine ("\tjsr\tstaxspidx");
|
AddCodeLine ("\tjsr\tstaxspidx");
|
||||||
} else {
|
} else {
|
||||||
AddCodeLine ("\tjsr\tstaxspp");
|
AddCodeLine ("\tjsr\tstaxspp");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CF_LONG:
|
case CF_LONG:
|
||||||
if (offs) {
|
if (Offs) {
|
||||||
ldyconst (offs);
|
ldyconst (Offs);
|
||||||
AddCodeLine ("\tjsr\tsteaxspidx");
|
AddCodeLine ("\tjsr\tsteaxspidx");
|
||||||
} else {
|
} else {
|
||||||
AddCodeLine ("\tjsr\tsteaxspp");
|
AddCodeLine ("\tjsr\tsteaxspp");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
typeerror (flags);
|
typeerror (Flags);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user