Classic Computer Magazine Archive COMPUTE! ISSUE 67 / DECEMBER 1985 / PAGE 74

The New MLX

Enhanced Machine Language Editor For The commodore 64

Ottis R, Cowper, Technical Editor

This significantly improved version of computers "MLX" utility will help you enter machine language program listings without typos. It's more fool-proof than the old MLX and is easier to use, too—especially for beginners. The new MLX is required to enter all machine language programs published in COMPUTE! for the Commodore 64, starting with "Balloon Crazy" in this issue.

Since its initial publication in the December 1983 issue of COMPUTE!, our "MLX" machine language editor has helped thousands of readers type in dozens of ML programs with a minimum of problems. MLX detects most common typing mistakes as they're made. However, your growing appetite for high-quality programs is leading us to publish longer and longer listings. Such programs demand a more efficient entry system, so this month we're introducing a new MLX with important enhancements:

  • A much more compact format. With each line of a new MLX listing, you enter eight bytes of data with 18 keystrokes, as opposed to only six bytes of data in 21 keystrokes when using the original MLX. This means you can enter machine language programs with 40 percent less typing.
  • A more sophisticated checksum scheme. Transposition errors that could slip past the original MLX are caught by this version. Typing mistakes are now virtually impossible.
  • A buffer (reserved area of memory) that holds the data you enter instead of direct storage in memory. This means that you'll never again have to worry with those bothersome POKEs that were sometimes necessary to reconfigure memory before using the old MLX.

Hexadecimal Checksums

Type in and save a copy of the new MLX. You'll need it for all future machine language programs in COMPUTE!, as well as ML programs in our companion magazine, COMPUTE!'s GAZETTE, and COMPUTE! books.

When you're ready to enter an ML program, load and run the new MLX. It asks you for a starting address and ending address. These addresses appear in the article accompanying the MLX-format program listing you're typing. If you're unfamiliar with machine language, the addresses (and all other values you enter in MLX) may appear strange. Instead of the usual decimal numbers you're accustomed to, these numbers are in hexadecimal— a base 16 numbering system commonly used by ML programmers. Hexadecimal—hex for short—includes the numerals 0–9 and the letters A–F. But don't worry—even if you know nothing about ML or hex, you should have no trouble using the new MLX.

After you enter the starting and ending addresses, MLX offers the option of clearing the workspace. Choose this option if you're starting to enter a new listing. If you're continuing a listing that's partially typed from a previous session, don't choose this option.

It's not necessary to know more about this option to use MLX, but here's an explanation if you're interested: When you first run MLX, the workspace area contains random values. Clearing the workspace fills it with zeros. This makes it easier to find where you left off if you enter the listing in multiple sittings. However, clearing the workspace is useful only before you first begin entering a listing; there's no need to clear it before you reload to continue entering a partially typed listing. When you save your work with the new MLX, it stores the entire contents of the data buffer. If you clear the workspace before starting, the incomplete portion of the listing is filled with zeros when saved and thus refilled with zeros when reloaded. If you don't clear the workspace when first starting, the incomplete portion of the listing is filled with random data. Whether or not you clear the workspace before you reload, this random data will refill the unfinished part of the listing when you load your previous work. The rule, then, is to use the clear workspace feature before you begin entering data from a listing, and not bother with it afterward.

At this point, MLX presents a menu of commands:

Enter data

Display data

Load data

Save file

Quit

You no longer have to remember SHIFT command keys as in the original MLX. Instead, just press the letter of a menu option. These commands are available only while the menu is displayed. You can get back to the menu from most options by pressing RETURN with no other input.

Entering A Listing

To begin entering data, press E. You'll be asked for the address at which you wish to begin entering data. (If you pressed E by mistake, you can return to the command menu by pressing RETURN.) When you begin typing a listing, you should enter the starting address here. If you're typing in a long listing in multiple sittings, you should enter the address where you left off typing at the end of the previous session. In any case, make sure the address you enter corresponds to the address of a line in the MLX listing. Otherwise, you'll be unable to enter the data correctly.

After you enter the address, you'll see that address appear as a prompt with a nonblinking cursor. Now you're ready to enter data.

To help prevent typing mistakes, only a few keys are active while you're entering data, so you may have to unlearn some habits. The new MLX listings consist of nine columns of two-digit numbers—eight bytes of data and a checksum:

C000:A9 0C 8D 15 D0 A9 FF 8D 17
C008:3B 63 8D 3C 63 A9 01 8D C6
C010:01 58 A9 00 8D 33 63 20 7D
C018:0B C5 20 Cl CB A9 FF 8D 43

You do not type spaces between the columns; the new MLX automatically inserts these for you.

You do not press RETURN after typing the last number in a line; the new MLX automatically enters and checks the line after you type the last digit. The only keys you need for data entry are 0–9 and A–F. Pressing most of the other keys generates a warning buzz.

To correct typing mistakes before finishing a line, use the INST/DEL key to delete the character to the left of the cursor. (The cursor-left key also deletes.) If you mess up a line really badly, press CLR/HOME to start the line over.

The RETURN key also is active, but only before any data is typed on a line. Pressing RETURN at this point returns you to the command menu. After you type a character of data, the new MLX disables RETURN until the cursor returns to the start of a line. Remember, you can press CLR/HOME to quickly get to a line number prompt.

Beep Or Buzz?

After you type the last digit in a line, MLX calculates a checksum of the line number and the first eight columns of data, then compares it with the value in the ninth column. The formula (found in lines 370–390 of the MLX program) catches almost every conceivable typing error, including the transposition of entire numbers that the original MLX could miss. If the values match, you'll hear a pleasant beep, the data is added to the workspace area, and the prompt for the next line of data appears (unless the line just entered was the last line of the listing—in which case you'll automatically advance to the Save option). But if MLX detects a typing error, you'll hear a low buzz and see an error message. Then MLX redisplays the line for editing.

To edit a line, move the cursor left and right using the normal cursor controls. (The INST/DEL key now works as an alternative cursor-left key.) You cannot move left beyond the first character in the line. If you try to move beyond the right­most character, you'll reenter the line.

To make corrections in a mistyped line, compare the line on the screen with the one printed in the listing, then move the cursor to the mistake and type the correct key.

During editing, RETURN is active; pressing it tells MLX to recheck the line. You can press the CLR/HOME key to clear the entire line if you want to start from scratch, or if you want to get to a line number prompt to use RETURN to get back to the menu.

Other MLX Functions

The Display data option lets you review your work. Unlike the original MLX, the new MLX calculates and displays checksums for each line. Thus, a quick way to check your typing is to compare the reverse video checksums on the screen with the data in the right­most column of the printed listing. If the values match, you can be confident that the line is entered correctly.

When you select D, you'll be asked for a starting address. (As with the other menu options, pressing RETURN at this point takes you back to the command menu.) When entering an address, make sure it corresponds to the address of a line from the listing. Otherwise, the checksums will be meaningless. You can pause the scrolling display by pressing the space bar. (MLX finishes printing the current line before halting.) To resume scrolling, press the space bar again. The display continues to scroll until the ending address is reached, then the menu reappears. To break out of the display and return to the menu before the ending address is reached, press RETURN.

The Save and Load menu options are straightforward. First, MLX asks for a filename. (Again, pressing RETURN at this prompt without entering anything returns you to the command menu.) Next, MLX asks you to press either T or D for tape or disk. If you notice the disk drive starting and stopping several times during a load or save, don't panic; MLX opens and reads from or writes to the file instead of using the usual LOAD and SAVE commands, so this behavior is normal. Disk users should also note that the drive prefix 0: is automatically added to the filename (line 750), so this should not be included when entering the name. (This also precludes the use of @ with for Save-with-Replace, so remember to give each version you save a different name.)

Remember that MLX saves the entire workspace area from the starting address to the ending address, so the save or load may take longer than you might expect if you've entered only a small amount of data from a long listing. When saving a partially completed listing, make sure to note the address where you stopped typing so you'll know where to resume entry when you reload.

Error Alert

MLX reports any errors detected during the save or load. Tape users should bear in mind that the Commodore 64 is never ableto detect errors when saving to tape. The new MLX also has three special load error messages:

• INCORRECT STARTING ADDRESS. This means the file you're trying to load does not have the starting address youspecified when you ran MLX. If you feel certain you're trying to load the right file, exit and rerun MLX, being careful to enter the correct starting address.

• LOAD ENDED AT address. This means the file you're trying to load ends before the ending address you specified when you started MLX. If you feel certain that you've loaded the right file, exit and rerun MLX, being careful to enter the correct ending address.

• TRUNCATED AT ENDING ADDRESS. This means the file you're trying to load extends beyond the ending address you specified when you started MLX. If you feel certain that you've loaded the right file, exit and rerun MLX, being careful to enterthe correct ending address.

The Quit menu option has the obvious effect—it stops MLX and enters BASIC at a READY prompt. Since the RUN/STOP key is disabled, Q lets you exit the program without turning off thecomputer (Of course, RUN/STOP-RESTORE also gets you out.) If you choose this option, MLX asks for verifica tion. Press Y to exit to BASIC, or any other key to return to the menu. After quitting, you can type RUN again and reenter MLX with-

out losing your data, as long as you don't use the clear workspace option.

The Finished Product

When you've finished typing all the data for an ML program and saved your work, you're ready to see the results. Unlike theoriginal MLX, this version keeps the data in a temporary holding area rather than in its final resting place in memory, so youmust always save the finished program with MLX and then reload it from BASIC with a standard LOAD command.

The instructions for loading the finished product varies from program to program. Some ML programs are designed to be loaded and run like BASIC programs, so all you need to type is LOAD "file­name",3 for disk or LOAD "file­name" for tape, and then RUN. (Such programs usually have 0801 as their MLX starting address.) Others must be reloaded to specific ad­dresses with a command such as LOAD "filename",8,1 for disk or LOAD "filename", 1,1 for tape, then started with a SYS to a particular memory address. (On the Commodore 64, the most common starting address for such programs is 49152, which corresponds to MLXaddress C000.) In either case, you should always refer to the article which accompanies the ML listing for information on loading and running the program.

An Ounce Of Prevention

By the time you finish typing in the data for a long ML program, you'll have several hours invested in the project. Don't take chances—use our "Automatic Proofreader" to type the new MLX, and then test your copy thoroughly before first using it to enter any significant amount of data. Make sure all the menu options work as they should. Enter fragments of the program starting at several different addresses, then use the Display option to verify that the data has been entered correctly. And be sure to test the Save and Load options several times to ensure that you can recall your work from disk ortape. Don't let a simple typing error in the new MLX cost you several nights of hard work.