}
}
+static void writehex(arith data, int size)
+{
+ if (data < 0)
+ fprintf(outputfile, "-0x%0*lx", size*2, -data);
+ else
+ fprintf(outputfile, "0x%0*lx", size*2, data);
+}
+
void data_int(arith data, size_t size, bool is_ro)
{
emit_header(is_ro ? SECTION_ROM : SECTION_DATA);
assert((size == 1) || (size == 2) || (size == 4) || (size == 8));
- fprintf(outputfile, "\t.data%d 0x%0*lld\n", size, size*2, data);
+ fprintf(outputfile, "\t.data%d ", size);
+ writehex(data, size);
+ fprintf(outputfile, "\n");
}
+
void data_float(const char* data, size_t size, bool is_ro)
{
unsigned char buffer[8];
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]);
+ fprintf(outputfile, "\t.data1 ");
+ writehex(buffer[0], 1);
for (i=1; i<size; i++)
- fprintf(outputfile, ", 0x%02x", buffer[i]);
+ {
+ fprintf(outputfile, ", ");
+ writehex(buffer[0], 1);
+ }
fprintf(outputfile, "\n");
}
{
if (!first)
fprintf(outputfile, ", ");
- fprintf(outputfile, "0x%02x", *start);
+ writehex(*start, 1);
start++;
first = false;
}