/* cc65 */
#include "asmcode.h"
-#include "asmlabel.h"
+#include "asmlabel.h"
#include "codeseg.h"
#include "cpu.h"
#include "dataseg.h"
#include "error.h"
#include "global.h"
-#include "segname.h"
+#include "segments.h"
#include "util.h"
#include "codegen.h"
/* Compiler relative stack pointer */
int oursp = 0;
-/* Current segment */
-segment_t CurSeg = SEG_INV;
-
/*****************************************************************************/
-/* Helpers */
+/* Helpers */
/*****************************************************************************/
void g_preamble (void)
/* Generate the assembler code preamble */
{
- /* Generate the global segments and push them */
- PushCodeSeg (NewCodeSeg (SegmentNames[SEG_CODE], ""));
- PushDataSeg (NewDataSeg (""));
+ /* Create a new segment list */
+ PushSegments (0);
/* Identify the compiler version */
- AddDataSegLine (DS, "; File generated by cc65 v %u.%u.%u",
- VER_MAJOR, VER_MINOR, VER_PATCH);
+ AddDataLine ("; File generated by cc65 v %u.%u.%u",
+ VER_MAJOR, VER_MINOR, VER_PATCH);
/* Insert some object file options */
- AddDataSegLine (DS, ".fopt\t\tcompiler,\"cc65 v %u.%u.%u\"",
+ AddDataLine (".fopt\t\tcompiler,\"cc65 v %u.%u.%u\"",
VER_MAJOR, VER_MINOR, VER_PATCH);
/* If we're producing code for some other CPU, switch the command set */
if (CPU == CPU_65C02) {
- AddDataSegLine (DS, ".pc02");
+ AddDataLine (".pc02");
}
/* Allow auto import for runtime library routines */
- AddDataSegLine (DS, ".autoimport\ton");
+ AddDataLine (".autoimport\ton");
/* Switch the assembler into case sensitive mode */
- AddDataSegLine (DS, ".case\t\ton");
+ AddDataLine (".case\t\ton");
/* Tell the assembler if we want to generate debug info */
- AddDataSegLine (DS, ".debuginfo\t%s", (DebugInfo != 0)? "on" : "off");
+ AddDataLine (".debuginfo\t%s", (DebugInfo != 0)? "on" : "off");
/* Import the stack pointer for direct auto variable access */
- AddDataSegLine (DS, ".importzp\tsp, sreg, regsave, regbank, tmp1, ptr1");
+ AddDataLine (".importzp\tsp, sreg, regsave, regbank, tmp1, ptr1");
/* Define long branch macros */
- AddDataSegLine (DS, ".macpack\tlongbranch");
+ AddDataLine (".macpack\tlongbranch");
}
/*****************************************************************************/
-/* Segment support */
+/* Segment support */
/*****************************************************************************/
-static void UseSeg (int NewSeg)
-/* Switch to a specific segment */
-{
- if (CurSeg != NewSeg) {
- CurSeg = (segment_t) NewSeg;
- if (CurSeg != SEG_CODE) {
- AddDataSegLine (DS, ".segment\t\"%s\"", SegmentNames [CurSeg]);
- }
- }
-}
-
-
-
-void g_pushseg (struct CodeSeg** FCS, struct DataSeg** FDS, const char* FuncName)
-/* Push the current segments and generate new ones for the given function */
-{
- PushCodeSeg (NewCodeSeg (SegmentNames[SEG_CODE], FuncName));
- *FCS = CS;
- PushDataSeg (NewDataSeg (FuncName));
- *FDS = DS;
-}
-
-
-
-void g_popseg (void)
-/* Restore the old segments */
-{
- PopCodeSeg ();
- PopDataSeg ();
-}
-
-
-
void g_userodata (void)
/* Switch to the read only data segment */
{
- UseSeg (SEG_RODATA);
+ UseDataSeg (SEG_RODATA);
}
void g_usedata (void)
/* Switch to the data segment */
{
- UseSeg (SEG_DATA);
+ UseDataSeg (SEG_DATA);
}
void g_usebss (void)
/* Switch to the bss segment */
{
- UseSeg (SEG_BSS);
-}
-
-
-
-static void SegName (segment_t Seg, const char* Name)
-/* Set the name of a segment */
-{
- /* Free the old name and set a new one */
- NewSegName (Seg, Name);
-
- /* If the new segment is the current segment, emit a segment directive
- * with the new name.
- */
- if (Seg == CurSeg) {
- CurSeg = SEG_INV; /* Invalidate */
- UseSeg (Seg);
- }
-}
-
-
-
-void g_codename (const char* Name)
-/* Set the name of the CODE segment */
-{
- SegName (SEG_CODE, Name);
-}
-
-
-
-void g_rodataname (const char* Name)
-/* Set the name of the RODATA segment */
-{
- SegName (SEG_RODATA, Name);
-}
-
-
-
-void g_dataname (const char* Name)
-/* Set the name of the DATA segment */
-{
- SegName (SEG_DATA, Name);
-}
-
-
-
-void g_bssname (const char* Name)
-/* Set the name of the BSS segment */
-{
- SegName (SEG_BSS, Name);
+ UseDataSeg (SEG_BSS);
}
void g_defcodelabel (unsigned label)
/* Define a local code label */
{
- AddCodeLabel (CS, LocalLabelName (label));
+ AddCodeLabel (CS->Code, LocalLabelName (label));
}
void g_defdatalabel (unsigned label)
/* Define a local data label */
{
- AddDataSegLine (DS, "%s:", LocalLabelName (label));
+ AddDataLine ("%s:", LocalLabelName (label));
}
/* Define a global label with the given name */
{
/* Global labels are always data labels */
- AddDataSegLine (DS, "_%s:", Name);
+ AddDataLine ("_%s:", Name);
}
/* Export the given label */
{
if (ZP) {
- AddDataSegLine (DS, "\t.exportzp\t_%s", Name);
+ AddDataLine ("\t.exportzp\t_%s", Name);
} else {
- AddDataSegLine (DS, "\t.export\t\t_%s", Name);
+ AddDataLine ("\t.export\t\t_%s", Name);
}
}
/* Import the given label */
{
if (ZP) {
- AddDataSegLine (DS, "\t.importzp\t_%s", Name);
+ AddDataLine ("\t.importzp\t_%s", Name);
} else {
- AddDataSegLine (DS, "\t.import\t\t_%s", Name);
+ AddDataLine ("\t.import\t\t_%s", Name);
}
}
static void ldaconst (unsigned val)
/* Load a with a constant */
{
- AddCodeSegLine (CS, "lda #$%02X", val & 0xFF);
+ AddCodeLine ("lda #$%02X", val & 0xFF);
}
static void ldxconst (unsigned val)
/* Load x with a constant */
{
- AddCodeSegLine (CS, "ldx #$%02X", val & 0xFF);
+ AddCodeLine ("ldx #$%02X", val & 0xFF);
}
static void ldyconst (unsigned val)
/* Load y with a constant */
{
- AddCodeSegLine (CS, "ldy #$%02X", val & 0xFF);
+ AddCodeLine ("ldy #$%02X", val & 0xFF);
}
funcargs = argsize;
} else {
funcargs = -1;
- AddCodeSegLine (CS, "jsr enter");
+ AddCodeLine ("jsr enter");
}
}
k += funcargs;
if (k == 0) {
AddCodeHint ("y:-"); /* Y register no longer used */
- AddCodeSegLine (CS, "rts");
+ AddCodeLine ("rts");
} else if (k <= 8) {
AddCodeHint ("y:-"); /* Y register no longer used */
- AddCodeSegLine (CS, "jmp incsp%d", k);
+ AddCodeLine ("jmp incsp%d", k);
} else {
CheckLocalOffs (k);
ldyconst (k);
- AddCodeSegLine (CS, "jmp addysp");
+ AddCodeLine ("jmp addysp");
}
} else {
}
/* Output the jump */
- AddCodeSegLine (CS, buf);
+ AddCodeLine (buf);
}
}
/* Don't loop for up to two bytes */
if (Bytes == 1) {
- AddCodeSegLine (CS, "lda regbank%+d", RegOffs);
- AddCodeSegLine (CS, "jsr pusha");
+ AddCodeLine ("lda regbank%+d", RegOffs);
+ AddCodeLine ("jsr pusha");
} else if (Bytes == 2) {
- AddCodeSegLine (CS, "lda regbank%+d", RegOffs);
- AddCodeSegLine (CS, "ldx regbank%+d", RegOffs+1);
- AddCodeSegLine (CS, "jsr pushax");
+ AddCodeLine ("lda regbank%+d", RegOffs);
+ AddCodeLine ("ldx regbank%+d", RegOffs+1);
+ AddCodeLine ("jsr pushax");
} else {
ldyconst (Bytes - 1);
ldxconst (Bytes);
g_defcodelabel (Label);
- AddCodeSegLine (CS, "lda regbank%+d,x", RegOffs-1);
- AddCodeSegLine (CS, "sta (sp),y");
- AddCodeSegLine (CS, "dey");
- AddCodeSegLine (CS, "dex");
- AddCodeSegLine (CS, "bne %s", LocalLabelName (Label));
+ AddCodeLine ("lda regbank%+d,x", RegOffs-1);
+ AddCodeLine ("sta (sp),y");
+ AddCodeLine ("dey");
+ AddCodeLine ("dex");
+ AddCodeLine ("bne %s", LocalLabelName (Label));
}
if (Bytes == 1) {
ldyconst (StackOffs);
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "sta regbank%+d", RegOffs);
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("sta regbank%+d", RegOffs);
} else if (Bytes == 2) {
ldyconst (StackOffs);
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "sta regbank%+d", RegOffs);
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "sta regbank%+d", RegOffs+1);
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("sta regbank%+d", RegOffs);
+ AddCodeLine ("iny");
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("sta regbank%+d", RegOffs+1);
} else {
ldyconst (StackOffs+Bytes-1);
ldxconst (Bytes);
g_defcodelabel (Label);
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "sta regbank%+d,x", RegOffs-1);
- AddCodeSegLine (CS, "dey");
- AddCodeSegLine (CS, "dex");
- AddCodeSegLine (CS, "bne %s", LocalLabelName (Label));
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("sta regbank%+d,x", RegOffs-1);
+ AddCodeLine ("dey");
+ AddCodeLine ("dex");
+ AddCodeLine ("bne %s", LocalLabelName (Label));
}
}
case CF_LONG:
if (val < 0x100) {
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "stx sreg+1");
- AddCodeSegLine (CS, "stx sreg");
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char) val);
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("stx sreg+1");
+ AddCodeLine ("stx sreg");
+ AddCodeLine ("lda #$%02X", (unsigned char) val);
} else if ((val & 0xFFFF00FF) == 0) {
- AddCodeSegLine (CS, "lda #$00");
- AddCodeSegLine (CS, "sta sreg+1");
- AddCodeSegLine (CS, "sta sreg");
- AddCodeSegLine (CS, "ldx #$%02X", (unsigned char) (val >> 8));
+ AddCodeLine ("lda #$00");
+ AddCodeLine ("sta sreg+1");
+ AddCodeLine ("sta sreg");
+ AddCodeLine ("ldx #$%02X", (unsigned char) (val >> 8));
} else if ((val & 0xFFFF0000) == 0 && CodeSizeFactor > 140) {
- AddCodeSegLine (CS, "lda #$00");
- AddCodeSegLine (CS, "sta sreg+1");
- AddCodeSegLine (CS, "sta sreg");
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char) val);
- AddCodeSegLine (CS, "ldx #$%02X", (unsigned char) (val >> 8));
+ AddCodeLine ("lda #$00");
+ AddCodeLine ("sta sreg+1");
+ AddCodeLine ("sta sreg");
+ AddCodeLine ("lda #$%02X", (unsigned char) val);
+ AddCodeLine ("ldx #$%02X", (unsigned char) (val >> 8));
} else if ((val & 0xFFFFFF00) == 0xFFFFFF00) {
- AddCodeSegLine (CS, "ldx #$FF");
- AddCodeSegLine (CS, "stx sreg+1");
- AddCodeSegLine (CS, "stx sreg");
+ AddCodeLine ("ldx #$FF");
+ AddCodeLine ("stx sreg+1");
+ AddCodeLine ("stx sreg");
if ((val & 0xFF) == 0xFF) {
- AddCodeSegLine (CS, "txa");
+ AddCodeLine ("txa");
} else {
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char) val);
+ AddCodeLine ("lda #$%02X", (unsigned char) val);
}
} else if ((val & 0xFFFF00FF) == 0xFFFF00FF) {
- AddCodeSegLine (CS, "lda #$FF");
- AddCodeSegLine (CS, "sta sreg+1");
- AddCodeSegLine (CS, "sta sreg");
- AddCodeSegLine (CS, "ldx #$%02X", (unsigned char) (val >> 8));
+ AddCodeLine ("lda #$FF");
+ AddCodeLine ("sta sreg+1");
+ AddCodeLine ("sta sreg");
+ AddCodeLine ("ldx #$%02X", (unsigned char) (val >> 8));
} else {
/* Call a subroutine that will load following value */
- AddCodeSegLine (CS, "jsr ldeax");
- AddCodeSegLine (CS, ".dword $%08lX", val & 0xFFFFFFFF);
+ AddCodeLine ("jsr ldeax");
+ AddCodeLine (".dword $%08lX", val & 0xFFFFFFFF);
}
break;
const char* Label = GetLabelName (flags, val, offs);
/* Load the address into the primary */
- AddCodeSegLine (CS, "lda #<(%s)", Label);
- AddCodeSegLine (CS, "ldx #>(%s)", Label);
+ AddCodeLine ("lda #<(%s)", Label);
+ AddCodeLine ("ldx #>(%s)", Label);
}
}
case CF_CHAR:
if ((flags & CF_FORCECHAR) || (flags & CF_TEST)) {
- AddCodeSegLine (CS, "lda %s", lbuf); /* load A from the label */
+ AddCodeLine ("lda %s", lbuf); /* load A from the label */
} else {
ldxconst (0);
- AddCodeSegLine (CS, "lda %s", lbuf); /* load A from the label */
+ AddCodeLine ("lda %s", lbuf); /* load A from the label */
if (!(flags & CF_UNSIGNED)) {
/* Must sign extend */
- AddCodeSegLine (CS, "bpl *+3");
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("bpl *+3");
+ AddCodeLine ("dex");
AddCodeHint ("x:!"); /* X is invalid now */
}
}
break;
case CF_INT:
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("lda %s", lbuf);
if (flags & CF_TEST) {
- AddCodeSegLine (CS, "ora %s+1", lbuf);
+ AddCodeLine ("ora %s+1", lbuf);
} else {
- AddCodeSegLine (CS, "ldx %s+1", lbuf);
+ AddCodeLine ("ldx %s+1", lbuf);
}
break;
case CF_LONG:
if (flags & CF_TEST) {
- AddCodeSegLine (CS, "lda %s+3", lbuf);
- AddCodeSegLine (CS, "ora %s+2", lbuf);
- AddCodeSegLine (CS, "ora %s+1", lbuf);
- AddCodeSegLine (CS, "ora %s+0", lbuf);
+ AddCodeLine ("lda %s+3", lbuf);
+ AddCodeLine ("ora %s+2", lbuf);
+ AddCodeLine ("ora %s+1", lbuf);
+ AddCodeLine ("ora %s+0", lbuf);
} else {
- AddCodeSegLine (CS, "lda %s+3", lbuf);
- AddCodeSegLine (CS, "sta sreg+1");
- AddCodeSegLine (CS, "lda %s+2", lbuf);
- AddCodeSegLine (CS, "sta sreg");
- AddCodeSegLine (CS, "ldx %s+1", lbuf);
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("lda %s+3", lbuf);
+ AddCodeLine ("sta sreg+1");
+ AddCodeLine ("lda %s+2", lbuf);
+ AddCodeLine ("sta sreg");
+ AddCodeLine ("ldx %s+1", lbuf);
+ AddCodeLine ("lda %s", lbuf);
}
break;
case CF_CHAR:
if ((flags & CF_FORCECHAR) || (flags & CF_TEST)) {
if (CPU == CPU_65C02 && offs == 0) {
- AddCodeSegLine (CS, "lda (sp)");
+ AddCodeLine ("lda (sp)");
} else {
ldyconst (offs);
- AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeLine ("lda (sp),y");
}
} else {
if (offs == 0) {
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "lda (sp,x)");
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("lda (sp,x)");
} else {
ldyconst (offs);
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("lda (sp),y");
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeSegLine (CS, "bpl *+3");
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("bpl *+3");
+ AddCodeLine ("dex");
AddCodeHint ("x:!"); /* X is invalid now */
}
}
CheckLocalOffs (offs + 1);
if (flags & CF_TEST) {
ldyconst (offs + 1);
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "dey");
- AddCodeSegLine (CS, "ora (sp),y");
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("dey");
+ AddCodeLine ("ora (sp),y");
} else {
if (CodeSizeFactor > 180) {
ldyconst (offs + 1);
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "dey");
- AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("tax");
+ AddCodeLine ("dey");
+ AddCodeLine ("lda (sp),y");
} else {
if (offs) {
ldyconst (offs+1);
- AddCodeSegLine (CS, "jsr ldaxysp");
+ AddCodeLine ("jsr ldaxysp");
} else {
- AddCodeSegLine (CS, "jsr ldax0sp");
+ AddCodeLine ("jsr ldax0sp");
}
}
}
case CF_LONG:
if (offs) {
ldyconst (offs+3);
- AddCodeSegLine (CS, "jsr ldeaxysp");
+ AddCodeLine ("jsr ldeaxysp");
} else {
- AddCodeSegLine (CS, "jsr ldeax0sp");
+ AddCodeLine ("jsr ldeax0sp");
}
break;
if (offs) {
ldyconst (offs);
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr ldauidx");
+ AddCodeLine ("jsr ldauidx");
} else {
- AddCodeSegLine (CS, "jsr ldaidx");
+ AddCodeLine ("jsr ldaidx");
}
} else {
if (flags & CF_UNSIGNED) {
if (CodeSizeFactor > 250) {
- AddCodeSegLine (CS, "sta ptr1");
- AddCodeSegLine (CS, "stx ptr1+1");
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "lda (ptr1,x)");
+ AddCodeLine ("sta ptr1");
+ AddCodeLine ("stx ptr1+1");
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("lda (ptr1,x)");
} else {
- AddCodeSegLine (CS, "jsr ldaui");
+ AddCodeLine ("jsr ldaui");
}
} else {
- AddCodeSegLine (CS, "jsr ldai");
+ AddCodeLine ("jsr ldai");
}
}
break;
case CF_INT:
if (flags & CF_TEST) {
ldyconst (offs);
- AddCodeSegLine (CS, "sta ptr1");
- AddCodeSegLine (CS, "stx ptr1+1");
- AddCodeSegLine (CS, "lda (ptr1),y");
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "ora (ptr1),y");
+ AddCodeLine ("sta ptr1");
+ AddCodeLine ("stx ptr1+1");
+ AddCodeLine ("lda (ptr1),y");
+ AddCodeLine ("iny");
+ AddCodeLine ("ora (ptr1),y");
} else {
if (offs == 0) {
- AddCodeSegLine (CS, "jsr ldaxi");
+ AddCodeLine ("jsr ldaxi");
} else {
ldyconst (offs+1);
- AddCodeSegLine (CS, "jsr ldaxidx");
+ AddCodeLine ("jsr ldaxidx");
}
}
break;
case CF_LONG:
if (offs == 0) {
- AddCodeSegLine (CS, "jsr ldeaxi");
+ AddCodeLine ("jsr ldeaxi");
} else {
ldyconst (offs+3);
- AddCodeSegLine (CS, "jsr ldeaxidx");
+ AddCodeLine ("jsr ldeaxidx");
}
if (flags & CF_TEST) {
- AddCodeSegLine (CS, "jsr tsteax");
+ AddCodeLine ("jsr tsteax");
}
break;
/* For value 0 we do direct code */
if (offs == 0) {
- AddCodeSegLine (CS, "lda sp");
- AddCodeSegLine (CS, "ldx sp+1");
+ AddCodeLine ("lda sp");
+ AddCodeLine ("ldx sp+1");
} else {
if (CodeSizeFactor < 300) {
ldaconst (offs); /* Load A with offset value */
- AddCodeSegLine (CS, "jsr leaasp"); /* Load effective address */
+ AddCodeLine ("jsr leaasp"); /* Load effective address */
} else {
if (CPU == CPU_65C02 && offs == 1) {
- AddCodeSegLine (CS, "lda sp");
- AddCodeSegLine (CS, "ldx sp+1");
- AddCodeSegLine (CS, "ina");
- AddCodeSegLine (CS, "bne *+3");
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("lda sp");
+ AddCodeLine ("ldx sp+1");
+ AddCodeLine ("ina");
+ AddCodeLine ("bne *+3");
+ AddCodeLine ("inx");
AddCodeHint ("x:!"); /* Invalidate X */
} else {
ldaconst (offs);
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "ldx sp+1");
- AddCodeSegLine (CS, "adc sp");
- AddCodeSegLine (CS, "bcc *+3");
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("clc");
+ AddCodeLine ("ldx sp+1");
+ AddCodeLine ("adc sp");
+ AddCodeLine ("bcc *+3");
+ AddCodeLine ("inx");
AddCodeHint ("x:!"); /* Invalidate X */
}
}
/* Get the size of all parameters. */
if (ArgSizeOffs == 0 && CPU == CPU_65C02) {
- AddCodeSegLine (CS, "lda (sp)");
+ AddCodeLine ("lda (sp)");
} else {
ldyconst (ArgSizeOffs);
- AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeLine ("lda (sp),y");
}
/* Add the value of the stackpointer */
if (CodeSizeFactor > 250) {
- AddCodeSegLine (CS, "ldx sp+1");
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc sp");
- AddCodeSegLine (CS, "bcc *+3");
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("ldx sp+1");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc sp");
+ AddCodeLine ("bcc *+3");
+ AddCodeLine ("inx");
AddCodeHint ("x:!"); /* Invalidate X */
} else {
- AddCodeSegLine (CS, "jsr leaasp");
+ AddCodeLine ("jsr leaasp");
}
/* Add the offset to the primary */
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
break;
case CF_INT:
- AddCodeSegLine (CS, "sta %s", lbuf);
- AddCodeSegLine (CS, "stx %s+1", lbuf);
+ AddCodeLine ("sta %s", lbuf);
+ AddCodeLine ("stx %s+1", lbuf);
break;
case CF_LONG:
- AddCodeSegLine (CS, "sta %s", lbuf);
- AddCodeSegLine (CS, "stx %s+1", lbuf);
- AddCodeSegLine (CS, "ldy sreg");
- AddCodeSegLine (CS, "sty %s+2", lbuf);
- AddCodeSegLine (CS, "ldy sreg+1");
- AddCodeSegLine (CS, "sty %s+3", lbuf);
+ AddCodeLine ("sta %s", lbuf);
+ AddCodeLine ("stx %s+1", lbuf);
+ AddCodeLine ("ldy sreg");
+ AddCodeLine ("sty %s+2", lbuf);
+ AddCodeLine ("ldy sreg+1");
+ AddCodeLine ("sty %s+3", lbuf);
break;
default:
case CF_CHAR:
if (Flags & CF_CONST) {
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char) Val);
+ AddCodeLine ("lda #$%02X", (unsigned char) Val);
}
if (CPU == CPU_65C02 && Offs == 0) {
- AddCodeSegLine (CS, "sta (sp)");
+ AddCodeLine ("sta (sp)");
} else {
ldyconst (Offs);
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("sta (sp),y");
}
break;
case CF_INT:
if (Flags & CF_CONST) {
ldyconst (Offs+1);
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char) (Val >> 8));
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("lda #$%02X", (unsigned char) (Val >> 8));
+ AddCodeLine ("sta (sp),y");
if ((Flags & CF_NOKEEP) == 0) {
/* Place high byte into X */
- AddCodeSegLine (CS, "tax");
+ AddCodeLine ("tax");
}
if (CPU == CPU_65C02 && Offs == 0) {
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char) Val);
- AddCodeSegLine (CS, "sta (sp)");
+ AddCodeLine ("lda #$%02X", (unsigned char) Val);
+ AddCodeLine ("sta (sp)");
} else {
if ((Val & 0xFF) == Offs+1) {
/* The value we need is already in Y */
- AddCodeSegLine (CS, "tya");
- AddCodeSegLine (CS, "dey");
+ AddCodeLine ("tya");
+ AddCodeLine ("dey");
} else {
- AddCodeSegLine (CS, "dey");
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char) Val);
+ AddCodeLine ("dey");
+ AddCodeLine ("lda #$%02X", (unsigned char) Val);
}
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("sta (sp),y");
}
} else {
if ((Flags & CF_NOKEEP) == 0 || CodeSizeFactor < 160) {
if (Offs) {
ldyconst (Offs);
- AddCodeSegLine (CS, "jsr staxysp");
+ AddCodeLine ("jsr staxysp");
} else {
- AddCodeSegLine (CS, "jsr stax0sp");
+ AddCodeLine ("jsr stax0sp");
}
} else {
if (CPU == CPU_65C02 && Offs == 0) {
- AddCodeSegLine (CS, "sta (sp)");
+ AddCodeLine ("sta (sp)");
ldyconst (1);
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("txa");
+ AddCodeLine ("sta (sp),y");
} else {
ldyconst (Offs);
- AddCodeSegLine (CS, "sta (sp),y");
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("sta (sp),y");
+ AddCodeLine ("iny");
+ AddCodeLine ("txa");
+ AddCodeLine ("sta (sp),y");
}
}
}
}
if (Offs) {
ldyconst (Offs);
- AddCodeSegLine (CS, "jsr steaxysp");
+ AddCodeLine ("jsr steaxysp");
} else {
- AddCodeSegLine (CS, "jsr steax0sp");
+ AddCodeLine ("jsr steax0sp");
}
break;
if ((Offs & 0xFF) > 256 - sizeofarg (Flags | CF_FORCECHAR)) {
/* Overflow - we need to add the low byte also */
- AddCodeSegLine (CS, "ldy #$00");
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "lda #$%02X", Offs & 0xFF);
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "sta (sp),y");
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "lda #$%02X", (Offs >> 8) & 0xFF);
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "sta (sp),y");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("ldy #$00");
+ AddCodeLine ("clc");
+ AddCodeLine ("pha");
+ AddCodeLine ("lda #$%02X", Offs & 0xFF);
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("sta (sp),y");
+ AddCodeLine ("iny");
+ AddCodeLine ("lda #$%02X", (Offs >> 8) & 0xFF);
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("sta (sp),y");
+ AddCodeLine ("pla");
/* Complete address is on stack, new offset is zero */
Offs = 0;
} else if ((Offs & 0xFF00) != 0) {
/* We can just add the high byte */
- AddCodeSegLine (CS, "ldy #$01");
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "lda #$%02X", (Offs >> 8) & 0xFF);
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "sta (sp),y");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("ldy #$01");
+ AddCodeLine ("clc");
+ AddCodeLine ("pha");
+ AddCodeLine ("lda #$%02X", (Offs >> 8) & 0xFF);
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("sta (sp),y");
+ AddCodeLine ("pla");
/* Offset is now just the low byte */
Offs &= 0x00FF;
case CF_CHAR:
if (Offs) {
ldyconst (Offs);
- AddCodeSegLine (CS, "jsr staspidx");
+ AddCodeLine ("jsr staspidx");
} else {
- AddCodeSegLine (CS, "jsr staspp");
+ AddCodeLine ("jsr staspp");
}
break;
case CF_INT:
if (Offs) {
ldyconst (Offs);
- AddCodeSegLine (CS, "jsr staxspidx");
+ AddCodeLine ("jsr staxspidx");
} else {
- AddCodeSegLine (CS, "jsr staxspp");
+ AddCodeLine ("jsr staxspp");
}
break;
case CF_LONG:
if (Offs) {
ldyconst (Offs);
- AddCodeSegLine (CS, "jsr steaxspidx");
+ AddCodeLine ("jsr steaxspidx");
} else {
- AddCodeSegLine (CS, "jsr steaxspp");
+ AddCodeLine ("jsr steaxspp");
}
break;
case CF_CHAR:
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr tosulong");
+ AddCodeLine ("jsr tosulong");
} else {
- AddCodeSegLine (CS, "jsr toslong");
+ AddCodeLine ("jsr toslong");
}
push (CF_INT);
break;
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr tosint");
+ AddCodeLine ("jsr tosint");
pop (CF_INT);
break;
if (flags & CF_UNSIGNED) {
if (CodeSizeFactor >= 200) {
ldyconst (0);
- AddCodeSegLine (CS, "sty sreg");
- AddCodeSegLine (CS, "sty sreg+1");
+ AddCodeLine ("sty sreg");
+ AddCodeLine ("sty sreg+1");
} else {
- AddCodeSegLine (CS, "jsr axulong");
+ AddCodeLine ("jsr axulong");
}
} else {
- AddCodeSegLine (CS, "jsr axlong");
+ AddCodeLine ("jsr axlong");
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
while (p2--) {
- AddCodeSegLine (CS, "asl a");
+ AddCodeLine ("asl a");
}
break;
}
case CF_INT:
if (CodeSizeFactor >= (p2+1)*130U) {
- AddCodeSegLine (CS, "stx tmp1");
+ AddCodeLine ("stx tmp1");
while (p2--) {
- AddCodeSegLine (CS, "asl a");
- AddCodeSegLine (CS, "rol tmp1");
+ AddCodeLine ("asl a");
+ AddCodeLine ("rol tmp1");
}
- AddCodeSegLine (CS, "ldx tmp1");
+ AddCodeLine ("ldx tmp1");
} else {
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr shlax%d", p2);
+ AddCodeLine ("jsr shlax%d", p2);
} else {
- AddCodeSegLine (CS, "jsr aslax%d", p2);
+ AddCodeLine ("jsr aslax%d", p2);
}
}
break;
case CF_LONG:
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr shleax%d", p2);
+ AddCodeLine ("jsr shleax%d", p2);
} else {
- AddCodeSegLine (CS, "jsr asleax%d", p2);
+ AddCodeLine ("jsr asleax%d", p2);
}
break;
if (flags & CF_FORCECHAR) {
if (flags & CF_UNSIGNED) {
while (p2--) {
- AddCodeSegLine (CS, "lsr a");
+ AddCodeLine ("lsr a");
}
break;
} else if (p2 <= 2) {
- AddCodeSegLine (CS, "cmp #$80");
- AddCodeSegLine (CS, "ror a");
+ AddCodeLine ("cmp #$80");
+ AddCodeLine ("ror a");
break;
}
}
case CF_INT:
if (flags & CF_UNSIGNED) {
if (CodeSizeFactor >= (p2+1)*130U) {
- AddCodeSegLine (CS, "stx tmp1");
+ AddCodeLine ("stx tmp1");
while (p2--) {
- AddCodeSegLine (CS, "lsr tmp1");
- AddCodeSegLine (CS, "ror a");
+ AddCodeLine ("lsr tmp1");
+ AddCodeLine ("ror a");
}
- AddCodeSegLine (CS, "ldx tmp1");
+ AddCodeLine ("ldx tmp1");
} else {
- AddCodeSegLine (CS, "jsr lsrax%d", p2);
+ AddCodeLine ("jsr lsrax%d", p2);
}
} else {
if (CodeSizeFactor >= (p2+1)*150U) {
- AddCodeSegLine (CS, "stx tmp1");
+ AddCodeLine ("stx tmp1");
while (p2--) {
- AddCodeSegLine (CS, "cpx #$80");
- AddCodeSegLine (CS, "ror tmp1");
- AddCodeSegLine (CS, "ror a");
+ AddCodeLine ("cpx #$80");
+ AddCodeLine ("ror tmp1");
+ AddCodeLine ("ror a");
}
- AddCodeSegLine (CS, "ldx tmp1");
+ AddCodeLine ("ldx tmp1");
} else {
- AddCodeSegLine (CS, "jsr asrax%d", p2);
+ AddCodeLine ("jsr asrax%d", p2);
}
}
break;
case CF_LONG:
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr lsreax%d", p2);
+ AddCodeLine ("jsr lsreax%d", p2);
} else {
- AddCodeSegLine (CS, "jsr asreax%d", p2);
+ AddCodeLine ("jsr asreax%d", p2);
}
break;
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeSegLine (CS, "ldy #$%02X", offs & 0xFF);
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "bcc *+3");
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("ldy #$%02X", offs & 0xFF);
+ AddCodeLine ("clc");
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("bcc *+3");
+ AddCodeLine ("inx");
AddCodeHint ("x:!");
break;
case CF_INT:
- AddCodeSegLine (CS, "ldy #$%02X", offs & 0xFF);
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("ldy #$%02X", offs & 0xFF);
+ AddCodeLine ("clc");
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("pha");
+ AddCodeLine ("txa");
+ AddCodeLine ("iny");
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("tax");
+ AddCodeLine ("pla");
break;
case CF_LONG:
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc %s", lbuf);
- AddCodeSegLine (CS, "bcc *+3");
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("bcc *+3");
+ AddCodeLine ("inx");
AddCodeHint ("x:!");
break;
case CF_INT:
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc %s", lbuf);
- AddCodeSegLine (CS, "tay");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "adc %s+1", lbuf);
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "tya");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("tay");
+ AddCodeLine ("txa");
+ AddCodeLine ("adc %s+1", lbuf);
+ AddCodeLine ("tax");
+ AddCodeLine ("tya");
break;
case CF_LONG:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "ldx #$00");
+ AddCodeLine ("ldx #$00");
if (flags & CF_CONST) {
if (val == 1) {
- AddCodeSegLine (CS, "inc %s", lbuf);
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("inc %s", lbuf);
+ AddCodeLine ("lda %s", lbuf);
} else {
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc %s", lbuf);
- AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
}
} else {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc %s", lbuf);
- AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeSegLine (CS, "bpl *+3");
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("bpl *+3");
+ AddCodeLine ("dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
if (flags & CF_CONST) {
if (val == 1) {
unsigned L = GetLocalLabel ();
- AddCodeSegLine (CS, "inc %s", lbuf);
- AddCodeSegLine (CS, "bne %s", LocalLabelName (L));
- AddCodeSegLine (CS, "inc %s+1", lbuf);
+ AddCodeLine ("inc %s", lbuf);
+ AddCodeLine ("bne %s", LocalLabelName (L));
+ AddCodeLine ("inc %s+1", lbuf);
g_defcodelabel (L);
- AddCodeSegLine (CS, "lda %s", lbuf); /* Hmmm... */
- AddCodeSegLine (CS, "ldx %s+1", lbuf);
+ AddCodeLine ("lda %s", lbuf); /* Hmmm... */
+ AddCodeLine ("ldx %s+1", lbuf);
} else {
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc %s", lbuf);
- AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
if (val < 0x100) {
unsigned L = GetLocalLabel ();
- AddCodeSegLine (CS, "bcc %s", LocalLabelName (L));
- AddCodeSegLine (CS, "inc %s+1", lbuf);
+ AddCodeLine ("bcc %s", LocalLabelName (L));
+ AddCodeLine ("inc %s+1", lbuf);
g_defcodelabel (L);
- AddCodeSegLine (CS, "ldx %s+1", lbuf);
+ AddCodeLine ("ldx %s+1", lbuf);
} else {
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "adc %s+1", lbuf);
- AddCodeSegLine (CS, "sta %s+1", lbuf);
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("lda #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("adc %s+1", lbuf);
+ AddCodeLine ("sta %s+1", lbuf);
+ AddCodeLine ("tax");
+ AddCodeLine ("lda %s", lbuf);
}
}
} else {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc %s", lbuf);
- AddCodeSegLine (CS, "sta %s", lbuf);
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "adc %s+1", lbuf);
- AddCodeSegLine (CS, "sta %s+1", lbuf);
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
+ AddCodeLine ("txa");
+ AddCodeLine ("adc %s+1", lbuf);
+ AddCodeLine ("sta %s+1", lbuf);
+ AddCodeLine ("tax");
+ AddCodeLine ("lda %s", lbuf);
}
break;
case CF_LONG:
if (flags & CF_CONST) {
if (val < 0x100) {
- AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
- AddCodeSegLine (CS, "sty ptr1");
- AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
+ AddCodeLine ("ldy #<(%s)", lbuf);
+ AddCodeLine ("sty ptr1");
+ AddCodeLine ("ldy #>(%s+1)", lbuf);
if (val == 1) {
- AddCodeSegLine (CS, "jsr laddeq1");
+ AddCodeLine ("jsr laddeq1");
} else {
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "jsr laddeqa");
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("jsr laddeqa");
}
} else {
g_getstatic (flags, label, offs);
g_putstatic (flags, label, offs);
}
} else {
- AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
- AddCodeSegLine (CS, "sty ptr1");
- AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
- AddCodeSegLine (CS, "jsr laddeq");
+ AddCodeLine ("ldy #<(%s)", lbuf);
+ AddCodeLine ("sty ptr1");
+ AddCodeLine ("ldy #>(%s+1)", lbuf);
+ AddCodeLine ("jsr laddeq");
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if (offs == 0) {
- AddCodeSegLine (CS, "ldx #$00");
+ AddCodeLine ("ldx #$00");
if (flags & CF_CONST) {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "adc (sp,x)");
- AddCodeSegLine (CS, "sta (sp,x)");
+ AddCodeLine ("clc");
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("adc (sp,x)");
+ AddCodeLine ("sta (sp,x)");
} else {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc (sp,x)");
- AddCodeSegLine (CS, "sta (sp,x)");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc (sp,x)");
+ AddCodeLine ("sta (sp,x)");
}
} else {
ldyconst (offs);
- AddCodeSegLine (CS, "ldx #$00");
+ AddCodeLine ("ldx #$00");
if (flags & CF_CONST) {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("clc");
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("sta (sp),y");
} else {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc (sp),y");
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc (sp),y");
+ AddCodeLine ("sta (sp),y");
}
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeSegLine (CS, "bpl *+3");
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("bpl *+3");
+ AddCodeLine ("dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeSegLine (CS, "jsr addeq0sp");
+ AddCodeLine ("jsr addeq0sp");
} else {
ldyconst (offs);
- AddCodeSegLine (CS, "jsr addeqysp");
+ AddCodeLine ("jsr addeqysp");
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeSegLine (CS, "jsr laddeq0sp");
+ AddCodeLine ("jsr laddeq0sp");
} else {
ldyconst (offs);
- AddCodeSegLine (CS, "jsr laddeqysp");
+ AddCodeLine ("jsr laddeqysp");
}
break;
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeSegLine (CS, "sta ptr1");
- AddCodeSegLine (CS, "stx ptr1+1");
+ AddCodeLine ("sta ptr1");
+ AddCodeLine ("stx ptr1+1");
if (offs == 0) {
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc (ptr1,x)");
- AddCodeSegLine (CS, "sta (ptr1,x)");
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc (ptr1,x)");
+ AddCodeLine ("sta (ptr1,x)");
} else {
- AddCodeSegLine (CS, "ldy #$%02X", offs);
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc (ptr1),y");
- AddCodeSegLine (CS, "sta (ptr1),y");
+ AddCodeLine ("ldy #$%02X", offs);
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc (ptr1),y");
+ AddCodeLine ("sta (ptr1),y");
}
break;
case CF_INT:
if (CodeSizeFactor >= 200) {
/* Lots of code, use only if size is not important */
- AddCodeSegLine (CS, "sta ptr1");
- AddCodeSegLine (CS, "stx ptr1+1");
- AddCodeSegLine (CS, "ldy #$%02X", offs);
- AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc (ptr1),y");
- AddCodeSegLine (CS, "sta (ptr1),y");
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "adc (ptr1),y");
- AddCodeSegLine (CS, "sta (ptr1),y");
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("sta ptr1");
+ AddCodeLine ("stx ptr1+1");
+ AddCodeLine ("ldy #$%02X", offs);
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc (ptr1),y");
+ AddCodeLine ("sta (ptr1),y");
+ AddCodeLine ("pha");
+ AddCodeLine ("iny");
+ AddCodeLine ("lda #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("adc (ptr1),y");
+ AddCodeLine ("sta (ptr1),y");
+ AddCodeLine ("tax");
+ AddCodeLine ("pla");
break;
}
/* FALL THROUGH */
case CF_LONG:
- AddCodeSegLine (CS, "jsr pushax"); /* Push the address */
+ AddCodeLine ("jsr pushax"); /* Push the address */
push (flags); /* Correct the internal sp */
g_getind (flags, offs); /* Fetch the value */
g_inc (flags, val); /* Increment value in primary */
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "ldx #$00");
+ AddCodeLine ("ldx #$00");
if (flags & CF_CONST) {
if (val == 1) {
- AddCodeSegLine (CS, "dec %s", lbuf);
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("dec %s", lbuf);
+ AddCodeLine ("lda %s", lbuf);
} else {
- AddCodeSegLine (CS, "sec");
- AddCodeSegLine (CS, "lda %s", lbuf);
- AddCodeSegLine (CS, "sbc #$%02X", (int)(val & 0xFF));
- AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeLine ("sec");
+ AddCodeLine ("lda %s", lbuf);
+ AddCodeLine ("sbc #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("sta %s", lbuf);
}
} else {
- AddCodeSegLine (CS, "sec");
- AddCodeSegLine (CS, "sta tmp1");
- AddCodeSegLine (CS, "lda %s", lbuf);
- AddCodeSegLine (CS, "sbc tmp1");
- AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeLine ("sec");
+ AddCodeLine ("sta tmp1");
+ AddCodeLine ("lda %s", lbuf);
+ AddCodeLine ("sbc tmp1");
+ AddCodeLine ("sta %s", lbuf);
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeSegLine (CS, "bpl *+3");
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("bpl *+3");
+ AddCodeLine ("dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
/* FALLTHROUGH */
case CF_INT:
- AddCodeSegLine (CS, "sec");
+ AddCodeLine ("sec");
if (flags & CF_CONST) {
- AddCodeSegLine (CS, "lda %s", lbuf);
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeLine ("lda %s", lbuf);
+ AddCodeLine ("sbc #$%02X", (unsigned char)val);
+ AddCodeLine ("sta %s", lbuf);
if (val < 0x100) {
unsigned L = GetLocalLabel ();
- AddCodeSegLine (CS, "bcs %s", LocalLabelName (L));
- AddCodeSegLine (CS, "dec %s+1", lbuf);
+ AddCodeLine ("bcs %s", LocalLabelName (L));
+ AddCodeLine ("dec %s+1", lbuf);
g_defcodelabel (L);
- AddCodeSegLine (CS, "ldx %s+1", lbuf);
+ AddCodeLine ("ldx %s+1", lbuf);
} else {
- AddCodeSegLine (CS, "lda %s+1", lbuf);
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "sta %s+1", lbuf);
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("lda %s+1", lbuf);
+ AddCodeLine ("sbc #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("sta %s+1", lbuf);
+ AddCodeLine ("tax");
+ AddCodeLine ("lda %s", lbuf);
}
} else {
- AddCodeSegLine (CS, "sta tmp1");
- AddCodeSegLine (CS, "lda %s", lbuf);
- AddCodeSegLine (CS, "sbc tmp1");
- AddCodeSegLine (CS, "sta %s", lbuf);
- AddCodeSegLine (CS, "stx tmp1");
- AddCodeSegLine (CS, "lda %s+1", lbuf);
- AddCodeSegLine (CS, "sbc tmp1");
- AddCodeSegLine (CS, "sta %s+1", lbuf);
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeLine ("sta tmp1");
+ AddCodeLine ("lda %s", lbuf);
+ AddCodeLine ("sbc tmp1");
+ AddCodeLine ("sta %s", lbuf);
+ AddCodeLine ("stx tmp1");
+ AddCodeLine ("lda %s+1", lbuf);
+ AddCodeLine ("sbc tmp1");
+ AddCodeLine ("sta %s+1", lbuf);
+ AddCodeLine ("tax");
+ AddCodeLine ("lda %s", lbuf);
}
break;
case CF_LONG:
if (flags & CF_CONST) {
if (val < 0x100) {
- AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
- AddCodeSegLine (CS, "sty ptr1");
- AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
+ AddCodeLine ("ldy #<(%s)", lbuf);
+ AddCodeLine ("sty ptr1");
+ AddCodeLine ("ldy #>(%s+1)", lbuf);
if (val == 1) {
- AddCodeSegLine (CS, "jsr lsubeq1");
+ AddCodeLine ("jsr lsubeq1");
} else {
- AddCodeSegLine (CS, "lda #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr lsubeqa");
+ AddCodeLine ("lda #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr lsubeqa");
}
} else {
g_getstatic (flags, label, offs);
g_putstatic (flags, label, offs);
}
} else {
- AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
- AddCodeSegLine (CS, "sty ptr1");
- AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
- AddCodeSegLine (CS, "jsr lsubeq");
+ AddCodeLine ("ldy #<(%s)", lbuf);
+ AddCodeLine ("sty ptr1");
+ AddCodeLine ("ldy #>(%s+1)", lbuf);
+ AddCodeLine ("jsr lsubeq");
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
ldyconst (offs);
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "sec");
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("sec");
if (flags & CF_CONST) {
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("sbc #$%02X", (unsigned char)val);
} else {
- AddCodeSegLine (CS, "sta tmp1");
- AddCodeSegLine (CS, "lda (sp),y");
- AddCodeSegLine (CS, "sbc tmp1");
+ AddCodeLine ("sta tmp1");
+ AddCodeLine ("lda (sp),y");
+ AddCodeLine ("sbc tmp1");
}
- AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeLine ("sta (sp),y");
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeSegLine (CS, "bpl *+3");
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("bpl *+3");
+ AddCodeLine ("dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeSegLine (CS, "jsr subeq0sp");
+ AddCodeLine ("jsr subeq0sp");
} else {
ldyconst (offs);
- AddCodeSegLine (CS, "jsr subeqysp");
+ AddCodeLine ("jsr subeqysp");
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeSegLine (CS, "jsr lsubeq0sp");
+ AddCodeLine ("jsr lsubeq0sp");
} else {
ldyconst (offs);
- AddCodeSegLine (CS, "jsr lsubeqysp");
+ AddCodeLine ("jsr lsubeqysp");
}
break;
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeSegLine (CS, "sta ptr1");
- AddCodeSegLine (CS, "stx ptr1+1");
+ AddCodeLine ("sta ptr1");
+ AddCodeLine ("stx ptr1+1");
if (offs == 0) {
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "lda (ptr1,x)");
- AddCodeSegLine (CS, "sec");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "sta (ptr1,x)");
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("lda (ptr1,x)");
+ AddCodeLine ("sec");
+ AddCodeLine ("sbc #$%02X", (unsigned char)val);
+ AddCodeLine ("sta (ptr1,x)");
} else {
- AddCodeSegLine (CS, "ldy #$%02X", offs);
- AddCodeSegLine (CS, "ldx #$00");
- AddCodeSegLine (CS, "lda (ptr1),y");
- AddCodeSegLine (CS, "sec");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "sta (ptr1),y");
+ AddCodeLine ("ldy #$%02X", offs);
+ AddCodeLine ("ldx #$00");
+ AddCodeLine ("lda (ptr1),y");
+ AddCodeLine ("sec");
+ AddCodeLine ("sbc #$%02X", (unsigned char)val);
+ AddCodeLine ("sta (ptr1),y");
}
break;
case CF_INT:
if (CodeSizeFactor >= 200) {
/* Lots of code, use only if size is not important */
- AddCodeSegLine (CS, "sta ptr1");
- AddCodeSegLine (CS, "stx ptr1+1");
- AddCodeSegLine (CS, "ldy #$%02X", offs);
- AddCodeSegLine (CS, "lda (ptr1),y");
- AddCodeSegLine (CS, "sec");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "sta (ptr1),y");
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "lda (ptr1),y");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "sta (ptr1),y");
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("sta ptr1");
+ AddCodeLine ("stx ptr1+1");
+ AddCodeLine ("ldy #$%02X", offs);
+ AddCodeLine ("lda (ptr1),y");
+ AddCodeLine ("sec");
+ AddCodeLine ("sbc #$%02X", (unsigned char)val);
+ AddCodeLine ("sta (ptr1),y");
+ AddCodeLine ("pha");
+ AddCodeLine ("iny");
+ AddCodeLine ("lda (ptr1),y");
+ AddCodeLine ("sbc #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("sta (ptr1),y");
+ AddCodeLine ("tax");
+ AddCodeLine ("pla");
break;
}
/* FALL THROUGH */
case CF_LONG:
- AddCodeSegLine (CS, "jsr pushax"); /* Push the address */
+ AddCodeLine ("jsr pushax"); /* Push the address */
push (flags); /* Correct the internal sp */
g_getind (flags, offs); /* Fetch the value */
g_dec (flags, val); /* Increment value in primary */
if (offs != 0) {
/* We cannot address more then 256 bytes of locals anyway */
CheckLocalOffs (offs);
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc #$%02X", offs & 0xFF);
- AddCodeSegLine (CS, "bcc *+4"); /* Do also skip the CLC insn below */
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc #$%02X", offs & 0xFF);
+ AddCodeLine ("bcc *+4"); /* Do also skip the CLC insn below */
+ AddCodeLine ("inx");
AddCodeHint ("x:!"); /* Invalidate X */
}
/* Add the current stackpointer value */
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc sp");
- AddCodeSegLine (CS, "tay");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "adc sp+1");
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "tya");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc sp");
+ AddCodeLine ("tay");
+ AddCodeLine ("txa");
+ AddCodeLine ("adc sp+1");
+ AddCodeLine ("tax");
+ AddCodeLine ("tya");
}
char* lbuf = GetLabelName (flags, label, offs);
/* Add the address to the current ax value */
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc #<(%s)", lbuf);
- AddCodeSegLine (CS, "tay");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "adc #>(%s)", lbuf);
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "tya");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc #<(%s)", lbuf);
+ AddCodeLine ("tay");
+ AddCodeLine ("txa");
+ AddCodeLine ("adc #>(%s)", lbuf);
+ AddCodeLine ("tax");
+ AddCodeLine ("tya");
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "pha");
+ AddCodeLine ("pha");
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeSegLine (CS, "sta regsave");
- AddCodeSegLine (CS, "stx regsave+1");
+ AddCodeLine ("sta regsave");
+ AddCodeLine ("stx regsave+1");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr saveeax");
+ AddCodeLine ("jsr saveeax");
break;
default:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("pla");
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeSegLine (CS, "lda regsave");
- AddCodeSegLine (CS, "ldx regsave+1");
+ AddCodeLine ("lda regsave");
+ AddCodeLine ("ldx regsave+1");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr resteax");
+ AddCodeLine ("jsr resteax");
break;
default:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "bne *+4");
- AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("bne *+4");
+ AddCodeLine ("cpx #$%02X", (unsigned char)(val >> 8));
break;
case CF_LONG:
/* Constant value given */
if (val == 0 && subs [offs+0]) {
/* Special case: constant with value zero */
- AddCodeSegLine (CS, "jsr %s", subs [offs+0]);
+ AddCodeLine ("jsr %s", subs [offs+0]);
} else if (val < 0x100 && subs [offs+1]) {
/* Special case: constant with high byte zero */
ldaconst (val); /* Load low byte */
- AddCodeSegLine (CS, "jsr %s", subs [offs+1]);
+ AddCodeLine ("jsr %s", subs [offs+1]);
} else {
/* Others: arbitrary constant value */
g_getimmed (flags, val, 0); /* Load value */
- AddCodeSegLine (CS, "jsr %s", subs [offs+2]);
+ AddCodeLine ("jsr %s", subs [offs+2]);
}
} else {
/* Value not constant (is already in (e)ax) */
- AddCodeSegLine (CS, "jsr %s", subs [offs+2]);
+ AddCodeLine ("jsr %s", subs [offs+2]);
}
/* The operation will pop it's argument */
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "tax");
+ AddCodeLine ("tax");
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeSegLine (CS, "stx tmp1");
- AddCodeSegLine (CS, "ora tmp1");
+ AddCodeLine ("stx tmp1");
+ AddCodeLine ("ora tmp1");
break;
case CF_LONG:
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr utsteax");
+ AddCodeLine ("jsr utsteax");
} else {
- AddCodeSegLine (CS, "jsr tsteax");
+ AddCodeLine ("jsr tsteax");
}
break;
/* Handle as 8 bit value */
if (CodeSizeFactor >= 165 || val > 2) {
ldaconst (val);
- AddCodeSegLine (CS, "jsr pusha");
+ AddCodeLine ("jsr pusha");
} else {
- AddCodeSegLine (CS, "jsr pushc%d", (int) val);
+ AddCodeLine ("jsr pushc%d", (int) val);
}
} else {
/* Handle as 16 bit value */
hi = (unsigned char) (val >> 8);
if (val <= 7) {
- AddCodeSegLine (CS, "jsr push%u", (unsigned) val);
+ AddCodeLine ("jsr push%u", (unsigned) val);
} else if (hi == 0 || hi == 0xFF) {
/* Use special function */
ldaconst (val);
- AddCodeSegLine (CS, "jsr %s", (hi == 0)? "pusha0" : "pushaFF");
+ AddCodeLine ("jsr %s", (hi == 0)? "pusha0" : "pushaFF");
} else {
/* Long way ... */
g_getimmed (flags, val, 0);
- AddCodeSegLine (CS, "jsr pushax");
+ AddCodeLine ("jsr pushax");
}
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
/* Handle as char */
- AddCodeSegLine (CS, "jsr pusha");
+ AddCodeLine ("jsr pusha");
break;
}
/* FALL THROUGH */
case CF_INT:
- AddCodeSegLine (CS, "jsr pushax");
+ AddCodeLine ("jsr pushax");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr pusheax");
+ AddCodeLine ("jsr pusheax");
break;
default:
case CF_CHAR:
case CF_INT:
- AddCodeSegLine (CS, "jsr swapstk");
+ AddCodeLine ("jsr swapstk");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr swapestk");
+ AddCodeLine ("jsr swapestk");
break;
default:
/* Pass the argument count */
ldyconst (ArgSize);
}
- AddCodeSegLine (CS, "jsr _%s", Label);
+ AddCodeLine ("jsr _%s", Label);
oursp += ArgSize; /* callee pops args */
}
/* Pass arg count */
ldyconst (ArgSize);
}
- AddCodeSegLine (CS, "jsr callax"); /* do the call */
+ AddCodeLine ("jsr callax"); /* do the call */
oursp += ArgSize; /* callee pops args */
}
void g_jump (unsigned Label)
/* Jump to specified internal label number */
{
- AddCodeSegLine (CS, "jmp %s", LocalLabelName (Label));
+ AddCodeLine ("jmp %s", LocalLabelName (Label));
}
case CF_CHAR:
case CF_INT:
- AddCodeSegLine (CS, "jsr switch");
+ AddCodeLine ("jsr switch");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr lswitch");
+ AddCodeLine ("jsr lswitch");
break;
default:
case CF_CHAR:
case CF_INT:
- AddCodeSegLine (CS, ".word $%04X, %s",
+ AddCodeLine (".word $%04X, %s",
(unsigned)(val & 0xFFFF),
LocalLabelName (label));
break;
case CF_LONG:
- AddCodeSegLine (CS, ".dword $%08lX", val);
- AddCodeSegLine (CS, ".word %s", LocalLabelName (label));
+ AddCodeLine (".dword $%08lX", val);
+ AddCodeLine (".word %s", LocalLabelName (label));
break;
default:
void g_truejump (unsigned flags, unsigned label)
/* Jump to label if zero flag clear */
{
- AddCodeSegLine (CS, "jne %s", LocalLabelName (label));
+ AddCodeLine ("jne %s", LocalLabelName (label));
}
void g_falsejump (unsigned flags, unsigned label)
/* Jump to label if zero flag set */
{
- AddCodeSegLine (CS, "jeq %s", LocalLabelName (label));
+ AddCodeLine ("jeq %s", LocalLabelName (label));
}
static void mod_internal (int k, char* verb1, char* verb2)
{
if (k <= 8) {
- AddCodeSegLine (CS, "jsr %ssp%c", verb1, k + '0');
+ AddCodeLine ("jsr %ssp%c", verb1, k + '0');
} else {
CheckLocalOffs (k);
ldyconst (k);
- AddCodeSegLine (CS, "jsr %ssp", verb2);
+ AddCodeLine ("jsr %ssp", verb2);
}
}
void g_cstackcheck (void)
/* Check for a C stack overflow */
{
- AddCodeSegLine (CS, "jsr cstkchk");
+ AddCodeLine ("jsr cstkchk");
}
void g_stackcheck (void)
/* Check for a stack overflow */
{
- AddCodeSegLine (CS, "jsr stkchk");
+ AddCodeLine ("jsr stkchk");
}
switch (val) {
case 3:
- AddCodeSegLine (CS, "sta tmp1");
- AddCodeSegLine (CS, "asl a");
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc tmp1");
+ AddCodeLine ("sta tmp1");
+ AddCodeLine ("asl a");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc tmp1");
return;
case 5:
- AddCodeSegLine (CS, "sta tmp1");
- AddCodeSegLine (CS, "asl a");
- AddCodeSegLine (CS, "asl a");
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc tmp1");
+ AddCodeLine ("sta tmp1");
+ AddCodeLine ("asl a");
+ AddCodeLine ("asl a");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc tmp1");
return;
case 10:
- AddCodeSegLine (CS, "sta tmp1");
- AddCodeSegLine (CS, "asl a");
- AddCodeSegLine (CS, "asl a");
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc tmp1");
- AddCodeSegLine (CS, "asl a");
+ AddCodeLine ("sta tmp1");
+ AddCodeLine ("asl a");
+ AddCodeLine ("asl a");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc tmp1");
+ AddCodeLine ("asl a");
return;
}
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if ((val & 0xFF) != 0xFF) {
- AddCodeSegLine (CS, "ora #$%02X", (unsigned char)val);
+ AddCodeLine ("ora #$%02X", (unsigned char)val);
}
return;
}
case CF_INT:
if (val <= 0xFF) {
- AddCodeSegLine (CS, "ora #$%02X", (unsigned char)val);
+ AddCodeLine ("ora #$%02X", (unsigned char)val);
return;
}
break;
case CF_LONG:
if (val <= 0xFF) {
- AddCodeSegLine (CS, "ora #$%02X", (unsigned char)val);
+ AddCodeLine ("ora #$%02X", (unsigned char)val);
return;
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if ((val & 0xFF) != 0) {
- AddCodeSegLine (CS, "eor #$%02X", (unsigned char)val);
+ AddCodeLine ("eor #$%02X", (unsigned char)val);
}
return;
}
case CF_INT:
if (val <= 0xFF) {
if (val != 0) {
- AddCodeSegLine (CS, "eor #$%02X", (unsigned char)val);
+ AddCodeLine ("eor #$%02X", (unsigned char)val);
}
return;
} else if ((val & 0xFF) == 0) {
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "eor #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("pha");
+ AddCodeLine ("txa");
+ AddCodeLine ("eor #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("tax");
+ AddCodeLine ("pla");
return;
}
break;
case CF_LONG:
if (val <= 0xFF) {
if (val != 0) {
- AddCodeSegLine (CS, "eor #$%02X", (unsigned char)val);
+ AddCodeLine ("eor #$%02X", (unsigned char)val);
}
return;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
+ AddCodeLine ("and #$%02X", (unsigned char)val);
return;
}
/* FALLTHROUGH */
if (val == 0) {
ldaconst (0);
} else if (val != 0xFF) {
- AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
+ AddCodeLine ("and #$%02X", (unsigned char)val);
}
} else if ((val & 0xFF00) == 0xFF00) {
- AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
+ AddCodeLine ("and #$%02X", (unsigned char)val);
} else if ((val & 0x00FF) == 0x0000) {
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "and #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "tax");
+ AddCodeLine ("txa");
+ AddCodeLine ("and #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("tax");
ldaconst (0);
} else {
- AddCodeSegLine (CS, "tay");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "and #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "tya");
+ AddCodeLine ("tay");
+ AddCodeLine ("txa");
+ AddCodeLine ("and #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("tax");
+ AddCodeLine ("tya");
if ((val & 0x00FF) != 0x00FF) {
- AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
+ AddCodeLine ("and #$%02X", (unsigned char)val);
}
}
}
case CF_LONG:
if (val <= 0xFF) {
ldxconst (0);
- AddCodeSegLine (CS, "stx sreg+1");
- AddCodeSegLine (CS, "stx sreg");
+ AddCodeLine ("stx sreg+1");
+ AddCodeLine ("stx sreg");
if ((val & 0xFF) != 0xFF) {
- AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
+ AddCodeLine ("and #$%02X", (unsigned char)val);
}
return;
} else if (val == 0xFF00) {
ldaconst (0);
- AddCodeSegLine (CS, "sta sreg+1");
- AddCodeSegLine (CS, "sta sreg");
+ AddCodeLine ("sta sreg+1");
+ AddCodeLine ("sta sreg");
return;
}
break;
case CF_INT:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr shrax%ld", val);
+ AddCodeLine ("jsr shrax%ld", val);
} else {
- AddCodeSegLine (CS, "jsr asrax%ld", val);
+ AddCodeLine ("jsr asrax%ld", val);
}
return;
} else if (val == 8 && (flags & CF_UNSIGNED)) {
- AddCodeSegLine (CS, "txa");
+ AddCodeLine ("txa");
ldxconst (0);
return;
}
case CF_LONG:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr shreax%ld", val);
+ AddCodeLine ("jsr shreax%ld", val);
} else {
- AddCodeSegLine (CS, "jsr asreax%ld", val);
+ AddCodeLine ("jsr asreax%ld", val);
}
return;
} else if (val == 8 && (flags & CF_UNSIGNED)) {
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "ldx sreg");
- AddCodeSegLine (CS, "ldy sreg+1");
- AddCodeSegLine (CS, "sty sreg");
- AddCodeSegLine (CS, "ldy #$00");
- AddCodeSegLine (CS, "sty sreg+1");
+ AddCodeLine ("txa");
+ AddCodeLine ("ldx sreg");
+ AddCodeLine ("ldy sreg+1");
+ AddCodeLine ("sty sreg");
+ AddCodeLine ("ldy #$00");
+ AddCodeLine ("sty sreg+1");
return;
} else if (val == 16) {
- AddCodeSegLine (CS, "ldy #$00");
- AddCodeSegLine (CS, "ldx sreg+1");
+ AddCodeLine ("ldy #$00");
+ AddCodeLine ("ldx sreg+1");
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeSegLine (CS, "bpl *+3");
- AddCodeSegLine (CS, "dey");
+ AddCodeLine ("bpl *+3");
+ AddCodeLine ("dey");
AddCodeHint ("y:!");
}
- AddCodeSegLine (CS, "lda sreg");
- AddCodeSegLine (CS, "sty sreg+1");
- AddCodeSegLine (CS, "sty sreg");
+ AddCodeLine ("lda sreg");
+ AddCodeLine ("sty sreg+1");
+ AddCodeLine ("sty sreg");
return;
}
break;
case CF_INT:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr shlax%ld", val);
+ AddCodeLine ("jsr shlax%ld", val);
} else {
- AddCodeSegLine (CS, "jsr aslax%ld", val);
+ AddCodeLine ("jsr aslax%ld", val);
}
return;
} else if (val == 8) {
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "lda #$00");
+ AddCodeLine ("tax");
+ AddCodeLine ("lda #$00");
return;
}
break;
case CF_LONG:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr shleax%ld", val);
+ AddCodeLine ("jsr shleax%ld", val);
} else {
- AddCodeSegLine (CS, "jsr asleax%ld", val);
+ AddCodeLine ("jsr asleax%ld", val);
}
return;
} else if (val == 8) {
- AddCodeSegLine (CS, "ldy sreg");
- AddCodeSegLine (CS, "sty sreg+1");
- AddCodeSegLine (CS, "stx sreg");
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "lda #$00");
+ AddCodeLine ("ldy sreg");
+ AddCodeLine ("sty sreg+1");
+ AddCodeLine ("stx sreg");
+ AddCodeLine ("tax");
+ AddCodeLine ("lda #$00");
return;
} else if (val == 16) {
- AddCodeSegLine (CS, "stx sreg+1");
- AddCodeSegLine (CS, "sta sreg");
- AddCodeSegLine (CS, "lda #$00");
- AddCodeSegLine (CS, "tax");
+ AddCodeLine ("stx sreg+1");
+ AddCodeLine ("sta sreg");
+ AddCodeLine ("lda #$00");
+ AddCodeLine ("tax");
return;
}
break;
case CF_CHAR:
case CF_INT:
- AddCodeSegLine (CS, "jsr negax");
+ AddCodeLine ("jsr negax");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr negeax");
+ AddCodeLine ("jsr negeax");
break;
default:
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeSegLine (CS, "jsr bnega");
+ AddCodeLine ("jsr bnega");
break;
case CF_INT:
- AddCodeSegLine (CS, "jsr bnegax");
+ AddCodeLine ("jsr bnegax");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr bnegeax");
+ AddCodeLine ("jsr bnegeax");
break;
default:
case CF_CHAR:
case CF_INT:
- AddCodeSegLine (CS, "jsr complax");
+ AddCodeLine ("jsr complax");
break;
case CF_LONG:
- AddCodeSegLine (CS, "jsr compleax");
+ AddCodeLine ("jsr compleax");
break;
default:
if (flags & CF_FORCECHAR) {
if (CPU == CPU_65C02 && val <= 2) {
while (val--) {
- AddCodeSegLine (CS, "ina");
+ AddCodeLine ("ina");
}
} else {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc #$%02X", (unsigned char)val);
+ AddCodeLine ("clc");
+ AddCodeLine ("adc #$%02X", (unsigned char)val);
}
break;
}
case CF_INT:
if (CPU == CPU_65C02 && val == 1) {
- AddCodeSegLine (CS, "ina");
- AddCodeSegLine (CS, "bne *+3");
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("ina");
+ AddCodeLine ("bne *+3");
+ AddCodeLine ("inx");
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
} else if (CodeSizeFactor < 200) {
/* Use jsr calls */
if (val <= 8) {
- AddCodeSegLine (CS, "jsr incax%lu", val);
+ AddCodeLine ("jsr incax%lu", val);
} else if (val <= 255) {
ldyconst (val);
- AddCodeSegLine (CS, "jsr incaxy");
+ AddCodeLine ("jsr incaxy");
} else {
g_add (flags | CF_CONST, val);
}
/* Inline the code */
if (val < 0x300) {
if ((val & 0xFF) != 0) {
- AddCodeSegLine (CS, "clc");
- AddCodeSegLine (CS, "adc #$%02X", (unsigned char) val);
- AddCodeSegLine (CS, "bcc *+3");
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("clc");
+ AddCodeLine ("adc #$%02X", (unsigned char) val);
+ AddCodeLine ("bcc *+3");
+ AddCodeLine ("inx");
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
if (val >= 0x100) {
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("inx");
}
if (val >= 0x200) {
- AddCodeSegLine (CS, "inx");
+ AddCodeLine ("inx");
}
} else {
- AddCodeSegLine (CS, "clc");
+ AddCodeLine ("clc");
if ((val & 0xFF) != 0) {
- AddCodeSegLine (CS, "adc #$%02X", (unsigned char) val);
+ AddCodeLine ("adc #$%02X", (unsigned char) val);
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "adc #$%02X", (unsigned char) (val >> 8));
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("pha");
+ AddCodeLine ("txa");
+ AddCodeLine ("adc #$%02X", (unsigned char) (val >> 8));
+ AddCodeLine ("tax");
+ AddCodeLine ("pla");
}
}
break;
case CF_LONG:
if (val <= 255) {
ldyconst (val);
- AddCodeSegLine (CS, "jsr inceaxy");
+ AddCodeLine ("jsr inceaxy");
} else {
g_add (flags | CF_CONST, val);
}
if (flags & CF_FORCECHAR) {
if (CPU == CPU_65C02 && val <= 2) {
while (val--) {
- AddCodeSegLine (CS, "dea");
+ AddCodeLine ("dea");
}
} else {
- AddCodeSegLine (CS, "sec");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
+ AddCodeLine ("sec");
+ AddCodeLine ("sbc #$%02X", (unsigned char)val);
}
break;
}
if (CodeSizeFactor < 200) {
/* Use subroutines */
if (val <= 8) {
- AddCodeSegLine (CS, "jsr decax%d", (int) val);
+ AddCodeLine ("jsr decax%d", (int) val);
} else if (val <= 255) {
ldyconst (val);
- AddCodeSegLine (CS, "jsr decaxy");
+ AddCodeLine ("jsr decaxy");
} else {
g_sub (flags | CF_CONST, val);
}
/* Inline the code */
if (val < 0x300) {
if ((val & 0xFF) != 0) {
- AddCodeSegLine (CS, "sec");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char) val);
- AddCodeSegLine (CS, "bcs *+3");
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("sec");
+ AddCodeLine ("sbc #$%02X", (unsigned char) val);
+ AddCodeLine ("bcs *+3");
+ AddCodeLine ("dex");
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
if (val >= 0x100) {
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("dex");
}
if (val >= 0x200) {
- AddCodeSegLine (CS, "dex");
+ AddCodeLine ("dex");
}
} else {
- AddCodeSegLine (CS, "sec");
+ AddCodeLine ("sec");
if ((val & 0xFF) != 0) {
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char) val);
+ AddCodeLine ("sbc #$%02X", (unsigned char) val);
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
- AddCodeSegLine (CS, "pha");
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "sbc #$%02X", (unsigned char) (val >> 8));
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "pla");
+ AddCodeLine ("pha");
+ AddCodeLine ("txa");
+ AddCodeLine ("sbc #$%02X", (unsigned char) (val >> 8));
+ AddCodeLine ("tax");
+ AddCodeLine ("pla");
}
}
break;
case CF_LONG:
if (val <= 255) {
ldyconst (val);
- AddCodeSegLine (CS, "jsr deceaxy");
+ AddCodeLine ("jsr deceaxy");
} else {
g_sub (flags | CF_CONST, val);
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr booleq");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr booleq");
return;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "bne *+4");
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr booleq");
+ AddCodeLine ("cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("bne *+4");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr booleq");
return;
case CF_LONG:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr boolne");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr boolne");
return;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "bne *+4");
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr boolne");
+ AddCodeLine ("cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("bne *+4");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr boolne");
return;
case CF_LONG:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr boolult");
+ AddCodeLine ("jsr boolult");
} else {
- AddCodeSegLine (CS, "jsr boollt");
+ AddCodeLine ("jsr boollt");
}
return;
}
/* If we have a signed compare against zero, we only need to
* test the high byte.
*/
- AddCodeSegLine (CS, "txa");
- AddCodeSegLine (CS, "jsr boollt");
+ AddCodeLine ("txa");
+ AddCodeLine ("jsr boollt");
return;
}
/* Direct code only for unsigned data types */
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "bne *+4");
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr boolult");
+ AddCodeLine ("cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("bne *+4");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr boolult");
return;
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr boolule");
+ AddCodeLine ("jsr boolule");
} else {
- AddCodeSegLine (CS, "jsr boolle");
+ AddCodeLine ("jsr boolle");
}
return;
}
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "bne *+4");
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr boolule");
+ AddCodeLine ("cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("bne *+4");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr boolule");
return;
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("cmp #$%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
* is easier to optimize.
*/
if (val & 0xFF) {
- AddCodeSegLine (CS, "jsr boolugt");
+ AddCodeLine ("jsr boolugt");
} else {
- AddCodeSegLine (CS, "jsr boolne");
+ AddCodeLine ("jsr boolne");
}
} else {
- AddCodeSegLine (CS, "jsr boolgt");
+ AddCodeLine ("jsr boolgt");
}
return;
}
* is easier to optimize.
*/
if ((val & 0xFFFF) == 0) {
- AddCodeSegLine (CS, "stx tmp1");
- AddCodeSegLine (CS, "ora tmp1");
- AddCodeSegLine (CS, "jsr boolne");
+ AddCodeLine ("stx tmp1");
+ AddCodeLine ("ora tmp1");
+ AddCodeLine ("jsr boolne");
} else {
- AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "bne *+4");
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr boolugt");
+ AddCodeLine ("cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("bne *+4");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr boolugt");
}
return;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "jsr booluge");
+ AddCodeLine ("jsr booluge");
} else {
- AddCodeSegLine (CS, "jsr boolge");
+ AddCodeLine ("jsr boolge");
}
return;
}
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
- AddCodeSegLine (CS, "bne *+4");
- AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
- AddCodeSegLine (CS, "jsr booluge");
+ AddCodeLine ("cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("bne *+4");
+ AddCodeLine ("cmp #$%02X", (unsigned char)val);
+ AddCodeLine ("jsr booluge");
return;
}
break;
void g_res (unsigned n)
/* Reserve static storage, n bytes */
{
- AddDataSegLine (DS, "\t.res\t%u,$00", n);
+ AddDataLine ("\t.res\t%u,$00", n);
}
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddDataSegLine (DS, "\t.byte\t$%02lX", val & 0xFF);
+ AddDataLine ("\t.byte\t$%02lX", val & 0xFF);
break;
case CF_INT:
- AddDataSegLine (DS, "\t.word\t$%04lX", val & 0xFFFF);
+ AddDataLine ("\t.word\t$%04lX", val & 0xFFFF);
break;
case CF_LONG:
- AddDataSegLine (DS, "\t.dword\t$%08lX", val & 0xFFFFFFFF);
+ AddDataLine ("\t.dword\t$%08lX", val & 0xFFFFFFFF);
break;
default:
const char* Label = GetLabelName (flags, val, offs);
/* Labels are always 16 bit */
- AddDataSegLine (DS, "\t.word\t%s", Label);
+ AddDataLine ("\t.word\t%s", Label);
}
}
} while (Chunk);
/* Output the line */
- AddDataSegLine (DS, Buf);
+ AddDataLine (Buf);
}
}
void g_zerobytes (unsigned n)
/* Output n bytes of data initialized with zero */
{
- AddDataSegLine (DS, "\t.res\t%u,$00", n);
+ AddDataLine ("\t.res\t%u,$00", n);
}
*/
{
if (Len >= 0) {
- AddCodeSegLine (CS, "%.*s", Len, Line);
+ AddCodeLine ("%.*s", Len, Line);
} else {
- AddCodeSegLine (CS, "%s", Line);
+ AddCodeLine ("%s", Line);
}
}
char* lbuf = GetLabelName (flags, val, offs);
/* Generate the strlen code */
- AddCodeSegLine (CS, "ldy #$FF");
+ AddCodeLine ("ldy #$FF");
g_defcodelabel (label);
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "lda %s,y", lbuf);
- AddCodeSegLine (CS, "bne %s", LocalLabelName (label));
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "tya");
+ AddCodeLine ("iny");
+ AddCodeLine ("lda %s,y", lbuf);
+ AddCodeLine ("bne %s", LocalLabelName (label));
+ AddCodeLine ("tax");
+ AddCodeLine ("tya");
} else {
/* Address not constant but in primary */
if (CodeSizeFactor < 400) {
/* This is too much code, so call strlen instead of inlining */
- AddCodeSegLine (CS, "jsr _strlen");
+ AddCodeLine ("jsr _strlen");
} else {
/* Inline the function */
- AddCodeSegLine (CS, "sta ptr1");
- AddCodeSegLine (CS, "stx ptr1+1");
- AddCodeSegLine (CS, "ldy #$FF");
+ AddCodeLine ("sta ptr1");
+ AddCodeLine ("stx ptr1+1");
+ AddCodeLine ("ldy #$FF");
g_defcodelabel (label);
- AddCodeSegLine (CS, "iny");
- AddCodeSegLine (CS, "lda (ptr1),y");
- AddCodeSegLine (CS, "bne %s", LocalLabelName (label));
- AddCodeSegLine (CS, "tax");
- AddCodeSegLine (CS, "tya");
+ AddCodeLine ("iny");
+ AddCodeLine ("lda (ptr1),y");
+ AddCodeLine ("bne %s", LocalLabelName (label));
+ AddCodeLine ("tax");
+ AddCodeLine ("tya");
}
}
}