REM lines can be used to store machine code so that it can be SAVEd/LOADed as part of a BASIC program. The only problem is that you have to enter as many chars. in the REM line as the number of bytes used in the MC. Not bad if it’s a short routine but a real bear if the code is several hundred bytes long. This routine will generate a REM statement of any length, for any line number.
Since this program uses machine code that is stored in a REM line, the first thing to do is create line 1, REM, 63 chars.
001 REM (63 chars)
010 FOR N=16514 TO 16576
030 INPUT A
040 PRINT A;" ";
050 NEXT N
RUN and enter the following numbers:
205 35 15 42 10 64 229 205 216 9 43 237 75 50 64 3 3 197 3 3 3 3 205 158 9 193 209 35 35 114 35 115 35 113 35 112 35 54 234 11 11 35 54 0 120 177 32 248 54 117 52 42 12 64 34 41 64 213 205 43 15 193 201
Check the numbers on the screen against the listing. If the numbers are correct then change the program with the following lines:
001 REM - (MC gibberish)
010 REM USE IN IMMEDIATE MODE
020 REM (LINE #)
030 REM RAND (# OF BYTES)
040 REM LIST USR 16415 (32600)
SAVE the program at this point.
If you want to generate a line #1 REM you will have to move the MC. Use this program to move it to high ram.
050 POKE 16388,88
060 POKE 16389,127
070 FOR N=16514 TO 16576
080 POKE (N+16086),PEEK N
090 NEXT N
Lines 50 & 60 reset RAMTOP to protect the MC.
Now, for the explanation. Say that you want line 32 to be a REM statement with 100 bytes in it. Type the following, in immediate mode, pressing ENTER after each:
32 (ENTER)
RAND 100 (ENTER)
LIST USR 16514 (or 32600)
The routine will insert line 25 REM into the program and LIST it.
WARNING: ALWAYS make sure that there is another line, with a higher line number, with your generated REM – or the program will crash. It has something to do with trying to list a MC REM if it is the last line.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.