More shifting. Remove SDCCralloc.h, made all in mcs51 static,
[fw/sdcc] / src / SDCCglue.c
index eb574a35426c6a83b68d47887097cb1766109b0c..3dfe3748f384f51a5256f53b15bc0be45adb72b0 100644 (file)
@@ -63,6 +63,39 @@ void copyFile (FILE * dest, FILE * src)
            fputc (ch, dest);
 }
 
+/*-----------------------------------------------------------------*/
+/* aopLiteral - string from a literal value                        */
+/*-----------------------------------------------------------------*/
+char *aopLiteral (value *val, int offset)
+{
+    char *rs;
+    union {
+        float f;
+        unsigned char c[4];
+    } fl;
+
+    /* if it is a float then it gets tricky */
+    /* otherwise it is fairly simple */
+    if (!IS_FLOAT(val->type)) {
+        unsigned long v = floatFromVal(val);
+
+        v >>= (offset * 8);
+        sprintf(buffer,"#0x%02x",((char) v) & 0xff);
+        ALLOC_ATOMIC(rs,strlen(buffer)+1);
+        return strcpy (rs,buffer);
+    }
+
+    /* it is type float */
+    fl.f = (float) floatFromVal(val);
+#ifdef _BIG_ENDIAN    
+    sprintf(buffer,"#0x%02x",fl.c[3-offset]);
+#else
+    sprintf(buffer,"#0x%02x",fl.c[offset]);
+#endif
+    ALLOC_ATOMIC(rs,strlen(buffer)+1);
+    return strcpy (rs,buffer);
+}
+
 /*-----------------------------------------------------------------*/
 /* emitRegularMap - emit code for maps with no special cases       */
 /*-----------------------------------------------------------------*/