-/*****************************************************************************/
-/* Special op= functions */
-/*****************************************************************************/
-
-
-
-void g_addeqstatic (unsigned flags, unsigned long label, unsigned offs,
- unsigned long val)
-/* Emit += for a static variable */
-{
- /* Create the correct label name */
- char* lbuf = GetLabelName (flags, label, offs);
-
- /* Check the size and determine operation */
- switch (flags & CF_TYPE) {
-
- 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);
- }
-}
-
-
-
-void g_addeqlocal (unsigned flags, int offs, unsigned long val)