|   |
![]() |
||||||||||||||
Home |
The MPF-1 monitor provides the necessary functions for the user to develop his programs. These functions include:
You'll only have to know how to load a program into memory and start it in order to get going with the experiments on this web site.
So you'll have to read at least the parts which explain how to enter data and programs into memory.
Possibly you'll have to read how to read and store programs on audio tape.
Remember that all your typing will vanish into thin air as soon as the power is removed!
In order to operate the MPF-1 you should at least have to know how to examine memory and modify data in RAM memory.
Remember that a program can also be considered to be data, a program is simply a set of executable data.
Press the ADDR key. The display should now show something like this: 1.8.0.0.0 0. This brings us to the first definition: The dots on the display indicate the entry field. In this case we can enter 4 digits, which is not really a surprise because an address is 16-bits long, which can be represented by 4 hexadecimal digits.
Now type the digits 0000.
The display should now show 0.0.0.0.0 6, thus telling us that the contents of address 0000H are 06H, which is in ROM and should be the same on all models.
Maybe you've noticed that the entry field has changed from the address field to the data field after we've pressed the + key the first time.
You can tell it has changed by the dots being to the right of the two right most digits, which is the data field.
We're going to try our luck on RAM memory now.
RAM memory on the standard MPF-1 ranges from 1800H to 1FFFH.
Press the ADDR key again and then type 1800.
After you've entered the address the display should look something like this 1.8.0.0.0 0 (the data field may differ from what you see here).
Well done, we know how to enter data into memory now. I want you to enter the following data in memory starting at location 1800H for me. DD 21 09 18 CD 24 06 18 FB 02 BD 85 85 8F 37
I'll give you a hint on how to do that, just in case you are not sure about yourself yet:
After entering this data you can verify that the data you've entered is correct (just to be sure this time). Do this by going back to address 1800H again and use the + to walk through the memory until the end of the table.
Congratulations, you've just entered your very first program into the MPF-1 (at least some of you have).
You start this program by going back to address 1800H and press GO.
To stop your program and return to the monitor you'll have to press the RESET key.
Don't worry, your program will still be there.
You can start it again by going back to address 1800H and press GO again.
BTW, the GO key only works if the address field on the display really holds an address. So far this was always the case, but later in this chapter we'll see that other information can be displayed there as well (for instance register contents). So far we have almost covered 2/3 of the keys on the keyboard. Not too bad in such a short time eh! A few keys more and we know everything there is to know about the monitor. But if you are anxious to start with the experiments right away I would urge you to read one more paragraph, the one about Tape Read/Write. That way you'll be able to store your programs on tape (or in the computer nowadays).
Programs in RAM are highly volatile, they will immediately disappear as soon as the power is removed from the system. That's why it is quite handy if we can store the programs somewhere. We can! On audio tape.
Maybe you are too young to remember the audio cassette, which was the main storage medium for home computers in the seventies and eighties.
The MPF-1 uses the audio tape as its main non volatile memory too.
The TAPE WR key is used to store your programs or data to tape.
The TAPE RD key is used to read your data back again.
As an example we're going to save our HELLO program to tape. After that we're going to remove the power from the board for a short while, effectively erasing our program. Then we'll read the program back from tape again. Press the TAPE WR key and the display will show something like 1.2.3.4.- F. The F on the display is the prompt to let you know that you now should enter the "file name". It is not a file name as we know it from the PC of course, it is simply a 4 digit hexadecimal number to identify your file with. As this is our first program, let's number it 0001H. So type 0, 0, 0, 1 and then +.
Now the display shows something like this: 1.2.3.4.- S.
Our prompt now is the letter "S" (not the digit 5).
This "S" stands for start address.
It may come as not surprise to you that we should enter 1800 here, because that is the starting address of the program we want to save at the moment.
Again we get another entry field, followed by the "E" prompt, which looks something like this 1.2.3.4.- E.
We'll have to enter the end address of the data block we want to send here.
In our case this is address 180EH.
Please note that the end address is inclusive, which means it will be the last byte to be written to tape.
Now set the tape to its proper position and start the recording.
Only then it's time to press the GO key.
Don't worry, there's nothing wrong with your MPF-1!
The noise it makes after pressing GO is perfectly normal!
It is also quite normal that the display blanks during this noise because the Z80 is executing some very precise timing loops and it can't handle the display at this moment.
The green LED should be on now too.
In fact the green LED, the speaker and the MIC output are all driven by the same output bit of the 8255.
You may now stop the recording and rewind the tape to the beginning of the program. Remove the power from the MPF-1 to destroy your program in RAM (don't forget to reconnect the power :).
Press the TAPE RD key and you'll see a display similar as this F.F.F.F.- F.
The right F prompts us for the filename, which was 0001 in our example.
What to do if you don't know what filename you used when you stored the program? Simple, press TAPE RD, press GO and start the tape. Watch the display carefully, it will show you all the filenames which happen to pass by. As soon as you found out what filename you should use you can press RESET, rewind the tape and start over again but this time with the right filename.
When you're entering a program by hand you are likely to make typing errors.
You may even skip a byte, or type a few too many.
It is also possible that you are developing a program and want to make place for some extra instructions somewhere in memory.
Be careful with these two keys, they are very primitive!
Not only do they work on a very limited and fixed block of memory, they also don't adjust absolute addresses in your program.
Simply inserting or deleting bytes will require a total review of your program!
You've written your own program and it doesn't do exactly what you had intended.
What to do now?
The MPF-1 features some simple debugging tools.
You can set a break point for instance.
You can then start the program and as soon as it reaches your break point it will stop and return you to the monitor.
This gives you the opportunity to examine the processor register and memory contents.
If you don't like what you see you can even alter the processor or memory contents before you continue the program.
In all honesty, the debugging tools of the MPF-1 are rather primitive.
First of all you can only set one break point at a time, thus you'll have to know which path a program is going to take in order to set the break point at a strategic location.
SBR and CBR If you want to know what has happened to registers and/or memory locations at a certain point in your program you can set a break point there. A break point is simply set by pressing the SBR key. If the break point is successfully set the display will show address and data fields with all the dots visible (for instance 1.8.0.6.F.3.). There are some restrictions on the use of the SBR key:
When you press go the program is executed until and including the instruction where the break point is set.
All processor registers are saved and can be examined and altered (see description of the REG key).
If you no longer need your break point you can simply press the CBR key at any location in memory. The display will show F.F.F.F.F.F. to indicate that the break point is disabled. STEP
The STEP key allows you to go through your program one step at a time.
It doesn't matter whether you start from the beginning of your program, or single step whenever you're returned to the monitor either by a break point or the MONI key.
After each program step you are returned to the monitor again, where you can examine or alter register and memory contents.
It is also possible to restart the normal program execution, simply by pressing GO when the Program Counter is in the display. Be carefull when you single step through the monitor routines. Chances are that you will find yourself stuck inside an endless loop because the monitor routines are not really designed for single stepping. MONI
The MONI key may help you find the cause of a runaway program, even when you haven't set a break point.
By pressing the MONI key you are immediately returned to the monitor, with all registers saved.
If your runaway program uses one of the monitor's display scan routines heavily the MONI key may prove to be of little use. Chances are that you will always interrupt the scan routine instead of your own program simply because the processor is likely to spend much more time waiting inside the scan routine than it is actually running your program. REG Finally the REG key allows you to examine or alter the processor's registers. These registers are used whenever you start, step through or continue your program. By pressing the REG key followed by one of the digit keys the display changes into the register mode. In the register mode the left 4 digits show the contents of a register pair, followed by the name of the register pair. In this example 1 2 3 4 B C the digits 1 2 are the contents of the register B, while the digits 3 4 are the contents of the register C. B C is of course the register pair's name. You may press more than one digit key after pressing REG, this will display all the requested registers in turn. This allows you to examine all the registers without having to press REG each time.
You may start altering register contents by pressing the DATA key when a register pair is displayed.
As an example I display the contents of the AF register first by pressing REG and AF.
The display may now look like this: 1 2 3 4 A F.
Be sure though to press PC every time you're in register display or edit mode before you press STEP or GO!
The monitor can help you to move some data around in memory. Usually this is necessary to make room for some modifications. Keep in mind thought that it is only a simple move, no absolute destination addresses are renumbered. This means that after moving a working program you'll probably end up with a non working program!
If the source block doesn't overlap the destination block the move is none destructive.
This means that the source block will still exist after the move.
In fact copy would be a more appropriate name for this monitor function.
To move some data simply press the MOVE key. The display will now show something like this: F.F.F.F.- S, which means that you can now enter the Start address of the source block. After entering the start address of the source block you can press + to get a display similar like: F.F.F.F.- E. Now enter the End address of the source block and press + again. Finally F.F.F.F.- D prompts you to enter the start address of the Destination block. After entering this destination address you press GO to start the move operation. The relatively high speed of the processor in combination with the fairly small memory capacity of the computer makes the move instantaneous. After the move the address field will show you the last address which was moved.
The monitor can also assist you in calculating relative addresses when you want to hand-assemble your programs. We will use the SB-Assembler to assemble our programs, making this monitor function obsolete for us. JR and DNJZ instructions use relative addresses as operand. A relative address is the distance between the current address and the destination address. You can of course simply count your way to the destination, or you can use a hexadecimal calculator to this job. But you can also use the monitor to help you.
Press the RELA key and the display shows something like this: 1.9.0.0.- S.
Now you can enter the Start address of the relative instruction.
After entering this start address press + and the display will show something like: 1.8.F.F.- D.
This prompts you to enter the destination address.
This function will only work properly if Start address + 1 is in RAM memory! The range of the relative addressing mode is from +127 to -128. If this range is exceeded the display will show - E r r .
We have almost covered all keys on the MPF-1's keyboard now. There are only 2 keys remaining to be explained, and that is quite an easy job because their function is rather straight forward. The USER KEY is directly connected to Port A bit 6 of the 8255. This input is active low, which means that the key is pressed if this input reads 0.
The INTR is an Interrupt key.
With this key you can experiment with Interrupts.
When you press this key the current program is interrupted and control is transferred to the INT routine.
Be careful with the interrupt key!
In mode IM0 it is all straight forward.
But if you're going to work with IM2, the sophisticated interrupt mode of the Z80 peripherals, you may be in for a surprise.
When pressing INTR when the processor is in IM2 an interrupt is called at address (I)FFH.
Thus if the I register of the Z80 holds 18H, the INTR key will use the values in 18FFH and 1900H as a vector to the interrupt handling routine.
BTW, the MPF-1 has no NMI facilities. |