+ currentorg[0] = address;
+ ch_size = 0;
+ lsloc = sloc = address;
+ chptr = scode->chptr + address;
+ orgaddr = address;
+ orgactive = 1;
+ }
+ else if (dsp56001)
+ {
+ // Only mark segments we actually wrote something
+ if (chptr != dsp_currentorg->start && dsp_written_data_in_current_org)
+ {
+ dsp_currentorg->end = chptr;
+ dsp_currentorg++;
+ }
+
+ // Maybe we switched from a non-DSP section (TEXT, DATA, etc) and
+ // scode isn't initialised yet. Not that it's going to be a valid
+ // scenario, but if we try it anyhow it's going to lead to a crash. So
+ // let's fudge a value of 0 and get on with it.
+ orgaddr = (scode != NULL ? sloc : 0);
+ SaveSection();
+
+ if (tok[1] != ':')
+ return error(syntax_error);
+
+ int sectionToSwitch = 0;
+
+ switch (tok[0])
+ {
+ case REG56_X:
+ dsp_currentorg->memtype = ORG_X;
+ sectionToSwitch = M56001X;
+ break;
+
+ case REG56_Y:
+ dsp_currentorg->memtype = ORG_Y;
+ sectionToSwitch = M56001Y;
+ break;
+
+ case REG56_P:
+ dsp_currentorg->memtype = ORG_P;
+ sectionToSwitch = M56001P;
+ break;
+
+ case REG56_L:
+ dsp_currentorg->memtype = ORG_L;
+ sectionToSwitch = M56001L;
+ break;
+
+ default:
+ return error("unknown type in ORG");
+ }
+
+ if ((obj_format == LOD) || (obj_format == P56))
+ SwitchSection(sectionToSwitch);
+
+ tok += 2;
+ chcheck(3); // Ensure we got a valid address to write
+ dsp_currentorg->chunk = scode; // Mark down which chunk this org starts from (will be needed when outputting)
+
+ if (*tok == EOL)
+ {
+ // Well, the user didn't specify an address at all so we'll have to
+ // use the last used address of that section (or 0 if there wasn't one)
+ address = orgaddr;
+ dsp_currentorg->start = chptr;
+ dsp_currentorg->orgadr = orgaddr;
+ }
+ else
+ {
+ if (abs_expr(&address) == ERROR)
+ {
+ error("cannot determine org'd address");
+ return ERROR;
+ }
+
+ dsp_currentorg->start = chptr;
+ dsp_currentorg->orgadr = (uint32_t)address;
+ sect[cursect].orgaddr = (uint32_t)address;
+ }
+
+ if (address > DSP_MAX_RAM)
+ {
+ return error(range_error);
+ }
+
+ dsp_written_data_in_current_org = 0;
+
+ // Copied from 6502 above: kludge `lsloc' so the listing generator
+ // doesn't try to spew out megabytes.
+ lsloc = sloc = (int32_t)address;
+// N.B.: It seems that by enabling this, even though it works elsewhere, will cause symbols to royally fuck up. Will have to do some digging to figure out why.
+// orgactive = 1;
+ }
+ else
+ {
+ // If we get here we assume it's 68k with RAW output, so this is allowed
+ if (orgactive)
+ {
+ return error("In 68k mode only one .org statement is allowed");
+ }
+
+ org68k_address = address;
+ org68k_active = 1;
+ }
+
+ ErrorIfNotAtEOL();