When you want to use two or more machine language routines in one program, there’s no need to load them separately. Since each machine language routine is complete within itself, it can be placed one after another in one routine and individually called by referring to their beginning addresses. Converting machine code to hexadecimal and writing the resulting hex in a REM line makes concatenation easy. The example program contains the hex representation of the Syntactic Sum program (Jun.81) and the Renumber routine (Jun.82).
Before you typing or loading (regardless of attached memory),
POKE 16388, 198
POKE 16389, PEEK 16389-1 and NEW
to reserve memory for ML routines.
Type SAVE, RUN and write down the displayed values. The first value shown is the beginning address of the first routine (Syntactic Sum). PRINT USR that value to get Syntactic Sum. The second value represents Renumber’s starting address. RAND USR that value to renumber.
Renumber makes the first line of the program 10 and increments by 10. It does not renumber GOTO and GOSUB destinations. You must edit them individually.
In line 4, 16628 was calculated by adding 2 less than the number of characters in REM line (114) to the address 16514 (16514 is the address of the first byte of machine code in line 10). In line 5, 16576 is the number of characters in the first routine (62) added to 16514 and marks the beginning of the second routine. Number 198 in the above POKE is 256 less half the total number of characters, 58.
Line 2 gets the beginning address of the first routine and line 5 gets the second routine. Line 6 PEEKs hex from the REM line, and converts it to decimal, then POKEs it to reserved memory.
1 REM 217D40ED5B0C40DD2100007CBA20087DBB2004DDE5C1C94E0600DD092318EC217D40110A00722373234E234623097ED676C8010A00EB09EB18EB
2 LET A=PEEK 16388+PEEK 16389*256
3 PRINT A
4 FOR X=16514 TO 16628 STEP 2
5 IF X=16576 THEN PRINT A
6 POKE A,(PEEK X-28)*16+PEEK (X+1)-28
7 LET A=A+1
8 NEXT X
SYNTACTIC SUM: 14684, 8K ROM
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.