This program will allow you to place machine code that is located anywhere in memory into a data statement in line 1 of your Basic program.
Enter the program as is and SAVE it by typing GOTO 8000. RUN the program, and it will POKE the necessary data starting at 65000. If you have made a typing error, then the program will stop and indicate the line in which the error was made. Check the line and correct the error. From this point on it will only be necessary to have the code located at 65000 in order to create a 1 DATA statement.
You will then be asked to give the starting address of the machine code to be placed in line 1, followed by the length of the code. For instance, if you enter 65000 for the starting address, and 8 for the number of bytes, then line 1 will have the same contents as line 10 (except for the checksum at the end).
If there is a line 1 already present, then the program will return to basic without creating a DATA statement. This utility was adapted from John hardman and Andrew Huson‘s, 40 Best Machine Code Utilities for the ZX Spectrum (Hewson Consultants: London, 1982), pp. 96-100.
10 DATA 237,91,0,91,237,75,2,91,824
20 DATA 120,177,200,42,83,92,126,254,1094
30 DATA 0,32,6,35,126,254,1,200,654
40 DATA 43,229,197,213,151,205,238,10,1286
50 DATA 235,62,1,205,238,10,235,205,1191
60 DATA 238,10,235,205,238,10,235,62,1233
70 DATA 228,205,238,10,235,209,26,213,1364
80 DATA 14,47,12,6,100,144,48,250,621
90 DATA 128,71,121,197,205,238,10,235,1205
100 DATA 193,120,14,47,12,6,10,144,546
110 DATA 48,250,128,71,121,197,205,238,1258
120 DATA 10,193,235,120,198,48,205,238,1247
130 DATA 10,235,62,14,6,6,197,205,735
140 DATA 238,10,193,235,151,16,247,209,1299
150 DATA 229,43,43,43,26,119,225,19,747
160 DATA 193,11,120,177,40,10,197,213,961
170 DATA 62,44,205,238,10,235,24,173,991
180 DATA 62,13,205,238,10,225,1,0,754
190 DATA 0,35,35,84,93,35,35,3,320
200 DATA 126,254,14,32,12,3,3,3,447
210 DATA 3,3,35,35,35,35,35,24,205
220 DATA 237,254,13,32,233,121,18,19,927
230 DATA 120,18,201,0,0,0,0,0,339
1000 RESTORE : CLEAR 64999: LET line=0: PRINT "LOADING DATA "
1010 FOR k=65000 TO 65178 STEP 8: LET line=line+10: LET test=0
1020 FOR j=0 TO 7: READ data: LET test=test+data: POKE (k+j),data: NEXT j
1030 READ total: IF total<>test THEN PRINT FLASH 1;"Typing mistake AT LINE ";line: LIST line
1040 NEXT k
1999 REM
2000 REM Actual program follows.
2001 REM delete lines 10 TO 2001
2010 CLS : PRINT " TO PUT MACHINE CODE INTO"," DATA STATEMENT IN LINE 1"
2020 INPUT " INPUT STARTING ADDRESS OF CODE ";A: PRINT A
2025 POKE 23297,INT (A/256): POKE 23296,A-(INT (A/256))*256
2030 INPUT " INPUT NUMBER OF BYTES TO PUT IN LINE 1";A: PRINT A''' FLASH 1;"LOADING DATA INTO LINE 1"
2035 POKE 23299,INT (A/256): POKE 23298,A-(INT (A/256))*256
2040 RANDOMIZE USR 65000: CLS : LIST
7999 STOP
8000 SAVE "DATALINE1" LINE 1: SAVE "MC2DATA"CODE 65000,179: VERIFY "": VERIFY ""CODE
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.