• Aucun résultat trouvé

Katherine Myers

Dans le document 64/128 (Page 28-31)

You can save time with this short machine language rou-tine that spotlights errors in BASIC programs. A good tool

for debugging programs you've written or those you've typed in. For the Commodore 64 and 128 in 64 mode.

Your program comes to an abrupt halt and the words SYN-TAX ERROR IN 50 are on the screen. You list line 50 and study it time and again, wondering where the problem lies.

Why, with all the amazing speed and power of your com-puter, won't it show you where your error is?

I know I've spent many hours-especially when I first got my computer-staring at lines I thought were written correctly and wondering where that error was. If you've spent too much time searching for errors, this program is for you.

"Searchlight" is written in machine language (in the form of a BASIC loader) and is easy to use. Type in the program, save a copy, and run it before you load or start typing the pro-gram you'll be working on.

A Safe Section of Memory

Searchlight first asks you for the starting address so that you can locate it where it won't interfere with your program or with any other machine language utilities in memory. Since it's only 121 bytes long, it will fit in the cassette buffer. Of course, if you're using tape, this location would be inappropriate.

It's important to put the program somewhere safe in memory where BASIC can't interfere with it. Here are some suggestions for a starting address: Disk users can use 828 (the beginning of the cassette buffer) or the 4K section at 49152-53247. (Remember to allow for 121 bytes.) Also, 50000 would work, and it's easy to remember.

You can also create a protected area of memory. Before running Searchlight, follow these instructions:

• Enter

TM = PEEK(55)

+

256*PEEK(56):SA = TM -121:PRINTSA 20

• •

• •

• •

• •

• •

• •

• •

• •

• •

• •

• •

• •

BASIC PROGRAMMING UTILITIES

and write down the number that will be the starting address.

• Next, move the top of memory down with

HB = INT(SA/256):LB = SA - 256*HB:POKE55,LB:POKE56,HB:CLR Line 20 is written for the user's protection-it prevents the program from being inappropriately located (to screen RAM, for example). It also won't let you locate it in an address below 820 or in ROM.

After a location has been chosen, the loader POKEs in the data for the machine language routine and erases itself with the NEW command if all the data entered is correct. Be sure to note the location you first selected as you'll have to SYS to it.

Putting It into Action

When you wish to use Searchlight, SYS to the address you've chosen before you run your program. I usually put the SYS command in the first line of the program I'm testing so that I don't have to type it in each time. When you run a program and an error is encountered, type LIST. The line that contains the error will be listed with an arrow pointing to the appropri-ate place in the code. For example, it may be in a spot where some code is missing, to a place where you're trying to go to a nonexistent line number, and so on. If the arrow is placed in a statement that contains parentheses, check to see whether there are an equal number of open and closed parentheses. If there isn't an arrow in the statement listed, the error is at the end of the line. After Searchlight lists an erroneous statement and it is corrected, run the program again. If another error ex-ists, this, too, will be listed. Keep running it until the program is free of errors.

Anytime you use RUN/STOP-RESTORE, Searchlight will be deactivated. This feature has been programmed for user convenience-you don't have to turn off the machine or re-member any POKEs. Also, you can use Searchlight as a TRACE function by using the RUN/STOP key. Pressing RUN/STOP when a program is running will cause BREAK IN <line num-ber> to appear. Now, when you type LIST, the arrow will point to the statement that was executing when you pressed the RUN/STOP key. This can be useful in testing and debugging.

When you make a correction, be sure to delete the arrow before pressing RETURN. If you don't, the arrow will become part of the BASIC line in which it appears.

21

CHAPTER 1

Certain errors, like those encountered during an INPUT • statement (EXTRA IGNORED and REDO FROM START, for

example) will not activate Searchlight since these are user er- • rors and are not problems related to a program line. Also, the

program will not indicate errors encountered during state- • ments entered in direct mode.

This program can save you many hours of searching for errors-especially when you're dealing with long lines. You can use it for your own programs or for those you type in from books or magazines. It's especially helpful when you're typing in a program since it points to the place in the line where you need to look. You won't have to start from the be-ginning of that line when you compare your version with the printed copy.

Searchlight

For mistake-proof program entry, use "The Automatic Proofreader," Appendix B, to type in this program.

BF 10 INPUT"{CLR}STARTING ADDRESS";SA$:SA=VAL(SA$) XC 20 IFSA<8200R(SA>900ANDSA<2048)OR(SA>32643ANDSA

<49152)ORSA>53122THEN10

MP 30 FORI=SATOSA+121:READA:POKEI,A:N=N+A:NEXT EP 40 IFN<>16667THENPRINT"{CLR}ERROR IN DATA":STOP SG 50 A=INT«SA+11)/256):B=SA+11-A*256:C=INT«SA+4

6)/256):D=SA+46-C*256

EA 60 POKESA+1,B:POKESA+6,A:POKESA+34,D:POKESA+39, C

GG 70 PRINT"SYS"SA"TO USE":NEW

EA 80 DATA169,11,141,34,3,169,192,141,35,3,96,165 SE 90 DATA123,201,2,240,26,165,122,133,251,165,57,

133

XB 100 DATA181,165,58,133,182,169,0,133,183,169,46 ,141

CX 110 DATA6,3,169,192,141,7,3,76,51,243,133,252 XE 120 DATA165,183,208,18,230,183,169,145,32,210,2

55,165

EK 130 DATA181,133,20,165,182,133,21,76,167,166,16 5,183

MA 140 DATA201,1,208,9,230,183,56,165,251,229,95,1 33

XK 150 DATA253,132,254,196,253,240,13,200,200,177, 95,240

EF 160 DATA9,164,254,165,252,76,26,167,198,254,169 ,95

PH 170 DATA133,252,169,26,141,6,3,169,167,141,7,3, 208,231

22

• •

• •

• •

• •

• •

• •

,

.

• •

• •

Triple 64

Feeman Ng

Three computers in your Commodore

64?

This seven-line

Dans le document 64/128 (Page 28-31)