/* common */
#include "check.h"
#include "cpu.h"
+#include "inttypes.h"
#include "strbuf.h"
#include "xmalloc.h"
#include "xsprintf.h"
-static const char* GetLabelName (unsigned Flags, unsigned long Label, long Offs)
+static const char* GetLabelName (unsigned Flags, uintptr_t Label, long Offs)
{
static char Buf [256]; /* Label name */
case CF_ABSOLUTE:
/* Absolute address */
- xsprintf (Buf, sizeof (Buf), "$%04X", (int)((Label+Offs) & 0xFFFF));
+ xsprintf (Buf, sizeof (Buf), "$%04X", (unsigned)((Label+Offs) & 0xFFFF));
break;
case CF_REGVAR:
-void g_getstatic (unsigned flags, unsigned long label, long offs)
+void g_getstatic (unsigned flags, uintptr_t label, long offs)
/* Fetch an static memory cell into the primary register */
{
/* Create the correct label name */
-void g_putstatic (unsigned flags, unsigned long label, long offs)
+void g_putstatic (unsigned flags, uintptr_t label, long offs)
/* Store the primary register into the specified static memory cell */
{
/* Create the correct label name */
-void g_addstatic (unsigned flags, unsigned long label, long offs)
+void g_addstatic (unsigned flags, uintptr_t label, long offs)
/* Add a static variable to ax */
{
unsigned L;
-void g_addeqstatic (unsigned flags, unsigned long label, long offs,
+void g_addeqstatic (unsigned flags, uintptr_t label, long offs,
unsigned long val)
/* Emit += for a static variable */
{
-void g_subeqstatic (unsigned flags, unsigned long label, long offs,
+void g_subeqstatic (unsigned flags, uintptr_t label, long offs,
unsigned long val)
/* Emit -= for a static variable */
{
-void g_addaddr_static (unsigned flags, unsigned long label, long offs)
+void g_addaddr_static (unsigned flags, uintptr_t label, long offs)
/* Add the address of a static variable to ax */
{
/* Create the correct label name */
}
+void g_lateadjustSP (unsigned label)
+/* Adjust stack based on non-immediate data */
+{
+ AddCodeLine ("pha");
+ AddCodeLine ("lda %s", LocalLabelName (label));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc sp");
+ AddCodeLine ("sta sp");
+ AddCodeLine ("lda %s+1", LocalLabelName (label));
+ AddCodeLine ("adc sp+1");
+ AddCodeLine ("sta sp+1");
+ AddCodeLine ("pla");
+}
void g_drop (unsigned Space)
/* Drop space allocated on the stack */
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0));
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
- AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
+ AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
AddCodeLine ("bne %s", LocalLabelName (CodeLabel));
}
}
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, InitLabel, 0));
AddCodeLine ("sta %s,y", GetLabelName (CF_STATIC, VarLabel, 0));
AddCodeLine ("iny");
- AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
+ AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
AddCodeLine ("bne %s", LocalLabelName (CodeLabel));
} else {
/* Use the easy way here: memcpy() */
g_getimmed (CF_STATIC, InitLabel, 0);
AddCodeLine ("jsr pushax");
g_getimmed (CF_INT | CF_UNSIGNED | CF_CONST, Size, 0);
- AddCodeLine ("jsr %s", GetLabelName (CF_EXTERNAL, (unsigned long) "memcpy", 0));
+ AddCodeLine ("jsr %s", GetLabelName (CF_EXTERNAL, (uintptr_t) "memcpy", 0));
}
}