MC-DATA

by Kevin Gale



Kevin Gale's got a bit of a reputation in programming circles for

writing corking utility programs. At least, he has now - here's a

little something he knocked up for converting blocks of machine code

into DATA statements to slip into your Basic programs with the minimum

of effort. Now there was actually something a bit like this in Pitstop

a few years ago, but that was a few years ago. Besides, this version's

a lot more straightforward.



So what are we actually wobbling on about here? Well, you know how

sometimes you're typing in a program from Pitstop and you come across

a huge load of lines that are just DATA statements with lots of

numbers in? (Interesting Fact No 1: there are lots of these in

MC-DATA.) Well, actually these tend to be machine code routines in

disguise, and this program makes the process of 'disguising' the

machine code (as it were) a lot simpler. (Interesting Fact No 2: the

MC-DATA listing on this page was actually created using itself, if you

see what I mean.) All you need to do is tell the program the

whereabouts of the code in memory and how you'd like it all laid out

and it'll take care of everything else. This makes things easier not

only for you, but also for Pitstop readers (erm, and me) - if you run

your programs through this before you send them in it saves us all

from having to worry about hex dumps and other such horrors.



How does it work, then? Well, I won't bother simplifying things too

much as the program's only really going to be any use to techies. All

you've go to do is type in the First Listing (look - no hex) and save

it. When you run it, MC-DATA will be installed at address 60000. You

may need to change this if it clashes with your own program. Then you

need to set up the following variables ...



xx+54-55, start address of code

xx+60-61, length of code

xx+43-44, start line of Basic

xx+49, step of line numbers

xx+66, bytes per line (1-50)

xx+71, flags



... where xx is the start address of MC-DATA. If you want checksums to

be generated at the end of each line set 'flags' to 1, otherwise set

it to 0. Then RANDOMIZE USR 60000 and you're away.



Alternatively there's an easier way of doing this. Type in the Second

Listing, and enter numbers when requested, and it'll sort out

everything for you.



All that remains is to tag on a short routine to convert all the DATA

back into machine code and you're there. This is a doddle if you

haven't selected the checksum option - just set up a loop that reads

in all the numbers and POKEs them into memory. Otherwise you'll need

to keep a running total on each line and compare it with the checksum

at the end. This is a bit more complicated, but will save hours of

frustration for people typing the program back in.

