diff options
author | B. Watson <urchlay@slackware.uk> | 2024-06-17 17:05:51 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-06-17 17:05:51 -0400 |
commit | 2a73f95e7204ded74409adc03eeac62868e3500f (patch) | |
tree | 6887a9803e4421df99c41fc1d7e8a13f2cd036ac | |
parent | ed910cdfa474bd7a3fd0cf3082119abc41b094e4 (diff) | |
download | bw-atari8-tools-2a73f95e7204ded74409adc03eeac62868e3500f.tar.gz |
cxrefbas: handle IF <x> THEN <lineno>.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | bas.h | 1 | ||||
-rw-r--r-- | cxrefbas.1 | 4 | ||||
-rw-r--r-- | cxrefbas.c | 19 | ||||
-rw-r--r-- | cxrefbas.rst | 2 |
5 files changed, 25 insertions, 3 deletions
@@ -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 @@ -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 @@ -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 @@ -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 ======= |