Using RAM Packs

Authors

Edward E. Beeler

Publication

Publication Details

Volume: 4 Issue: 2

Date

March/April 1984

Pages

56-57
See all articles from SYNC v4 n2

TS1500 Plus 16K RAM

Getting the TS1500 and the TS1016 RAM pack to work properly involves a little more than plugging everything together and turning the power on. The following steps are suggested:

Plug the RAM pack in, type in:

POKE 16388,0
POKE 16389,192
NEW

These will clear everything (program lines and variables) out of the system and activate the additional 16K from addresses 32768 to 49151. This step has to be performed each time you power up.

Verify the existence of the additional RAM to make sure that everything is as it should be, e,g., connectors connected and a working RAM pack. First, enter:

PRINK (PEEK 16388+256*PEEK 16389 )-l6384)/1024

This should return a value of 32, representing 32K, It only means that 16388 and 16389 are POKEd correctly, not necessarily that you have 32K of RAM available.

To confirm the existence of our 32K of RAM, type in Listing 1 which will test all addresses from 16K-32K and print out any addresses that fail to pass the test. If you find any errors, unplug everything and start from the beginning. If the errors persist, you can assume that there is a bug in the system. If, on the other hand, everything went smoothly, you are ready to use your machine with confidence.

To better signal that the test is finished, you can add this line:

85 PRINT AT 10,15;"END TEST"

Before we get all excited about all this extra RAM, we need to keep in mind something of how the computer works:

  1. No memory exists from 8K-16K (819316383). That is rightโ€” nothing.
  2. When you write or load a program, the display file is pushed up into memory the length of the listing. This means that, if you enter a program line 10 addresses long, the display file would be moved 10 addresses up from its present address. This is done automatically as the line is entered.

The danger in this is that, if you are entering a very long program (around 16K), the display file is pushed to 32767. When this happens, the builtin memory tester will tell the computer it is out of memory , and the computer will not accept any more input of any kind, in some cases the system completely freezes so that the only option is to unplug and start over.

To keep from getting caught in this predicament, we need to keep track of the VARS file which is right behind the end of the display file. The trick here is to keep the end of the display file away from 32767. One way to do this is to enter as a program line:

PRINT 32767-PEEK 16400-256*PEEK 16401

Addresses 16400-16401 keep track of the beginning addresses of the VARS file. The above statement will let you know how many bytes are available for programming so just GOTO it from time to time. Keep in mind, 16K for programming is a lot.

Using the 16K to 32K Area

The area 16K to 32K (32678-49151) is now available for storing variables, USR routines, any stacks that are pushed up, and data storage. These suggestions will help you to take advantage of the space.

Variables and Data Storage

To store variables and data (string variables), you do not need to do much more than describe your intentions to the computer, perhaps in a program line. The machine does the rest.

To get some idea of how this works, type in Listing 2, Press CLEAR and ENTER. Type in GOTO 9910 and ENTER. Record the numbers printed on the screen. Now press RUN and ENTER. Notice the number change of E-LINE, This number changed because E-LINE follows the VARS file and the computer has automatically expanded the VARS file to accommodate the A$ just entered.

Figure 1 shows a typical screen printout. Notice that the difference between the two E-LINE values is a little more than 5000. This is because of the way the computer sets up each variable in order to find it when you so instruct it.

Review Chapter 26 of the TS 1000 manual or Appendix D of the TS15G0 manual for byte allocations.

Now EDIT line 9960 , delete the 0, and create line 9961. ENTER it, and RUN the program again. This time notice the difference in the values of the various files. Everything has been shifted to make room for the new program line. Repeat this process and notice the numbers change again. Remember that D-FILE marks the end of the program area which always starts at 16509.

USR Routines (Machine Code)

Some magazine articles suggest storing machine code above RAMTOP, If we are going to do this, we must now lower RAMTOP since previously we opened all the addresses for Basic. (The process for lowering RAMTOP is given in your manual).

To see how changing RAMTOP works, let’s re POKE 16388 and 16389 which should now contain 0 and 192 respectively. This combination equals 49152. Each decrement in 16389 is worth 256. So

POKE 16389,191

and RUN Listing 2. Notice that RAMTOP is now 48896 which is 256 less. Now let’s

POKE 16388,1

and RUN the program again. Notice that RAMTOP is increased by 1. Each value in 16388 = 1x that value, and each value in 16389 = 256x that value.

After RAMTOP has been set, all values in addresses above RAMTOP are safe from being accidentally overwritten by something in the VARS file.

We access machine code routines by the USR function which is similar to GOSUB in Basic except that GOSUB tells the computer to go to a specific line in the program while USR tells the computer to go to a specific address in memory, run through the addresses in order until a machine code return statement is encountered, and then continue executing the Basic program.

If you have wondered about those machine code routines stored in REM statement and why they are always accessed by

RAND USR 16514

enter Listing 3 and RUN it. Note in the results (Figure 2) that 16509-16510 indicate the line number; 1651 M6512, the number of bytes in the line; 16513, the REM; and 16524 (118), end of line. But 16514 to 16523 can be rePOKEd with a machine code routine. 16514 will always be the usable address after a REM statement when it is the first line of the program. (Enter CONT to see more of your program.)

The hazard of a REM statement is that you can wipe out the MC routine if you accidentally enter the line number. On the good side, you can SAVE the routine whereas you do not SAVE anything that is held above RAMTOP.

It is time to check the address shift again. Type in GOTO 100 and notice the differences.

TS1000/ZX81 Plus 64K RAM

The procedure for setting up a TS1000/ZX81 with a 64K RAM pack is similar to setting up the TS1500 with the I6K RAM pack. The steps suggested below are for the Memopak 64.

1) Before you connect the RAM pack, you must check the switch settings on the back. One switch must be on at all times, and no more than two can be on at one time. The most common switch combinations is: 2 and 3 on, 1 and 4 off. This yields the highest density of RAM. The other combinations are for different exposures of the 8K-16K area, and one is specifically for the ZX8G.

2) With the computer off, plug the pack into the computer and turn it on. Note that it takes a little time for the K cursor to appear. This is because, without doing anything else, the RAM pack has just cleared and activated 16K of RAM (1638432767). If all you wanted was 16K, you are finished.

3) If you want more RAM, you must activate the rest of the RAM. Run the following program:

POKE 16388,255 POKE 16389,255 NEW

This will clear and activate all the addresses to 65536 (64K), except, of course, ROM (0-8192). The activated addresses include 8193-16383 which are not included in any Timex or Sinclair hardware.

4) Now we must test the RAM pack. Use Listing 1 again, but change 49151 to 65535 in line 20.

Some of the same things that plague the TS1500 are also present with the 64K RAM pack. Let’s look at some of the good and bad points of the system as a whole.

1) You have available an additional 8K of RAM in the 8K-16K area which is normally not available with Timex/ Sinclair hardware. The basic system does not give access to this area; you have to use PEEKs, POKEs, and machine code, but nevertheless it is still there.

2) This 8K-16K area is a nice place to store machine code. You do not have to lower RAMTOP, You could store machine code in a REM statement, and then after your program is loaded from cassette it can be POKEd into the 8193-16383 area via a FOR-NEXT loop.

3) The problem with the display file running into 32676 still exists; however, with so much RAM it is possible to push this file beyond 32676 so larger programs are possible.

4) For data storage the 64K RAM pack is a must.

5) The same checks performed on the TS 1000/1500 by Listing 2 are applicable to the 64K RAM.

Listing 1

 10 FAST
 20 FOR J=32768 TO 49151
 30 POKE J,255
 40 LET A=PEEK J
 50 POKE J,0
 60 LET B=PEEK J
 70 IF A<>255 OR B<>0 THEN GOSUB 100
 80 NEXT J
 85 PRINT AT 10,15;"END"
100 PRINT "ERROR AT ";J
110 RETURN

Listing 2

 100 DIM A$(5000)
 110 PRINT LEN A$;"  = LEN A$"
9910 PRINT PEEK 16396+256*PEEK 16397;" = D-FILE"
9920 PRINT PEEK 16400+256*PEEK 16401;" = VARS"
9930 PRINT PEEK 16404+256*PEEK 16405;" = E-LINE"
9940 PRINT PEEK 16410+256*PEEK 16411;" = STKBOT"
9950 PRINT PEEK 16412+256*PEEK 16413;" = STKEND"
9960 PRINT PEEK 16388+256*PEEK 16389;" = RAMTOP"

Figure 1

16864 = D-FILE
17657 = VARS
17658 = E-LINE
17658 = STKBOT
17914 = STKEND
65535 = RAMTOP
5000  = LEN A$
16864 = D-FILE
17647 = VARS
22664 = E-LINE
22664 = STKBOT
22664 = STKEND
65535 = RAMTOP

Figure 2

16509  0
16510  1
16511  12
16512  0
16513  234
16514  1
16515  2
16516  3
16517  4
16518  5
16519  6
16520  7
16521  8
16522  9
16523  0

Listing 3

 1 REM 1234567890
10 FOR J=16509 TO 60000
15 PRINT J;"  ";PEEK J;TAB 12;CHR$ PEEK J
20 NEXT J

Products

 

Downloadable Media

 
Scroll to Top