Datasave – Files Without Programs

Author(s): Ron Charlton
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v5 n8 (Volume 5, Issue 8)
Date: August 1984
Pages: 4-5

DATASAVE allows you to save a selected portion of memory to tape and then load it back again to any part of memory. Loading code with DATASAVE does not (of necessity) write over the program that you are running, so a program can load data from tape, manipulate it, and then save it back to tape.

DATASAVE’s machine code (MC) resides in the first REM. To make the REM, type listing 1 exactly as shown. Note that there are a total of 155 A’s, and the last line of REM should have four A’s.

If the Syntactic Sum checks out, RUN the program and enter the numbers from listing 2, reading left to right. When the program stops you should see a screen as in listing 3. Skip the next paragraph if the Syntactic Sum agrees with the one shown following listing 3.

If you have a wrong Syntactic Sum, add lines 1000-1040, shown in listing 4. RUN 1000 and check the data on the TV screen (ignoring the final five numbers) against listing 2. POKE as appropriate to correct data, or if you need major repairs, re-RUN the whole program. Now test for the Syntactic Sum shown at the end of listing 4.

Delete all line numbers except 1. The Syntactic Sum for line 1 is 18612. As a precaution, you may want to change the line number to 0 with POKE 16510,0. This prevents accidentally editing the REM. The POKE makes the Syntactic Sum 18611.

DATASAVE works much like the ZX/TS’s normal SAVE and LOAD: it uses ROM calls when possible. Set your recorder as you would normally for SAVE or LOAD. No “program name” is used, so none is required to SAVE data, and the first data found during LOADing will be read.

Look at listing 5 to see how you can use DATASAVE. Variable S defines the start of your memory area to SAVE or LOAD: E sets the end. After defining S and E, you SAVE data with RAND USR 16514 or LOAD data using RAND USR 16543. Change S and E as you wish. The sample in listing 5 SAVEs and LOADs the top 1024 bytes of a 16K memory. Set RAMTOP below this area.

Three error reports can occur when using DATASAVE:

    Report 2 - S or E not defined
    Report B - S or E out of range
               (0-65535)
    Report D - BREAK depressed

When you use DATASAVE its Syntactic Sum changes. Restore it to its original value with POKE 16667,0 and POKE 16668,0.

LISTING 1

   1 REM AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
10 FOR A=16514 TO 16668
20 SCROLL
30 PRINT A;
40 INPUT C
50 POKE A,C
60 PRINT " ";C
70 NEXT A
SYNTACTIC SUM: 10777, 8K ROM

LISTING 2–POKE TABLE

  0    0    205  226  64   17   203  18
  205  70   15   210  166  3    16   254
  27   122  179  32   243  205  30   3
  205  171  64   24   248  205  226  64
  205  183  64   113  205  171  64   24
  247  35   235  42   27   65   55   237
  82   235  208  225  201  14   1    219
  254  211  255  31   209  210  166  3
  213  23   23   48   242  30   148  6
  26   29   219  254  23   203  123  123
  56   245  16   245  32   4    254  86
  48   221  63   203  17   48   216  201
  205  231  2    33   25   65   205  248
  64   237  67   27   65   33   23   65
  205  248  64   197  225  201  34   22
  64   205  28   17   218  75   13   35
  237  91   28   64   205  246  25   235
  34   28   64   205  138  21   218  162
  27   194  162  27   201  56   21   42
  21   0    0    118  0    10   27   0

LISTING 3

Listing 3 - the REM after the POKEs; as LISTed
Listing 3 – the REM after the POKEs; as LISTed

LISTING 4

1000 FOR N=16514 TO 16668 STEP 8
1010 FOR K=0 TO 7
1020 PRINT TAB K*4;PEEK (N+K);
1030 NEXT K
1040 NEXT N SYNTACTIC SUM WITH LINES 1-1040:28736 8K ROM

LISTING 5 (append these to 1 REM)

   5 REM SAVE TOP 1024 BYTES
10 LET S=31744
20 LET E=32767
30 RAND USR 16514
SYNTACTIC SUM: 23055 8K ROM

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