X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Favr%2Fgen.c;h=cde734ea6a7c045364837ed46dfe5e8f7fda913b;hb=195ee3f3ee25ce2c5f2a59fbd2779c4cb80527c3;hp=651dab24039a843048a1072a0fc72193942024e8;hpb=4d711df34233a47f093f6d6a3e8840b17d577887;p=fw%2Fsdcc diff --git a/src/avr/gen.c b/src/avr/gen.c index 651dab24..cde734ea 100644 --- a/src/avr/gen.c +++ b/src/avr/gen.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- - avrgen.c - source file for code generation for ATMEL AVR + gen.c - source file for code generation for ATMEL AVR Written By - Sandeep Dutta . sandeep.dutta@usa.net (2000) @@ -31,23 +31,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#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 - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" @@ -266,7 +249,7 @@ emitcode (char *inst, char *fmt, ...) else vsprintf (lb, fmt, ap); - while (isspace (*lbp)) + while (isspace ((unsigned char)*lbp)) lbp++; if (lbp && *lbp) @@ -278,6 +261,18 @@ emitcode (char *inst, char *fmt, ...) va_end (ap); } +/*-----------------------------------------------------------------*/ +/* avr_emitDebuggerSymbol - associate the current code location */ +/* with a debugger symbol */ +/*-----------------------------------------------------------------*/ +void +avr_emitDebuggerSymbol (char * debugSym) +{ + _G.debugLine = 1; + emitcode ("", "%s ==.", debugSym); + _G.debugLine = 0; +} + /*-----------------------------------------------------------------*/ /* hasInc - operand is incremented before any other use */ /*-----------------------------------------------------------------*/ @@ -301,7 +296,7 @@ hasInc (operand *op, iCode *ic) return lic; } /* if the operand used or deffed */ - if (bitVectBitValue(OP_USES(op),lic->key) || ((unsigned) lic->defKey == op->key)) { + if (bitVectBitValue(OP_USES(op),lic->key) || (lic->defKey == op->key)) { return NULL; } lic = lic->next; @@ -1046,7 +1041,7 @@ aopPut (asmop * aop, char *s, int offset) break; case AOP_REG: - if (toupper (*s) != 'R') { + if (toupper ((unsigned char)*s) != 'R') { if (s == zero) { emitcode ("clr", "%s", aop->aopu.aop_reg[offset]->name); @@ -1114,7 +1109,7 @@ aopPut (asmop * aop, char *s, int offset) case AOP_CRY: /* if used only for a condition code check */ - assert (toupper (*s) == 'R'); + assert (toupper ((unsigned char)*s) == 'R'); if (offset == 0) { emitcode ("xrl", "r0,r0"); emitcode ("cpi", "%s,0", s); @@ -1550,7 +1545,7 @@ static void genCall (iCode * ic) { - /* if send set is not empty the assign */ + /* if send set is not empty then assign */ if (_G.sendSet) { iCode *sic; int rnum = 16; @@ -1832,6 +1827,10 @@ genEndFunction (iCode * ic) if (IFFUNC_ISCRITICAL (sym->type)) emitcode ("sti", ""); + if (options.debug && currFunc) { + debugFile->writeEndFunction (currFunc, ic, 1); + } + if (IFFUNC_ISISR (sym->type)) { emitcode ("rti", ""); } @@ -4945,8 +4944,6 @@ genCast (iCode * ic) /* pointer to generic pointer */ if (IS_GENPTR (ctype)) { - char *l = zero; - if (IS_PTR (type)) p_type = DCL_TYPE (type); else { @@ -4962,30 +4959,22 @@ genCast (iCode * ic) aopGet (AOP (right), offset), offset); offset++; } - /* the last byte depending on type */ - switch (p_type) { - case IPOINTER: - case POINTER: - l = zero; - break; - case FPOINTER: - l = one; - break; - case CPOINTER: - l = "0x02"; - break; - case PPOINTER: - l = "0x03"; - break; - - default: - /* this should never happen */ - werror (E_INTERNAL_ERROR, __FILE__, __LINE__, - "got unknown pointer type"); - exit (1); + + /* the last byte depending on type */ + { + int gpVal = pointerTypeToGPByte(p_type, NULL, NULL); + char gpValStr[10]; + + if (gpVal == -1) + { + // pointerTypeToGPByte will have bitched. + exit(1); } - aopPut (AOP (result), l, GPTRSIZE - 1); - goto release; + + sprintf(gpValStr, "#0x%x", gpVal); + aopPut (AOP (result), gpValStr, GPTRSIZE - 1); + } + goto release; } /* just copy the pointers */ @@ -5113,6 +5102,18 @@ genReceive (iCode * ic) freeAsmop (IC_RESULT (ic), NULL, ic, TRUE); } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + emitcode ("; genDummyRead",""); + emitcode ("; not implemented",""); + + ic = ic; +} + /*-----------------------------------------------------------------*/ /* gen51Code - generate code for 8051 based controllers */ /*-----------------------------------------------------------------*/ @@ -5128,12 +5129,8 @@ genAVRCode (iCode * lic) if (allocInfo) printAllocInfo (currFunc, codeOutFile); /* if debug information required */ - /* if (options.debug && currFunc) { */ - if (currFunc) { - cdbSymbol (currFunc, cdbFile, FALSE, TRUE); - _G.debugLine = 1; -/* emitcode ("", ".type %s,@function", currFunc->name); */ - _G.debugLine = 0; + if (options.debug && currFunc) { + debugFile->writeFunction (currFunc, lic); } /* stack pointer name */ spname = "sp"; @@ -5143,11 +5140,7 @@ genAVRCode (iCode * lic) if (cln != ic->lineno) { if (options.debug) { - _G.debugLine = 1; - emitcode ("", "C$%s$%d$%d$%d ==.", - FileBaseName (ic->filename), - ic->lineno, ic->level, ic->block); - _G.debugLine = 0; + debugFile->writeCLine (ic); } emitcode (";", "%s %d", ic->filename, ic->lineno); cln = ic->lineno; @@ -5344,6 +5337,10 @@ genAVRCode (iCode * lic) addSet (&_G.sendSet, ic); break; + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + default: ic = ic; }