void emit2(int);
void emit4(long);
void emitx(valu_t, int);
-void emitf(int size);
+void emitf(int size, int negative);
void emitstr(int);
void ffreopen(char *, FILE *);
FILE *ffcreat(char *);
}
;
-dataflist
- : NUMBERF
+numberf
+ : NUMBERF
{
- emitf((int)$<y_word>0);
+ emitf((int)$<y_word>-1, 0);
}
- | dataflist ',' NUMBERF
+ | '-' NUMBERF
{
- emitf((int)$<y_word>3);
+ emitf((int)$<y_word>-1, 1);
}
;
+dataflist
+ : numberf
+ | dataflist ',' numberf
+ ;
+
expr : error
{ serror("expr syntax err");
$$.val = 0; $$.typ = S_UND;
static int inescape(void);
static int infbsym(const char*);
+static int maxstring = 0;
+
int yylex(void)
{
int c, c0, c1;
{
if (--radix < 0)
fatal("number too long");
- if (isupper(c))
- c += ('a' - 'A');
*p++ = c;
c = nextchar();
- } while (isdigit(c) || (c == '.') || (c == 'E') || (c == '+') || (c == '-'));
+ if (isupper(c))
+ c = tolower(c);
+ } while (isdigit(c) || (c == '.') || (c == 'e') || (c == '+') || (c == '-'));
peekc = c;
*p = '\0';
- stringbuf = strdup(num);
stringlen = p - num;
+ if (stringlen > maxstring)
+ {
+ maxstring = stringlen;
+ stringbuf = realloc(stringbuf, maxstring);
+ }
+ strcpy(stringbuf, num);
return NUMBERF;
}
{
char* p;
int c;
- static int maxstring = 0;
if (!maxstring)
{
#define gen1 emit1
#include <con_float>
-void emitf(int size)
+void emitf(int size, int negative)
{
- con_float(stringbuf, size);
+ char buffer[40];
+
+ if (stringlen > sizeof(buffer)-1)
+ fatal("floating point constant too long");
+
+ if (negative)
+ {
+ buffer[0] = '-';
+ strcpy(buffer+1, stringbuf);
+ con_float(buffer, size);
+ }
+ else
+ con_float(stringbuf, size);
}
/* ---------- Error checked file I/O ---------- */
"modules/src/data+lib",
"modules/src/em_code+lib_k",
"modules/src/em_data+lib",
- "modules/src/flt_arith+lib",
"modules/src/idf+lib",
"modules/src/object+lib",
"modules/src/read_em+lib_kv",
#include "mcg.h"
#include <ctype.h>
-#define IEEEFLOAT
-#define FL_MSL_AT_LOW_ADDRESS 1
-#define FL_MSW_AT_LOW_ADDRESS 1
-#define FL_MSB_AT_LOW_ADDRESS 1
-
-#include "con_float"
-
static struct symbol* pending;
void data_label(const char* label)
emit_header(is_ro ? SECTION_ROM : SECTION_DATA);
assert((size == 4) || (size == 8));
- i = float_cst(data, size, (char*) buffer);
- if ((i != 0) && (i != 2)) /* 2 == overflow */
- fatal("cannot parse floating point constant %s sz %d", data, size);
-
- fprintf(outputfile, "\t!float %s sz %d\n", data, size);
- fprintf(outputfile, "\t.data1 ");
- writehex(buffer[0], 1);
- for (i=1; i<size; i++)
- {
- fprintf(outputfile, ", ");
- writehex(buffer[i], 1);
- }
- fprintf(outputfile, "\n");
+ fprintf(outputfile, "\t.dataf%d %s\n", size, data);
}
static bool istext(c)
#include <stdint.h>
#include <string.h>
#include <assert.h>
-#include "flt_arith.h"
#include "em_arith.h"
#include "em_label.h"
#include "em.h"