63-64

From C64-Wiki
Jump to navigationJump to search

The addresses 63-64 (hexadecimal $3F–40) contains the line number of the BASIC line from which DATA was last READ, with the first address holding the least significant byte, and the last one the most significant byte.

This is sometimes used in conjunction with checksum schemes in machine code "type-ins": Checks are performed on a DATA-line-by-DATA-line basis, and in case of errors, addresses 63 and 64 are used to obtain the line number of the "error-ridden" DATA statement.

Here is an example demonstrating how to obtain the line number:

10 read i$
20 print i$;" (read from line";
30 print peek(63)+256*peek(64)chr$(157)")"
40 if i$<>"end" then 10
50 data This,is
300 data a,test,of
1000 data addresses,63
50000 data and,64
50010 data end

Starting the program with run leads to the following output:

This (read from line 50)
is (read from line 50)
a (read from line 300)
test (read from line 300)
of (read from line 300)
addresses (read from line 1000)
63 (read from line 1000)
and (read from line 50000)
64 (read from line 50000)
end (read from line 50010)
ready.

Note that it is not possible to "dictate" where to READ the DATA solely by POKEing the desired line numbers into addresses 63 and 64; this also requires manipulation of addresses 65–66/$41–42.