MC Converter



Ed Corteen,

Westbury,

Wiltshire.



This program is designed to convert machine code into data

statements which are then ready for publication. I have

used the method used by Ian Briscoe in his Windos program.

  To use the program simply type it into your Spectrum,

altering the program to suit. The addition of the Inter-

face 1 and Microdrives alters the base address of Basic, so

use LET poke=23761 for non-Microdrive users and LET poke=

23819 if the Microdrives are fitted. [In fact, there are

some other reasons for the start of Basic to move, so I've

changed the relevant program lines to read the PROG system

variable. If you want to change them back to the hard-coded

values, they're lines 8055 and 8100. Note that line 8500

still refers to a hard-coded value for the IF1-attached

case; this means that if you use an IF1 _and_ change the

start of Basic in other ways as well, the program will not

load from Microdrive, but this is at least safe.]

  The program as listed is self-explanatory. Run the

program and you will be presented with the menu. If your

program is a long one it is probably best if you use option

3 first to ensure you don't run out of memory when using

EDIT to enter copies of line 1000.

  Once the program has been run, always use GO TO g to run.

Now use option 1 to initialise the variables. Use EDIT to

enter copies of line 1000. Use a line interval of 10.

  Next use option 2 to check that you have entered enough

copies.

  Now we come to the interesting part. If you look in the

manual on page 166, you will see how the lines of Basic are

organised. We know the address and length of each line -

119 bytes. Option 4 will read the machine code, convert it

to hex notation, and POKE the code into each line. At the

same time it calculates the checksum, and this is POKEd in

at the end of the line. Using EDIT to enter copies of line

1000 reserves space at the correct address for your machine

code.

  This process is quite slow, being Basic. It takes about

40 seconds per line. Clever machine-code programmers can

convert this. [So can Basic programmers - see the REMs.]

  Once the code has been POKEd into each line, it can be

checked with option 5. [Which doesn't work as is, and is

somewhat harder to remedy in Basic. A workaround is easy,

though. A clue is in the value of the checksum read from

the DATA statements.] To publish your masterpiece, simply

send off the data lines with the loader program (lines 7200

to 7630) plus any extra Basic lines required. And there you

have it - all the hours spent converting and checking your

code have been overcome.

  The data lines, once "decompiled", can now be anywhere in

your completed program. But remember: they must be at the

beginning of your program while they are being converted.

If they aren't, you will end up with some very strange

looking lines - or more likely a crash!