VER_MAJOR, VER_MINOR, VER_PATCH);
/* If we're producing code for some other CPU, switch the command set */
- if (CPU == CPU_65C02) {
- AddTextLine ("\t.setcpu\t\t\"65C02\"");
+ switch (CPU) {
+ case CPU_6502: AddTextLine ("\t.setcpu\t\t\"6502\""); break;
+ case CPU_65SC02: AddTextLine ("\t.setcpu\t\t\"65SC02\""); break;
+ case CPU_65C02: AddTextLine ("\t.setcpu\t\t\"65C02\""); break;
+ case CPU_65816: AddTextLine ("\t.setcpu\t\t\"65816\""); break;
+ default: Internal ("Unknown CPU: %d", CPU);
}
+ /* Use smart mode */
+ AddTextLine ("\t.smart\t\ton");
+
/* Allow auto import for runtime library routines */
AddTextLine ("\t.autoimport\ton");
}
-
+
int pop (unsigned flags)
/* Pop an argument of the given size */
{
AddCodeLine ("jsr leaasp"); /* Load effective address */
} else {
unsigned L = GetLocalLabel ();
- if (CPU == CPU_65C02 && offs == 1) {
+ if ((CPUIsets[CPU] & CPU_ISET_65SC02) != 0 && offs == 1) {
AddCodeLine ("lda sp");
AddCodeLine ("ldx sp+1");
AddCodeLine ("ina");
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- if (CPU == CPU_65C02 && val <= 2) {
+ if ((CPUIsets[CPU] & CPU_ISET_65SC02) != 0 && val <= 2) {
while (val--) {
AddCodeLine ("ina");
}
/* FALLTHROUGH */
case CF_INT:
- if (CPU == CPU_65C02 && val == 1) {
+ if ((CPUIsets[CPU] & CPU_ISET_65SC02) != 0 && val == 1) {
unsigned L = GetLocalLabel();
AddCodeLine ("ina");
AddCodeLine ("bne %s", LocalLabelName (L));
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- if (CPU == CPU_65C02 && val <= 2) {
+ if ((CPUIsets[CPU] & CPU_ISET_65SC02) != 0 && val <= 2) {
while (val--) {
AddCodeLine ("dea");
}
/* */
/* */
/* (C) 2001-2003 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
+/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
{
unsigned Changes = 0;
- if (CPU >= CPU_65C02) {
+ if (CPUIsets[CPU] & CPU_ISET_65SC02) {
Changes += RunOptFunc (S, &DOpt65C02BitOps, 1);
Changes += RunOptFunc (S, &DOpt65C02Ind, 1);
Changes += RunOptFunc (S, &DOpt65C02Stores, 1);
}
- } else if (CPU == CPU_65C02 &&
- (E->Info & OF_UBRA) != 0 &&
- E->JumpTo != 0 &&
+ } else if ((CPUIsets[CPU] & CPU_ISET_65SC02) != 0 &&
+ (E->Info & OF_UBRA) != 0 &&
+ E->JumpTo != 0 &&
IsShortDist (GetBranchDist (S, I, E->JumpTo->Owner))) {
/* The jump is short and may be replaced by a BRA on the 65C02 CPU */
/* */
/* */
/* */
-/* (C) 2002 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
+/* (C) 2002-2003 Ullrich von Bassewitz */
+/* Römerstraße 52 */
+/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
X = NewCodeEntry (OP65_TXA, AM65_IMP, 0, 0, E->LI);
} else if (Val == In->RegY) {
X = NewCodeEntry (OP65_TYA, AM65_IMP, 0, 0, E->LI);
- } else if (RegValIsKnown (In->RegA) && CPU >= CPU_65C02) {
+ } else if (RegValIsKnown (In->RegA) && (CPUIsets[CPU] & CPU_ISET_65SC02) != 0) {
if (Val == ((In->RegA - 1) & 0xFF)) {
X = NewCodeEntry (OP65_DEA, AM65_IMP, 0, 0, E->LI);
} else if (Val == ((In->RegA + 1) & 0xFF)) {
{
/* Find the CPU from the given name */
CPU = FindCPU (Arg);
- if (CPU != CPU_6502 && CPU != CPU_65C02) {
+ if (CPU != CPU_6502 && CPU != CPU_65SC02 &&
+ CPU != CPU_65C02 && CPU != CPU_65816) {
AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
}
}
}
}
+ /* If no memory model was given, use the default */
+ if (MemoryModel == MMODEL_UNKNOWN) {
+ SetMemoryModel (MMODEL_NEAR);
+ }
+
/* Go! */
Compile (InputFile);
/* */
/* */
/* */
-/* (C) 2001-2002 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
+/* (C) 2001-2003 Ullrich von Bassewitz */
+/* Römerstraße 52 */
+/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
REG_NONE, /* use */
REG_NONE, /* chg */
OF_SETF /* flags */
- },
+ },
/* Mark RTI as "uses all registers but doesn't change them", so the
* optimizer won't remove preceeding loads.
*/
case OP65_BVS:
case OP65_JVS: return OP65_BVS;
case OP65_BRA:
- case OP65_JMP: return (CPU == CPU_65C02)? OP65_BRA : OP65_JMP;
+ case OP65_JMP: return (CPUIsets[CPU] & CPU_ISET_65SC02)? OP65_BRA : OP65_JMP;
default:
Internal ("MakeShortBranch: Invalid opcode: %d", OPC);
return 0;