Mike’s Notebook: MKDATA

Author(s): Michael DiRienzo
Publication: The Plotter
Pub Details: The Plotter v8 n10 (Volume 8, Issue 10)
Date: October 1990
Pages: 3-4

(NOTE: REPRINTING OR REPRODUCING THIS COLUMN WITHOUT THE EXPRESSED WRITTEN PERMISSION OF THE AUTHOR IS HEREBY PROHIBITED. FOR PERMISSION, WRITE THE AUTHOR IN CARE OF THIS PUBLICATION.)

One of the “must have” utilities that any self respecting software “hacker” needs in his/her arsenal of tools is a DATA line maker. Although there are several available,especially for the Spectrum ROM, my favorite one appeared in the May 1988 Newsletter of the Capital Area Timex Sinclair Users Group by H.E. Weppler. I have simplified it and moved the CODE to a safe area below BASIC.

This program performs the opposite of POKing CODE into RAM addresses from a DATA line. It will create a user specified DATA line containing CODE extracted from a user specified range of addresses. For example, if you have some machine code, font code, or an ASCII text file located somewhere in memory, and would like to extract the code and place it into DATA statements to use in another program, this simple program can be MERGEd or LOADED to do the job. Enter the following BASIC program and be sure to RUN line 9950 to initialize the short machine code. The program will then automatically RUN. You will be prompted for a line number to assign the DATA statement. Any line number will do if it is less than 9900. Next INPUT the starting address of the CODE you wish to extract. Lastly you will be prompted for the end address of the range of bytes you want to extract. I recommend that you don’t extract more than 150 bytes at any one time. If you do, editing that DATA line will be difficult. If your CODE is more than 150 bytes long then keep track of the line numbers and address ranges and RUN line 9900 until you have all your CODE placed into BASIC lines. The machine code used in this program is completely relocatable.

To quickly see how this program works, try this: RUN line 9900. At the prompt, enter 10 (ENTER). That means we want to make a DATA statement at line 10. The next prompt asks you to enter the starting address of the CODE. Lets extract the CODE from this program which begins at address 24311, so input that number. Next, INPUT the end address of the range of addresses we are extracting, ie. 24352 (ENTER). Now you’re done. Compare your result with line 9965. If your CODE is lengthy, break it down into several DATA statements by re-RUNning line 9900 several times. Have fun!

Happy TIMEXing…

“MKDATA” By Michael J. Di Rienzo

9900 INPUT "Input Line # to put DATA (<9900)";LL
9910 INPUT "Input CODE Start address ";SS
9915 INPUT "Input CODE End address ";EE
9920 LET R$=STR$ LL+CHR$ 228
9925 FOR N=SS TO EE
9930 LET R$=R$+STR$ PEEK N+","
9935 NEXT N: LET R$=R$( TO LEN R$-1)
9940 RANDOMIZE USR 24311
9945 STOP
9950 FOR N=24311 TO 24352
9955 READ M: POKE N,M: NEXT N
9960 RUN
9965 DATA 33,19,0,9,229,229,42,97,92,43,43,205,99,19,14,82,205,187,44,35,78,35,70,35,229,197,42,89,92,229,205,187,18,209,193,225,237,176,205,58,14,201
9999 SAVE "MKDATA" LINE 9950

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.