RESTRINGS - Use Commodore REUs as string data storage in BASIC 1) HARDWARE REQUIREMENTS You require a C64 (or C128 in C64 mode) with a Commodore 1700, 1750 or 1764 REU (RAM Expansion Unit). 2) FEATURES The utility program RESTRINGS extends the C64 BASIC interpreter in a way that the expanded memory of 17xx REUs is used to store string data. Depending on the module used, up to 512 KByte string data memory are available, the main memory is only used for other variables and programs. Thus, large data can be processed in BASIC without complicated and inefficient disk or RAM disk access. Due to an new fast Garbage Collection the usual waiting periodes during work with a high number of strings are avoided. Therefore, using RESTRINGS can make sense even if main memory is sufficient. It can be selected, which REU memory banks are to be used. Thus, parts of the expanded memory can remain available for other purposes. 3) ACTIVATION There are two ways of loading and starting RESTRINGS. First, it can be loaded and started like a BASIC program with LOAD"RESTRINGS",8 and RUN. The number of free BASIC bytes in main and expanded memory will be displayed. Alternatively, it can be loaded from within a running BASIC program. Add the following lines at the beginning of a BASIC programs that requires RESTRINGS: 0 ifpeek(43645)=145thensys57812"restrings",8:poke780,0:poke781,0 1 ifpeek(43645)=145thenpoke782,192:sys65493:sys57633:sys49167:clr Every time the BASIC program will be executed, RESTRINGS will be loaded and activated automatically, if necessary. 4) RAM BANK SELECTION Expanded memory is divided into banks 0 to 7, each bank containing 64 KByte RAM. In a 1700 REU only banks 0 and 1, in a 1764 REU only banks 0 to 3 are implemented. With an extended CLR command the banks to be used for string data can be selected. The numbers of the first and the last bank to be used can be given as parameter. Examples: CLR ... normal CLR command CLR 0,7 ... use all banks CLR 3,4 ... use banks 3 and 4 CLR 1,1 ... use bank 1 only Be careful not to select unimplemented banks. Immediately after activation of RESTRINGS with a 1700 REU banks 0 and 1 are selected, with a 1750 or 1764 REU banks 0 to 3 are selected. Thus, in order to use the entire 1750 memory for string data, the extended CLR command is necessary. 5) MEMORY USAGE Note that only the string data, but not the string descriptors belonging to them, are stored in expanded memory. Three bytes of main memory per string are still needed. Therefore, in order to utilize the complete REU capacity, strings have to be of a certain minimum average length. Also, during execution of string functions, a certain amount of free main memory is required. Up to 765 bytes can be necessary for temporary string storage. For empty strings and strings with length 1 no expanded memory is used. For each other string LEN( string ) + 3 bytes are allocated in expanded memory. The number of free string data bytes in expanded memory can be investigated with the function USR(1). This will automatically invocate the fast garbage collection. The number of free bytes in main memory can be investigated with FRE(1) as usual. 6) SPEED Due to indirect access to the expanded memory, assignment and access to strings is a bit slower than normal. However, due to the fast garbage collection string handling is faster in the long run. With 256 KByte expanded memory selected, the garbage collection will take 7 seconds in the worst case. Normally, hardly any delay is noticable. 7) COMPATIBILITY RESTRINGS uses main memory between $A000 and $C6FC . This memory area and the memory configuration ( PEEK(1)=54 ) must not be changed by other programs. Problems are likely with programs that implement their own string handling, e.g. BASIC compilers. RESTRINGS has been developed on a C64 with a 1764 REU. 8) COPYRIGHT The program and instructions were written by Richard Hable. (EMail: Richard.Hable@jk.uni-linz.ac.at) You may distribute them freely. There is no warranty, use them at your own risk!