aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bas.c12
-rw-r--r--bas.h5
-rw-r--r--whichbas.c7
-rw-r--r--whichbas.rst6
4 files changed, 25 insertions, 5 deletions
diff --git a/bas.c b/bas.c
index 13385f1..595ed97 100644
--- a/bas.c
+++ b/bas.c
@@ -11,6 +11,7 @@
#include "bas.h"
int verbose = 0;
+int allow_hex_const = 0;
unsigned short lomem;
unsigned short vntp;
unsigned short vntd;
@@ -340,9 +341,16 @@ void walk_code(unsigned int startlineno, unsigned int endlineno) {
tok = program[pos];
switch(tok) {
case OP_NUMCONST:
- CALL(on_exp_token);
+ case OP_HEXCONST:
+ if(allow_hex_const) {
+ CALL(on_exp_token);
+ } else {
+ fprintf(stderr, "%s: found Turbo/BXL/BXE hex constant at line %d, skipping\n", self, lineno);
+ }
pos++;
- CALL(on_num_const);
+ if(allow_hex_const) {
+ CALL(on_num_const);
+ }
pos += 6;
break;
case OP_STRCONST:
diff --git a/bas.h b/bas.h
index 3a24c38..4374543 100644
--- a/bas.h
+++ b/bas.h
@@ -92,8 +92,10 @@
#define CMD_ILET 0x36 /* implied LET */
#define CMD_ERROR 0x37
-/* operators. 0x00-0x0d and 0x0a-0x11 are not used.
+/* operators. 0x00-0x0d and 0x0a-0x11 are not used in Atari BASIC;
+ 0x0d is used (in the same way) in both Turbo BASIC and BXL/BXE.
0x3d-0x54 are functions. */
+#define OP_HEXCONST 0x0d
#define OP_NUMCONST 0x0e
#define OP_STRCONST 0x0f
#define OP_COMMA 0x12
@@ -200,6 +202,7 @@ extern FILE *output_file;
extern char *output_filename;
extern int verbose;
+extern int allow_hex_const;
extern void set_self(const char *argv0);
extern void die(const char *msg);
diff --git a/whichbas.c b/whichbas.c
index dabf414..f2b1f4d 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -68,6 +68,8 @@ void print_result(void) {
name = "Not Atari BASIC; probably either Turbo or BXL/BXE";
}
+ if(verbose) fprintf(stderr, " final bas_type %02x\n", bas_type);
+
fputs(name, stdout);
putchar('\n');
@@ -96,7 +98,7 @@ CALLBACK(handle_cmd) {
if(tok <= CMD_ERROR) return; /* legal in BASIC, ignore */
remove_type(BT_ATARI);
- if(tok >= 0x5b) remove_type(BT_BXL);
+ if(tok >= 0x59) remove_type(BT_BXL);
nexttok = program[pos + 1];
has_args = !(nexttok == OP_EOS || nexttok == OP_EOL);
@@ -335,7 +337,7 @@ CALLBACK(handle_end_stmt) {
break;
default: break;
}
- if(verbose) fprintf(stderr, " now %02x\n", bas_type);
+ if(verbose) fprintf(stderr, " bas_type now %02x\n", bas_type);
}
void foreign(const char *name) {
@@ -406,6 +408,7 @@ int main(int argc, char **argv) {
readfile();
parse_header();
+ allow_hex_const = 1;
on_cmd_token = handle_cmd;
on_exp_token = handle_op;
on_end_stmt = handle_end_stmt;
diff --git a/whichbas.rst b/whichbas.rst
index 3eb8854..14ec718 100644
--- a/whichbas.rst
+++ b/whichbas.rst
@@ -18,6 +18,9 @@ DESCRIPTION
BASIC XL, BASIC XE, or Atari Microsoft BASIC program and attempts to
discover which BASIC is required to run it.
+*input-file* must be an actual file. **whichbas** can't read from
+standard input, because it seeks in the input file.
+
OPTIONS
=======
@@ -37,6 +40,9 @@ NOTES
Turbo BASIC, BASIC XL, and BASIC XE are all supersets of Atari BASIC.
If you wrote a program using one of them, but didn't use any of the
extra commands or functions, the result is still an Atari BASIC program.
+Likewise, if you wrote a program using BASIC XE, but only used the
+commands/functions it has in common with BASIC XL, it would be
+detected as BASIC XL.
There are two types of BASIC XE programs: regular and *EXTEND*\ed. The
extended type is detected 100% reliably, because the first byte of the