//
#include "debug.h"
+#include "6502.h"
#include "amode.h"
#include "direct.h"
#include "expr.h"
start[i+2] & 0xFF, start[i+3] & 0xFF);
i += 4;
break;
- case 3:
- break;
}
if (base != -1)
//
int dump_everything(void)
{
+ // FFS
+ if ((currentorg[1] - currentorg[0]) == 0)
+ sect[M6502].sfcode = NULL;
+
for(int i=1; i<NSECTS; i++)
{
if (sect[i].scattr & SUSED)
just_bss = 1; // No data deposited (8-bit CPU mode)
}
+ else if (cursect == M56001P || cursect == M56001X || cursect == M56001Y || cursect == M56001L)
+ {
+ // Change segment instead of marking blanks.
+ // Only mark segments we actually wrote something
+ if (chptr != dsp_currentorg->start && dsp_written_data_in_current_org)
+ {
+ dsp_currentorg->end = chptr;
+ dsp_currentorg++;
+ dsp_currentorg->memtype = dsp_currentorg[-1].memtype;
+ }
+
+ listvalue((uint32_t)eval);
+ sloc += (uint32_t)eval;
+
+ // And now let's create a new segment
+ dsp_currentorg->start = chptr;
+ dsp_currentorg->chunk = scode; // Mark down which chunk this org starts from (will be needed when outputting)
+ sect[cursect].orgaddr = sloc;
+ dsp_currentorg->orgadr = sloc;
+ dsp_written_data_in_current_org = 0;
+
+ just_bss = 1; // No data deposited
+ }
else
{
- dep_block(eval, siz, 0, (WORD)(DEFINED | ABS), NULL);
+ dep_block(eval, siz, 0, (DEFINED | ABS), NULL);
}
ErrorIfNotAtEOL();
//
int dep_block(uint32_t count, WORD siz, uint32_t eval, WORD eattr, TOKEN * exprbuf)
{
- WORD tdb;
- WORD defined;
-
- tdb = (WORD)(eattr & TDB);
- defined = (WORD)(eattr & DEFINED);
+ WORD tdb = eattr & TDB;
+ WORD defined = eattr & DEFINED;
while (count--)
{
char fnbuf[FNSIZ]; // Filename buffer
int i; // Iterator
- errcnt = 0; // Initialise error count
- listing = 0; // Initialise listing level
- list_flag = 0; // Initialise listing flag
- verb_flag = perm_verb_flag; // Initialise verbose flag
- as68_flag = 0; // Initialise as68 kludge mode
- glob_flag = 0; // Initialise .globl flag
- sbra_flag = 0; // Initialise short branch flag
- debug = 0; // Initialise debug flag
- searchpath = NULL; // Initialise search path
- objfname = NULL; // Initialise object filename
- list_fname = NULL; // Initialise listing filename
- err_fname = NULL; // Initialise error filename
- obj_format = BSD; // Initialise object format
- firstfname = NULL; // Initialise first filename
- err_fd = ERROUT; // Initialise error file descriptor
- err_flag = 0; // Initialise error flag
- rgpu = 0; // Initialise GPU assembly flag
- rdsp = 0; // Initialise DSP assembly flag
- robjproc = 0; // Initialise OP assembly flag
+ errcnt = 0; // Initialize error count
+ listing = 0; // Initialize listing level
+ list_flag = 0; // Initialize listing flag
+ verb_flag = perm_verb_flag; // Initialize verbose flag
+ as68_flag = 0; // Initialize as68 kludge mode
+ glob_flag = 0; // Initialize .globl flag
+ sbra_flag = 0; // Initialize short branch flag
+ debug = 0; // Initialize debug flag
+ searchpath = NULL; // Initialize search path
+ objfname = NULL; // Initialize object filename
+ list_fname = NULL; // Initialize listing filename
+ err_fname = NULL; // Initialize error filename
+ obj_format = BSD; // Initialize object format
+ firstfname = NULL; // Initialize first filename
+ err_fd = ERROUT; // Initialize error file descriptor
+ err_flag = 0; // Initialize error flag
+ rgpu = 0; // Initialize GPU assembly flag
+ rdsp = 0; // Initialize DSP assembly flag
+ robjproc = 0; // Initialize OP assembly flag
lsym_flag = 1; // Include local symbols in object file
regbank = BANK_N; // No RISC register bank specified
orgactive = 0; // Not in RISC org section
orgwarning = 0; // No ORG warning issued
- segpadsize = 2; // Initialise segment padding size
+ segpadsize = 2; // Initialize segment padding size
+ dsp_orgmap[0].start = 0; // Initialize 56001 org initial address
+ dsp_orgmap[0].memtype = ORG_P; // Initialize 56001 org start segment
m6502 = 0; // 6502 mode off by default
- // Initialise modules
+ // Initialize modules
InitSymbolTable(); // Symbol table
InitTokenizer(); // Tokenizer
InitLineProcessor(); // Line processor
sp->sloc = sloc;
sp->orgaddr = orgaddr;
- if (scode != NULL) // Bailout code chunk
+ if (scode != NULL) // Bailout code chunk (if any)
scode->ch_size = ch_size;
}
DEBUG { printf(" amt (adjusted)=%u\n", amt); }
SECT * p = §[cursect];
CHUNK * cp = malloc(sizeof(CHUNK) + amt);
+ int first = 0;
- // First chunk in section
if (scode == NULL)
{
+ // First chunk in section
cp->chprev = NULL;
p->sfcode = cp;
+ first = 1;
}
- // Add chunk to other chunks
else
{
+ // Add second and on to previous chunk
cp->chprev = scode;
scode->chnext = cp;
scode->ch_size = ch_size; // Save old chunk's globals
}
// Setup chunk and global vars
- cp->chloc = sloc;
+/*
+So, whenever there's an ORG in a 56K section, it sets sloc TO THE ADDRESS IN THE ORG. Also, the loc/sloc are incremented by 1s, which means to alias correctly to the byte-oriented memory model we have here, we have to fix that kind of crap.
+*/
+ cp->chloc = sloc; // <-- HERE'S THE PROBLEM FOR 56K :-/
cp->chnext = NULL;
challoc = cp->challoc = amt;
ch_size = cp->ch_size = 0;
chptr = cp->chptr = ((uint8_t *)cp) + sizeof(CHUNK);
scode = p->scode = cp;
+ // A quick kludge
+/*
+OK, so this is a bit shite, but at least it gets things working the way they should. The right way to do this is not rely on sloc & friends for the right fixup address but to have an accurate model of the thing. That will probably come with v2.0.1 :-P
+
+So the problem is, d_org sets sloc to the address of the ORG statement, and that gives an incorrect base for the fixup. And so when a second (or later) chunk is allocated, it gets set wrong. Further complicating things is that the orgaddress *does not* get used in a typical way with the DSP56001 code, and, as such, causes incorrect addresses to be generated. All that has to be dealt with in order to get this right and do away with this kludge.
+*/
+ if (((cursect == M56001P) || (cursect == M56001X) || (cursect == M56001Y)) && !first)
+ cp->chloc = cp->chprev->chloc + cp->chprev->ch_size;
+
return;
}
{
attr |= FU_56001;
// Save the exact spot in this chunk where the fixup should go
- _orgaddr = chptr - scode->chptr;
+ _orgaddr = chptr - scode->chptr + scode->chloc;
}
// Allocate space for the fixup + any expression
// Complex expression
if (dw & FU_EXPR)
{
+ // evexpr presumably issues the errors/warnings here
if (evexpr(fup->expr, &eval, &eattr, &esym) != OK)
continue;
}
// If the symbol is not defined, but global, set esym to sy
if ((eattr & (GLOBAL | DEFINED)) == GLOBAL)
esym = sy;
+
+ DEBUG { printf(" name: %s, value: $%" PRIX64 "\n", sy->sname, sy->svalue); }
}
uint16_t tdb = eattr & TDB;