static void ldaconst (unsigned val)
/* Load a with a constant */
{
- AddCodeLine ("\tlda\t#$%02X", val & 0xFF);
+ AddCodeSegLine (CS, "lda #$%02X", val & 0xFF);
}
static void ldxconst (unsigned val)
/* Load x with a constant */
{
- AddCodeLine ("\tldx\t#$%02X", val & 0xFF);
+ AddCodeSegLine (CS, "ldx #$%02X", val & 0xFF);
}
static void ldyconst (unsigned val)
/* Load y with a constant */
{
- AddCodeLine ("\tldy\t#$%02X", val & 0xFF);
+ AddCodeSegLine (CS, "ldy #$%02X", val & 0xFF);
}
funcargs = argsize;
} else {
funcargs = -1;
- AddCodeLine ("\tjsr\tenter");
+ AddCodeSegLine (CS, "jsr enter");
}
}
k += funcargs;
if (k == 0) {
AddCodeHint ("y:-"); /* Y register no longer used */
- AddCodeLine ("\trts");
+ AddCodeSegLine (CS, "rts");
} else if (k <= 8) {
AddCodeHint ("y:-"); /* Y register no longer used */
- AddCodeLine ("\tjmp\tincsp%d", k);
+ AddCodeSegLine (CS, "jmp incsp%d", k);
} else {
CheckLocalOffs (k);
ldyconst (k);
- AddCodeLine ("\tjmp\taddysp");
+ AddCodeSegLine (CS, "jmp addysp");
}
} else {
/* Don't loop for up to two bytes */
if (Bytes == 1) {
- AddCodeLine ("\tlda\tregbank%+d", RegOffs);
- AddCodeLine ("\tjsr\tpusha");
+ AddCodeSegLine (CS, "lda regbank%+d", RegOffs);
+ AddCodeSegLine (CS, "jsr pusha");
} else if (Bytes == 2) {
- AddCodeLine ("\tlda\tregbank%+d", RegOffs);
- AddCodeLine ("\tldx\tregbank%+d", RegOffs+1);
- AddCodeLine ("\tjsr\tpushax");
+ AddCodeSegLine (CS, "lda regbank%+d", RegOffs);
+ AddCodeSegLine (CS, "ldx regbank%+d", RegOffs+1);
+ AddCodeSegLine (CS, "jsr pushax");
} else {
ldyconst (Bytes - 1);
ldxconst (Bytes);
g_defloclabel (Label);
- AddCodeLine ("\tlda\tregbank%+d,x", RegOffs-1);
- AddCodeLine ("\tsta\t(sp),y");
- AddCodeLine ("\tdey");
- AddCodeLine ("\tdex");
- AddCodeLine ("\tbne\tL%04X", Label);
+ AddCodeSegLine (CS, "lda regbank%+d,x", RegOffs-1);
+ AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeSegLine (CS, "dey");
+ AddCodeSegLine (CS, "dex");
+ AddCodeSegLine (CS, "bne L%04X", Label);
}
if (Bytes == 1) {
ldyconst (StackOffs);
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tsta\tregbank%+d", RegOffs);
+ AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeSegLine (CS, "sta regbank%+d", RegOffs);
} else if (Bytes == 2) {
ldyconst (StackOffs);
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tsta\tregbank%+d", RegOffs);
- AddCodeLine ("\tiny");
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tsta\tregbank%+d", RegOffs+1);
+ 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);
} else {
ldyconst (StackOffs+Bytes-1);
ldxconst (Bytes);
g_defloclabel (Label);
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tsta\tregbank%+d,x", RegOffs-1);
- AddCodeLine ("\tdey");
- AddCodeLine ("\tdex");
- AddCodeLine ("\tbne\tL%04X", Label);
+ AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeSegLine (CS, "sta regbank%+d,x", RegOffs-1);
+ AddCodeSegLine (CS, "dey");
+ AddCodeSegLine (CS, "dex");
+ AddCodeSegLine (CS, "bne L%04X", Label);
}
}
case CF_LONG:
if (val < 0x100) {
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tstx\tsreg+1");
- AddCodeLine ("\tstx\tsreg");
- AddCodeLine ("\tlda\t#$%02X", (unsigned char) val);
+ AddCodeSegLine (CS, "ldx #$00");
+ AddCodeSegLine (CS, "stx sreg+1");
+ AddCodeSegLine (CS, "stx sreg");
+ AddCodeSegLine (CS, "lda #$%02X", (unsigned char) val);
} else if ((val & 0xFFFF00FF) == 0) {
- AddCodeLine ("\tlda\t#$00");
- AddCodeLine ("\tsta\tsreg+1");
- AddCodeLine ("\tsta\tsreg");
- AddCodeLine ("\tldx\t#$%02X", (unsigned char) (val >> 8));
+ AddCodeSegLine (CS, "lda #$00");
+ AddCodeSegLine (CS, "sta sreg+1");
+ AddCodeSegLine (CS, "sta sreg");
+ AddCodeSegLine (CS, "ldx #$%02X", (unsigned char) (val >> 8));
} else if ((val & 0xFFFF0000) == 0 && CodeSizeFactor > 140) {
- AddCodeLine ("\tlda\t#$00");
- AddCodeLine ("\tsta\tsreg+1");
- AddCodeLine ("\tsta\tsreg");
- AddCodeLine ("\tlda\t#$%02X", (unsigned char) val);
- AddCodeLine ("\tldx\t#$%02X", (unsigned char) (val >> 8));
+ 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));
} else if ((val & 0xFFFFFF00) == 0xFFFFFF00) {
- AddCodeLine ("\tldx\t#$FF");
- AddCodeLine ("\tstx\tsreg+1");
- AddCodeLine ("\tstx\tsreg");
+ AddCodeSegLine (CS, "ldx #$FF");
+ AddCodeSegLine (CS, "stx sreg+1");
+ AddCodeSegLine (CS, "stx sreg");
if ((val & 0xFF) == 0xFF) {
- AddCodeLine ("\ttxa");
+ AddCodeSegLine (CS, "txa");
} else {
- AddCodeLine ("\tlda\t#$%02X", (unsigned char) val);
+ AddCodeSegLine (CS, "lda #$%02X", (unsigned char) val);
}
} else if ((val & 0xFFFF00FF) == 0xFFFF00FF) {
- AddCodeLine ("\tlda\t#$FF");
- AddCodeLine ("\tsta\tsreg+1");
- AddCodeLine ("\tsta\tsreg");
- AddCodeLine ("\tldx\t#$%02X", (unsigned char) (val >> 8));
+ AddCodeSegLine (CS, "lda #$FF");
+ AddCodeSegLine (CS, "sta sreg+1");
+ AddCodeSegLine (CS, "sta sreg");
+ AddCodeSegLine (CS, "ldx #$%02X", (unsigned char) (val >> 8));
} else {
/* Call a subroutine that will load following value */
- AddCodeLine ("\tjsr\tldeax");
- AddCodeLine ("\t.dword\t$%08lX", val & 0xFFFFFFFF);
+ AddCodeSegLine (CS, "jsr ldeax");
+ AddCodeSegLine (CS, ".dword $%08lX", val & 0xFFFFFFFF);
}
break;
const char* Label = GetLabelName (flags, val, offs);
/* Load the address into the primary */
- AddCodeLine ("\tlda\t#<(%s)", Label);
- AddCodeLine ("\tldx\t#>(%s)", Label);
+ AddCodeSegLine (CS, "lda #<(%s)", Label);
+ AddCodeSegLine (CS, "ldx #>(%s)", Label);
}
}
case CF_CHAR:
if ((flags & CF_FORCECHAR) || (flags & CF_TEST)) {
- AddCodeLine ("\tlda\t%s", lbuf); /* load A from the label */
+ AddCodeSegLine (CS, "lda %s", lbuf); /* load A from the label */
} else {
ldxconst (0);
- AddCodeLine ("\tlda\t%s", lbuf); /* load A from the label */
+ AddCodeSegLine (CS, "lda %s", lbuf); /* load A from the label */
if (!(flags & CF_UNSIGNED)) {
/* Must sign extend */
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "bpl *+3");
+ AddCodeSegLine (CS, "dex");
AddCodeHint ("x:!"); /* X is invalid now */
}
}
break;
case CF_INT:
- AddCodeLine ("\tlda\t%s", lbuf);
+ AddCodeSegLine (CS, "lda %s", lbuf);
if (flags & CF_TEST) {
- AddCodeLine ("\tora\t%s+1", lbuf);
+ AddCodeSegLine (CS, "ora %s+1", lbuf);
} else {
- AddCodeLine ("\tldx\t%s+1", lbuf);
+ AddCodeSegLine (CS, "ldx %s+1", lbuf);
}
break;
case CF_LONG:
if (flags & CF_TEST) {
- AddCodeLine ("\tlda\t%s+3", lbuf);
- AddCodeLine ("\tora\t%s+2", lbuf);
- AddCodeLine ("\tora\t%s+1", lbuf);
- AddCodeLine ("\tora\t%s+0", lbuf);
+ AddCodeSegLine (CS, "lda %s+3", lbuf);
+ AddCodeSegLine (CS, "ora %s+2", lbuf);
+ AddCodeSegLine (CS, "ora %s+1", lbuf);
+ AddCodeSegLine (CS, "ora %s+0", lbuf);
} else {
- AddCodeLine ("\tlda\t%s+3", lbuf);
- AddCodeLine ("\tsta\tsreg+1");
- AddCodeLine ("\tlda\t%s+2", lbuf);
- AddCodeLine ("\tsta\tsreg");
- AddCodeLine ("\tldx\t%s+1", lbuf);
- AddCodeLine ("\tlda\t%s", lbuf);
+ 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);
}
break;
case CF_CHAR:
if ((flags & CF_FORCECHAR) || (flags & CF_TEST)) {
if (CPU == CPU_65C02 && offs == 0) {
- AddCodeLine ("\tlda\t(sp)");
+ AddCodeSegLine (CS, "lda (sp)");
} else {
ldyconst (offs);
- AddCodeLine ("\tlda\t(sp),y");
+ AddCodeSegLine (CS, "lda (sp),y");
}
} else {
if (offs == 0) {
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t(sp,x)");
+ AddCodeSegLine (CS, "ldx #$00");
+ AddCodeSegLine (CS, "lda (sp,x)");
} else {
ldyconst (offs);
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t(sp),y");
+ AddCodeSegLine (CS, "ldx #$00");
+ AddCodeSegLine (CS, "lda (sp),y");
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "bpl *+3");
+ AddCodeSegLine (CS, "dex");
AddCodeHint ("x:!"); /* X is invalid now */
}
}
CheckLocalOffs (offs + 1);
if (flags & CF_TEST) {
ldyconst (offs + 1);
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tdey");
- AddCodeLine ("\tora\t(sp),y");
+ AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeSegLine (CS, "dey");
+ AddCodeSegLine (CS, "ora (sp),y");
} else {
if (CodeSizeFactor > 180) {
ldyconst (offs + 1);
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\ttax");
- AddCodeLine ("\tdey");
- AddCodeLine ("\tlda\t(sp),y");
+ AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "dey");
+ AddCodeSegLine (CS, "lda (sp),y");
} else {
if (offs) {
ldyconst (offs+1);
- AddCodeLine ("\tjsr\tldaxysp");
+ AddCodeSegLine (CS, "jsr ldaxysp");
} else {
- AddCodeLine ("\tjsr\tldax0sp");
+ AddCodeSegLine (CS, "jsr ldax0sp");
}
}
}
case CF_LONG:
if (offs) {
ldyconst (offs+3);
- AddCodeLine ("\tjsr\tldeaxysp");
+ AddCodeSegLine (CS, "jsr ldeaxysp");
} else {
- AddCodeLine ("\tjsr\tldeax0sp");
+ AddCodeSegLine (CS, "jsr ldeax0sp");
}
break;
if (offs) {
ldyconst (offs);
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tldauidx");
+ AddCodeSegLine (CS, "jsr ldauidx");
} else {
- AddCodeLine ("\tjsr\tldaidx");
+ AddCodeSegLine (CS, "jsr ldaidx");
}
} else {
if (flags & CF_UNSIGNED) {
if (CodeSizeFactor > 250) {
- AddCodeLine ("\tsta\tptr1");
- AddCodeLine ("\tstx\tptr1+1");
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t(ptr1,x)");
+ AddCodeSegLine (CS, "sta ptr1");
+ AddCodeSegLine (CS, "stx ptr1+1");
+ AddCodeSegLine (CS, "ldx #$00");
+ AddCodeSegLine (CS, "lda (ptr1,x)");
} else {
- AddCodeLine ("\tjsr\tldaui");
+ AddCodeSegLine (CS, "jsr ldaui");
}
} else {
- AddCodeLine ("\tjsr\tldai");
+ AddCodeSegLine (CS, "jsr ldai");
}
}
break;
case CF_INT:
if (flags & CF_TEST) {
ldyconst (offs);
- AddCodeLine ("\tsta\tptr1");
- AddCodeLine ("\tstx\tptr1+1");
- AddCodeLine ("\tlda\t(ptr1),y");
- AddCodeLine ("\tiny");
- AddCodeLine ("\tora\t(ptr1),y");
+ AddCodeSegLine (CS, "sta ptr1");
+ AddCodeSegLine (CS, "stx ptr1+1");
+ AddCodeSegLine (CS, "lda (ptr1),y");
+ AddCodeSegLine (CS, "iny");
+ AddCodeSegLine (CS, "ora (ptr1),y");
} else {
if (offs == 0) {
- AddCodeLine ("\tjsr\tldaxi");
+ AddCodeSegLine (CS, "jsr ldaxi");
} else {
ldyconst (offs+1);
- AddCodeLine ("\tjsr\tldaxidx");
+ AddCodeSegLine (CS, "jsr ldaxidx");
}
}
break;
case CF_LONG:
if (offs == 0) {
- AddCodeLine ("\tjsr\tldeaxi");
+ AddCodeSegLine (CS, "jsr ldeaxi");
} else {
ldyconst (offs+3);
- AddCodeLine ("\tjsr\tldeaxidx");
+ AddCodeSegLine (CS, "jsr ldeaxidx");
}
if (flags & CF_TEST) {
- AddCodeLine ("\tjsr\ttsteax");
+ AddCodeSegLine (CS, "jsr tsteax");
}
break;
/* For value 0 we do direct code */
if (offs == 0) {
- AddCodeLine ("\tlda\tsp");
- AddCodeLine ("\tldx\tsp+1");
+ AddCodeSegLine (CS, "lda sp");
+ AddCodeSegLine (CS, "ldx sp+1");
} else {
if (CodeSizeFactor < 300) {
ldaconst (offs); /* Load A with offset value */
- AddCodeLine ("\tjsr\tleaasp"); /* Load effective address */
+ AddCodeSegLine (CS, "jsr leaasp"); /* Load effective address */
} else {
if (CPU == CPU_65C02 && offs == 1) {
- AddCodeLine ("\tlda\tsp");
- AddCodeLine ("\tldx\tsp+1");
- AddCodeLine ("\tina");
- AddCodeLine ("\tbne\t*+3");
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "lda sp");
+ AddCodeSegLine (CS, "ldx sp+1");
+ AddCodeSegLine (CS, "ina");
+ AddCodeSegLine (CS, "bne *+3");
+ AddCodeSegLine (CS, "inx");
AddCodeHint ("x:!"); /* Invalidate X */
} else {
ldaconst (offs);
- AddCodeLine ("\tclc");
- AddCodeLine ("\tldx\tsp+1");
- AddCodeLine ("\tadc\tsp");
- AddCodeLine ("\tbcc\t*+3");
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "ldx sp+1");
+ AddCodeSegLine (CS, "adc sp");
+ AddCodeSegLine (CS, "bcc *+3");
+ AddCodeSegLine (CS, "inx");
AddCodeHint ("x:!"); /* Invalidate X */
}
}
/* Get the size of all parameters. */
if (ArgSizeOffs == 0 && CPU == CPU_65C02) {
- AddCodeLine ("\tlda\t(sp)");
+ AddCodeSegLine (CS, "lda (sp)");
} else {
ldyconst (ArgSizeOffs);
- AddCodeLine ("\tlda\t(sp),y");
+ AddCodeSegLine (CS, "lda (sp),y");
}
/* Add the value of the stackpointer */
if (CodeSizeFactor > 250) {
- AddCodeLine ("\tldx\tsp+1");
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\tsp");
- AddCodeLine ("\tbcc\t*+3");
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "ldx sp+1");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc sp");
+ AddCodeSegLine (CS, "bcc *+3");
+ AddCodeSegLine (CS, "inx");
AddCodeHint ("x:!"); /* Invalidate X */
} else {
- AddCodeLine ("\tjsr\tleaasp");
+ AddCodeSegLine (CS, "jsr leaasp");
}
/* Add the offset to the primary */
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeLine ("\tsta\t%s", lbuf);
+ AddCodeSegLine (CS, "sta %s", lbuf);
break;
case CF_INT:
- AddCodeLine ("\tsta\t%s", lbuf);
- AddCodeLine ("\tstx\t%s+1", lbuf);
+ AddCodeSegLine (CS, "sta %s", lbuf);
+ AddCodeSegLine (CS, "stx %s+1", lbuf);
break;
case CF_LONG:
- AddCodeLine ("\tsta\t%s", lbuf);
- AddCodeLine ("\tstx\t%s+1", lbuf);
- AddCodeLine ("\tldy\tsreg");
- AddCodeLine ("\tsty\t%s+2", lbuf);
- AddCodeLine ("\tldy\tsreg+1");
- AddCodeLine ("\tsty\t%s+3", lbuf);
+ 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);
break;
default:
case CF_CHAR:
if (Flags & CF_CONST) {
- AddCodeLine ("\tlda\t#$%02X", (unsigned char) Val);
+ AddCodeSegLine (CS, "lda #$%02X", (unsigned char) Val);
}
if (CPU == CPU_65C02 && Offs == 0) {
- AddCodeLine ("\tsta\t(sp)");
+ AddCodeSegLine (CS, "sta (sp)");
} else {
ldyconst (Offs);
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "sta (sp),y");
}
break;
case CF_INT:
if (Flags & CF_CONST) {
ldyconst (Offs+1);
- AddCodeLine ("\tlda\t#$%02X", (unsigned char) (Val >> 8));
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "lda #$%02X", (unsigned char) (Val >> 8));
+ AddCodeSegLine (CS, "sta (sp),y");
if ((Flags & CF_NOKEEP) == 0) {
/* Place high byte into X */
- AddCodeLine ("\ttax");
+ AddCodeSegLine (CS, "tax");
}
if (CPU == CPU_65C02 && Offs == 0) {
- AddCodeLine ("\tlda\t#$%02X", (unsigned char) Val);
- AddCodeLine ("\tsta\t(sp)");
+ AddCodeSegLine (CS, "lda #$%02X", (unsigned char) Val);
+ AddCodeSegLine (CS, "sta (sp)");
} else {
if ((Val & 0xFF) == Offs+1) {
/* The value we need is already in Y */
- AddCodeLine ("\ttya");
- AddCodeLine ("\tdey");
+ AddCodeSegLine (CS, "tya");
+ AddCodeSegLine (CS, "dey");
} else {
- AddCodeLine ("\tdey");
- AddCodeLine ("\tlda\t#$%02X", (unsigned char) Val);
+ AddCodeSegLine (CS, "dey");
+ AddCodeSegLine (CS, "lda #$%02X", (unsigned char) Val);
}
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "sta (sp),y");
}
} else {
if ((Flags & CF_NOKEEP) == 0 || CodeSizeFactor < 160) {
if (Offs) {
ldyconst (Offs);
- AddCodeLine ("\tjsr\tstaxysp");
+ AddCodeSegLine (CS, "jsr staxysp");
} else {
- AddCodeLine ("\tjsr\tstax0sp");
+ AddCodeSegLine (CS, "jsr stax0sp");
}
} else {
if (CPU == CPU_65C02 && Offs == 0) {
- AddCodeLine ("\tsta\t(sp)");
+ AddCodeSegLine (CS, "sta (sp)");
ldyconst (1);
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "sta (sp),y");
} else {
ldyconst (Offs);
- AddCodeLine ("\tsta\t(sp),y");
- AddCodeLine ("\tiny");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "sta (sp),y");
+ AddCodeSegLine (CS, "iny");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "sta (sp),y");
}
}
}
}
if (Offs) {
ldyconst (Offs);
- AddCodeLine ("\tjsr\tsteaxysp");
+ AddCodeSegLine (CS, "jsr steaxysp");
} else {
- AddCodeLine ("\tjsr\tsteax0sp");
+ AddCodeSegLine (CS, "jsr steax0sp");
}
break;
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");
+ 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");
/* 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");
+ 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");
/* Offset is now just the low byte */
Offs &= 0x00FF;
case CF_CHAR:
if (Offs) {
ldyconst (Offs);
- AddCodeLine ("\tjsr\tstaspidx");
+ AddCodeSegLine (CS, "jsr staspidx");
} else {
- AddCodeLine ("\tjsr\tstaspp");
+ AddCodeSegLine (CS, "jsr staspp");
}
break;
case CF_INT:
if (Offs) {
ldyconst (Offs);
- AddCodeLine ("\tjsr\tstaxspidx");
+ AddCodeSegLine (CS, "jsr staxspidx");
} else {
- AddCodeLine ("\tjsr\tstaxspp");
+ AddCodeSegLine (CS, "jsr staxspp");
}
break;
case CF_LONG:
if (Offs) {
ldyconst (Offs);
- AddCodeLine ("\tjsr\tsteaxspidx");
+ AddCodeSegLine (CS, "jsr steaxspidx");
} else {
- AddCodeLine ("\tjsr\tsteaxspp");
+ AddCodeSegLine (CS, "jsr steaxspp");
}
break;
case CF_CHAR:
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\ttosulong");
+ AddCodeSegLine (CS, "jsr tosulong");
} else {
- AddCodeLine ("\tjsr\ttoslong");
+ AddCodeSegLine (CS, "jsr toslong");
}
push (CF_INT);
break;
break;
case CF_LONG:
- AddCodeLine ("\tjsr\ttosint");
+ AddCodeSegLine (CS, "jsr tosint");
pop (CF_INT);
break;
if (flags & CF_UNSIGNED) {
if (CodeSizeFactor >= 200) {
ldyconst (0);
- AddCodeLine ("\tsty\tsreg");
- AddCodeLine ("\tsty\tsreg+1");
+ AddCodeSegLine (CS, "sty sreg");
+ AddCodeSegLine (CS, "sty sreg+1");
} else {
- AddCodeLine ("\tjsr\taxulong");
+ AddCodeSegLine (CS, "jsr axulong");
}
} else {
- AddCodeLine ("\tjsr\taxlong");
+ AddCodeSegLine (CS, "jsr axlong");
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
while (p2--) {
- AddCodeLine ("\tasl\ta");
+ AddCodeSegLine (CS, "asl a");
}
break;
}
case CF_INT:
if (CodeSizeFactor >= (p2+1)*130U) {
- AddCodeLine ("\tstx\ttmp1");
+ AddCodeSegLine (CS, "stx tmp1");
while (p2--) {
- AddCodeLine ("\tasl\ta");
- AddCodeLine ("\trol\ttmp1");
+ AddCodeSegLine (CS, "asl a");
+ AddCodeSegLine (CS, "rol tmp1");
}
- AddCodeLine ("\tldx\ttmp1");
+ AddCodeSegLine (CS, "ldx tmp1");
} else {
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tshlax%d", p2);
+ AddCodeSegLine (CS, "jsr shlax%d", p2);
} else {
- AddCodeLine ("\tjsr\taslax%d", p2);
+ AddCodeSegLine (CS, "jsr aslax%d", p2);
}
}
break;
case CF_LONG:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tshleax%d", p2);
+ AddCodeSegLine (CS, "jsr shleax%d", p2);
} else {
- AddCodeLine ("\tjsr\tasleax%d", p2);
+ AddCodeSegLine (CS, "jsr asleax%d", p2);
}
break;
if (flags & CF_FORCECHAR) {
if (flags & CF_UNSIGNED) {
while (p2--) {
- AddCodeLine ("\tlsr\ta");
+ AddCodeSegLine (CS, "lsr a");
}
break;
} else if (p2 <= 2) {
- AddCodeLine ("\tcmp\t#$80");
- AddCodeLine ("\tror\ta");
+ AddCodeSegLine (CS, "cmp #$80");
+ AddCodeSegLine (CS, "ror a");
break;
}
}
case CF_INT:
if (flags & CF_UNSIGNED) {
if (CodeSizeFactor >= (p2+1)*130U) {
- AddCodeLine ("\tstx\ttmp1");
+ AddCodeSegLine (CS, "stx tmp1");
while (p2--) {
- AddCodeLine ("\tlsr\ttmp1");
- AddCodeLine ("\tror\ta");
+ AddCodeSegLine (CS, "lsr tmp1");
+ AddCodeSegLine (CS, "ror a");
}
- AddCodeLine ("\tldx\ttmp1");
+ AddCodeSegLine (CS, "ldx tmp1");
} else {
- AddCodeLine ("\tjsr\tlsrax%d", p2);
+ AddCodeSegLine (CS, "jsr lsrax%d", p2);
}
} else {
if (CodeSizeFactor >= (p2+1)*150U) {
- AddCodeLine ("\tstx\ttmp1");
+ AddCodeSegLine (CS, "stx tmp1");
while (p2--) {
- AddCodeLine ("\tcpx\t#$80");
- AddCodeLine ("\tror\ttmp1");
- AddCodeLine ("\tror\ta");
+ AddCodeSegLine (CS, "cpx #$80");
+ AddCodeSegLine (CS, "ror tmp1");
+ AddCodeSegLine (CS, "ror a");
}
- AddCodeLine ("\tldx\ttmp1");
+ AddCodeSegLine (CS, "ldx tmp1");
} else {
- AddCodeLine ("\tjsr\tasrax%d", p2);
+ AddCodeSegLine (CS, "jsr asrax%d", p2);
}
}
break;
case CF_LONG:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tlsreax%d", p2);
+ AddCodeSegLine (CS, "jsr lsreax%d", p2);
} else {
- AddCodeLine ("\tjsr\tasreax%d", p2);
+ AddCodeSegLine (CS, "jsr asreax%d", p2);
}
break;
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeLine ("\tldy\t#$%02X", offs & 0xFF);
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t(sp),y");
- AddCodeLine ("\tbcc\t*+3");
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "ldy #$%02X", offs & 0xFF);
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc (sp),y");
+ AddCodeSegLine (CS, "bcc *+3");
+ AddCodeSegLine (CS, "inx");
AddCodeHint ("x:!");
break;
case CF_INT:
- AddCodeLine ("\tldy\t#$%02X", offs & 0xFF);
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t(sp),y");
- AddCodeLine ("\tpha");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tiny");
- AddCodeLine ("\tadc\t(sp),y");
- AddCodeLine ("\ttax");
- AddCodeLine ("\tpla");
+ 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");
break;
case CF_LONG:
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tbcc\t*+3");
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc %s", lbuf);
+ AddCodeSegLine (CS, "bcc *+3");
+ AddCodeSegLine (CS, "inx");
AddCodeHint ("x:!");
break;
case CF_INT:
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\ttay");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tadc\t%s+1", lbuf);
- AddCodeLine ("\ttax");
- AddCodeLine ("\ttya");
+ 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");
break;
case CF_LONG:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tldx\t#$00");
+ AddCodeSegLine (CS, "ldx #$00");
if (flags & CF_CONST) {
if (val == 1) {
- AddCodeLine ("\tinc\t%s", lbuf);
- AddCodeLine ("\tlda\t%s", lbuf);
+ AddCodeSegLine (CS, "inc %s", lbuf);
+ AddCodeSegLine (CS, "lda %s", lbuf);
} else {
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tsta\t%s", lbuf);
+ AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc %s", lbuf);
+ AddCodeSegLine (CS, "sta %s", lbuf);
}
} else {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tsta\t%s", lbuf);
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc %s", lbuf);
+ AddCodeSegLine (CS, "sta %s", lbuf);
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "bpl *+3");
+ AddCodeSegLine (CS, "dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
if (flags & CF_CONST) {
if (val == 1) {
label = GetLocalLabel ();
- AddCodeLine ("\tinc\t%s", lbuf);
- AddCodeLine ("\tbne\tL%04X", (int)label);
- AddCodeLine ("\tinc\t%s+1", lbuf);
+ AddCodeSegLine (CS, "inc %s", lbuf);
+ AddCodeSegLine (CS, "bne L%04X", (int)label);
+ AddCodeSegLine (CS, "inc %s+1", lbuf);
g_defloclabel (label);
- AddCodeLine ("\tlda\t%s", lbuf); /* Hmmm... */
- AddCodeLine ("\tldx\t%s+1", lbuf);
+ AddCodeSegLine (CS, "lda %s", lbuf); /* Hmmm... */
+ AddCodeSegLine (CS, "ldx %s+1", lbuf);
} else {
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tsta\t%s", lbuf);
+ AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc %s", lbuf);
+ AddCodeSegLine (CS, "sta %s", lbuf);
if (val < 0x100) {
label = GetLocalLabel ();
- AddCodeLine ("\tbcc\tL%04X", (int)label);
- AddCodeLine ("\tinc\t%s+1", lbuf);
+ AddCodeSegLine (CS, "bcc L%04X", (int)label);
+ AddCodeSegLine (CS, "inc %s+1", lbuf);
g_defloclabel (label);
- AddCodeLine ("\tldx\t%s+1", lbuf);
+ AddCodeSegLine (CS, "ldx %s+1", lbuf);
} else {
- AddCodeLine ("\tlda\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tadc\t%s+1", lbuf);
- AddCodeLine ("\tsta\t%s+1", lbuf);
- AddCodeLine ("\ttax");
- AddCodeLine ("\tlda\t%s", lbuf);
+ 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);
}
}
} else {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tsta\t%s", lbuf);
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tadc\t%s+1", lbuf);
- AddCodeLine ("\tsta\t%s+1", lbuf);
- AddCodeLine ("\ttax");
- AddCodeLine ("\tlda\t%s", lbuf);
+ 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);
}
break;
case CF_LONG:
if (flags & CF_CONST) {
if (val < 0x100) {
- AddCodeLine ("\tldy\t#<(%s)", lbuf);
- AddCodeLine ("\tsty\tptr1");
- AddCodeLine ("\tldy\t#>(%s+1)", lbuf);
+ AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
+ AddCodeSegLine (CS, "sty ptr1");
+ AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
if (val == 1) {
- AddCodeLine ("\tjsr\tladdeq1");
+ AddCodeSegLine (CS, "jsr laddeq1");
} else {
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tjsr\tladdeqa");
+ AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
+ AddCodeSegLine (CS, "jsr laddeqa");
}
} else {
g_getstatic (flags, label, offs);
g_putstatic (flags, label, offs);
}
} else {
- AddCodeLine ("\tldy\t#<(%s)", lbuf);
- AddCodeLine ("\tsty\tptr1");
- AddCodeLine ("\tldy\t#>(%s+1)", lbuf);
- AddCodeLine ("\tjsr\tladdeq");
+ AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
+ AddCodeSegLine (CS, "sty ptr1");
+ AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
+ AddCodeSegLine (CS, "jsr laddeq");
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if (offs == 0) {
- AddCodeLine ("\tldx\t#$00");
+ AddCodeSegLine (CS, "ldx #$00");
if (flags & CF_CONST) {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tadc\t(sp,x)");
- AddCodeLine ("\tsta\t(sp,x)");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
+ AddCodeSegLine (CS, "adc (sp,x)");
+ AddCodeSegLine (CS, "sta (sp,x)");
} else {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t(sp,x)");
- AddCodeLine ("\tsta\t(sp,x)");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc (sp,x)");
+ AddCodeSegLine (CS, "sta (sp,x)");
}
} else {
ldyconst (offs);
- AddCodeLine ("\tldx\t#$00");
+ AddCodeSegLine (CS, "ldx #$00");
if (flags & CF_CONST) {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tadc\t(sp),y");
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
+ AddCodeSegLine (CS, "adc (sp),y");
+ AddCodeSegLine (CS, "sta (sp),y");
} else {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t(sp),y");
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc (sp),y");
+ AddCodeSegLine (CS, "sta (sp),y");
}
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "bpl *+3");
+ AddCodeSegLine (CS, "dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeLine ("\tjsr\taddeq0sp");
+ AddCodeSegLine (CS, "jsr addeq0sp");
} else {
ldyconst (offs);
- AddCodeLine ("\tjsr\taddeqysp");
+ AddCodeSegLine (CS, "jsr addeqysp");
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeLine ("\tjsr\tladdeq0sp");
+ AddCodeSegLine (CS, "jsr laddeq0sp");
} else {
ldyconst (offs);
- AddCodeLine ("\tjsr\tladdeqysp");
+ AddCodeSegLine (CS, "jsr laddeqysp");
}
break;
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeLine ("\tsta\tptr1");
- AddCodeLine ("\tstx\tptr1+1");
+ AddCodeSegLine (CS, "sta ptr1");
+ AddCodeSegLine (CS, "stx ptr1+1");
if (offs == 0) {
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t(ptr1,x)");
- AddCodeLine ("\tsta\t(ptr1,x)");
+ AddCodeSegLine (CS, "ldx #$00");
+ AddCodeSegLine (CS, "lda #$%02X", (int)(val & 0xFF));
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc (ptr1,x)");
+ AddCodeSegLine (CS, "sta (ptr1,x)");
} else {
- AddCodeLine ("\tldy\t#$%02X", offs);
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t(ptr1),y");
- AddCodeLine ("\tsta\t(ptr1),y");
+ 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");
}
break;
case CF_INT:
if (CodeSizeFactor >= 200) {
/* Lots of code, use only if size is not important */
- AddCodeLine ("\tsta\tptr1");
- AddCodeLine ("\tstx\tptr1+1");
- AddCodeLine ("\tldy\t#$%02X", offs);
- 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", (unsigned char)(val >> 8));
- AddCodeLine ("\tadc\t(ptr1),y");
- AddCodeLine ("\tsta\t(ptr1),y");
- AddCodeLine ("\ttax");
- AddCodeLine ("\tpla");
+ 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");
break;
}
/* FALL THROUGH */
case CF_LONG:
- AddCodeLine ("\tjsr\tpushax"); /* Push the address */
+ AddCodeSegLine (CS, "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) {
- AddCodeLine ("\tldx\t#$00");
+ AddCodeSegLine (CS, "ldx #$00");
if (flags & CF_CONST) {
if (val == 1) {
- AddCodeLine ("\tdec\t%s", lbuf);
- AddCodeLine ("\tlda\t%s", lbuf);
+ AddCodeSegLine (CS, "dec %s", lbuf);
+ AddCodeSegLine (CS, "lda %s", lbuf);
} else {
- AddCodeLine ("\tsec");
- AddCodeLine ("\tlda\t%s", lbuf);
- AddCodeLine ("\tsbc\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tsta\t%s", lbuf);
+ AddCodeSegLine (CS, "sec");
+ AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeSegLine (CS, "sbc #$%02X", (int)(val & 0xFF));
+ AddCodeSegLine (CS, "sta %s", lbuf);
}
} else {
- AddCodeLine ("\tsec");
- AddCodeLine ("\tsta\ttmp1");
- AddCodeLine ("\tlda\t%s", lbuf);
- AddCodeLine ("\tsbc\ttmp1");
- AddCodeLine ("\tsta\t%s", lbuf);
+ AddCodeSegLine (CS, "sec");
+ AddCodeSegLine (CS, "sta tmp1");
+ AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeSegLine (CS, "sbc tmp1");
+ AddCodeSegLine (CS, "sta %s", lbuf);
}
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "bpl *+3");
+ AddCodeSegLine (CS, "dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tsec");
+ AddCodeSegLine (CS, "sec");
if (flags & CF_CONST) {
- AddCodeLine ("\tlda\t%s", lbuf);
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tsta\t%s", lbuf);
+ AddCodeSegLine (CS, "lda %s", lbuf);
+ AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "sta %s", lbuf);
if (val < 0x100) {
label = GetLocalLabel ();
- AddCodeLine ("\tbcs\tL%04X", (unsigned)label);
- AddCodeLine ("\tdec\t%s+1", lbuf);
+ AddCodeSegLine (CS, "bcs L%04X", (unsigned)label);
+ AddCodeSegLine (CS, "dec %s+1", lbuf);
g_defloclabel (label);
- AddCodeLine ("\tldx\t%s+1", lbuf);
+ AddCodeSegLine (CS, "ldx %s+1", lbuf);
} else {
- AddCodeLine ("\tlda\t%s+1", lbuf);
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tsta\t%s+1", lbuf);
- AddCodeLine ("\ttax");
- AddCodeLine ("\tlda\t%s", lbuf);
+ 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);
}
} else {
- AddCodeLine ("\tsta\ttmp1");
- AddCodeLine ("\tlda\t%s", lbuf);
- AddCodeLine ("\tsbc\ttmp1");
- AddCodeLine ("\tsta\t%s", lbuf);
- AddCodeLine ("\tstx\ttmp1");
- AddCodeLine ("\tlda\t%s+1", lbuf);
- AddCodeLine ("\tsbc\ttmp1");
- AddCodeLine ("\tsta\t%s+1", lbuf);
- AddCodeLine ("\ttax");
- AddCodeLine ("\tlda\t%s", lbuf);
+ 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);
}
break;
case CF_LONG:
if (flags & CF_CONST) {
if (val < 0x100) {
- AddCodeLine ("\tldy\t#<(%s)", lbuf);
- AddCodeLine ("\tsty\tptr1");
- AddCodeLine ("\tldy\t#>(%s+1)", lbuf);
+ AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
+ AddCodeSegLine (CS, "sty ptr1");
+ AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
if (val == 1) {
- AddCodeLine ("\tjsr\tlsubeq1");
+ AddCodeSegLine (CS, "jsr lsubeq1");
} else {
- AddCodeLine ("\tlda\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tlsubeqa");
+ AddCodeSegLine (CS, "lda #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr lsubeqa");
}
} else {
g_getstatic (flags, label, offs);
g_putstatic (flags, label, offs);
}
} else {
- AddCodeLine ("\tldy\t#<(%s)", lbuf);
- AddCodeLine ("\tsty\tptr1");
- AddCodeLine ("\tldy\t#>(%s+1)", lbuf);
- AddCodeLine ("\tjsr\tlsubeq");
+ AddCodeSegLine (CS, "ldy #<(%s)", lbuf);
+ AddCodeSegLine (CS, "sty ptr1");
+ AddCodeSegLine (CS, "ldy #>(%s+1)", lbuf);
+ AddCodeSegLine (CS, "jsr lsubeq");
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
ldyconst (offs);
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tsec");
+ AddCodeSegLine (CS, "ldx #$00");
+ AddCodeSegLine (CS, "sec");
if (flags & CF_CONST) {
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
} else {
- AddCodeLine ("\tsta\ttmp1");
- AddCodeLine ("\tlda\t(sp),y");
- AddCodeLine ("\tsbc\ttmp1");
+ AddCodeSegLine (CS, "sta tmp1");
+ AddCodeSegLine (CS, "lda (sp),y");
+ AddCodeSegLine (CS, "sbc tmp1");
}
- AddCodeLine ("\tsta\t(sp),y");
+ AddCodeSegLine (CS, "sta (sp),y");
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "bpl *+3");
+ AddCodeSegLine (CS, "dex");
AddCodeHint ("x:!"); /* Invalidate X */
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeLine ("\tjsr\tsubeq0sp");
+ AddCodeSegLine (CS, "jsr subeq0sp");
} else {
ldyconst (offs);
- AddCodeLine ("\tjsr\tsubeqysp");
+ AddCodeSegLine (CS, "jsr subeqysp");
}
break;
g_getimmed (flags, val, 0);
}
if (offs == 0) {
- AddCodeLine ("\tjsr\tlsubeq0sp");
+ AddCodeSegLine (CS, "jsr lsubeq0sp");
} else {
ldyconst (offs);
- AddCodeLine ("\tjsr\tlsubeqysp");
+ AddCodeSegLine (CS, "jsr lsubeqysp");
}
break;
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeLine ("\tsta\tptr1");
- AddCodeLine ("\tstx\tptr1+1");
+ AddCodeSegLine (CS, "sta ptr1");
+ AddCodeSegLine (CS, "stx ptr1+1");
if (offs == 0) {
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t(ptr1,x)");
- AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tsta\t(ptr1,x)");
+ AddCodeSegLine (CS, "ldx #$00");
+ AddCodeSegLine (CS, "lda (ptr1,x)");
+ AddCodeSegLine (CS, "sec");
+ AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "sta (ptr1,x)");
} else {
- AddCodeLine ("\tldy\t#$%02X", offs);
- AddCodeLine ("\tldx\t#$00");
- AddCodeLine ("\tlda\t(ptr1),y");
- AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tsta\t(ptr1),y");
+ 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");
}
break;
case CF_INT:
if (CodeSizeFactor >= 200) {
/* Lots of code, use only if size is not important */
- AddCodeLine ("\tsta\tptr1");
- AddCodeLine ("\tstx\tptr1+1");
- AddCodeLine ("\tldy\t#$%02X", offs);
- AddCodeLine ("\tlda\t(ptr1),y");
- AddCodeLine ("\tsec");
- 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", (unsigned char)(val >> 8));
- AddCodeLine ("\tsta\t(ptr1),y");
- AddCodeLine ("\ttax");
- AddCodeLine ("\tpla");
+ 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");
break;
}
/* FALL THROUGH */
case CF_LONG:
- AddCodeLine ("\tjsr\tpushax"); /* Push the address */
+ AddCodeSegLine (CS, "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);
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t#$%02X", offs & 0xFF);
- AddCodeLine ("\tbcc\t*+4"); /* Do also skip the CLC insn below */
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc #$%02X", offs & 0xFF);
+ AddCodeSegLine (CS, "bcc *+4"); /* Do also skip the CLC insn below */
+ AddCodeSegLine (CS, "inx");
AddCodeHint ("x:!"); /* Invalidate X */
}
/* Add the current stackpointer value */
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\tsp");
- AddCodeLine ("\ttay");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tadc\tsp+1");
- AddCodeLine ("\ttax");
- AddCodeLine ("\ttya");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc sp");
+ AddCodeSegLine (CS, "tay");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "adc sp+1");
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "tya");
}
char* lbuf = GetLabelName (flags, label, offs);
/* Add the address to the current ax value */
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t#<(%s)", lbuf);
- AddCodeLine ("\ttay");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tadc\t#>(%s)", lbuf);
- AddCodeLine ("\ttax");
- AddCodeLine ("\ttya");
+ 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");
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tpha");
+ AddCodeSegLine (CS, "pha");
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tsta\tregsave");
- AddCodeLine ("\tstx\tregsave+1");
+ AddCodeSegLine (CS, "sta regsave");
+ AddCodeSegLine (CS, "stx regsave+1");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tsaveeax");
+ AddCodeSegLine (CS, "jsr saveeax");
break;
default:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tpla");
+ AddCodeSegLine (CS, "pla");
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tlda\tregsave");
- AddCodeLine ("\tldx\tregsave+1");
+ AddCodeSegLine (CS, "lda regsave");
+ AddCodeSegLine (CS, "ldx regsave+1");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tresteax");
+ AddCodeSegLine (CS, "jsr resteax");
break;
default:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "bne *+4");
+ AddCodeSegLine (CS, "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 */
- AddCodeLine ("\tjsr\t%s", subs [offs+0]);
+ AddCodeSegLine (CS, "jsr %s", subs [offs+0]);
} else if (val < 0x100 && subs [offs+1]) {
/* Special case: constant with high byte zero */
ldaconst (val); /* Load low byte */
- AddCodeLine ("\tjsr\t%s", subs [offs+1]);
+ AddCodeSegLine (CS, "jsr %s", subs [offs+1]);
} else {
/* Others: arbitrary constant value */
g_getimmed (flags, val, 0); /* Load value */
- AddCodeLine ("\tjsr\t%s", subs [offs+2]);
+ AddCodeSegLine (CS, "jsr %s", subs [offs+2]);
}
} else {
/* Value not constant (is already in (e)ax) */
- AddCodeLine ("\tjsr\t%s", subs [offs+2]);
+ AddCodeSegLine (CS, "jsr %s", subs [offs+2]);
}
/* The operation will pop it's argument */
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\ttax");
+ AddCodeSegLine (CS, "tax");
break;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tstx\ttmp1");
- AddCodeLine ("\tora\ttmp1");
+ AddCodeSegLine (CS, "stx tmp1");
+ AddCodeSegLine (CS, "ora tmp1");
break;
case CF_LONG:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tutsteax");
+ AddCodeSegLine (CS, "jsr utsteax");
} else {
- AddCodeLine ("\tjsr\ttsteax");
+ AddCodeSegLine (CS, "jsr tsteax");
}
break;
/* Handle as 8 bit value */
if (CodeSizeFactor >= 165 || val > 2) {
ldaconst (val);
- AddCodeLine ("\tjsr\tpusha");
+ AddCodeSegLine (CS, "jsr pusha");
} else {
- AddCodeLine ("\tjsr\tpushc%d", (int) val);
+ AddCodeSegLine (CS, "jsr pushc%d", (int) val);
}
} else {
/* Handle as 16 bit value */
hi = (unsigned char) (val >> 8);
if (val <= 7) {
- AddCodeLine ("\tjsr\tpush%u", (unsigned) val);
+ AddCodeSegLine (CS, "jsr push%u", (unsigned) val);
} else if (hi == 0 || hi == 0xFF) {
/* Use special function */
ldaconst (val);
- AddCodeLine ("\tjsr\t%s", (hi == 0)? "pusha0" : "pushaFF");
+ AddCodeSegLine (CS, "jsr %s", (hi == 0)? "pusha0" : "pushaFF");
} else {
/* Long way ... */
g_getimmed (flags, val, 0);
- AddCodeLine ("\tjsr\tpushax");
+ AddCodeSegLine (CS, "jsr pushax");
}
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
/* Handle as char */
- AddCodeLine ("\tjsr\tpusha");
+ AddCodeSegLine (CS, "jsr pusha");
break;
}
/* FALL THROUGH */
case CF_INT:
- AddCodeLine ("\tjsr\tpushax");
+ AddCodeSegLine (CS, "jsr pushax");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tpusheax");
+ AddCodeSegLine (CS, "jsr pusheax");
break;
default:
case CF_CHAR:
case CF_INT:
- AddCodeLine ("\tjsr\tswapstk");
+ AddCodeSegLine (CS, "jsr swapstk");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tswapestk");
+ AddCodeSegLine (CS, "jsr swapestk");
break;
default:
/* Pass the argument count */
ldyconst (ArgSize);
}
- AddCodeLine ("\tjsr\t_%s", Label);
+ AddCodeSegLine (CS, "jsr _%s", Label);
oursp += ArgSize; /* callee pops args */
}
/* Pass arg count */
ldyconst (ArgSize);
}
- AddCodeLine ("\tjsr\tcallax"); /* do the call */
+ AddCodeSegLine (CS, "jsr callax"); /* do the call */
oursp += ArgSize; /* callee pops args */
}
void g_jump (unsigned Label)
/* Jump to specified internal label number */
{
- AddCodeLine ("\tjmp\tL%04X", Label);
+ AddCodeSegLine (CS, "jmp L%04X", Label);
}
case CF_CHAR:
case CF_INT:
- AddCodeLine ("\tjsr\tswitch");
+ AddCodeSegLine (CS, "jsr switch");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tlswitch");
+ AddCodeSegLine (CS, "jsr lswitch");
break;
default:
case CF_CHAR:
case CF_INT:
- AddCodeLine ("\t.word\t$%04X, L%04X",
+ AddCodeSegLine (CS, ".word $%04X, L%04X",
(unsigned)(val & 0xFFFF),
(unsigned)(label & 0xFFFF));
break;
case CF_LONG:
- AddCodeLine ("\t.dword\t$%08lX", val);
- AddCodeLine ("\t.word\tL%04X", label & 0xFFFF);
+ AddCodeSegLine (CS, ".dword $%08lX", val);
+ AddCodeSegLine (CS, ".word L%04X", label & 0xFFFF);
break;
default:
/* Jump to label if zero flag clear */
{
if (flags & CF_SHORT) {
- AddCodeLine ("\tbne\tL%04X", label);
+ AddCodeSegLine (CS, "bne L%04X", label);
} else {
- AddCodeLine ("\tjne\tL%04X", label);
+ AddCodeSegLine (CS, "jne L%04X", label);
}
}
/* Jump to label if zero flag set */
{
if (flags & CF_SHORT) {
- AddCodeLine ("\tbeq\tL%04X", label);
+ AddCodeSegLine (CS, "beq L%04X", label);
} else {
- AddCodeLine ("\tjeq\tL%04X", label);
+ AddCodeSegLine (CS, "jeq L%04X", label);
}
}
static void mod_internal (int k, char* verb1, char* verb2)
{
if (k <= 8) {
- AddCodeLine ("\tjsr\t%ssp%c", verb1, k + '0');
+ AddCodeSegLine (CS, "jsr %ssp%c", verb1, k + '0');
} else {
CheckLocalOffs (k);
ldyconst (k);
- AddCodeLine ("\tjsr\t%ssp", verb2);
+ AddCodeSegLine (CS, "jsr %ssp", verb2);
}
}
void g_cstackcheck (void)
/* Check for a C stack overflow */
{
- AddCodeLine ("\tjsr\tcstkchk");
+ AddCodeSegLine (CS, "jsr cstkchk");
}
void g_stackcheck (void)
/* Check for a stack overflow */
{
- AddCodeLine ("\tjsr\tstkchk");
+ AddCodeSegLine (CS, "jsr stkchk");
}
switch (val) {
case 3:
- AddCodeLine ("\tsta\ttmp1");
- AddCodeLine ("\tasl\ta");
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\ttmp1");
+ AddCodeSegLine (CS, "sta tmp1");
+ AddCodeSegLine (CS, "asl a");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc tmp1");
return;
case 5:
- AddCodeLine ("\tsta\ttmp1");
- AddCodeLine ("\tasl\ta");
- AddCodeLine ("\tasl\ta");
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\ttmp1");
+ AddCodeSegLine (CS, "sta tmp1");
+ AddCodeSegLine (CS, "asl a");
+ AddCodeSegLine (CS, "asl a");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc tmp1");
return;
case 10:
- AddCodeLine ("\tsta\ttmp1");
- AddCodeLine ("\tasl\ta");
- AddCodeLine ("\tasl\ta");
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\ttmp1");
- AddCodeLine ("\tasl\ta");
+ AddCodeSegLine (CS, "sta tmp1");
+ AddCodeSegLine (CS, "asl a");
+ AddCodeSegLine (CS, "asl a");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc tmp1");
+ AddCodeSegLine (CS, "asl a");
return;
}
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if ((val & 0xFF) != 0xFF) {
- AddCodeLine ("\tora\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "ora #$%02X", (unsigned char)val);
}
return;
}
case CF_INT:
if (val <= 0xFF) {
- AddCodeLine ("\tora\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "ora #$%02X", (unsigned char)val);
return;
}
break;
case CF_LONG:
if (val <= 0xFF) {
- AddCodeLine ("\tora\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "ora #$%02X", (unsigned char)val);
return;
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
if ((val & 0xFF) != 0) {
- AddCodeLine ("\teor\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "eor #$%02X", (unsigned char)val);
}
return;
}
case CF_INT:
if (val <= 0xFF) {
if (val != 0) {
- AddCodeLine ("\teor\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "eor #$%02X", (unsigned char)val);
}
return;
} else if ((val & 0xFF) == 0) {
- AddCodeLine ("\tpha");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\teor\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\ttax");
- AddCodeLine ("\tpla");
+ AddCodeSegLine (CS, "pha");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "eor #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "pla");
return;
}
break;
case CF_LONG:
if (val <= 0xFF) {
if (val != 0) {
- AddCodeLine ("\teor\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "eor #$%02X", (unsigned char)val);
}
return;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
return;
}
/* FALLTHROUGH */
if (val == 0) {
ldaconst (0);
} else if (val != 0xFF) {
- AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
}
} else if ((val & 0xFF00) == 0xFF00) {
- AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
} else if ((val & 0x00FF) == 0x0000) {
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tand\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\ttax");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "and #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "tax");
ldaconst (0);
} else {
- AddCodeLine ("\ttay");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tand\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\ttax");
- AddCodeLine ("\ttya");
+ AddCodeSegLine (CS, "tay");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "and #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "tya");
if ((val & 0x00FF) != 0x00FF) {
- AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
}
}
}
case CF_LONG:
if (val <= 0xFF) {
ldxconst (0);
- AddCodeLine ("\tstx\tsreg+1");
- AddCodeLine ("\tstx\tsreg");
+ AddCodeSegLine (CS, "stx sreg+1");
+ AddCodeSegLine (CS, "stx sreg");
if ((val & 0xFF) != 0xFF) {
- AddCodeLine ("\tand\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "and #$%02X", (unsigned char)val);
}
return;
} else if (val == 0xFF00) {
ldaconst (0);
- AddCodeLine ("\tsta\tsreg+1");
- AddCodeLine ("\tsta\tsreg");
+ AddCodeSegLine (CS, "sta sreg+1");
+ AddCodeSegLine (CS, "sta sreg");
return;
}
break;
case CF_INT:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tshrax%ld", val);
+ AddCodeSegLine (CS, "jsr shrax%ld", val);
} else {
- AddCodeLine ("\tjsr\tasrax%ld", val);
+ AddCodeSegLine (CS, "jsr asrax%ld", val);
}
return;
} else if (val == 8 && (flags & CF_UNSIGNED)) {
- AddCodeLine ("\ttxa");
+ AddCodeSegLine (CS, "txa");
ldxconst (0);
return;
}
case CF_LONG:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tshreax%ld", val);
+ AddCodeSegLine (CS, "jsr shreax%ld", val);
} else {
- AddCodeLine ("\tjsr\tasreax%ld", val);
+ AddCodeSegLine (CS, "jsr asreax%ld", val);
}
return;
} else if (val == 8 && (flags & CF_UNSIGNED)) {
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tldx\tsreg");
- AddCodeLine ("\tldy\tsreg+1");
- AddCodeLine ("\tsty\tsreg");
- AddCodeLine ("\tldy\t#$00");
- AddCodeLine ("\tsty\tsreg+1");
+ 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");
return;
} else if (val == 16) {
- AddCodeLine ("\tldy\t#$00");
- AddCodeLine ("\tldx\tsreg+1");
+ AddCodeSegLine (CS, "ldy #$00");
+ AddCodeSegLine (CS, "ldx sreg+1");
if ((flags & CF_UNSIGNED) == 0) {
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdey");
+ AddCodeSegLine (CS, "bpl *+3");
+ AddCodeSegLine (CS, "dey");
AddCodeHint ("y:!");
}
- AddCodeLine ("\tlda\tsreg");
- AddCodeLine ("\tsty\tsreg+1");
- AddCodeLine ("\tsty\tsreg");
+ AddCodeSegLine (CS, "lda sreg");
+ AddCodeSegLine (CS, "sty sreg+1");
+ AddCodeSegLine (CS, "sty sreg");
return;
}
break;
case CF_INT:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tshlax%ld", val);
+ AddCodeSegLine (CS, "jsr shlax%ld", val);
} else {
- AddCodeLine ("\tjsr\taslax%ld", val);
+ AddCodeSegLine (CS, "jsr aslax%ld", val);
}
return;
} else if (val == 8) {
- AddCodeLine ("\ttax");
- AddCodeLine ("\tlda\t#$00");
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "lda #$00");
return;
}
break;
case CF_LONG:
if (val >= 1 && val <= 3) {
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tshleax%ld", val);
+ AddCodeSegLine (CS, "jsr shleax%ld", val);
} else {
- AddCodeLine ("\tjsr\tasleax%ld", val);
+ AddCodeSegLine (CS, "jsr asleax%ld", val);
}
return;
} else if (val == 8) {
- AddCodeLine ("\tldy\tsreg");
- AddCodeLine ("\tsty\tsreg+1");
- AddCodeLine ("\tstx\tsreg");
- AddCodeLine ("\ttax");
- AddCodeLine ("\tlda\t#$00");
+ AddCodeSegLine (CS, "ldy sreg");
+ AddCodeSegLine (CS, "sty sreg+1");
+ AddCodeSegLine (CS, "stx sreg");
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "lda #$00");
return;
} else if (val == 16) {
- AddCodeLine ("\tstx\tsreg+1");
- AddCodeLine ("\tsta\tsreg");
- AddCodeLine ("\tlda\t#$00");
- AddCodeLine ("\ttax");
+ AddCodeSegLine (CS, "stx sreg+1");
+ AddCodeSegLine (CS, "sta sreg");
+ AddCodeSegLine (CS, "lda #$00");
+ AddCodeSegLine (CS, "tax");
return;
}
break;
case CF_CHAR:
case CF_INT:
- AddCodeLine ("\tjsr\tnegax");
+ AddCodeSegLine (CS, "jsr negax");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tnegeax");
+ AddCodeSegLine (CS, "jsr negeax");
break;
default:
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeLine ("\tjsr\tbnega");
+ AddCodeSegLine (CS, "jsr bnega");
break;
case CF_INT:
- AddCodeLine ("\tjsr\tbnegax");
+ AddCodeSegLine (CS, "jsr bnegax");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tbnegeax");
+ AddCodeSegLine (CS, "jsr bnegeax");
break;
default:
case CF_CHAR:
case CF_INT:
- AddCodeLine ("\tjsr\tcomplax");
+ AddCodeSegLine (CS, "jsr complax");
break;
case CF_LONG:
- AddCodeLine ("\tjsr\tcompleax");
+ AddCodeSegLine (CS, "jsr compleax");
break;
default:
if (flags & CF_FORCECHAR) {
if (CPU == CPU_65C02 && val <= 2) {
while (val--) {
- AddCodeLine ("\tina");
+ AddCodeSegLine (CS, "ina");
}
} else {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc #$%02X", (unsigned char)val);
}
break;
}
case CF_INT:
if (CPU == CPU_65C02 && val == 1) {
- AddCodeLine ("\tina");
- AddCodeLine ("\tbne\t*+3");
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "ina");
+ AddCodeSegLine (CS, "bne *+3");
+ AddCodeSegLine (CS, "inx");
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
} else if (CodeSizeFactor < 200) {
/* Use jsr calls */
if (val <= 8) {
- AddCodeLine ("\tjsr\tincax%lu", val);
+ AddCodeSegLine (CS, "jsr incax%lu", val);
} else if (val <= 255) {
ldyconst (val);
- AddCodeLine ("\tjsr\tincaxy");
+ AddCodeSegLine (CS, "jsr incaxy");
} else {
g_add (flags | CF_CONST, val);
}
/* Inline the code */
if (val < 0x300) {
if ((val & 0xFF) != 0) {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t#$%02X", (unsigned char) val);
- AddCodeLine ("\tbcc\t*+3");
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "clc");
+ AddCodeSegLine (CS, "adc #$%02X", (unsigned char) val);
+ AddCodeSegLine (CS, "bcc *+3");
+ AddCodeSegLine (CS, "inx");
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
if (val >= 0x100) {
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "inx");
}
if (val >= 0x200) {
- AddCodeLine ("\tinx");
+ AddCodeSegLine (CS, "inx");
}
} else {
- AddCodeLine ("\tclc");
+ AddCodeSegLine (CS, "clc");
if ((val & 0xFF) != 0) {
- AddCodeLine ("\tadc\t#$%02X", (unsigned char) val);
+ AddCodeSegLine (CS, "adc #$%02X", (unsigned char) val);
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
- AddCodeLine ("\tpha");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tadc\t#$%02X", (unsigned char) (val >> 8));
- AddCodeLine ("\ttax");
- AddCodeLine ("\tpla");
+ AddCodeSegLine (CS, "pha");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "adc #$%02X", (unsigned char) (val >> 8));
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "pla");
}
}
break;
case CF_LONG:
if (val <= 255) {
ldyconst (val);
- AddCodeLine ("\tjsr\tinceaxy");
+ AddCodeSegLine (CS, "jsr inceaxy");
} else {
g_add (flags | CF_CONST, val);
}
if (flags & CF_FORCECHAR) {
if (CPU == CPU_65C02 && val <= 2) {
while (val--) {
- AddCodeLine ("\tdea");
+ AddCodeSegLine (CS, "dea");
}
} else {
- AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "sec");
+ AddCodeSegLine (CS, "sbc #$%02X", (unsigned char)val);
}
break;
}
if (CodeSizeFactor < 200) {
/* Use subroutines */
if (val <= 8) {
- AddCodeLine ("\tjsr\tdecax%d", (int) val);
+ AddCodeSegLine (CS, "jsr decax%d", (int) val);
} else if (val <= 255) {
ldyconst (val);
- AddCodeLine ("\tjsr\tdecaxy");
+ AddCodeSegLine (CS, "jsr decaxy");
} else {
g_sub (flags | CF_CONST, val);
}
/* Inline the code */
if (val < 0x300) {
if ((val & 0xFF) != 0) {
- AddCodeLine ("\tsec");
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char) val);
- AddCodeLine ("\tbcs\t*+3");
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "sec");
+ AddCodeSegLine (CS, "sbc #$%02X", (unsigned char) val);
+ AddCodeSegLine (CS, "bcs *+3");
+ AddCodeSegLine (CS, "dex");
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
if (val >= 0x100) {
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "dex");
}
if (val >= 0x200) {
- AddCodeLine ("\tdex");
+ AddCodeSegLine (CS, "dex");
}
} else {
- AddCodeLine ("\tsec");
+ AddCodeSegLine (CS, "sec");
if ((val & 0xFF) != 0) {
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char) val);
+ AddCodeSegLine (CS, "sbc #$%02X", (unsigned char) val);
/* Tell the optimizer that the X register may be invalid */
AddCodeHint ("x:!");
}
- AddCodeLine ("\tpha");
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tsbc\t#$%02X", (unsigned char) (val >> 8));
- AddCodeLine ("\ttax");
- AddCodeLine ("\tpla");
+ AddCodeSegLine (CS, "pha");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "sbc #$%02X", (unsigned char) (val >> 8));
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "pla");
}
}
break;
case CF_LONG:
if (val <= 255) {
ldyconst (val);
- AddCodeLine ("\tjsr\tdeceaxy");
+ AddCodeSegLine (CS, "jsr deceaxy");
} else {
g_sub (flags | CF_CONST, val);
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tbooleq");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr booleq");
return;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tbooleq");
+ AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "bne *+4");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr booleq");
return;
case CF_LONG:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tboolne");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr boolne");
return;
}
/* FALLTHROUGH */
case CF_INT:
- AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tboolne");
+ AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "bne *+4");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr boolne");
return;
case CF_LONG:
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tboolult");
+ AddCodeSegLine (CS, "jsr boolult");
} else {
- AddCodeLine ("\tjsr\tboollt");
+ AddCodeSegLine (CS, "jsr boollt");
}
return;
}
/* If we have a signed compare against zero, we only need to
* test the high byte.
*/
- AddCodeLine ("\ttxa");
- AddCodeLine ("\tjsr\tboollt");
+ AddCodeSegLine (CS, "txa");
+ AddCodeSegLine (CS, "jsr boollt");
return;
}
/* Direct code only for unsigned data types */
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tboolult");
+ AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "bne *+4");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr boolult");
return;
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tboolule");
+ AddCodeSegLine (CS, "jsr boolule");
} else {
- AddCodeLine ("\tjsr\tboolle");
+ AddCodeSegLine (CS, "jsr boolle");
}
return;
}
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tboolule");
+ AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "bne *+4");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr boolule");
return;
}
break;
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "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) {
- AddCodeLine ("\tjsr\tboolugt");
+ AddCodeSegLine (CS, "jsr boolugt");
} else {
- AddCodeLine ("\tjsr\tboolne");
+ AddCodeSegLine (CS, "jsr boolne");
}
} else {
- AddCodeLine ("\tjsr\tboolgt");
+ AddCodeSegLine (CS, "jsr boolgt");
}
return;
}
* is easier to optimize.
*/
if ((val & 0xFFFF) == 0) {
- AddCodeLine ("\tstx\ttmp1");
- AddCodeLine ("\tora\ttmp1");
- AddCodeLine ("\tjsr\tboolne");
+ AddCodeSegLine (CS, "stx tmp1");
+ AddCodeSegLine (CS, "ora tmp1");
+ AddCodeSegLine (CS, "jsr boolne");
} else {
- AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tboolugt");
+ AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "bne *+4");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr boolugt");
}
return;
}
case CF_CHAR:
if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tjsr\tbooluge");
+ AddCodeSegLine (CS, "jsr booluge");
} else {
- AddCodeLine ("\tjsr\tboolge");
+ AddCodeSegLine (CS, "jsr boolge");
}
return;
}
case CF_INT:
if (flags & CF_UNSIGNED) {
- AddCodeLine ("\tcpx\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tbne\t*+4");
- AddCodeLine ("\tcmp\t#$%02X", (unsigned char)val);
- AddCodeLine ("\tjsr\tbooluge");
+ AddCodeSegLine (CS, "cpx #$%02X", (unsigned char)(val >> 8));
+ AddCodeSegLine (CS, "bne *+4");
+ AddCodeSegLine (CS, "cmp #$%02X", (unsigned char)val);
+ AddCodeSegLine (CS, "jsr booluge");
return;
}
break;
void g_res (unsigned n)
/* Reserve static storage, n bytes */
{
- AddCodeLine ("\t.res\t%u,$00", n);
+ AddDataSegLine (DS, "\t.res\t%u,$00", n);
}
switch (flags & CF_TYPE) {
case CF_CHAR:
- AddCodeLine ("\t.byte\t$%02lX", val & 0xFF);
+ AddDataSegLine (DS, "\t.byte\t$%02lX", val & 0xFF);
break;
case CF_INT:
- AddCodeLine ("\t.word\t$%04lX", val & 0xFFFF);
+ AddDataSegLine (DS, "\t.word\t$%04lX", val & 0xFFFF);
break;
case CF_LONG:
- AddCodeLine ("\t.dword\t$%08lX", val & 0xFFFFFFFF);
+ AddDataSegLine (DS, "\t.dword\t$%08lX", val & 0xFFFFFFFF);
break;
default:
const char* Label = GetLabelName (flags, val, offs);
/* Labels are always 16 bit */
- AddCodeLine ("\t.word\t%s", Label);
+ AddDataSegLine (DS, "\t.word\t%s", Label);
}
}
void g_zerobytes (unsigned n)
/* Output n bytes of data initialized with zero */
{
- AddCodeLine ("\t.res\t%u,$00", n);
-}
+ AddDataSegLine (DS, "\t.res\t%u,$00", n);
+}
char* lbuf = GetLabelName (flags, val, offs);
/* Generate the strlen code */
- AddCodeLine ("\tldy\t#$FF");
+ AddCodeSegLine (CS, "ldy #$FF");
g_defloclabel (label);
- AddCodeLine ("\tiny");
- AddCodeLine ("\tlda\t%s,y", lbuf);
- AddCodeLine ("\tbne\tL%04X", label);
- AddCodeLine ("\ttax");
- AddCodeLine ("\ttya");
+ AddCodeSegLine (CS, "iny");
+ AddCodeSegLine (CS, "lda %s,y", lbuf);
+ AddCodeSegLine (CS, "bne L%04X", label);
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "tya");
} else {
/* Address not constant but in primary */
if (CodeSizeFactor < 400) {
/* This is too much code, so call strlen instead of inlining */
- AddCodeLine ("\tjsr\t_strlen");
+ AddCodeSegLine (CS, "jsr _strlen");
} else {
/* Inline the function */
- AddCodeLine ("\tsta\tptr1");
- AddCodeLine ("\tstx\tptr1+1");
- AddCodeLine ("\tldy\t#$FF");
+ AddCodeSegLine (CS, "sta ptr1");
+ AddCodeSegLine (CS, "stx ptr1+1");
+ AddCodeSegLine (CS, "ldy #$FF");
g_defloclabel (label);
- AddCodeLine ("\tiny");
- AddCodeLine ("\tlda\t(ptr1),y");
- AddCodeLine ("\tbne\tL%04X", label);
- AddCodeLine ("\ttax");
- AddCodeLine ("\ttya");
+ AddCodeSegLine (CS, "iny");
+ AddCodeSegLine (CS, "lda (ptr1),y");
+ AddCodeSegLine (CS, "bne L%04X", label);
+ AddCodeSegLine (CS, "tax");
+ AddCodeSegLine (CS, "tya");
}
}
}