Fixed floating point support in assembler.

This commit is contained in:
cdkersey 2013-10-07 17:49:00 -04:00
parent 0e0aa64e74
commit 021f08e180
2 changed files with 6 additions and 6 deletions

View file

@ -94,9 +94,9 @@ static uint64_t readParenExpression(const string &s, const map<string, Word> &d,
exit(1);
}
int lexerBytes;
int lexerFloatBytes;
Obj *AsmReader::read(std::istream &input) {
lexerBytes = wordSize;
lexerFloatBytes = wordSize;
FlexLexer *f = new yyFlexLexer(&input);
Obj *o = new Obj();
std::vector<Chunk>::reverse_iterator cur;

View file

@ -16,14 +16,14 @@
#include "include/asm-tokens.h"
#include "include/harpfloat.h"
extern int lexerBytes;
extern int lexerFloatBytes;
static int64_t read_number(const char *s) {
while (!isdigit(*s) && *s != '-' && *s != '+') s++;
if (strchr(s, 'f') || strchr(s, '.')) {
if (strchr(s, 'f') && !strchr(s, 'x') || strchr(s, '.')) {
double d;
sscanf(s, "%f", &d);
return Harp::Word_u(Harp::Float(d, lexerBytes));
sscanf(s, "%lf", &d);
return Harp::Word_u(Harp::Float(d, lexerFloatBytes));
} else {
long long u;
sscanf(s, "%lli", &u);