aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--listbas.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/listbas.c b/listbas.c
index dac8253..33f6202 100644
--- a/listbas.c
+++ b/listbas.c
@@ -300,9 +300,17 @@ void color_off(void) {
fputs(COLOR_OFF, outfh);
}
-void print_number(unsigned int pos) {
+void print_number(unsigned int pos, int hex) {
+ double num = bcd2double(program + pos);
if(color) color_on(color_const);
- fprintf(outfh, "%G", bcd2double(program + pos));
+ if(hex) {
+ if(num < 0 || num > 0xffff) {
+ fprintf(stderr, "%s: invalid Turbo/BXL/BXE hex const %lf at pos $%04x\n", self, num, pos);
+ }
+ fprintf(outfh, (num > 0xff ? "%04x" : "%02x"), (unsigned int)num);
+ } else {
+ fprintf(outfh, "%G", num);
+ }
if(color) color_off();
}
@@ -598,10 +606,10 @@ CALLBACK(print_op) {
case OP_HEXCONST:
if(color) color_on(color_op);
outchr('$');
- if(color) color_off();
- /* fall thru */
+ print_number(pos + 1, 1);
+ return;
case OP_NUMCONST:
- print_number(pos + 1);
+ print_number(pos + 1, 0);
return;
case OP_STRCONST:
print_string(pos + 2, program[pos + 1]);
@@ -815,7 +823,7 @@ void init_bas_dialect() {
if(autodetect)
detect_bas_dialect();
- if(bas_type == B_BXL || bas_type == B_BXE)
+ if(bas_type == B_TURBO || bas_type == B_BXL || bas_type == B_BXE)
allow_hex_const = 1;
if(bas_type == B_APLUS)