/* This is a cheap hack. The xa51 has a couple of ways to scramble
relocation info into it's opcode that the standard linker can't
- handle. No hash or qsort yet.
+ handle, not to mention word allignment.
+
+ No hash or qsort yet.
The relocatable format looks like the known one, BUT ISN'T.
GSINIT=1,
CSEG,
XINIT,
- GSFINAL, // here goes the final output
+
+ // here goes the final output and should be used by the assembler
+ GSFINAL,
// these are only for storage
BSEG,
DSEG,
XSEG,
XISEG,
+
+ // that's all
MAX_SEGMENTS
};
}
currentLine++;
}
- // that's all for now, thanks for watching */
fclose (relModule);
}
int rel8 = symbol->address-(reference->pc & ~1);
if (rel8<-256 || rel8>256) {
fprintf (stderr,
- "rel8 target for %s is out of range in module %s\n",
- reference->name, reference->module->name);
+ "rel8 target for %s is out of range in module %s:%d\n",
+ reference->name, reference->module->name,
+ reference->lineno);
fatalErrors++;
}
gsfinalImage[reference->address]=rel8/2;
int rel16 = symbol->address-(reference->pc & ~1);
if (rel16<-65536 || rel16>65534) {
fprintf (stderr,
- "rel16 target for %s is out of range in module %s\n",
- reference->name, reference->module->name);
+ "rel16 target for %s is out of range in module %s:%d\n",
+ reference->name, reference->module->name,
+ reference->lineno);
fatalErrors++;
}
gsfinalImage[reference->address]=(rel16/2)>>8;
for (nlp=0; nlp<nlibPaths; nlp++) {
for (nlf=0; nlf<nlibFiles; nlf++) {
sprintf (libFiles, "%s/%s.lib", libraryPaths[nlp], libraryFiles[nlf]);
- //fprintf (stderr, " %s\n", libFiles);
if ((lfs=fopen(libFiles,"r"))==NULL) {
continue;
}
// remove trailing \n
line[strlen(line)-1]='\0';
sprintf (libFile, "%s/%s", libraryPaths[nlp], line);
- //fprintf (stderr, " %s\n", libFile);
- if ((lf=fopen(libFile,"r"))==0) {
+ if ((lf=fopen(libFile,"r"))==NULL) {
continue;
}
while (fgets(line, 132, lf)) {
int dummy; // we need this to get the right count of the next sscanf
if (sscanf(line, "S %[^ ] Def%04x", symName, &dummy)==2) {
if (isUnresolved(symName, 1)) {
- //fprintf (stderr, "%s:%s\n", libFile, symName);
readModule(libFile,1);
if (resolved++ == unresolved) {
// we are done
addToDefs("s_XISEG", 0, 0);
addToDefs("l_XISEG", segments[XISEG]._size, 1);
-#if 1
// mark the resolved references
resolve();
if (unresolved==0) {
writeModule(outFileName);
}
-#endif
// the modules
fprintf (mapOut, "Modules:\n");
fprintf(sym_fp, " Line %d\n", p->line_def);
#else
if (p->issfr) {
- fprintf (sym_fp, "%-5s", "SFR");
+ fprintf (sym_fp, "%-7s", "SFR");
} else if (p->isbit && !p->area) {
- fprintf (sym_fp, "%-5s", "SBIT");
+ fprintf (sym_fp, "%-7s", "SBIT");
} else if (p->mode=='=') {
- fprintf (sym_fp,"ABS");
+ fprintf (sym_fp,"ABS ");
} else if (!p->isdef) {
- fprintf (sym_fp,"EXTRN");
+ fprintf (sym_fp,"EXTRN ");
} else {
- fprintf (sym_fp, "%-5s", areaToString(p->area));
+ fprintf (sym_fp, "%-7s", areaToString(p->area));
}
fprintf (sym_fp, " 0x%04x (%5d)", p->value, p->value);
fprintf (sym_fp, " %s", p->isdef ? "D" : "-");
return NULL;
}
+int is_abs(char *thename) {
+ struct symbol *p;
+ p = sym_list;
+ while (p != NULL) {
+ if (strcasecmp(thename, p->name)==0)
+ return p->mode == '=';
+ p = p->next;
+ }
+ return 0;
+}
+
/* this routine is used to dump a group of bytes to the output */
/* it is responsible for generating the list file and sending */
/* the bytes one at a time to the object code generator */
MEM_POS += $3;
}
| linenosym {
- MEM_POS += $1;
+ if (!is_abs(symbol_name)) {
+ MEM_POS += $1;
+ }
}
linenosym: directive EOL {
extern code ce;
extern data de;
extern xdata xe;
-xdata at 0x1234 abs;
extern xdata xee;
+xdata at 0x1234 abs;
void main(void) {
puts ("Hello world.\n\r");
switch (size)
{
case 1:
- emitcode ("mov.b", "r0l,[%s]", getStackOffset(sym->stack));
+ emitcode ("mov.b", "r0l,[%s] ;aopForSym:stack:1", getStackOffset(sym->stack));
sprintf (aop->name[0], "r0l");
return aop;
case 2:
- emitcode ("mov.w", "r0,[%s]", getStackOffset(sym->stack));
+ emitcode ("mov.w", "r0,[%s] ;aopForSym:stack:2", getStackOffset(sym->stack));
sprintf (aop->name[0], "r0");
return aop;
case 3:
- emitcode ("mov.w", "r0,[%s]", getStackOffset(sym->stack));
+ emitcode ("mov.w", "r0,[%s] ;aopForSym:stack:3", getStackOffset(sym->stack));
sprintf (aop->name[0], "r0");
- emitcode ("mov.b", "r1l,[%s]", getStackOffset(sym->stack+2));
+ emitcode ("mov.b", "r1l,[%s] ;aopForSym:stack:3", getStackOffset(sym->stack+2));
sprintf (aop->name[1], "r1l");
return aop;
case 4:
- emitcode ("mov.w", "r0,[%s]", getStackOffset(sym->stack));
+ emitcode ("mov.w", "r0,[%s] ;aopForSym:stack:4", getStackOffset(sym->stack));
sprintf (aop->name[0], "r0");
- emitcode ("mov.w", "r1,[%s]", getStackOffset(sym->stack+2));
+ emitcode ("mov.w", "r1,[%s] ;aopForSym:stack:4", getStackOffset(sym->stack+2));
sprintf (aop->name[1], "r1");
return aop;
}
aopOp(left, !aopIsPtr(result), !aopIsDir(result));
aopOp(right, !aopIsPtr(result), !aopIsDir(result));
- // special case for * = * + char, needs a closer look
+ // special case for "* = * + char", needs a closer look
// heck, this shouldn't have come here but bug-223113 does
if (size==3 && AOP_SIZE(right)==1) {
emitcode ("mov", "r1l,%s", AOP_NAME(right)[0]);
return;
}
- // special case for (whatever)* = (whatever)** + char, needs a closer look
+ // special case for "xdata * = xdata * + char", needs a closer look
// heck, this shouldn't have come here but bug-441448 does
if (size==2 && AOP_SIZE(right)==1) {
emitcode ("mov", "r1l,%s", AOP_NAME(right)[0]);
/* genMinus - generates code for subtraction */
/*-----------------------------------------------------------------*/
static void genMinus (iCode * ic) {
+ operand *result=IC_RESULT(ic), *left=IC_LEFT(ic), *right=IC_RIGHT(ic);
+ int size;
+ char *instr;
+
printIc (0, "genMinus", ic, 1,1,1);
-}
+ size=aopOp(result, TRUE, TRUE);
+
+ /* if left is a literal, then exchange them */
+ if (IS_LITERAL(operandType(left))) {
+ operand *tmp = right;
+ right = left;
+ left = tmp;
+ }
+
+ if (aopIsBit(result)) {
+ if (IS_LITERAL(operandType(right))) {
+ if (operandLitValue(right)) {
+ emitcode ("clr", AOP_NAME(result)[0]);
+ return;
+ }
+ aopOp(left, TRUE, TRUE);
+ emitcode ("mov", "%s,%s", AOP_NAME(result)[0], toBoolean(left));
+ return;
+ }
+ bailOut("genPlus: unfinished genPlus bit");
+ }
+
+ if (isOperandEqual(result,left)) {
+ left->aop=result->aop;
+ } else {
+ aopOp(left, !aopIsPtr(result), !aopIsDir(result));
+ }
+ aopOp(right, !aopIsPtr(result), !aopIsDir(result));
+
+ if (size>1) {
+ instr="sub.w";
+ } else {
+ instr="sub.b";
+ }
+ if (!aopEqual(result->aop, left->aop, 0)) {
+ emitcode ("mov", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
+ }
+ emitcode (instr, "%s,%s", AOP_NAME(result)[0], AOP_NAME(right)[0]);
+ if (size>2) {
+ if (!aopEqual(result->aop, left->aop, 1)) {
+ emitcode ("mov", "%s,%s", AOP_NAME(result)[1], AOP_NAME(left)[1]);
+ }
+ if (size==3) {
+ // generic pointer
+ } else {
+ emitcode ("subb.w", "%s,%s", AOP_NAME(result)[1], AOP_NAME(right)[1]);
+ }
+ }
+ return;
+}
/*-----------------------------------------------------------------*/
/* genMult - generates code for multiplication */
fprintf (of, "\t.dw\t__sdcc_gsinit_startup\n");
fprintf (of, "\n");
fprintf (of, "__sdcc_gsinit_startup:\n");
- //fprintf (of, ";\tmov.b\t_SCR,#0x01\t; page zero mode\n");
+ fprintf (of, ";\tmov.b\t_SCR,#0x01\t; page zero mode\n");
fprintf (of, "\t.db 0x96,0x48,0x40,0x01\n");
fprintf (of, "\tmov\tr7,#0x%04x\n", options.stack_loc);
fprintf (of, "\tcall\t_external_startup\n");