Cromemco Z80 Instruction Manual

--
-
'J- _
InstructIon Manual
[3Cromemeo
i n cor p 0 rat e d
Specialists in computers and peripherals
2400 CHARLESTON RD., MOUNTAIN VIEW, CA 94043
© Copyright 1977. All rights reserved.
C3Cromemeo
incorporated
Specialists in computers and peripherals
2400 CHARLESTON RD., MOUNTAIN VIEW, CA 94043
Table of Contents
Pg.No.
Introduction 1 Entry 1
System Stack 1 Command Format 1
Swath Operator 1 Multiple Commands: The After Operator 1
Example 1: Writing Paper Tapes Example 2: Copying Paper Tapes Example 3: Multiple Copies of PROMs Example 4: Initializing UARTs
Example 5: A Timer Errors and Escapes 3 Input and Output 3
Baud Rates and UART Selection 3 Interrupts 3 Loading the Monitor .4 Using the Monitor .4
COMMANDS 4
Display Memory, DM
Display Registers, DR
Go,G
Go with Breakpoints Set, G/
Initialize Baud Rate, I
Move, M Nulls, N Output, 0 Program PROMs, P Read, R Substitute Memory, 8M
Substitute Register
SA, SB, SC, SD, SE, SF, SH, SI, SN, SP, SS, SX, SY, SA', SB', SC', SD', SE', SF', SH'
UART Select, U Verify, V Write, W
Program Listing 7 Cross Reference 24
Z80 Monitor
~ Introduction
The Z80 Monitor makes it possible to control computers which use the CROMEMCO zputm from a terminal keyboard. It includes executive commands to
examine and change memory, make a binary or an ASCII dump of memory, move and compare blocks of memory, output a byte of data to any port, read, write, and punch nulls on binary paper tapes, program 2708 and 2704 PROMs using the CROMEMCO BYTE- SAVER, and initialize and control both serial ports on
the CROMEMCOTUART.
Transfer of control to a program in memory can be commanded from the keyboard with up to five
breakpoints set and with the initial contents of the ZPU registers specified. When a breakpoint is en- countered during execution, control is transferred
back to the monitor and the contents of all 22 ZPU
registers are stored. These register values can be exam- ined and changed before execution of the program
is resumed.
Entry Points
The Z80 Monitor has three entry points. A
cold-start entry at EOOO hex selects bank 0 on
CROMEMCO memory boards and UART A on the
'-------"CROMEMCO TUART. It initializes the baud rate of
the UART to match that of the terminal being used. In addition, it saves the contents of the Z80 registers I,
N (IFF), S (SP) , X (IX) , Y (IY) , A' , B' , C' , D' , E' ,
F' , and H' (HL') in the user-register area which is part of the system stack. (If the Z80 stack pointer is point-
ing to RAM, then all registers except A and P (PC) will be saved.) The contents of these registers are restored when the monitor is exited by means of the GO
command.
The warm-start entry point at E008 hex is pro-
vided so that the monitor can be re-entered without affecting the memory banks or the UART. The same registers are saved as for the cold-start entry point.
The third entry point is used by the break-
point facility. Entry here saves the contents of all registers. Memory banks and UART are unaffected.
System Stack
The monitor does not require the user to address a RAM board at a special place in memory for its stack and working storage area. (However, if the breakpoint facility is used, there must be either RAM at locations 30, 31, and 32 hex or PROM with the data
C3, 45, EO hex at those locations.) The monitor finds
the highest page of RAM active in the machine and
places its stack and temporary storage area there. At least 60H or 96 bytes of this page must be reserved for system use. If the multiple command facility is used,
1
-------- ---- --
- - ------ ---
= -- -===-=- ~=
- ----~ --.•.. ""-""" ~
each additional command in a command line requires an additional 20 hex or 32 bytes stack room. (See
Multiple Commands.)
Command Format
The Z80 Monitor is controlled by one and two- character commands from the terminal keyboard. The format is free-form with respect to spaces.
In the following, DM is the Display Memory com- mand and S is the Swath operator (see below). The four examples are equivalent commands. They display the contents of 100 hex bytes of memory beginning with location 1000 hex. (' (CR) , indicates a carriage
return.)
DM1000 10FF (CR) DM1000S100 (CR)
D M 1000 10FF (CR) D M 1000 S 100 (CR)
When entering an address as a operand, only the last four digits typed in are retained. For example, '321000' is read as '1000'. Therefore, if a wrong digit is entered, continue typing until the last four digits are
correct.
Only the last two digits typed are retained when a
two-digit number such as a data byte is entered.
Swatl. Operator
There are two ways to specify the address range of many commands. The first is to simply list the beginning and ending addresses (and, where appropriate, the destination address). For example, the first command below programs the range 0 through
13FF into PROMs starting at E400. The second com-
mand displays the contents of memory between addresses E400 and E402.
PO 13F F E400 DME400 E402
Another way to do the same thing is to use the Swath operator, S, to specify the width of the address
range rather than state the ending address explicitly.
PO S1400 E400 DM E400S3
Multiple Commands:
The After Operator
The After operator, , < " can be used to place
more than one command on a command line. All of
Z80 M -~ --- --- - ----=--=-
ODIlOr 5.-= =-- === .: -=
-==.:::..::::.-.=..:.=.::..===.;::.::..:::._-------------
the commands on the command line are executed before the monitor returns with its prompt' : " for
a new command.
With this feature, the monitor can write an area of memory onto paper tape preceded and followed by a sequence of nulls without any undesirable carriage- returns or prompts inserted by the monitor.
Example 1
where, again, all colons are provided by the monitor. ~ Example 3
Suppose we wish to make three copies of the
same PROM. Assume that the source is in RAM at location 0 and that we want three identical copies in PROMs located at E400, E800, and ECOOhex. The
following command line will accomplish this:
Example 4
:POS400 ECOO<:POS400 E800 <:POS400 E400 (CR)
First, we re-initialize the UART by typing the
following:
:1 < :VB (CR)
:VA<:I < :VB (CR)
Time (minutes)
0.035
3.5
7.0
14.0
28.0
56.0
112.0
Number of Bytes (hex)
10
640
C80
1900 3200 6400
C800
After entering one of these commands on the console connected to UART A, push CARRIAGE- RETURN on the other terminal until the monitor
prompt' : ' appears.
Either of the following will initialize the baud
rate of a terminal connected to UART B of the TUART:
Example 5
Assume that we would like to take a brief nap to ~
refresh ourselves but have no alarm clock. Assume further that two beeps of the console bell spaced 2.1
seconds apart are sufficient to wake us and that the console can run at 300 baud. Since the Display Mem- ory command takes 63 characters to display 10 hex or
16 bytes of memory, at 300 baud it takes 2.1 seconds
or 0.035 minutes to display 10 hex bytes.
Example 2
Assume that we are using a CROMEMCO TUART I/O card with a console connected to UART A and with a paper tape reader and punch connected to the input and output, respectively, of UART B. Assume that the baud rate of UART B has already been set to that of the reader and punch. (See Baud Rates pg. 3.) We can copy a paper tape by switching the current UART to B, reading the tape into a memory buffer, writing a leader, writing the buffer to the punch, and finally switching the current UART back to A, the
console, by typing:
Assume that the terminal being used is a teletype-
writer with paper tape punch. In order to write the contents of 400 hex bytes starting at 100 hex with a leader of 95 hex nulls and a trailer of 80 nulls, type:
:N80 < :W100 S 400 <:N 95 (CR)
:VA < :WOS2000 < :N80 < :ROS2000 < :VB (CR)
where the colons are prompts provided by the monitor. Turn on the paper tape punch after typing the carriage- return in order to avoid writing it onto the tape.
There are several points to be made about the use
of the After operator:
(a) The order of execution of the commands is from right to left. Hence, the name 'After' and the shape'
< '.
(b) The After operator is logically equivalent to a carriage-return. Anywhere a carriage-return can reason- ably appear in a command, the After operator may be used instead. However, no commands in the line are executed until an actual carriage-return is typed.
(c) If any of the GO commands appears in a multiple-command line, it must be the last command executed, i.e., the first command typed.
(d) Each additional command on a line adds from 10 to 20 hex bytes to the system stack size.
In this case, we can leave the reader and punch on all the time. There is no question of a carriage-return from the command line being punched onto the paper tape since two different UARTs are involved.
Perhaps we forgot to write nulls as a trailer to the output tape. After the prompt, , : " again appears on the console, we can rectify this by typing:
:1(CR)
Set the console baud rate to 300 and push the
CARRIAGE-RETURN until the monitor issues its prompt,': '. ~
To ring the bell, output 7 to port 1. For a nap of
14 minutes:
:V A < :N 80 < : V B (CR)
:0 7 1 < :DMOS10 < :07 1 < :DMOS1900 (CR)
2
Z80 M -., --------- ----~-=-
onIlor = -_ -=--==;;=== _~~
-=:=.;:;...;:;;......=.:.=-=~~.;;;;.,;,~--------------
Errors and Escapes
When the monitor detects an error condition, the
command is aborted, all breakpoints are cleared, and a
'?' is printed followed by the prompt ' : ' for the
next command.
Any command may be aborted from the keyboard
either when the monitor is requesting further input, or during print-out, by depressing either the ESCAPE or
the ALT MODE key. CONTROL-SEMI-COLON, CONTROL-SHIFT-'K', and' }' may also work.
The baud rate can also be changed by using the
Initialize command (see page 5).
Some peripheral devices such as paper tape read- ers or punches may have no keyboards. The TUART baud rate can also be set by outputting a data byte from the following table to port 0 for the currently selected UART or to port 50 hex for the unselected UART. (To make UART B current, output 80 hex to port 4. For UART A, output 0 to port 54 hex. UART selection can also be accomplished by means of the monitor's UART command, U).
Interrupts
The baud rate can be octupled by outputting 10 hex to port 2 for the selected UART or to port 52 hex for the other UART. Outputting 0 to these ports brings the baud rate back to normal.
The monitor can be used to enable interrupts in
the Z80. This is done by changing the value of the N
register to 1 by using the Substitute Register com-
mand, SN. (The N register stores the value of the Z80 interrupt flip-flop at the time the monitor is entered.) Then interrupts will be enabled when one of the Go commands is given.
Note, however, that the interrupt mask registers
on the TUART must have been set previously, either by a user program or by the monitor. (If this is not
done, then an immediate interrupt will be generated
because the print buffer is empty.) To mask out all interrupts output 0 to port 3 for the current UART
and to port 53 hex for the other UART.
The mask bit corresponding to each of the pos- sible interrupts is given in the following table:
Input and output
The monitor assumes that a data transfer occurs
on I/O port 1. Status flags are transmitted over input
port O. The data-available flag is on bit 6 of input port
O. The transmitter-buffer-empty flag is on bit 7 of input port O.Both flags are active high.
To use the CROMEMCO TUART with the
monitor, set switches 1, 7, and 9 of the 10-position TUART switch OFF, all others ON. The currently
selected UART uses I/O port 1 for date transfer and input port 0 for status flags. The UART which is not current uses I/O port 51 hex for date transfer and input port 50 hex for status flags. (The UARTs are selected by means of the UART command.)
The following locations may be changed for dif-
ferent I/O conventions:
Status port number (00): EOOF, E020 Input data port number (01): E014 Output data port number (01): E027 Input-data-available mask (40): E011 Output-transmitter-buffer-empty mask (80): E022
For active-low status flags change locations E019
and E379 from 28 hex to 20 hex and change location E120 from 20 hex to 28 hex.
Baud Rates and UART selection
Baud Rate
110 150
300 1200 2400
4800
9600
Data Byte
01
82
84
88 90
AO
CO
When the monitor is entered at EOOOhex, the
cold-start entry point, push CARRIAGE-RETURN until the monitor responds with:
CROMEMCO ZM1.4
The monitor is capable of selecting 19200, 9600, 4800, 2400, 1200, 300, 150, or 110 baud when used with the CROMEMCO TUART I/O board.
The maximum number of carriage-returns re- quired to select any of these baud rates is four. (Two carriage-returns are required for any UART with a fixed baud rate.)
3
Bit Interrupting Device
o Timer 1 1 Timer 2 2 Sens (external) 3 Timer 3 4 Receiver Data Available
5 Transmitter Buffer Empty 6 Timer 4
7 Timer 5 or external
For example, to allow only interrupts from the serial input port and from Timer 1 on the current UART, output 11 hex to port 3 and 0 to port 53 hex.
Z80M -. --------------=
-=.:~..::.:.::.o::..:;n~I;;;;.;:;..lo..;;..;:r~ =_- ' ....::_
Loading the Monitor
The paper tape can be loaded into RAM and
thence into PROM as follows.
Temporarily address a RAM card at EOOO hex. Address the BYTESA VER card at some other address, say AOOOhex. Place an erased 2708 in PROM position 1 (A400 hex).
Enter the following loader program via the front panel switches at any convenient address. Since' it
only contains relative jumps, it will execute anywhere in memory without change. The places that may need to be altered for different I/O conventions are under,
lined.
CARRIAGE-RETURN twice. The monitor will then ~ respond:
CROMEMCO ZM1.4
followed by a prompt' : '. The monitor is then ready to accept commands from the keyboard.
COMMANDS
DISPLA Y MEMORY
[1] DM beginning-addr ending-addr (CR)
P EOOO S 400 A400 (CR)
Align the first byte of data on the paper tape over
the read sensors of the paper tape reader. Begin execu- tion of the loader program and then turn on the reader. After the tape is read, stop the reader.
If necessary, change the monitor locations indi-
cated above to fit your I/O conventions.
Execute the monitor starting at location EOOO
hex. Depress carriage return several times to set the
baud rate to suit your terminaL The monitor will now
program itself into the PROM at A400. Turn on the BYTESA VER program power switch and enter the
following command:
21 00 EO
DB 00 E6 40
28 FA
DB 01
77
23
18 F4
LD HL, OEOOOH
LOOP: IN A, (STATUS)
AND DAV JR Z, LOOP
IN A, (DATA) LD (HL), A
INC HL JR LOOP
or DM beginning-addr S swath-width (CR)
The contents of memory are displayed in hexa- decimal form. Each line of the display is preceded by the address of its first byte. Example:
:DMI00 S3 0100: C3 34 7F
DISPLAY REGISTERS
[2] DR (CR) ~
When the monitor is re-entered from a breakpoint,
the contents of all the Z80 registers are stored in an
area called the user-register area. (When the monitor is entered via reset or the warm-start entry point, all registers except A, B, C, D, E, F, HL, and P are saved in the user-register area. However, if the stack pointer is pointing to RAM, then all but A and P will be saved.)
DR causes these stored registers to be displayed
in the following format:
If the PROM programs correctly, the monitor will respond with a line feed and the prompt' : '. Turn off the program power switch and the computer power
switch. Re-address the BYTESA VER to EOOO and move the monitor PROM to PROM location O. Change the RAM address to something other than EOOO. You are then ready to use the monitor in PROM.
using the Monitor
Set the power-on jump switch on the Cromemco ZPU card to E (1110 binary). Whenever the computer is reset, control will then immediately pass to the monitor.
If the ZPU is used with the Cromemco TUART I/O card, depress CARRIAGE-RETURN two to four
times. This will set the UART on the serial interface card to the baud rate of the terminal being used.
When used with a serial interface card with baud rate fixed to that of the terminal, simply depress
4
A=OI B=12 C=34 D=56 E=78 F=9A HL=BCDE
I=FO N=OO P= 1234 S=5678 X=9ABC Y=DEFO
A'23 B'45 C'67 D'89 E'AB F'CD HL'EFOI
If interrupts were enabled when the monitor was entered, then N=1. Otherwise, N=O.
The flag registers, F and F', are packed as follows:
S,Z,x,H x,P/V,N,C
i.e., sign, zero, (unknown), half-carry, (unknown), parity or overflow, subtraction, and carry flags.
GO
[3] G (CR) ~
The Z80 registers are loaded with the values saved in the user-register area. (These are the values displayed with the DR command.) Execution then resumes at
Z80 M _I -------------=--=--
OnIor == -=-===:=::~====-::==
'=='= ~ =:s--=- :::: ~~-=-
-==.;:~~.;;;.;",;;;;.;:~;;;....;....;;,---------------
the location contained in the user-pro gram-counter, P.
~ .
[4] G startmg-addr (CR)
This command is exactly like [3] except that the user-program-counter, P, is first loaded with starting- address. Thus, execution begins at starting-address.
GO WITH BREAKPOINTS SET
[5] G / breakpoint-addr-1 breakpoint-addr-2 ... (CR) [6] G starting-addr / brkpt-addr-1 brkpt-addr-2 ... (CR)
Commands [5] and ] 6] are like [3] and [4], respectively, except that breakpoints are set at breakpoint-address-1, breakpoint-address-2, etc.
When a breakpoint is encountered in the execu- tion of the user program, the monitor is re-entered. All registers are saved in the user register area (which is part of the system stack), the address of the breakpoint is printed, and all breakpoints are cleared (i.e., the user program is restored to its original state). Finally, the prompt, , : ' is issued for the next command from the keyboard. Note the following about the use of break- points:
(a) Breakpoints can only be set in programs resid- ing in RAM. This is because the monitor inserts a RST 48 instruction (F7 hex) at each breakpoint location. (The original contents of these locations are saved so that they can later be restored.)
(b) Up to five breakpoints can be set. If an attempt is made to set a sixth breakpoint, the monitor will print a question mark to indicate error, erase all breakpoints, and prompt for a new command.
(c) When a breakpoint is set, the monitor inserts a 3-byte jump instruction at location 30 hex. This means that locations 30, 31, and 32 hex are not avail- able to the user program when breakpoints are used.
(d) The monitor temporarily uses ten bytes on the user's stack in executing a breakpoint. The area reserved for the user's stack must, therefore, be at least ten bytes larger than that required for the user's program.
(e) If breakpoints are set in a program and the computer is reset and the monitor re-entered before any breakpoint is reached in the execution of the pro- gram, then the breakpoints will have to be removed from the program by means of the Substitute Memory command, SM. However, if any breakpoint is reached, all breakpoints are automatically cleared by the
monitor.
INITIALIZE BAUD RATE
[7] I (CR)
After the CARRIAGE-RETURN is typed, change
the baud rate of the terminal to the desired value and
then push the CARRIAGE-RETURN until the monitor responds with its prompt, , : '.
5
The monitor is capable of selecting 19200, 9600, 4800, 2400, 1200, 300, 150, or 110 baud when used with the Cromemco TUART I/O board. The maximum number of carriage-returns required to select any of
these baud rates is four.
The command is particularly useful for setting the baud rate of the second serial port on the TUART. (See Multiple Commands.)
MOVE
[8] M source-addr source-end destination-addr (CR)
or
M source-addr S swath-widthdestination-addr (CR)
Move the contents of memory beginning with source-address and ending with source-end to destina- tion-address. After the move, the monitor verifies that
source and destination are the same. This will result in a print-out of discrepancies which are not really errors
after certain types of overlapping moves. However, this print-out can be terminated by depressing ESCAPE or ALT MODE.
The Move command can be used to fill a block of memory with a constant. For example, to enter zeros between locations 100 and 108, use the Substitute
Memory command to enter 0 at location 100, and then move 100 through 107 to 101:
M100 107 101
or
M 100 S 8 101
Care should be taken not to overwrite the system stack which resides in the top of active RAM. (See System Stack.)
NULLS
[9] N hex-number (CR)
Write hex-number nulls to the current device. This command is used to punch leaders and trailers on paper tape. (See Multiple Commands.)
OUTPUT
[10]
0 data-byte port-number (CR)
Outputs data to a port. One use of this command is to select banks on Cromemco memory boards. When the monitor is first entered on power-up or reset, it selects bank 0 and turns off all other memory banks.
Either a software output or a monitor output to port 40 hex serves to change the bank selection. To select bank n, output a byte with bit n high. To select two banks, nand m, output a byte with both bits n
and m high.
Z80 M _I ------------~~
Onl or == --=======~====:'==
~ = -=.:- =~S"-=- ==::-~~
....:;=-.;;...;;......:;;"";,,,;;~...;;;;;;.;;;;.;......;;;..~----------------
Bank
o
1
2 3
4
5
6
7
Output byte
01
02
04
08
10
20 40
80
Read binary or ASCII input from paper tape reader or console and store in memory from destination- address through destination-end. After destination-end
has been filled, the monitor prompts for the next
command. SUBSTITUTE MEMORY
[13] SM address (CR)
For example, the first command selects bank 5 and the second selects banks 4 and 5.
o
20 40
o 30 40
PROGRAM
[11] P source-addr source-end destination-addr (CR)
or
P source-addr S swath-widthdestination-addr (CR) Program from source-address through source-end
into PROMS beginning at destination-address.
If the length of the source is not a multiple of 400H (1024 decimal) or if the destination does not begin at 400H boundary, the monitor will reject the command. (Multiples of 400H end in '000', '400',
'800', or
'COO'.)
Any number of 2708 or 2704 PROMS can be
programmed in the execution of one command as long as there are enough BYTESAVERS to contain them. Each PROM is verified with its source after all are pro-
grammed and any discrepancies are printed out. If there are none, the prompt ' ; , is issued and the monitor awaits the next command.
Software can be loaded into a PROM in as small increments as you desire provided it is added to pre-
viously unused areas of the PROM.
This is done by first using the Move command, M, to transfer the current contents of the PROM down
to RAM, adding the new software to an area of RAM
which corresponds to the unused portion of the PROM
and finally using the Program command, P, to re-
program the PROM with the result.
Although the entire PROM must always be pro-
grammed, it never hurts to re-write the same data over again.
In general, a 1 may be written over a 1, a 0 over
either a 1 or a 0, but the only way to change O'sto l's is to erase the PROM with appropriate UV light. (See the BYTESAVER manual for details.)
READ
[12] R destination-addr destination-end (CR)
or
R destination-addr S swath-width (CR)
6
Substitute Memory desplays the contents of address and outputs a dot,' . ',as a prompt for the substituted value. If no change is desired, type a space or another dot. Otherwise, enter the new value.
The monitor accepts hex digits until it gets a delimiter, such as a space, dot, or carriage-return retaining the last two digits entered as the value. Unless the delimiter is a carriage-return, the monitor outputs the contents of the next sequential memory location with a dot prompt. A carriage-return terminates the command.
SUBSTITUTE REGISTER
[14] S register-name (CR)
Register-name may be A, B, C, D, E, F, H (HL), I, N (state of the Z80 interrupt flip-flop), P (PC), S (SP), A', B',
C', D', E', F', H' (HL'), X (IX), or Y (IY).
This command prints the name of the user-register requested, displays its contents, outputs a dot,' . ',as
a prompt for the substituted value. If no change is desired, type a space or another dot. Otherwise, enter the new value. The monitor accepts hex digits until it gets a delimiter such as space, dot, or carriage-return retaining the last two digits (four digits for a 2-byte register). Unless the delimiter is a carriage-return, the monitor prints the name and contents of the next register followed by the dot prompt. A carriage return
terminates the command.
UART SELECT
[15] U device-name (CR)
Device-name may be A or B. The Cromemco TUART has two UARTs. When the monitor is entered
via reset, UART A is selected for its input/output channel. This command allows the user to change the
UART selection. It is often used in the multiple com-
mand mode (see page 2).
VERIFY
[16] V source-addr source-end destination-addr (CR)
or V source-addr S swath-width destination-addr (CR)
Loading...
+ 22 hidden pages