Z80 SECOND PROCESSOR APPLICATION NOTE ===================================== Applicable Hardware: BBC B, BBC B+, BBC Master 128 Support Group, Acorn Computers Limited, Acorn House, Vision Park, Histon, Cambridge CB4 4AE. Related Application Notes: Copyright (C) Acorn Computers Limited 1992. Every effort has been made to ensure that the information in this leaflet is true and correct at the time of printing. However, the products described in this leaflet are subject to continuous development and improvements and Acorn Computers Limited reserves the right to change its specifications at any time. Acorn Computers Limited cannot accept liability for any loss or damage arising from the use of any information or particulars in this leaflet. ACORN, ECONET and ARCHIMEDES are trademarks of Acorn Computers Limited. Z80 User Guide Errata 16th January 1992 Support Group Application Note Number: 007 Issue: 1 Author: CP/M OPERATING SYSTEM TECHNICAL NOTES ===================================== Z80 Monitor ----------- After turning on the Z80 and pressing BREAK the following display appears: Acorn TUBE Z80 64K n.nn Acorn DFS BASIC * where n.nn is the version number of the Z80 ROM. The * prompt indicates that the Z80 Monitor is running and at this stage all the standard * commands can be entered ie *HELP, *FX4 etc. The Z80 Monitor will also recognise the following additional commands which allow memory to be examined and changed and small machine code programs to be entered directly and tested. CPM D GO
S In the above commands
refers to a hexadecimal address which can be entered as 1 to 4 digits, ie 3F can be entered as 3F, 03F or 003F. If more than 4 hex digits are entered the most significant digits will be truncated, ie 12345 will be treated as 2345. If no address is specified the most recently specified address will be used instead. For all commands any leading spaces or asterisks and trailing spaces will be ignored. The extra commands are now explained in more detail: CPM - this command allows the CP/M system to be loaded without resetting any previously entered *commands which would occur if CP/M was loaded using CTRL BREAK, ie typing *KEY0|M *KEY1 STAT *.*|M *KEY2 ERA *CPM would allow the function keys to be defined before starting up CP/M (These key definitions would have been reset if CTRL BREAK had been used to load CP/M.) D (Dump) - this command gives a memory dump with character interpretation between the two specified addresses. At least one space is expected between the start and end addresses but no space is necessary before the first address. A dump can be terminated at any time by pressing ESCAPE. GO - This command causes a jump to occur to the specified address. S (Set) - This command allows memory to be examined and altered from the specified start address. No space is needed between the command and the address. The displayed memory location can be altered by entering valid hex digits which are shifted in from the right. The command can be terminated by entering any nonhex character. To alter more than one location the UP and DOWN cursor keys can be used to increment or decrement the memory location. Z80 OSWORD CALL --------------- The Z80 provides an additional OSWORD call with A = 0FFH to read or write blocks of I/O processor memory. On entry HL point to the following control block: HL + 0 Number of OSWORD parameters sent to I/O processor - 0DH HL + 1 Number of OSWORD parameters read from I/O processor - 01H HL + 2 LSB of I/O processor address HL + 3 HL + 4 HL + 5 MSB of I/O processor address HL + 6 LSB of Z80 processor address HL + 7 HL + 8 HL + 9 MSB of Z80 processor address HL + A LSB of number of bytes to read/write HL + B MSB of number of bytes to read/write HL + C Operation type - 0 to write to I/O processor, 1 to read from I/O processor. The first two bytes are used by the Z80 OS and must not be changed. If the I/O processor uses 16 bit addresses only the first two least significant bytes need to be specified. An example of the use of this call is now given: To read I/O processor screen memory (mode 0) LDA, 0FFH ;OSWORD call 0FFH LDHL, BLOCK ;Set up HL to point to control block CALL 0FFF1H - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BLOCK: DEFB 0DH DEFB 01H DEFW 03000H ;start of screen memory in i/o processor DEFW 0 ;set high word to zero DEFW 08000H ;start of transfer address in Z80 DEFW 0 DEFW 05000H ;size of screen memory (20K) DEFB 1 ;read operation I/O Processor Memory Usage -------------------------- The following areas of I/O processor memory are reserved and should not be corrupted by any user programs: 2500H - 25FFH Reserved for use by Z80 OS 2600H - 2FFFH Reserved for use by CP/M CP/M Disc Format ---------------- Acorn CP/M uses the following double sided disc format: 80 tracks / surface 10 sectors / track 256 bytes / sector A double sided disc is regarded by CP/M as a single logical disc with 160 tracks numbered from 1 to 159. In order to obtain the best disc performance the following logical to physical track mapping is performed. Logical CP/M track Physical track 0-79 0-79 (top surface) 80-159 79-0 (bottom surface) The first 3 tracks on the top surface are reserved for the CP/M system. The CP/M directory starts at track 3 sector 0 and uses 4K bytes to allow up to 128 directory entries/disc. This leaves 388K bytes/disc available for user programs and data. Acorn CP/M uses deblocking to allow the physical disc sector size to be larger than the logical CP/M record size of 128 bytes. Although a 256 byte sector size is used the effective sector size is 512 bytes as all disc operations read or write 2 sectors at a time using an appropriate sector skew. The following table defines the logical record to physical sector relationship. +------------------------------------------------------------------------+ |Logical CP/M record | | | (128 bytes) | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | +------------------------------------------------------------------------+ |Logical disk sector | | | (512 bytes) | 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 | +------------------------------------------------------------------------+ |Pysical disk sector | | | (256 bytes) | 0 0 1 1 4 4 5 5 8 8 9 9 2 2 3 3 6 6 7 7 | +------------------------------------------------------------------------+ The IOBYTE Facility ------------------- The CP/M operating system allows the user to redirect the input and output of its logical devices to particular physical devices. As an example the CP/M system could be used with a remote terminal by assigning the physical device TTY: (the RS423 serial port) to the logical device CON: (the system console). The use of the IOBYTE to reassign the physical devices is covered in the Digital Research CP/M Operating System Manual. Care has been taken however to allow the user familiar with the BBC micro to use OSBYTE calls to redirect input and output as required. This has been done by providing the physical device UC1: which uses the normal BBC micro IO streams. These can be altered as required. The default setting of the IOBYTE assigns the UC1: device to CON: so the system console behaves like a normal BBC micro. The CP/M logical devices are as follows: CON: is the principal interactive console that communicates with the operator and is accessed through CP/M calls to the Console. LST: is the principal listing device, usually a printer. PUN: is the tape punching device - the name is a leftover from the days when computers used paper tape. RDR: is the tape reading device. As with PUN: above it is inherited from the early version of CP/M. The Acorn CP/M system implements the following physical devices which are used in conjunction with the above logical devices: UC1: is the normal BBC Micro IO channel. This allows the user familiar with the BBC to redirect IO without using the CP/M IOBYTE. It also supports the terminal emulation facility described elsewhere. CRT: provides direct access to the BBC screen and keyboard. Unlike the UC1: device input and output cannot be redirected by OSBYTE calls. Input always comes from the keyboard and output always goes tothe screen. It does not support the terminal emulation facility. TTY: is the RS423 serial port. The default baud rate is 9600. It can be used for both input and output. Please note that the user should not disable the RS423 input if using the TTY: input device. The default setting is input enabled. LPT: is the standard BBC micro printer device. This is a Centronics with no printer ignore character as default but can be changed using OSBYTE calls. If a printer is not present then attempts to send characters to the printer will cause a message 'Printer offline' to appear. The user may then connect a printer and carry on. Alternatively if a printer is not available after a short time the message 'SPACE starts Printer Sink' appears and the user can press the SPACE bar to throw away the printer output. The printer sink is detailed in the BBC Micro users Guide. Characters sent to the printer will continue to be ignored until the user selects another printer type with a *FX5 call. UL1: is the same as the LPT: device except no messages appear if the printer isn't connected. The system will simply stop. NUL: is a device which throws away all output and returns 1Ah on input, indicating End of file. This is present to prevent the system hanging if an unimplemented physical device is selected. UR1:, UR2:, UP1:, UP2: are all equivalent to the NUL: device. The default value for the IOBYTE in the Acorn CP/M system is 83h. This assigns UC1: to CON:, LTP: to LST:, TTY: to RDR:, and TTY: to PUN:. This can be changed by applications programs or by the STAT command. The System Patch Area --------------------- To allow temporary patches to be made to the Acorn CP/M system an area has been reserved in the BIOS. It starts immediately after the SECTRAN entry point in the CP/M BIOS jump table and is 60h bytes long. This is EA33h to EA92h inclusive in the current Acorn CP/M system. Please note this may alter in future systems. Patching should only be attempted by those familiar with the CP/M system. There are two main types of patch: The first is to add special initialisation code. The instruction at EA33h is a RET. This location is called at cold start which allows a special subroutine to be inserted in place of the RET. This could for example select a serial printer as default. The other use is to patch in temporary additions to the system. Certain applications programs do so. Please note that patches of this sort may be overwritten by other programs. As a result they can only form temporary additions to the system and they should 'tidy up' on termination, ie any changes made to other parts of the operating system should be reversed after the patch has done it's job.