CK Type 1000

Author(s): Earl Dunnington
Pub Details: Time Designs Magazine v4 n2 (Volume 4, Issue 2)
Date: January/February 1988
Pages: 21-22

My thanks to Stan Lemke for giving me permission to use his CK TYPE program that I have modified for the smaller Sinclair computers. This gives me the opportunity to present a very practical program, illustrating the use of some of the things covered in my recent “Your RAM Memory” series, and to dispel the myth that only line numbers from 1 to 9999 can be used in Timex Sinclair computers.

Three different versions of the program will be presented. Two BASIC versions, one using line numbers less than 10000, and one using line numbers 10000 and over. Due to the space required, a Machine Code version, compiled from BASIC will be presented in the next episode.

The BASIC versions require at least 2K RAM, and the MC version at least 16K RAM, and the 2040 printer. This program will help in debugging programs typed in from listings if the author has provided a CK TYPE listing made with this or a similar program.

At this point, please read paragraphs 1 to 5 and 8 of Stan’s CK TYPE article on page 13 of the MAY/JUNE ’87 issue of TIME DESIGNS.

Continuing Stan’s illustration labeling, Listing “E” is his CK TYPE program in BASIC as modified for the TS1000/1500. If you do not have “The ZX Compiler” (copyright 1983, Bob Berch, Cinagro Software, 155 Seventh St., Rochester, NY 14609), delete line 9999, as this is for use by the compiler. The variable names had to be changed as the compiler allows only two letters, or one letter and a number designations. I chose to use the first and last letters of the variable names as assigned by Stan. Those readers who do have the compiler should delete line 9996, as there is no way of continuing the MC program after the screen is filled and you get an error 5/ report (without rewriting the program). Those readers who do not have the compiler should go to the next paragraph without typing in Listing “E”. Those who chose to type in this listing should save it to tape with the direct command: SAVE “CKTYPE” then press ENTER. RUN the program in the FAST mode. You should get a listing on the screen and on the printer that agrees with Listing “F”.

Many authors have stated that you can only use line numbers from 1 to 9999. This is partially correct, as when typing a program into the computer, the syntax check will only allow the use of these line numbers. By POKEing the first two bytes of a program line that has been stored (High Byte then Low Byte) you can change the original line numbers. See the diagram of how each program line is stored on page 128 of the ZX81/TS1000 and page 155 of the TS1500 User Manuals. There are some restrictions on the use of line numbers, higher than 9999, by this method. I will cover these in my article on the Program Area of the BASIC system at a later date. Once changed to a line number greater than 9999, the line cannot be edited nor can you delete it without POKEing the line number back to 9999 or lower. The reason for changing line numbers, is so that they will not interfere with the line numbers of the program to be typed in from a listing.

Listing “G” is the program used to produce the final CK TYPE 1000 program in BASIC. In order to save memory, line 9999 was deleted and lines 9980 to 9998 of Listing “F” was revised using the program “KRUNCHER 1000” (copyright S&K Software, from RMG Enterprises, 1419 1/2 7th St., Oregon City, OR 97045):

1. Type in Listing “G”.

2. Using the direct command: GOTO 9980 operate the program. A CK TYPE listing will be displayed on the screen. When the screen is filled you will get a 5/ error report and the printer, if connected will stop.

3. Check the display or the printout against Listing “H”.

4. Press the C key and then press ENTER. The remainder of the listing will be displayed and printed if the printer is on.

5. Check against the rest of Listing “H”.

6. After making any corrections, change the 9983 in line 9998 to 10003.

7. Operate lines 10 to 100 of the program by using the direct command: RUN.

8. Delete lines 10 to 100 and LLIST or LIST the program. It should agree with Listing “I”.

9. RUN the program and you should get a CK TYPE listing that agrees with Listing “J”.

10. Press CLEAR and ENTER. Save the program on tape using the direct command: SAVE “CKTYPE”

11. Determine the total number of bytes in the program area by using the direct command: PRINT (PEEK 16396+256*PEEK 16397)-16509 Then press ENTER. The result should be 359. This value will be used when deleting the CK TYPE program lines and should be permanently recorded.

You now have the final BASIC version of CK TYPE 1000 on tape. You must load it before typing a published program listing that has a check type listing included with it. Do not use line number 9999, as it will be used to delete the CK TYPE program lines. If you do not wish to delete those lines, you may have to use that line for a STOP. Once you have typed in a program listing, you can obtain a CK TYPE listing by using the direct command: GOTO 1000 If the listing stops because of a full screen, press the CONT (C key), then press ENTER.

To delete the CK TYPE lines you must determine the address of the second byte of the start of these program lines. As you found before, these lines occupy 359 bytes. If we subtract 358 bytes from the address contained in the system variable D_FILE this will give you the address of the second byte of the first line of the CK TYPE program lines. Type the following direct command: PRINT (PEEK 16396+256*PEEK 16397)-358 Then press ENTER. POKE this address with 15 (decimal). This will change the line number from 10000 to 9999. Now you can delete this line. Continue POKEing 15 to the same address and delete the rest of the lines.

If you have a program on tape and wish to make a CK TYPE listing for it, you must have a “MERGE” utility program, the compiled version loaded above RAMTOP, or type in the CK TYPE program from the listing. If the line numbers will not conflict, this would be easier to do from Listing “E”, after deleting lines 9996 and 9999.

We will continue this discussion in the next issue of TDM.

LISTING E

9980 LET ST=16509
9981 LET SP=256*PEEK 16397+PEEK
16396
9982 LET BT=ST
9983 LET LE=0
9984 LET LH=0
9985 LET SM=0
9986 LET LE=256*PEEK BT+PEEK (BT
+1)
9987 LET BT=BT+2
9988 LET LH=256*PEEK (BT+1)+PEEK
BT
9989 LET BT=BT+2
9990 LET OD=1
9991 FOR I=1 TO LH
9992 LET SM=(SM+OD+1)+PEEK BT
9993 LET OD=NOT OD
9994 LET BT=BT+1
9995 NEXT I
9996 PRINT LE;TAB 6;": ";LH;TAB
13;": ";SM
9997 LPRINT LE;TAB 6;": ";LH;TAB
13;": ";SM
9998 IF BT<SP THEN GOTO 9983
9999 RETURN

LISTING F

9980  : 16   : 1196
9981  : 40   : 2293
9982  : 7    : 599
9983  : 12   : 642
9984  : 12   : 645
9985  : 12   : 657
9986  : 32   : 1874
9987  : 15   : 901
9988  : 32   : 1877
9989  : 15   : 901
9990  : 12   : 774
9991  : 14   : 1041
9992  : 24   : 1407
9993  : 8    : 792
9994  : 15   : 899
9995  : 3    : 412
9996  : 39   : 2076
9997  : 39   : 2056
9998  : 19   : 1767
9999  : 2    : 375

LISTING G

  10 LET START=(256*PEEK 16397+P
EEK 16396)-2
20 LET HIGHBYTE=39
30 LET LOWBYTE=34
40 FOR N=START TO START-358 ST
EP -1
50 IF PEEK N<>118 THEN GOTO 90
60 POKE N+1,HIGHBYTE
70 POKE N+2,LOWBYTE
80 LET LOWBYTE=LOWBYTE-1
90 NEXT N
100 STOP
9980 LET ST=VAL "16509"
9981 LET SP=VAL "256"*PEEK VAL "
16397"+PEEK VAL "16396"
9982 LET BT=ST
9983 LET LE=NOT PI
9984 LET LH=NOT PI
9985 LET SM=NOT PI
9986 LET LE=VAL "256"*PEEK BT+PE
EK (BT+SGN PI)
9987 LET BT=BT+VAL "2"
9988 LET LH=VAL "256"*PEEK (BT+S
GN PI)+PEEK BT
9989 LET BT=BT+VAL "2"
9990 LET OD=SGN PI
9991 FOR I=SGN PI TO LH
9992 LET SM=(SM+OD+SGN PI)+PEEK
BT
9993 LET OD=NOT OD
9994 LET BT=BT+SGN PI
9995 NEXT I
9996 PRINT LE;TAB VAL "6";": ";L
H;TAB VAL "13";": ";SM
9997 LPRINT LE;TAB VAL "6";": ";
LH;TAB VAL "13";": ";SM
9998 IF BT<SP THEN GOTO VAL "998
3"

LISTING H

10    : 53   : 2808
20    : 19   : 1144
30    : 18   : 1098
40    : 34   : 2190
50    : 24   : 2186
60    : 20   : 1154
70    : 19   : 1136
80    : 25   : 1445
90    : 3    : 417
100   : 2    : 348
9980  : 13   : 892
9981  : 31   : 2086
9982  : 7    : 599
9983  : 7    : 762
9984  : 7    : 765
9985  : 7    : 777
9986  : 24   : 1809
9987  : 12   : 859
9988  : 24   : 1812
9989  : 12   : 859
9990  : 7    : 758
9991
9991  : 9    : 1025
9992  : 19   : 1391
9993  : 8    : 792
9994  : 10   : 882
9995  : 3    : 412
9996  : 33   : 1846
9997  : 33   : 1826
9998  : 16   : 1434

LISTING I

A000 LET ST=VAL "16509"
A001 LET SP=VAL "256"*PEEK VAL "
16397"+PEEK VAL "16396"
A002 LET BT=ST
A003 LET LE=NOT PI
A004 LET LH=NOT PI
A005 LET SM=NOT PI
A006 LET LE=VAL "256"*PEEK BT+PE
EK (BT+SGN PI)
A007 LET BT=BT+VAL "2"
A008 LET LH=VAL "256"*PEEK (BT+S
GN PI)+PEEK BT
A009 LET BT=BT+VAL "2"
A010 LET OD=SGN PI
A011 FOR I=SGN PI TO LH
A012 LET SM=(SM+OD+SGN PI)+PEEK
BT
A013 LET OD=NOT OD
A014 LET BT=BT+SGN PI
A015 NEXT I
A016 PRINT LE;TAB VAL "6";": ";L
H;TAB VAL "13";": ";SM
A017 LPRINT LE;TAB VAL "6";": ";
LH;TAB VAL "13";": ";SM
A018 IF BT<SP THEN GOTO VAL "100
03"

LISTING J

10000 : 13   : 892
10001 : 31   : 2086
10002 : 7    : 599
10003 : 7    : 762
10004 : 7    : 765
10005 : 7    : 777
10006 : 24   : 1809
10007 : 12   : 859
10008 : 24   : 1812
10009 : 12   : 859
10010 : 7    : 758
10011 : 9    : 1025
10012 : 19   : 1391
10013 : 8    : 792
10014 : 10   : 882
10015 : 3    : 412
10016 : 33   : 1846
10017 : 33   : 1826
10018 : 17   : 1439

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.