How To Execute My Experiments

I encourage you to study and play with the experiments on this site. Hopefully they pay off to be educational in exercising your MPF-1 which has been standing there collecting dust all those years. I've made it all as easy as possible for you.

How can I participate in the experiments? Simple, download the software package of the experiment you want from my site. Unpack it somewhere on your hard drive. If you want to modify or assemble the programs yourself I recommend you to unpack the package in a subdirectory of the SB-Assembler main directory. This will allow you to simply type "sbasm program" to assemble it.

Anyway, if you unpack an experiment's package you will usually end up with 4 files:

.asm The assembler source file.
.lst The list file, created by the assembler.
.hex A plain HEX file, created by the assembler.
.mp3 The program, ready to be uploaded to the MPF-1.

The assembler source files are highly commented and should explain the main issues of the program. If I feel like it I may highlight some parts of the program on the program description page to explain the program even further.
You may want to read the source files to learn something from them, or you may want them to modify the program to your own liking.
It goes without saying that I only use my own SB-Assembler to assemble all the experiments. You may download it completely free of charge.

The list file can be useful if you feel like typing the program into the MPF-1's memory. I will explain shortly how this is done.

The HEX file can also be used to type the program into the MPF-1's memory. However HEX files are usually harder to read because of the dense code they contain.

The mp3 file is the easiest way to enter a program into the MPF-1's memory. Simply use the TAPE RD monitor function and use your PC as tape recorder.
Be warned though that the MPF-1 is a bit hard of hearing. You'll have to play it rather loud to him. Simply using the line-out of your computer is not likely to be enough. I use the headphones output on my PC speakers and turn the volume a little further than half way to make it work.

How To Get The Code Into Memory

Below you'll see a little excerpt from the .lst file of the first experiment. I use it only for demonstration here. This is not a complete program, so please go to the experiments page to get the entire program if you want to try your luck on a real program.

1800-1E C1    56 KEYMAP      LD    E,11000001B   Starting output mask
1802-16 00    57             LD    D,0           Clear the column index
1804-2E 06    58             LD    L,6           Set the column counter to 6
1806-         59
1806-         60 .COLUMN   ; Column scan loop
1806-7B       61             LD    A,E           Make only current column low
1807-2F       62             CPL
1808-F6 C0    63             OR    11000000B     Don't mess with these two bits!
180A-D3 02    64             OUT   (DIGIT),A
180C-         65
180C-06 06    66             LD    B,6           Set row counter to 6
180E-0E 00    67             LD    C,0           Clear the row index
1810-DB 00    68             IN    A,(KIN)       See if key down in this column
1812-67       69             LD    H,A

What do we see here?

The first column of each line holds the starting address of the code on that line. This starting address is followed by a dash.
Behind this dash you may find some bytes. These are the bytes you'll have to enter on that address (and the next if there is more than one byte on the line). If you don't find any bytes directly behind the dash, you're in luck, you may skip this line. Empty lines (59 and 65 in the example above) and lines which generate no code (line 60) are some examples of lines which have no bytes following the address.

The next column is simply a line number. It can be useful if the assembler reports some errors on line-x. Otherwise you may forget about line numbers here.

Behind the line number column you see the 4 usual assembler columns: Label, mnemonic, operand and remark fields. These are the fields which originally were in the .asm source file.

Here's the key sequence you'll have to follow in order to type this example into the MPF-1's memory:

ADDR, 1, 8, 0, 0, DATA, 1, E, +, C, 1, +, 1, 6, +, 0, 0, +, 2, E, +, 0, 6, +, 7, B, +, 2, F, +, F, 6, +, C, 0, +, D, 3, +, 0, 2, +, 0, 6, +, 0, 6, +, 0, E, +, 0, 0, +, D, B, +, 0, 0, +, 6, 7.

You can also copy the code from the .hex output file. However because of the dense nature of these files you may easily get lost between all the digits. Soon you may find yourself skipping digits or entering the same line twice.

How To Record To MP3

Of course you can use a real tape recorder to save your own programs. But saving it to the PC is more comfortable, and even more reliable. But you'll have to make some small modifications to the MPF-1 to make it work properly.

Originally the microphone output level of the MPF-1 is far too low. OK, I can use an external amplifier to increase the output level. However it is far easier to change the attenuation of the output level, after all we start off with a 5V square wave!
What I did was: remove R13 (to the right of the speaker on my board) and replace R12 by the resistor which originally was on R13's position. These two resistors originally formed a voltage divider of 10k and 330Ω. Now it is simply reduced to be a series resistor of 330Ω. Not that this resistor is of any importance, I only needed a low ohmic resistor to bridge the gap of the missing R12 and the old R13 volunteered for the job.

With this increased output level it is now possible to record the tape signal on my computer. I use the program Audacity to record the signal, which is stored as an MP3 file at a bit rate of 40k @ 44k1 sample rate. This results in about the highest possible compression, which can still be read back if you play it loud enough.

How To Speed Up Program Development

OK, you may have guessed by now that I've written all the example programs using my SB-Assembler, I've never made a secret about that. But how are the programs transferred from the PC to the MPF-1? We can't use the MP3 trick during development/debugging simply because the program doesn't exist yet. And surely the programs were not entered by hand during debugging! Mind you, in the old days this was the only way to enter your programs for the first time!

Some clever people have developed a way to connect the MPF-1's extension connector to the PC's parallel printer port. With a small addition to the monitor ROM this allowed easy transfer of programs from the computer to the MPF-1. I may include the details of this little trick later, for now I can only show you how I have done it.

I simply used my Tiny EPROM Simulator. This little gadget connects to the SB-Bus (or just about any serial port) and simply pretends to be a 32k EPROM. This simulated EPROM is connected to the U7 socket of the MPF-1, which is originally intended to hold an extra EEPROM or RAM chip.
However there is a little catch, well to be completely honest there's more than one. First of all I have to mention that my MPF-1 has a 28-pin U7 socket, allowing the use of an 8k EPROM. Some of the earliest MPF-1 revisions only had a 24-pin connector, allowing a maximum EPROM capacity of 4k. Needless to say you'll need to make some more adaptions in that case.
My Tiny EPROM Simulator pretends to be 32kB EPROM, whereas U7 officially excepts only an 8kB EPROM (on my MPF-1!). This is not really a problem, because all unused address pins are physically connected to +5 V on this socket. Therefore address lines A13 and A14 are high, which means that the code which can be seen from the MPF-1 should start at address 06000H in the simulated EPROM.
Thus the target address range for the code in the Tiny EPROM Simulator should be between 06000H and 07FFFH. The MPF-1 sees this code from its own range between 02000H and 03FFFH.
To make things even more complicated, programs written for the MPF-1 usually start at address 01800H which is the beginning of the RAM area. Therefore we need to setup an offset for the Tiny EPROM Simulator to make this code end up at address 06000H. Using some hexadecimal calculations on these numbers results in this offset:

offset =  - (06000H - 01800H) = 0B800H

So far our program, which should start at address 01800H, can now be seen by the MPF-1 at address 02000H. Before we can run the program we must copy the range from 02000H to 026FFH to the destination address starting at 01800H. Why not the entire range? Because usually the highest page in RAM is not occupied by any program, instead it is often used as stack and variables area.
The moving of the code to RAM can also be automated by adding the following piece of code to your programs at address 02800H, which ends up at address 03000H in the MPF-1's address space.

        .OR     02800H          Ends up at address 03000H
        LD      HL,02000H       Move the program from U7
        LD      DE,01800H        to RAM
        LD      BC,00700H
        JP      01800H          Start the program

After assembling the program, it can now be started by pressing ADDR, 3, 0, 0, 0, GO.

To prove that this all works I have included the following listing. Simply copy it into an empty file, name it proof.asm, assemble it, set the offset to $B800 on the Tiny EPROM Simulator, write the Intel hex file to the Tiny EPROM Simulator and press the above mentioned keys to start the program.

;  Some proof that the 0B800H offset is correct

                .CR     Z80
                .OR     01800H
                .TF     PROOF.HEX,INT

;  This part of the program ends up at address 01800H

PROOF           LD      IX,DSP_BFFR
                CALL    005FEH         Call SCAN routine
                JR      PROOF

DSP_BFFR        .DA     #0              Display buffer (from right to
                .DA     #%0000.1111      left)
                .DA     #%1010.0011
                .DA     #%1010.0011
                .DA     #%0000.0011
                .DA     #%0001.1111

;  Install and run, ends up at 03000H (Offset 0B800H)

                .OR     02800H
                LD      HL,02000H
                LD      DE,01800H
                LD      BC,00700H
                JP      01800H

One last tip for Windows users: Because Hyperterminal is a very peculiar program it insists on a .txt extension for files to send. Therefore it is better to name your object file proof.txt instead of proof.hex, this will save you a lot of clicking every time you want to upload the file.