/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include <stdio.h>
#include <string.h>
-#include "../common/version.h"
-#include "../common/xmalloc.h"
+/* common */
+#include "check.h"
+#include "version.h"
+#include "xmalloc.h"
+/* cc65 */
#include "asmcode.h"
#include "asmlabel.h"
-#include "check.h"
#include "cpu.h"
#include "error.h"
#include "global.h"
#include "litpool.h"
#include "optimize.h"
+#include "segname.h"
#include "util.h"
#include "codegen.h"
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/* Compiler relative stk ptr */
-int oursp = 0;
+int oursp = 0;
/* Current segment */
-static enum {
- SEG_INV = -1, /* Invalid segment */
- SEG_CODE,
- SEG_RODATA,
- SEG_DATA,
- SEG_BSS
-} CurSeg = SEG_CODE;
+segment_t CurSeg = SEG_INV;
/* Segment names */
-static char* SegmentNames [4];
static char* SegmentHints [4] = {
"seg:code", "seg:rodata", "seg:data", "seg:bss"
};
if (Offs >= 256) {
/* Too many local vars */
AddCodeLine (";*** Too many locals");
- Error (ERR_TOO_MANY_LOCALS);
+ Error ("Too many local variables");
}
}
/* Allow auto import for runtime library routines */
AddCodeLine (".autoimport\ton");
- /* Switch the assembler into case sensible mode */
+ /* Switch the assembler into case sensitive mode */
AddCodeLine (".case\t\ton");
/* Tell the assembler if we want to generate debug info */
AddCodeLine (".endmacro");
AddEmptyLine ();
- /* Define the default names for the segments */
- SegmentNames [SEG_CODE] = xstrdup ("CODE");
- SegmentNames [SEG_RODATA] = xstrdup ("RODATA");
- SegmentNames [SEG_DATA] = xstrdup ("DATA");
- SegmentNames [SEG_BSS] = xstrdup ("BSS");
-
/* Tell the optimizer that this is the end of the preamble */
AddCodeHint ("end_of_preamble");
}
-static void SegName (int Seg, const char* Name)
+static void SegName (segment_t Seg, const char* Name)
/* Set the name of a segment */
{
/* Free the old name and set a new one */
- xfree (SegmentNames [Seg]);
- SegmentNames [Seg] = xstrdup (Name);
+ NewSegName (Seg, Name);
/* If the new segment is the current segment, emit a segment directive
* with the new name.
int k;
char buf [40];
+ /* CF_REG is set if we're returning a value from the function */
+ if ((flags & CF_REG) == 0) {
+ AddCodeHint ("x:-");
+ AddCodeHint ("a:-");
+ }
+
/* How many bytes of locals do we have to drop? */
k = -oursp;
/* Drop stackframe or leave with rts */
k += funcargs;
if (k == 0) {
+ AddCodeHint ("y:-"); /* Y register no longer used */
AddCodeLine ("\trts");
} else if (k <= 8) {
+ AddCodeHint ("y:-"); /* Y register no longer used */
AddCodeLine ("\tjmp\tincsp%d", k);
} else {
CheckLocalOffs (k);
/* We've a stack frame to drop */
ldyconst (k);
strcat (buf, "y");
- }
+ } else {
+ /* Y register no longer used */
+ AddCodeHint ("y:-");
+ }
if (flags & CF_CONST) {
if ((flags & CF_TYPE) != CF_LONG) {
/* Constant int sized value given for return code */
-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
* on the top of the stack
*/
{
- /* We cannot currently handle more than byte sized offsets */
- if (offs > 256 - sizeofarg (flags)) {
- Internal ("g_putind: Large offsets not implemented");
+ /* We can handle offsets below $100 directly, larger offsets must be added
+ * to the address. Since a/x is in use, best code is achieved by adding
+ * 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 */
- switch (flags & CF_TYPE) {
+ switch (Flags & CF_TYPE) {
case CF_CHAR:
- if (offs) {
- ldyconst (offs);
+ if (Offs) {
+ ldyconst (Offs);
AddCodeLine ("\tjsr\tstaspidx");
} else {
- AddCodeLine ("\tjsr\tstaspp");
+ AddCodeLine ("\tjsr\tstaspp");
}
break;
case CF_INT:
- if (offs) {
- ldyconst (offs);
- AddCodeLine ("\tjsr\tstaxspidx");
+ if (Offs) {
+ ldyconst (Offs);
+ AddCodeLine ("\tjsr\tstaxspidx");
} else {
- AddCodeLine ("\tjsr\tstaxspp");
+ AddCodeLine ("\tjsr\tstaxspp");
}
break;
case CF_LONG:
- if (offs) {
- ldyconst (offs);
- AddCodeLine ("\tjsr\tsteaxspidx");
+ if (Offs) {
+ ldyconst (Offs);
+ AddCodeLine ("\tjsr\tsteaxspidx");
} else {
- AddCodeLine ("\tjsr\tsteaxspp");
+ AddCodeLine ("\tjsr\tsteaxspp");
}
break;
default:
- typeerror (flags);
+ typeerror (Flags);
}
AddCodeLine ("\tinc\t%s", lbuf);
AddCodeLine ("\tlda\t%s", lbuf);
} else {
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tclc");
AddCodeLine ("\tadc\t%s", lbuf);
AddCodeLine ("\tsta\t%s", lbuf);
if (val == 1) {
label = GetLabel ();
AddCodeLine ("\tinc\t%s", lbuf);
- AddCodeLine ("\tbne\tL%04X", label);
+ AddCodeLine ("\tbne\tL%04X", (int)label);
AddCodeLine ("\tinc\t%s+1", lbuf);
g_defloclabel (label);
- AddCodeLine ("\tlda\t%s", lbuf); /* Hmmm... */
+ AddCodeLine ("\tlda\t%s", lbuf); /* Hmmm... */
AddCodeLine ("\tldx\t%s+1", lbuf);
} else {
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tclc");
AddCodeLine ("\tadc\t%s", lbuf);
AddCodeLine ("\tsta\t%s", lbuf);
if (val < 0x100) {
label = GetLabel ();
- AddCodeLine ("\tbcc\tL%04X", label);
+ AddCodeLine ("\tbcc\tL%04X", (int)label);
AddCodeLine ("\tinc\t%s+1", lbuf);
g_defloclabel (label);
AddCodeLine ("\tldx\t%s+1", lbuf);
} else {
- AddCodeLine ("\tlda\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tadc\t%s+1", lbuf);
AddCodeLine ("\tsta\t%s+1", lbuf);
AddCodeLine ("\ttax");
if (val == 1) {
AddCodeLine ("\tjsr\tladdeq1");
} else {
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tjsr\tladdeqa");
}
} else {
AddCodeLine ("\tldx\t#$00");
if (flags & CF_CONST) {
AddCodeLine ("\tclc");
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tadc\t(sp,x)");
AddCodeLine ("\tsta\t(sp,x)");
} else {
AddCodeLine ("\tldx\t#$00");
if (flags & CF_CONST) {
AddCodeLine ("\tclc");
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tadc\t(sp),y");
AddCodeLine ("\tsta\t(sp),y");
} else {
AddCodeLine ("\tstx\tptr1+1");
if (offs == 0) {
AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tclc");
AddCodeLine ("\tadc\t(ptr1,x)");
AddCodeLine ("\tsta\t(ptr1,x)");
} else {
AddCodeLine ("\tldy\t#$%02X", offs);
AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tclc");
AddCodeLine ("\tadc\t(ptr1),y");
AddCodeLine ("\tsta\t(ptr1),y");
AddCodeLine ("\tsta\tptr1");
AddCodeLine ("\tstx\tptr1+1");
AddCodeLine ("\tldy\t#$%02X", offs);
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tclc");
AddCodeLine ("\tadc\t(ptr1),y");
AddCodeLine ("\tsta\t(ptr1),y");
AddCodeLine ("\tpha");
AddCodeLine ("\tiny");
- AddCodeLine ("\tlda\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tadc\t(ptr1),y");
AddCodeLine ("\tsta\t(ptr1),y");
AddCodeLine ("\ttax");
} else {
AddCodeLine ("\tsec");
AddCodeLine ("\tlda\t%s", lbuf);
- AddCodeLine ("\tsbc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (int)(val & 0xFF));
AddCodeLine ("\tsta\t%s", lbuf);
}
} else {
AddCodeLine ("\tsec");
if (flags & CF_CONST) {
AddCodeLine ("\tlda\t%s", lbuf);
- AddCodeLine ("\tsbc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
AddCodeLine ("\tsta\t%s", lbuf);
if (val < 0x100) {
label = GetLabel ();
- AddCodeLine ("\tbcs\tL%04X", label);
+ AddCodeLine ("\tbcs\tL%04X", (unsigned)label);
AddCodeLine ("\tdec\t%s+1", lbuf);
g_defloclabel (label);
AddCodeLine ("\tldx\t%s+1", lbuf);
} else {
AddCodeLine ("\tlda\t%s+1", lbuf);
- AddCodeLine ("\tsbc\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tsta\t%s+1", lbuf);
AddCodeLine ("\ttax");
AddCodeLine ("\tlda\t%s", lbuf);
if (val == 1) {
AddCodeLine ("\tjsr\tlsubeq1");
} else {
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tlda\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tlsubeqa");
}
} else {
AddCodeLine ("\tsec");
if (flags & CF_CONST) {
AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tsbc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
} else {
AddCodeLine ("\tsta\ttmp1");
AddCodeLine ("\tlda\t(sp),y");
AddCodeLine ("\tldx\t#$00");
AddCodeLine ("\tlda\t(ptr1,x)");
AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
AddCodeLine ("\tsta\t(ptr1,x)");
} else {
AddCodeLine ("\tldy\t#$%02X", offs);
AddCodeLine ("\tldx\t#$00");
AddCodeLine ("\tlda\t(ptr1),y");
AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
AddCodeLine ("\tsta\t(ptr1),y");
}
break;
AddCodeLine ("\tldy\t#$%02X", offs);
AddCodeLine ("\tlda\t(ptr1),y");
AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
AddCodeLine ("\tsta\t(ptr1),y");
AddCodeLine ("\tpha");
AddCodeLine ("\tiny");
AddCodeLine ("\tlda\t(ptr1),y");
- AddCodeLine ("\tsbc\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tsta\t(ptr1),y");
AddCodeLine ("\ttax");
AddCodeLine ("\tpla");
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcpx\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
break;
case CF_LONG:
case CF_CHAR:
case CF_INT:
- AddCodeLine ("\t.word\t$%04X, L%04X", val & 0xFFFF, label & 0xFFFF);
+ AddCodeLine ("\t.word\t$%04X, L%04X",
+ (unsigned)(val & 0xFFFF),
+ (unsigned)(label & 0xFFFF));
break;
case CF_LONG:
- AddCodeLine ("\t.dword\t$%08X", val);
+ AddCodeLine ("\t.dword\t$%08lX", val);
AddCodeLine ("\t.word\tL%04X", label & 0xFFFF);
break;
/* Create or drop space on the stack */
{
if (space < 0) {
- mod_internal (-space, "inc", "addy");
+ mod_internal (-space, "inc", "addy");
} else if (space > 0) {
- mod_internal (space, "dec", "suby");
+ mod_internal (space, "dec", "suby");
}
}
+void g_cstackcheck (void)
+/* Check for a C stack overflow */
+{
+ AddCodeLine ("\tjsr\tcstkchk");
+}
+
+
+
+void g_stackcheck (void)
+/* Check for a stack overflow */
+{
+ AddCodeLine ("\tjsr\tstkchk");
+}
+
+
+
void g_add (unsigned flags, unsigned long val)
/* Primary = TOS + Primary */
{
};
if (flags & CF_CONST) {
- flags &= ~CF_FORCECHAR; // Handle chars as ints
+ flags &= ~CF_FORCECHAR; /* Handle chars as ints */
g_push (flags & ~CF_CONST, 0);
}
oper (flags, val, ops);
};
if (flags & CF_CONST) {
- flags &= ~CF_FORCECHAR; // Handle chars as ints
+ flags &= ~CF_FORCECHAR; /* Handle chars as ints */
g_push (flags & ~CF_CONST, 0);
}
oper (flags, val, ops);
/* If we go here, we didn't emit code. Push the lhs on stack and fall
* into the normal, non-optimized stuff.
*/
- flags &= ~CF_FORCECHAR; // Handle chars as ints
+ flags &= ~CF_FORCECHAR; /* Handle chars as ints */
g_push (flags & ~CF_CONST, 0);
}
/* Generate a division */
if (flags & CF_CONST) {
/* lhs is not on stack */
- flags &= ~CF_FORCECHAR; // Handle chars as ints
+ flags &= ~CF_FORCECHAR; /* Handle chars as ints */
g_push (flags & ~CF_CONST, 0);
}
oper (flags, val, ops);
/* Do it the hard way... */
if (flags & CF_CONST) {
/* lhs is not on stack */
- flags &= ~CF_FORCECHAR; // Handle chars as ints
+ flags &= ~CF_FORCECHAR; /* Handle chars as ints */
g_push (flags & ~CF_CONST, 0);
}
oper (flags, val, ops);
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if ((val & 0xFF) != 0xFF) {
- AddCodeLine ("\tora\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tora\t#$%02X", (unsigned char)val);
}
return;
}
case CF_INT:
if (val <= 0xFF) {
- AddCodeLine ("\tora\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tora\t#$%02X", (unsigned char)val);
return;
}
break;
case CF_LONG:
if (val <= 0xFF) {
- AddCodeLine ("\tora\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tora\t#$%02X", (unsigned char)val);
return;
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if ((val & 0xFF) != 0) {
- AddCodeLine ("\teor\t#$%02X", val & 0xFF);
+ AddCodeLine ("\teor\t#$%02X", (unsigned char)val);
}
return;
}
case CF_INT:
if (val <= 0xFF) {
if (val != 0) {
- AddCodeLine ("\teor\t#$%02X", val);
+ AddCodeLine ("\teor\t#$%02X", (unsigned char)val);
}
return;
} else if ((val & 0xFF) == 0) {
AddCodeLine ("\tpha");
AddCodeLine ("\ttxa");
- AddCodeLine ("\teor\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\teor\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\ttax");
AddCodeLine ("\tpla");
return;
case CF_LONG:
if (val <= 0xFF) {
if (val != 0) {
- AddCodeLine ("\teor\t#$%02X", val & 0xFF);
+ AddCodeLine ("\teor\t#$%02X", (unsigned char)val);
}
return;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tand\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
return;
}
/* FALLTHROUGH */
if (val == 0) {
ldaconst (0);
} else if (val != 0xFF) {
- AddCodeLine ("\tand\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
}
} else if ((val & 0xFF00) == 0xFF00) {
- AddCodeLine ("\tand\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
} else if ((val & 0x00FF) == 0x0000) {
AddCodeLine ("\ttxa");
- AddCodeLine ("\tand\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tand\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\ttax");
ldaconst (0);
} else {
AddCodeLine ("\ttay");
AddCodeLine ("\ttxa");
- AddCodeLine ("\tand\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tand\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\ttax");
AddCodeLine ("\ttya");
if ((val & 0x00FF) != 0x00FF) {
- AddCodeLine ("\tand\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
}
}
}
AddCodeLine ("\tstx\tsreg+1");
AddCodeLine ("\tstx\tsreg");
if ((val & 0xFF) != 0xFF) {
- AddCodeLine ("\tand\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
}
return;
} else if (val == 0xFF00) {
}
} else {
AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tadc\t#$%02X", (unsigned char)val);
}
break;
}
} else if (FavourSize) {
/* Use jsr calls */
if (val <= 8) {
- AddCodeLine ("\tjsr\tincax%u", val);
+ AddCodeLine ("\tjsr\tincax%lu", val);
} else if (val <= 255) {
ldyconst (val);
AddCodeLine ("\tjsr\tincaxy");
void g_dec (unsigned flags, unsigned long val)
/* Decrement the primary register by a given number */
{
+ /* Don't dec by zero */
+ if (val == 0) {
+ return;
+ }
+
/* Generate code for the supported types */
flags &= ~CF_CONST;
switch (flags & CF_TYPE) {
}
} else {
AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
}
break;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tbooleq");
return;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tcpx\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tbooleq");
return;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tboolne");
return;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tcpx\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tboolne");
return;
/* Give a warning in some special cases */
if ((flags & CF_UNSIGNED) && val == 0) {
- Warning (WARN_COND_NEVER_TRUE);
+ Warning ("Condition is never true");
}
/* Look at the type */
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
AddCodeLine ("\tjsr\tboolult");
} else {
}
/* Direct code only for unsigned data types */
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tcpx\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tboolult");
return;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
AddCodeLine ("\tjsr\tboolule");
} else {
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tcpx\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tboolule");
return;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
/* If we have a compare > 0, we will replace it by
* != 0 here, since both are identical but the latter
AddCodeLine ("\tora\ttmp1");
AddCodeLine ("\tjsr\tboolne");
} else {
- AddCodeLine ("\tcpx\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tboolugt");
}
return;
/* Give a warning in some special cases */
if ((flags & CF_UNSIGNED) && val == 0) {
- Warning (WARN_COND_ALWAYS_TRUE);
+ Warning ("Condition is always true");
}
/* Look at the type */
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
AddCodeLine ("\tjsr\tbooluge");
} else {
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tcpx\t#$%02X", (val >> 8) & 0xFF);
+ AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", val & 0xFF);
+ AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
AddCodeLine ("\tjsr\tbooluge");
return;
}
/*****************************************************************************/
-/* Allocating static storage */
+/* Allocating static storage */
/*****************************************************************************/