/* */
/* */
/* */
-/* (C) 1998-2002 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
+/* (C) 1998-2003 Ullrich von Bassewitz */
+/* Römerstrasse 52 */
+/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
break;
default:
- Internal ("Invalid address flags");
+ Internal ("Invalid address flags: %04X", Flags);
}
/* Return a pointer to the static buffer */
/* Identify the compiler version */
AddTextLine (";");
AddTextLine ("; File generated by cc65 v %u.%u.%u",
- VER_MAJOR, VER_MINOR, VER_PATCH);
+ VER_MAJOR, VER_MINOR, VER_PATCH);
AddTextLine (";");
/* Insert some object file options */
AddTextLine ("\t.fopt\t\tcompiler,\"cc65 v %u.%u.%u\"",
- VER_MAJOR, VER_MINOR, VER_PATCH);
+ 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.pc02");
+ AddTextLine ("\t.pc02");
}
/* Allow auto import for runtime library routines */
void g_fileinfo (const char* Name, unsigned long Size, unsigned long MTime)
/* If debug info is enabled, place a file info into the source */
-{
+{
if (DebugInfo) {
/* We have to place this into the global text segment, so it will
* appear before all .dbg line statements.
+void g_importmainargs (void)
+/* Forced import of a special symbol that handles arguments to main */
+{
+ AddTextLine ("\t.forceimport\tinitmainargs");
+}
+
+
+
/*****************************************************************************/
/* Load functions for various registers */
/*****************************************************************************/
/*****************************************************************************/
-/* 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 */
{
-void g_zerobytes (unsigned n)
-/* Output n bytes of data initialized with zero */
+void g_zerobytes (unsigned Count)
+/* Output Count bytes of data initialized with zero */
{
- AddDataLine ("\t.res\t%u,$00", n);
+ if (Count > 0) {
+ AddDataLine ("\t.res\t%u,$00", Count);
+ }
+}
+
+
+
+void g_initregister (unsigned Label, unsigned Reg, unsigned Size)
+/* Initialize a register variable from static initialization data */
+{
+ /* Register variables do always have less than 128 bytes */
+ unsigned CodeLabel = GetLocalLabel ();
+ ldxconst (Size-1);
+ g_defcodelabel (CodeLabel);
+ AddCodeLine ("lda %s,x", GetLabelName (CF_STATIC, Label, 0));
+ AddCodeLine ("sta %s,x", GetLabelName (CF_REGVAR, Reg, 0));
+ AddCodeLine ("dex");
+ AddCodeLine ("bpl %s", LocalLabelName (CodeLabel));
}