aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-17 04:07:02 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-17 04:07:02 -0400
commit944b59a1e25f254694e5c58fddcb461d5a05a5a4 (patch)
tree460e589aece3c67bada0a7e52c83c134c1abc203
parent18bfe53f6d36a30ed2867aced9999e8d91f57a5f (diff)
downloadbw-atari8-tools-944b59a1e25f254694e5c58fddcb461d5a05a5a4.tar.gz
listbas: print Turbo/BXL/BXE hex constants correctly (in hex!).
-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)