#include "SDCCglobl.h"
#include "newalloc.h"
-#ifdef HAVE_SYS_ISA_DEFS_H
-#include <sys/isa_defs.h>
-#else
-#ifdef HAVE_MACHINE_ENDIAN_H
-#include <machine/endian.h>
-#else
-#ifdef HAVE_ENDIAN_H
-#include <endian.h>
-#else
-#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__)
-#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN"
-#warning "If you running sdcc on an INTEL 80x86 Platform you are okay"
-#endif
-#endif
-#endif
-#endif
-
#define BETTER_LITERAL_SHIFT
char *aopLiteral (value * val, int offset);
(IC_RESULT(x) && IC_RESULT(x)->aop && \
IC_RESULT(x)->aop->type == AOP_STK )
-/* #define MOVA(x) if (strcmp(x,"a") && strcmp(x,"acc")) emitcode("mov","a,%s",x); */
-#define MOVA(x) { \
- char *_mova_tmp = strdup(x); \
- if (strcmp(_mova_tmp,"a") && strcmp(_mova_tmp,"acc")) \
- { \
- emitcode("mov","a,%s",_mova_tmp); \
- } \
- free(_mova_tmp); \
- }
-#define MOVB(x) { char *_movb_tmp = strdup(x); \
- if (strcmp(_movb_tmp,"b")) \
- { \
- emitcode("mov","b,%s",_movb_tmp); \
- } \
- free(_movb_tmp); \
- }
+#define MOVA(x) _movA(x)
+#define MOVB(x) _movB(x)
+
#define CLRC emitcode("clr","c")
#define SETC emitcode("setb","c")
va_end (ap);
}
+//
+// Move the passed value into A unless it is already there.
+//
+static void
+_movA(const char *s)
+{
+ if (strcmp(s,"a") && strcmp(s,"acc"))
+ {
+ emitcode("mov","a,%s",s);
+ }
+}
+
+//
+// Move the passed value into B unless it is already there.
+//
+static void
+_movB(const char *s)
+{
+ if (strcmp(s,"b"))
+ {
+ emitcode("mov","b,%s",s);
+ }
+}
+
/*-----------------------------------------------------------------*/
/* getFreePtr - returns r0 or r1 whichever is free or can be pushed */
/*-----------------------------------------------------------------*/
"(%s %c 0x%04x)",
OP_SYMBOL (IC_LEFT (ic))->rname,
val >= 0 ? '+' : '-',
- abs (val) & 0xffff);
+ abs (val) & 0xffffff);
}
else
{
/* if the registers have been saved already then
do nothing */
- if (ic->regsSaved || IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT(ic)))) return ;
+ if (ic->regsSaved ||
+ (IS_SYMOP(IC_LEFT(ic)) && IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT(ic)))))
+ return ;
/* special case if DPTR alive across a function call then must save it
even though callee saves */
- if (IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type)) {
+ if (IS_SYMOP(IC_LEFT(ic)) &&
+ IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type)) {
int i;
rsave = newBitVect(ic->rMask->size);
for (i = DPL_IDX ; i <= B_IDX ; i++ ) {
}
}
}
- // jwk: this needs a closer look
+ // TODO: this needs a closer look
SPEC_ISR_SAVED_BANKS(currFunc->etype) = banksToSave;
}
}
* Restore any register banks saved by genFunction
* in reverse order.
*/
- // jwk: this needs a closer look
unsigned savedBanks = SPEC_ISR_SAVED_BANKS(currFunc->etype);
int ix;
// AOP_IS_DPTRn(IC_LEFT(ic)) ? "true" : "false",
// AOP_IS_DPTRn(IC_RIGHT(ic)) ? "true" : "false",
// AOP_IS_DPTRn(IC_RESULT(ic)) ? "true" : "false");
-// );
-
+// );
- // Right uses DPTR unless left or result is an AOP_STR.
- aopOp (IC_RIGHT(ic),ic,FALSE, AOP_IS_STR(IC_LEFT(ic)) || AOP_IS_STR(IC_RESULT(ic)));
+ // Right uses DPTR unless left or result is an AOP_STR; however,
+ // if right is an AOP_STR, it must use DPTR regardless.
+ if ((AOP_IS_STR(IC_LEFT(ic)) || AOP_IS_STR(IC_RESULT(ic)))
+ && !AOP_IS_STR(IC_RIGHT(ic)))
+ {
+ useDp2 = TRUE;
+ }
+ else
+ {
+ useDp2 = FALSE;
+ }
+
+ aopOp (IC_RIGHT(ic),ic,FALSE, useDp2);
// if the right used DPTR, left MUST use DPTR2.
// if the right used DPTR2, left MUST use DPTR.
AOP_TYPE (right) == AOP_CRY)
{
emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- emitcode ("anl", "c,/%s", AOP (left)->aopu.aop_dir);
+ emitcode ("anl", "c,%s", AOP (left)->aopu.aop_dir);
}
else
{
_endLazyDPSEvaluation ();
}
pi->generated = 1;
- } else if ((OP_SYMBOL(left)->ruonly || AOP_INDPTRn(left)) &&
+ } else if ((AOP_IS_STR(left) || AOP_INDPTRn(left)) &&
AOP_SIZE(result) > 1 &&
- (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) {
+ IS_SYMOP(left) &&
+ (OP_SYMBOL(left)->liveTo > ic->seq || ic->depth)) {
size = AOP_SIZE (result) - 1;
if (AOP_INDPTRn(left)) {
if (offset) {
switch (offset) {
case 1:
- tsprintf(s, sizeof(s), "!his",sym->rname);
+ tsprintf(s, sizeof(s), "#!his",sym->rname);
break;
case 2:
- tsprintf(s, sizeof(s), "!hihis",sym->rname);
+ tsprintf(s, sizeof(s), "#!hihis",sym->rname);
break;
case 3:
- tsprintf(s, sizeof(s), "!hihihis",sym->rname);
+ tsprintf(s, sizeof(s), "#!hihihis",sym->rname);
break;
default: /* should not need this (just in case) */
SNPRINTF (s, sizeof(s), "#(%s >> %d)",
}
#if 1
/* print the allocation information */
- if (allocInfo)
+ if (allocInfo && currFunc)
printAllocInfo (currFunc, codeOutFile);
#endif
/* if debug information required */
if (options.debug && currFunc)
{
- cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
+ debugFile->writeFunction(currFunc);
_G.debugLine = 1;
if (IS_STATIC (currFunc->etype))
emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);