--- title: "PEEK VARS" id: 72236 type: "computer_media" slug: "peek-vars" url: "http://localhost/computer_media/peek-vars/" markdown_url: "http://localhost/computer_media/peek-vars.md" published_at: "2026-10-23T01:09:06+00:00" modified_at: "2026-10-23T01:09:06+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/10/peekvars-1.png" excerpt: "Debugging subroutine to MERGE at line 9000 that prints the BASIC program's length and key system variables, then dumps the variables area byte by byte." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Bill Jones" slug: "bill-jones" taxonomy: "indiv" url: "http://localhost/indiv/bill-jones/" genre: - name: "Programming" slug: "programming" taxonomy: "genre" url: "http://localhost/type/programming/" media_type: "Program" programmers: - name: "Bill Jones" slug: "bill-jones" taxonomy: "indiv" url: "http://localhost/indiv/bill-jones/" download_url: "https://archive.org/download/timex-sinclair-software-archive/PEEK%20VARS%20%28198x%29%28Jones%2C%20Bill%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "PEEK VARS (198x)(Jones, Bill)(TS2068)(US)(Program)/PEEK VARS (198x)(Jones, Bill)(TS2068)(US)(Program).tap" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2026/10/peekvars-1.png" article_media: - id: 21683 title: "The “PEEK VARS” Utility" type: "article" url: "http://localhost/article/the-peek-vars-utility/" media_type_tags: "Programming" --- # PEEK VARS Prints the length of the BASIC program in memory and the current values of the main system variables, then on `CONTINUE` lists every byte of the variables area as address=value. It is meant to be `MERGE`d into a program under development as a dangling subroutine at line 9000 and started with `GO TO 9000` (or `RUN 9000`, which clears the variables first). The values shown are ERR SP, LIST SP, NEWPPC, NSPPC, VARS, PROG, E LINE, WORKSP, STKBOT, STKEND, S TOP, UDG, MEMBOT, RAMTOP, P-RAMT and the TS2068’s MSTBOT. Bill Jones described the utility in “The ‘PEEK VARS’ Utility” in the TS Update newsletter. The same program is on another of the disks. ## Program Analysis The routine is seven lines, 9000–9050. The program length is worked out as VARS minus PROG, and each two-byte system variable is read as `PEEK a+256*PEEK (a+1)`. Line 9025 prints a prompt and `STOP`s; because `STOP` is the last statement on the line, `CONTINUE` resumes at line 9030, where a `FOR` loop runs from VARS to E LINE−1 printing each address and its contents. ## Notable Techniques - Placing the routine at line 9000 keeps it out of the way of most programs, so it can be `MERGE`d in, used while debugging and deleted afterwards. - Using `STOP` as a pause point lets the user choose whether to go on to the long variables dump. ## Potential Issues - The MEMBOT line reads `PEEK 23698+256+PEEK 23699`, with `+` where `*` was meant. MEMBOT is the calculator’s memory area itself rather than a pointer, so the figure is not meaningful in either form. - The program length subtracts one more byte (`VARS-1` minus PROG), so it appears to report one byte less than the program occupies. This copy came from an Oliger (JLO SAFE) disk. It needed no changes to run from tape, and it was tested in ZEsarUX with `RUN 9000`. ## Source Code ``` 9000 REM ** PEEK VARS ** 9002 BORDER 0: PAPER 0: INK 7: CLS 9004 PRINT "The BASIC Program Length is ";(PEEK 23627+256*PEEK 23628-1)-(PEEK 23635+256*PEEK 23636);" bytes"'' 9006 PRINT "System Variables:"'' 9008 PRINT "ERR SP=";PEEK 23613+256*PEEK 23614'"LIST SP=";PEEK 23615+256*PEEK 23616'"NEWPPC=";PEEK 23618+256*PEEK 23619'"NSPPC=";PEEK 23620'"VARS=";PEEK 23627+256*PEEK 23628'"PROG=";PEEK 23635+256*PEEK 23636'"E LINE=";PEEK 23641+256*PEEK 23642 9010 PRINT "WORKSP=";PEEK 23649+256*PEEK 23650';"STKBOT=";PEEK 23651+256*PEEK 23652'"STKEND=";PEEK 23653+256*PEEK 23654'"S TOP=";PEEK 23660+256*PEEK 23661'"UDG=";PEEK 23675+256*PEEK 23676'"MEMBOT=";PEEK 23698+256+PEEK 23699 9018 PRINT "RAMTOP=";PEEK 23730+256*PEEK 23731'"P-RAMT=";PEEK 23732+256*PEEK 23733'"MSTBOT=";PEEK 23744+256*PEEK 23745 9025 PRINT ''"For a VARS area Print Out, Key ": STOP 9030 FOR n=(PEEK 23627+256*PEEK 23628) TO (PEEK 23641+256*PEEK 23642-1) 9040 PRINT n;"=";PEEK n: NEXT n 9050 STOP ```