+// Lists of registers may also be mentioned; they just take up space. Good for
+// "documentation" purposes:
+//
+// .cargs a6, .arg1, .arg2, .arg3...
+//
+// Symbols thus created are ABS and EQUATED.
+//
+int d_cargs(void)
+{
+ VALUE eval = 4; // Default to 4 if no offset specified (to account for
+ // return address)
+ WORD rlist;
+ SYM * symbol;
+ char * p;
+ int env;
+ int i;
+
+ if (rgpu || rdsp)
+ return error("directive forbidden in gpu/dsp mode");
+
+ if (*tok == '#')
+ {
+ tok++;
+
+ if (abs_expr(&eval) != OK)
+ return 0;
+
+ // Eat the comma, if it's there
+ if (*tok == ',')
+ tok++;
+ }
+
+ for(;;)
+ {
+ if (*tok == SYMBOL)
+ {
+// p = (char *)tok[1];
+ p = string[tok[1]];
+
+#if 0
+ if (*p == '.')
+ env = curenv; // Label is local
+ else
+ env = 0; // Label is global
+#else
+ // Set env to either local (dot prefixed) or global scope
+ env = (*p == '.' ? curenv : 0);
+#endif
+ symbol = lookup(p, LABEL, env);
+
+ if (symbol == NULL)
+ {
+ symbol = NewSymbol(p, LABEL, env);
+ symbol->sattr = 0;
+ }
+ else if (symbol->sattr & DEFINED)
+ return errors("multiply-defined label '%s'", p);
+
+ // Put symbol in "order of definition" list
+ if (!(symbol->sattr & SDECLLIST))
+ sym_decl(symbol);
+
+ symbol->sattr |= (ABS | DEFINED | EQUATED);
+ symbol->svalue = eval;
+ tok += 2;
+
+ // What this does is eat any dot suffixes attached to a symbol. If
+ // it's a .L, it adds 4 to eval; if it's .W or .B, it adds 2. If
+ // there is no dot suffix, it assumes a size of 2.
+ switch ((int)*tok)
+ {
+ case DOTL:
+ eval += 2;
+ case DOTB:
+ case DOTW:
+ tok++;
+ }
+
+ eval += 2;
+ }
+ else if (*tok >= KW_D0 && *tok <= KW_A7)
+ {
+ if (reglist(&rlist) < 0)
+ return 0;
+
+// for(i=0; i++<16; rlist>>=1)
+ for(i=0; i<16; i++, rlist>>=1)
+ {
+ if (rlist & 1)
+ eval += 4;
+ }
+ }
+ else
+ {
+ switch ((int)*tok)
+ {
+ case KW_USP:
+ case KW_SSP:
+ case KW_PC:
+ eval += 2;
+ // FALLTHROUGH
+ case KW_SR:
+ case KW_CCR:
+ eval += 2;
+ tok++;
+ break;
+ case EOL:
+ return 0;
+ default:
+ return error(".cargs syntax");
+ }
+ }
+
+ // Eat commas in between each argument, if they exist
+ if (*tok == ',')
+ tok++;
+ }
+}
+
+
+//
+// .cstruct [#offset], symbol[.size], ...
+//
+// Lists of registers may also be mentioned; they just take up space. Good for
+// "documentation" purposes: