30.12.2013 Views

May June 1980 - Commodore Computers

May June 1980 - Commodore Computers

May June 1980 - Commodore Computers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

48 COMPUTE. MAY/JUNE. 198O <strong>1980</strong> ISSUE 4a<br />

Using The PET's Second CasseHe<br />

Using The PET's Second Cassette<br />

Buffer To Increase Available<br />

Memory Space<br />

Chuck Stuart, President<br />

CMS Software Systems, Inc.<br />

5115 Menefee Drive, Dallas, TX 75227<br />

If you have tried all the known memory savingg<br />

tricks to reduce the size of your new super program to<br />

save mankind and it still won't t fit into your PET's<br />

available able memory, you might be able to save the day<br />

by storing part pan of the program in the PET's second<br />

cassette buffer.<br />

The second cassette buffer begins at address 826<br />

and extends through address 1023. If your program<br />

does not use the second casselte cassette then you call can use<br />

thiss 197 bytes for r program storage. Granted, 197<br />

bytes may not see m like a lot of extra space, but<br />

bytes may not seem like a lot of extra space, but<br />

used correctlyy it can save you several limes times that<br />

much space in the PET's regular memory.<br />

.<br />

Suppose, forr instance, your program requires res a<br />

deck of 52 cards to be stored in memory. . Such a deck<br />

wou ld normally contain the va lues 1 through 52 a nd<br />

would normally contain the values 1 through 52 and<br />

be stored in an integer array referenced by a name<br />

like D % . Si nce each clement in an integer array re­<br />

like D%. Since each element in an integer array re<br />

quires two bytes of memory and there are 52 elements<br />

in QU ourI' array, we can sec see that, al, s[O stored rc ci as a normal<br />

integer r array, our cleck deck of cards would require 104<br />

bytes of storage space plus atl least another 7 bytes<br />

and probably more to properly di mension the array.<br />

and probably more to properly dimension the array.<br />

Since no array clement element value exceeds 255, this<br />

array could easily be stored in the second cassette<br />

buffer with each element requiring only one byte fo r<br />

buffer with each element requiring only one byte for<br />

slOrage storage. . By moving g our deck of cards inlO into the<br />

second cassette buffer we have saved a minimum<br />

of 111 bytes of main memory while e using only 52<br />

bytes of the 197 available able to us in the second cassette<br />

buffer. T hi s same method works equally well for single<br />

buffer. This same method works equally well for single<br />

clement integer variables and strings.<br />

If you simply usc use this extra space for temporary<br />

storage of information during program operation then<br />

no special problems are crea ted. If yo u make full<br />

no special problems are created. If you make full<br />

usc use off the second cassette buffer for permanent<br />

storage of program data such as operator prompts,<br />

suit symbols for your card deck, orr other values<br />

normally stored in DATA Slalements, statements, etc., then the<br />

second cassette bu ffer must be stored along with the<br />

second cassette buffer must be stored along with the<br />

main program. Since the SAVE command begins<br />

s<br />

savingg att locationn 1024, any data stored below that<br />

address in the second cassette buffer would not be<br />

saved by using the standard SAVE command.<br />

Fortunately by us ing the PET's built-in ROM<br />

Fortunately by using the PET's built-in ROM<br />

Monitor o r wee can specify the exact beginning and ending<br />

addresses we want to save. If you still have the<br />

old ROM set without a Monitor don'tt panic. I I'll ' show you how to save the buffe r a li ttle later.<br />

show you how to save the buffer a little later.<br />

The first thing you have to do is determine thee<br />

address range you want to save in hexidedmal. idecimal. As<br />

we pointed Out out bcfore, before, the second cassette buffer<br />

begins al location 826 decimal or 033A in hex so we<br />

begins at location 826 decimal or 033A in hex so we<br />

know that we want to start saving at location<br />

033 A hex . To determine the ending address yo u must<br />

033A hex. To determine the ending address you must<br />

first save your program onto tape using g the normal<br />

SAVE command, and then load it back into memory<br />

with the LOAD command. . Data stored in the second<br />

cassette buffer will not be affected by this operation.<br />

Now type PRI NT PE EK( 43)'256 + PEEK(42). The<br />

Now type PRINT PEEK(43)*256 + PEEK(42). The<br />

answer you get willw be thc the address in decimal where<br />

your program ends and which you must now convert<br />

to hex. (If you've never taken the e time to LO learn how<br />

to 1O convert decimal to hex and vice versa because<br />

you figured you wouldd never need to know then you<br />

were wrong.)<br />

Now that you know the memory range you want<br />

to save, enter the Monitor by typing SYS1024 aand<br />

pressin g RETURN. To save your program including<br />

pressing RETURN. To save your program including<br />

the data slO stored in the second cassette buffer, type<br />

the following g line exactly, substitutingg the eending<br />

address for XXXX and filling ing in your own program<br />

name, and press RETURN:<br />

S ""PROGRAM NAME",01,033A,XXXX<br />

NAME",OI ,033A,XXXX<br />

PET will di splay the slandard PRESS PLA Y AND<br />

PET will display the standard PRESS PLAY AND<br />

RECORD message aand then save your program onn<br />

tape in the normal manner except it will begin<br />

saving at location n 826 instead of the usual<br />

location 1024 where you r BASIC program begin s.<br />

location 1024 where your BASIC program begins.<br />

You can LOAD aand use usc thee program ra m in the normal<br />

manner except that you must always use the Monitor<br />

to save the program or else you will lose any data<br />

slOred stored in the second cassette buffer. This means that<br />

no one else will be able to copy you r program un less<br />

no one else will be able to copy your program unless<br />

they know the secret. There is one other thing to<br />

remember. If you make any changes to your program ,<br />

remember. If you make any changes to your program,<br />

don't forget 1O to redetermine the new ending address<br />

before using the Monitor to resave the e program.<br />

If you have the old ROM set wilhoul a Monitor<br />

If you have the old ROM set without a Monitor<br />

then you can accomplish the same result resuh in the<br />

followingg manner:<br />

A) Save the program with the SAVE command<br />

and then reload it with the LOAD command.<br />

B) Type POKE247,58:POKE248,3 POKE248,3 and press<br />

RETURN.<br />

C) Type SYS63153 and press RETURN.<br />

PET will display the standard PRESS PLAY AND<br />

RECORD message and save the progra m beginn in g<br />

RECORD message and save the program beginning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!