Add support for floating point constants.
This commit is contained in:
parent
938fb8c2fc
commit
3520704ea8
|
@ -1,6 +1,13 @@
|
|||
#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)
|
||||
|
@ -49,6 +56,24 @@ void data_int(arith data, size_t size, bool is_ro)
|
|||
fprintf(outputfile, "\t.data%d 0x%0*lld\n", size, size*2, data);
|
||||
}
|
||||
|
||||
void data_float(const char* data, size_t size, bool is_ro)
|
||||
{
|
||||
unsigned char buffer[8];
|
||||
int i;
|
||||
|
||||
emit_header(is_ro ? SECTION_ROM : SECTION_DATA);
|
||||
assert((size == 4) || (size == 8));
|
||||
|
||||
if (float_cst(data, size, (char*) buffer))
|
||||
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 0x%02x", buffer[0]);
|
||||
for (i=1; i<size; i++)
|
||||
fprintf(outputfile, ", 0x%02x", buffer[i]);
|
||||
fprintf(outputfile, "\n");
|
||||
}
|
||||
|
||||
void data_block(const uint8_t* data, size_t size, bool is_ro)
|
||||
{
|
||||
const uint8_t* start = data;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "flt_arith.h"
|
||||
#include "em_arith.h"
|
||||
#include "em_label.h"
|
||||
#include "em.h"
|
||||
|
@ -93,6 +94,7 @@ extern struct symbol* symbol_walk(symbol_walker_t* walker, void* user);
|
|||
|
||||
extern void data_label(const char* name);
|
||||
extern void data_int(arith data, size_t size, bool is_ro);
|
||||
extern void data_float(const char* data, size_t size, bool is_ro);
|
||||
extern void data_block(const uint8_t* data, size_t size, bool is_ro);
|
||||
extern void data_offset(const char* label, arith offset, bool is_ro);
|
||||
extern void data_bss(arith size, int init);
|
||||
|
|
|
@ -230,6 +230,12 @@ static void parse_pseu(void)
|
|||
break;
|
||||
}
|
||||
|
||||
case fco_ptyp:
|
||||
{
|
||||
data_float(em.em_string, em.em_size, ro);
|
||||
break;
|
||||
}
|
||||
|
||||
case str_ptyp:
|
||||
data_block(strdup(em.em_string), em.em_size, ro);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue