- case CF_CHAR:
- if (flags & CF_FORCECHAR) {
- AddCodeLine ("\tldx\t#$00");
- if (flags & CF_CONST) {
- if (val == 1) {
- AddCodeLine ("\tinc\t%s", lbuf);
- AddCodeLine ("\tlda\t%s", lbuf);
- } else {
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tsta\t%s", lbuf);
- }
- } else {
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tsta\t%s", lbuf);
- }
- if ((flags & CF_UNSIGNED) == 0) {
- AddCodeLine ("\tbpl\t*+3");
- AddCodeLine ("\tdex");
- AddCodeHint ("x:!"); /* Invalidate X */
- }
- break;
- }
- /* FALLTHROUGH */
-
- case CF_INT:
- 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);
- g_defloclabel (label);
- AddCodeLine ("\tlda\t%s", lbuf); /* Hmmm... */
- AddCodeLine ("\tldx\t%s+1", lbuf);
- } else {
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tclc");
- AddCodeLine ("\tadc\t%s", lbuf);
- AddCodeLine ("\tsta\t%s", lbuf);
- if (val < 0x100) {
- label = GetLocalLabel ();
- AddCodeLine ("\tbcc\tL%04X", (int)label);
- AddCodeLine ("\tinc\t%s+1", lbuf);
- g_defloclabel (label);
- AddCodeLine ("\tldx\t%s+1", lbuf);
- } else {
- AddCodeLine ("\tlda\t#$%02X", (unsigned char)(val >> 8));
- AddCodeLine ("\tadc\t%s+1", lbuf);
- AddCodeLine ("\tsta\t%s+1", lbuf);
- AddCodeLine ("\ttax");
- AddCodeLine ("\tlda\t%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);
- }
- 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);
- if (val == 1) {
- AddCodeLine ("\tjsr\tladdeq1");
- } else {
- AddCodeLine ("\tlda\t#$%02X", (int)(val & 0xFF));
- AddCodeLine ("\tjsr\tladdeqa");
- }
- } else {
- g_getstatic (flags, label, offs);
- g_inc (flags, val);
- g_putstatic (flags, label, offs);
- }
- } else {
- AddCodeLine ("\tldy\t#<(%s)", lbuf);
- AddCodeLine ("\tsty\tptr1");
- AddCodeLine ("\tldy\t#>(%s+1)", lbuf);
- AddCodeLine ("\tjsr\tladdeq");
- }
- break;
-
- default:
- typeerror (flags);
+ case CF_CHAR:
+ if (flags & CF_FORCECHAR) {
+ AddCodeLine ("ldx #$00");
+ if (flags & CF_CONST) {
+ if (val == 1) {
+ AddCodeLine ("inc %s", lbuf);
+ AddCodeLine ("lda %s", lbuf);
+ } else {
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
+ }
+ } else {
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
+ }
+ if ((flags & CF_UNSIGNED) == 0) {
+ unsigned L = GetLocalLabel();
+ AddCodeLine ("bpl %s", LocalLabelName (L));
+ AddCodeLine ("dex");
+ g_defcodelabel (L);
+ }
+ break;
+ }
+ /* FALLTHROUGH */
+
+ case CF_INT:
+ if (flags & CF_CONST) {
+ if (val == 1) {
+ unsigned L = GetLocalLabel ();
+ AddCodeLine ("inc %s", lbuf);
+ AddCodeLine ("bne %s", LocalLabelName (L));
+ AddCodeLine ("inc %s+1", lbuf);
+ g_defcodelabel (L);
+ AddCodeLine ("lda %s", lbuf); /* Hmmm... */
+ AddCodeLine ("ldx %s+1", lbuf);
+ } else {
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("clc");
+ AddCodeLine ("adc %s", lbuf);
+ AddCodeLine ("sta %s", lbuf);
+ if (val < 0x100) {
+ unsigned L = GetLocalLabel ();
+ AddCodeLine ("bcc %s", LocalLabelName (L));
+ AddCodeLine ("inc %s+1", lbuf);
+ g_defcodelabel (L);
+ AddCodeLine ("ldx %s+1", lbuf);
+ } else {
+ AddCodeLine ("lda #$%02X", (unsigned char)(val >> 8));
+ AddCodeLine ("adc %s+1", lbuf);
+ AddCodeLine ("sta %s+1", lbuf);
+ AddCodeLine ("tax");
+ AddCodeLine ("lda %s", lbuf);
+ }
+ }
+ } else {
+ 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) {
+ AddCodeLine ("ldy #<(%s)", lbuf);
+ AddCodeLine ("sty ptr1");
+ AddCodeLine ("ldy #>(%s)", lbuf);
+ if (val == 1) {
+ AddCodeLine ("jsr laddeq1");
+ } else {
+ AddCodeLine ("lda #$%02X", (int)(val & 0xFF));
+ AddCodeLine ("jsr laddeqa");
+ }
+ } else {
+ g_getstatic (flags, label, offs);
+ g_inc (flags, val);
+ g_putstatic (flags, label, offs);
+ }
+ } else {
+ AddCodeLine ("ldy #<(%s)", lbuf);
+ AddCodeLine ("sty ptr1");
+ AddCodeLine ("ldy #>(%s)", lbuf);
+ AddCodeLine ("jsr laddeq");
+ }
+ break;
+
+ default:
+ typeerror (flags);