When working with machine code in USR routines, you need a convenient way to check and edit it. Add this program to the end of another program with MC subroutines. It lets you easily look at any address in memory, leave it alone or change its contents, and automatically go to the next address. On request it returns to the previous address.
Because the routine uses INKEY$ for data entry, run it in SLOW. This method also lets it interpret each character as typed instead of waiting for ENTER.
Give the program a starting address. It prints that address and its contents. To change the contents, enter a one- to three-digit decimal value. If you enter three digits, the computer goes on; if fewer, press ENTER to continue. Leave the contents unchanged by pressing ENTER. Go back to the previous address by pressing /. I find the / character convenient on my keyboard, but you can change line 9565 to check for a more convenient key.
Stop the program anytime by pressing BREAK. You can then run it again with another address.
9500 PRINT "ADDRESS"
9510 INPUT ADR
9515 SCROLL
9520 PRINT ADR;" ";PEEK ADR;" ";
9525 LET NEW=0
9530 FOR I=1 TO 3
9535 IF INKEY$<>"" THEN GOTO 9535
9536 IF INKEY$="" THEN GOTO 9536
9540 LET X$=INKEY$
9550 IF X$=CHR$ 118 AND I=1 THEN GOTO 9610
9560 IF X$=CHR$ 118 THEN GOTO 9600
9565 IF X$="/" THEN GOTO 9640
9566 PRINT X$;
9570 LET NEW=NEW*10+VAL X$
9580 NEXT I
9600 POKE ADR,NEW
9610 SCROLL
9620 LET ADR=ADR+1
9630 GOTO 9520
9640 SCROLL
9650 LET ADR=ADR-1
9960 GOTO 9520
SYNTACTIC SUM: 25094, 8K ROM
If you prefer to enter and see data as two-digit hex numbers, substitute the following lines:
9520 PRINT ADR;" ";CHR$ (INT ((PEEK ADR)/16+28));CHR$ ((PEEK ADR)-16*INT ((PEEK ADR)/16)+28);" -";
9530 FOR I=1 TO 2
9570 LET NEW=NEW*16+CODE X$-28
NEW SYNTACTIC SUM: 29259
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.