+2006-06-19 Raphael Neider <rneider AT web.de>
+
+ * src/pic/glue.h: added pic14aopLiteral prototype
+ * src/pic/glue.c (pic14aopLiteral): return unsigned int
+ * src/pic/gen.c: removed stdint.h dependency
+ (aopGet): use Safe_strdup()
+ (bitpatternFromVal): removed, replaced use with pic14aopLiteral
+ (genDataPointerSet): use pic14aopLiteral()
+ * src/pic16/glue.h, src/pic16/glue.c, src/pic16/gen.c: similar changes
+ for pic16; thanks to Bernhard and Maarten
+
2006-06-18 Borut Razem <borut.razem AT siol.net>
* support/regression/tests/structflexarray.c: flexible array members
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#ifndef __sun__
-#if defined(_MSC_VER)
- #include "pstdint.h"
-#else
- #include <stdint.h>
-#endif
-#endif
#include "SDCCglobl.h"
#include "newalloc.h"
#include "ralloc.h"
#include "pcode.h"
#include "gen.h"
+#include "glue.h"
/* When changing these, you must also update the assembler template
* in device/lib/libsdcc/macros.inc */
pCodeOp *popGetImmd(char *name, unsigned int offset, int index,int is_func);
extern char *get_op( pCodeOp *pcop,char *buff,size_t buf_size);
-unsigned int pic14aopLiteral (value *val, int offset);
const char *AopType(short type);
#define BYTEofLONG(l,b) ( (l>> (b<<3)) & 0x00ff)
return "AOP_accumulator_bug";
case AOP_LIT:
- sprintf(s,"0x%02x", pic14aopLiteral (aop->aopu.aop_lit,offset));
- rs = Safe_calloc(1,strlen(s)+1);
- strcpy(rs,s);
+ sprintf(s, "0x%02x", pic14aopLiteral (aop->aopu.aop_lit, offset));
+ rs = Safe_strdup(s);
return rs;
case AOP_STR:
assert( !"bitfields larger than 8 bits or crossing byte boundaries are not yet supported" );
}
-unsigned long
-bitpatternFromVal (value *val)
-{
- union {
- float d;
- uint32_t l;
- } float_long;
-
- assert (sizeof (float) == sizeof (uint32_t));
-
- //fprintf (stderr, "%s:%u(%s): val=%lf, type: %d, etype: %d\n", __FILE__, __LINE__, __FUNCTION__, floatFromVal(val), SPEC_NOUN(val->type), SPEC_NOUN(val->etype));
-
- switch (SPEC_NOUN(val->type))
- {
- case V_INT:
- case V_CHAR:
- return (unsigned long)floatFromVal (val);
-
- case V_FLOAT:
- case V_DOUBLE:
- float_long.d = floatFromVal (val);
- return float_long.l;
-
- default:
- assert( !"unhandled value type" );
- break;
- }
-
- float_long.d = floatFromVal (val);
- return float_long.l;
-}
-
/*-----------------------------------------------------------------*/
/* genDataPointerSet - remat pointer to data space */
/*-----------------------------------------------------------------*/
emitpComment ("%s:%u: size=%d/%d, offset=%i", __FILE__,__LINE__, size, ressize, offset);
if (AOP_TYPE(right) == AOP_LIT) {
- /* XXX: might be float... */
- unsigned int lit = bitpatternFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit);
- lit = lit >> (8*offset);
+ unsigned int lit = pic14aopLiteral(AOP(IC_RIGHT(ic))->aopu.aop_lit, offset);
//fprintf (stderr, "%s:%u: lit %d 0x%x\n", __FUNCTION__,__LINE__, lit, lit);
if(lit&0xff) {
emitpcode(POC_MOVLW, popGetLit(lit&0xff));
- emitpcode(POC_MOVWF, popGet(AOP(result),offset));
+ emitpcode(POC_MOVWF, popGet(AOP(result), offset));
} else {
- emitpcode(POC_CLRF, popGet(AOP(result),offset));
+ emitpcode(POC_CLRF, popGet(AOP(result), offset));
}
} else {
//fprintf (stderr, "%s:%u: no lit\n", __FUNCTION__,__LINE__);
- emitpcode(POC_MOVFW, popGet(AOP(right),offset));
- emitpcode(POC_MOVWF, popGet(AOP(result),offset));
+ emitpcode(POC_MOVFW, popGet(AOP(right), offset));
+ emitpcode(POC_MOVWF, popGet(AOP(result), offset));
}
offset++;
#include "genutils.h"
#include "device.h"
#include "main.h"
+#include "glue.h"
/* Set the following to 1 to enable the slower/bigger
* but more robust generic shifting routine (which also
pCodeOp *pic16_popGetImmd(char *name, unsigned int offset, int index);
-unsigned int pic16aopLiteral (value *val, int offset);
const char *pic16_AopType(short type);
static iCode *ifxForOp ( operand *op, iCode *ic );
while (size--) {
if (AOP_TYPE(right) == AOP_LIT) {
- unsigned int lit;
-
- if(!IS_FLOAT(operandType( right )))
- lit = (unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit);
- else {
- union {
- unsigned long lit_int;
- float lit_float;
- } info;
-
- /* take care if literal is a float */
- info.lit_float = floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit);
- lit = info.lit_int;
- }
- lit = lit >> (8*offset);
- pic16_movLit2f(pic16_popGet(AOP(result),offset), lit);
- } else {
- pic16_mov2w(AOP(right), offset);
- pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result),offset)); // patch 8
- }
- offset++;
- resoffset++;
- }
+ unsigned int lit = pic16aopLiteral(AOP(IC_RIGHT(ic))->aopu.aop_lit, offset);
+ pic16_movLit2f(pic16_popGet(AOP(result), offset), lit);
+ } else {
+ pic16_mov2w(AOP(right), offset);
+ pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result), offset)); // patch 8
+ }
+ offset++;
+ resoffset++;
+ }
pic16_freeAsmop(right,NULL,ic,TRUE);
}