aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-06-17 17:05:51 -0400
committerB. Watson <urchlay@slackware.uk>2024-06-17 17:05:51 -0400
commit2a73f95e7204ded74409adc03eeac62868e3500f (patch)
tree6887a9803e4421df99c41fc1d7e8a13f2cd036ac
parented910cdfa474bd7a3fd0cf3082119abc41b094e4 (diff)
downloadbw-atari8-tools-2a73f95e7204ded74409adc03eeac62868e3500f.tar.gz
cxrefbas: handle IF <x> THEN <lineno>.
-rw-r--r--Makefile2
-rw-r--r--bas.h1
-rw-r--r--cxrefbas.14
-rw-r--r--cxrefbas.c19
-rw-r--r--cxrefbas.rst2
5 files changed, 25 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index d49b400..f64b99c 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ cxrefbas: bas.o bcdfp.o
bas.o: bas.c bas.h
subdirs:
- for dir in $(SUBDIRS); do make -C $$dir COPT=$(COPT); done
+ for dir in $(SUBDIRS); do make -C $$dir COPT="$(COPT)"; done
a8eol: a8eol.c
diff --git a/bas.h b/bas.h
index 4e30431..dd75e19 100644
--- a/bas.h
+++ b/bas.h
@@ -38,6 +38,7 @@
#define CMD_ON 0x1e
#define CMD_GOSUB 0x0c
#define CMD_TRAP 0x0d
+#define CMD_IF 0x07
#define CMD_LIST 0x04
#define CMD_RESTORE 0x23
#define CMD_REM 0x00
diff --git a/cxrefbas.1 b/cxrefbas.1
index 8cfb9ac..99870a2 100644
--- a/cxrefbas.1
+++ b/cxrefbas.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "CXREFBAS" 1 "2024-06-16" "0.2.1" "Urchlay's Atari 8-bit Tools"
+.TH "CXREFBAS" 1 "2024-06-17" "0.2.1" "Urchlay's Atari 8-bit Tools"
.SH NAME
cxrefbas \- Code cross-reference for tokenized Atari 8-bit BASIC files
.SH SYNOPSIS
@@ -46,6 +46,8 @@ is no line 100), it\(aqs printed in the table, prefixed with \fI!\fP\&.
Any command that uses a computed value for a line number will print a
warning on standard error, e.g. \fIGOTO A\fP or \fIGOSUB 100*A\fP\&. Even \fIGOTO
100+0\fP is a computed value, since BASIC doesn\(aqt do constant folding.
+.sp
+Line numbers above 32767, e.g. \fITRAP 40000\fP, are not listed.
.SH OPTIONS
.SS General Options
.INDENT 0.0
diff --git a/cxrefbas.c b/cxrefbas.c
index 7cc3114..9228f28 100644
--- a/cxrefbas.c
+++ b/cxrefbas.c
@@ -8,6 +8,14 @@
#include "bas.h"
#include "bcdfp.h"
+/* not yet...
+typedef struct {
+ unsigned short lineno;
+ unsigned short pos;
+ unsigned char type;
+} lineref_t;
+*/
+
unsigned short *linerefs[32769];
int refcounts[32769];
int lines_exist[32769];
@@ -79,6 +87,10 @@ void computed_msg(unsigned short lineno) {
cmd = "RESTORE"; break;
case CMD_TRAP:
cmd = "TRAP"; break;
+ /*
+ case CMD_IF:
+ cmd = "IF/THEN"; break;
+ */
case CMD_ON:
if(on_op == OP_GOSUB)
cmd = "ON/GOSUB";
@@ -107,6 +119,7 @@ CALLBACK(got_var) {
}
CALLBACK(got_exp) {
+ unsigned char last_tok = program[pos - 1];
int standalone;
if(last_cmd == CMD_ON) {
@@ -129,8 +142,12 @@ CALLBACK(got_exp) {
computed_msg(lineno);
}
break;
+ case CMD_IF:
+ if(last_tok == OP_THEN) {
+ add_lineref(lineno, fp2int(program + pos + 1));
+ }
+ break;
case CMD_ON: {
- unsigned char last_tok = program[pos - 1];
switch(last_tok) {
case OP_GOTO:
case OP_GOSUB:
diff --git a/cxrefbas.rst b/cxrefbas.rst
index b32cdb0..2bba3f7 100644
--- a/cxrefbas.rst
+++ b/cxrefbas.rst
@@ -28,6 +28,8 @@ Any command that uses a computed value for a line number will print a
warning on standard error, e.g. *GOTO A* or *GOSUB 100\*A*. Even *GOTO
100+0* is a computed value, since BASIC doesn't do constant folding.
+Line numbers above 32767, e.g. *TRAP 40000*, are not listed.
+
OPTIONS
=======