+//
+// .org - Set origin
+//
+int d_org(void)
+{
+ VALUE address;
+
+ if (!rgpu && !rdsp && !m6502)
+ return error(".org permitted only in gpu/dsp and 6502 sections");
+
+ if (rgpu | rdsp)
+ {
+ orgaddr = 0;
+
+ if (abs_expr(&address) == ERROR)
+ {
+ error("cannot determine org'd address");
+ return ERROR;
+ }
+
+ orgaddr = address;
+ orgactive = 1;
+ //printf("ORG: address = $%08X...\n", orgaddr);
+
+ return 0;
+ }
+ else
+ {
+ // 6502
+ // We also kludge `lsloc' so the listing generator doesn't
+ // try to spew out megabytes.
+ VALUE eval;
+
+ //if (m6502 == 0) return error(".org permitted only in .6502 section");
+ if (abs_expr(&eval) < 0) return 0;
+ if (eval >= 0x10000L) return error(range_error);
+
+ if (sloc != currentorg[0])
+ {
+ currentorg[1] = sloc;
+ currentorg += 2;
+ }
+
+ currentorg[0] = eval;
+ ch_size = 0;
+ lsloc = sloc = eval;
+ chptr = scode->chptr + eval;
+ orgactive = 1;
+ orgaddr = eval;
+ at_eol();
+ return 0;
+ }