When I'm calling you
A selection of useful routines for the Amstrad CPC 464 from the keyboard of Brian Cadge.
This collection of machine code and cassette routines should be equally useful to both the Basic programmer and the machine code programmer. To use the program, type in the Basic listing, or the assembly language listing if you have an assembler, and Save it. The Basic program will warn you if you have made any errors in entering the Data statements, in which case you should recheck the listing.
Among the things the program will allow you to do are to enter machine code into Ram, examine the contents of any piece of Ram, set breakpoints in the code for testing subroutines, access the cassette motor, read in a cassette header and display relevant information from it, and write Basic data statements to tape.
To run the program, once loaded into reserved Ram type CALL 38000. The 1 >' character is the monitor's prompt for a command, the following commands are available:
- BYE — Returns to Basic, or the calling routine
- WRITE — Writes Basic data statements to tape
- LIST — Displays a section of Rom or Ram
- START — Turns on the cassette motor
- STOP — Turns off the cassette motor
- READ — Reads and displays information from a header block
- FAST — Sets the cassette to 2000 baud
- SLOW — Sets the cassette to 1000 baud
- WIDTH — Toggles between the 40 and 80 column display
- INPUT — Allows data to be entered directly into Ram
- REGS — Displays the contents of the Z80 registers
- CALL — Calls a machine code subroutine
- BREAK — Inserts a breakpoint
- JUMP — Jumps to a given address (used with Break)
- HELP — Displays a list of these commands
Some commands will ask for more information. For the purpose two other prompts are used; the '#' character means a 16 bit Hex number is required. Four characters must be entered, so to input the number 20(decimal), (which is 14 hex), you would type 0014. The '$' character means an eight bit hex number is required; here only two characters are required.
Here is a description of the commands in more detail. The Write command is used to record an ASCII file on tape, containing Basic data statements starting at Line 100. This File can be loaded as a normal Basic program, using Load This is very useful for anyone who writes a machine code program using an assembler, and wishes to produce a Basic loader program.
The Data statements in the Basic listing for this program were produced using this command. The program will ask for the start address and the length of the code to be put into data statements. It will then ask for confirmation before producing the file.
The List command will ask for a start address. A screenful of data is displayed, the program automatically formating it to fit whichever size display is being used. Pressing any key will continue the list; pressing Esc will return you to the command prompt.
To analyse a program's header block, the Read command is used. The cassette should be positioned as if to Load the program, and the Play button pressed. The monitor will read in the first header block it finds and display the following information. The filetype byte character, as given the Cat command in Basic, the start address of the program, the length, and the execute address. This is useful mainly for binary files you have saved, but have forgotten where they load and execute from.
The Input command allows you to enter data directly into Ram. After supplying the start address, you can type in the data, each byte separated by the Enter key. Press Esc when you've finished. This command can be used to enter small test programs, or to quickly change the contents of a memory address.
The Call command is used to test subroutines, which should end with a normal Ret instruction, to return to the monitor. On return, the values of the Z80 registers are saved, these can be displayed by the Regs command.
To enter a breakpoint into a program, use the Break command. This asks for the address of the breakpoint and saves the contents of this address, after which it inserts a RST 30 instruction. Using the Jump command to run the program under test, when a breakpoint occurs the monitor will halt the program, display the values of all the usable Z80 registers, and replace the original byte into the breakpoint address.
All the commands are quite straight forward and do not really need further explanation. All commands must be entered as one word, in capitals. The program sets the caps lock on when called so there should be no problem.
Next week, how to add your own commands to the monitor and the remainder of the assembly listing.