You can place and execute machine code (MC) in three places: REM line, memory reserved above RAMTOP, and a string.
Using a REM line lets you SAVE the code, but listing it can upset the system as it tries to interpret values not designed for display.
Using memory above RAMTOP eliminates the listing problem, but the code won’t SAVE. You must reserve the memory and reinstitute the MC each time you power up.
Using a string to store the code eliminates these disadvantages. But take care not to destroy the string variable. Also, unlike the other methods, the code’s start address does not remain constant; the system moves variables as needed to accommodate program and display space needs. So don’t use a string to execute MC if during execution, the space used by the programs or display changes.
Finding the string to execute it is no problem if the string is the first variable assignment in the program. The first assigned variable is always the first variable in the variable storage area, no matter where that area may be. To find that area, VARS, enter:
PEEK 16400+PEEK 16401*256
The string’s contents begin three bytes beyond.
This program assigns Z$, which holds the MC hex representation. Here Z$ holds two concatenated routines. The first 54 characters represent the 27 decimal codes for renumber. The rest is Syntactic Sum. Line 2 finds VARS+3. Lines 3-6 PEEK the contents of line 1, convert the character code to decimal, and POKE it into the space the Z$ assignment set aside in VARS. The decimal code occupies only half the space of Z$–check by PRINT Z$ after running–but Z$’s length doesn’t change.
RUN in FAST. It stops at line 7. GOTO 9990 to renumber the program lines by 10. It doesn’t renumber GOTOs and GOSUBs. (After renumber, Syntactic Sum is 20570.)
Renumbering does not alter program space because all line numbers are held in two bytes.
If after running the program you delete lines 1-7, remember that RUN will wipe out the code. Obviously, do not reassign Z$.
1 LET Z$="217D40110A00722373234E234623097ED676C8010A00EB09EB18EB217D40ED5B0C40DD2100007CBA20087DBB2004DDE5C1C94E0600DD092318EC"
2 LET Z=PEEK 16400+PEEK 16401*256+3
3 FOR A=16518 TO 16633 STEP 2
4 POKE Z,(PEEK A-28)*16+PEEK (A+1)-28
5 LET Z=Z+1
6 NEXT A
7 STOP
9980 RAND USR (PEEK 16400+PEEK 16401*256+3)
9981 STOP
9990 PRINT USR (PEEK 16400+PEEK 16401*256+30)
9991 STOP
SYNTACTIC SUM: 20610, 8K ROM
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.