Im Magazin „BYTE" wurde im Juli 1976 der folgende Artikel abgedruckt.
Ein Programm, um den Ablauf einer 8080 CPU kennenzulernen. Es schließt allerdings 16 Bit Operationen (z.B. LXI) ebenso aus wie Sprunganweisungen. (Die zur Verfügung stehenden Instruktionen sind in Tabelle 1 aufgelistet.)
Photo 1: In this example, Educator-8080 is shown before (left) and after (right) the execution of an XRA A instruction. The effect of this instruction is of course to dear the accumulator A, as is shown at the right.

Explore an 8080 with Educator-8080

Charles P Howerton
President, Digital Group Software Systems Inc
PO Box 1086
Arvada CO 80001

What Is an Educator?

Educator-8080 was designed as a classroom instruction aid for a microprocessor programming course. The principal design goals were to develop a system which would illustrate the architecture of the machine and the effect of the execution of various instructions. For example, the reader might ask to what use the logical EXCLUSIVE OR function may be put in an 8080. This function, which operates on each bit, has a value of 1 if either of the two operands or arguments, but not both, has a value of 1; otherwise it has a value of 0. The Educator-8080 can simply illustrate this function. In the example shown in photo 1 (left and right), both arguments of this function are equal: the first argument is the value in the accumulator (A) and the second argument is also the value stored in the accumulator (A). The function value (ie: the result) is placed in the accumulator after execution. The left photo shows the accumulator (and other registers, etc, which are not affected) before execution of the instruction XRA A, and the right photo shows it after execution. The result is that the accumulator (A) is cleared, ie: it contains eight 0 bits. This result is consistent with the definition of the EXCLUSIVE OR above: Whenever both bit arguments are 0, or are 1, a value of 0 is returned. This example shows that the Educator-8080 is a convenient means to illustrate rather complex operations which facilitate learning the instruction set and architecture without the tedium of plowing through books. A subordinate goal was to implement the entire system with the exception of the physical input output routines and the stack in 1024 bytes of memory. All of the design goals were met. In addition, if the IO devices are ASCII oriented, a reduction in the length of the error messages (perhaps limiting them to the error code number) should provide sufficient space for the inclusion of the physical input output routines and the stack within the 1 K byte memory space.
Educator-8080 is written in a fairly straightforward manner and it should not be particularly difficult to adapt it to any 8080 system with more than 1 K bytes of programmable memory, a keyboard, and an output device of some kind. It is designed to operate with a television display device and to dynamically show the results of the execution of the input commands.
It would probably be desirable to modify the display function somewhat if the output device is a hard copy device such as a Teletype. The content could be the same but the elimination of blank lines and printing the titles only every 10 or 15 instructions would speed things up considerably on a Teletype device. The input output routines required to adapt Educator-8080 to almost any system are described functionally but are not given in detail. They should be adapted from routines already in use for a given system.

The Instruction Set

The Educator-8080 instruction set is a subset of the 8080 instruction set. The commands implemented within Educator-8080 were selected to provide representative instructions from most of the functional instruction groups. Since the instructions are to be executed one at a time from keyboard input, there was no need to incorporate any of the Jump, Call or Return instructions; however, since the flags are displayed after each operation, it is very easy to determine whether or not a given conditional Jump, Call or Return would cause a transfer of control by simply observing the setting for the flag whose status is being tested. In addition, because of memory limitations none of the instructions which cause memory to be read or written were implemented. Finally, no instruction whose action could not be readily observed was implemented.
To keep the display as uncluttered as possible the registers which could be accessed by Educator-8080 instructions were limited to the accumulator and the B and C registers. It would not be particularly difficult to incorporate the rest of the registers into the display and as operands for the Educator-8080 instruction subset. However, unless the ability to address memory is desirable the only instructions which could be added to the subset would be the DAD and the XCHG.
The instruction subset and the valid operands for each instruction are shown in table 1. Table 2 contains the corresponding information as it is loaded into the computer's memory and used by Educator-8080.

Immediate Operands

Almost half of the instructions supported by Educator-8080 require immediate operands. An immediate operand is a constant value which is part of the instruction being executed and it immediately follows the operation code of the instruction, hence the name immediate.
Whenever a single byte "constant" is required in a program, its inclusion as the immediate value of an appropriate instruction reduces the length of the program because there is no need to address the value directly. Immediate values have an implied address which is the address of the byte following the opcode and this address is supplied from the program counter register automatically whenever an immediate type instruction is executed. In the Educator-8080 system the "program counter"¯ is provided by the operato's sequence of commands which are executed one by one
Photo 2: What happens when an 8080 executes an ADD B instruction? A specific example is illustrated in this set of before and after snapshots.
Educator-8080 has three different types of immediate values as part of the input command and defaults to one of these types if the input command omits type information.
The general form of an immediate operand is as follows:
T p V p
Where: T is the type code which designates the form of the immediate value and may be any of the following:
B - for a binary immediate value
Q - for an octal immediate value
H - for a hexadecimal immediate value
If the type code is omitted entirely and the first nonpunctuation character encountered is a numeric digit 0 to 7, then a default type of octal is assumed.
p is any form of punctuation (eg: single or double quotes, parentheses, etc). Punctuation is not required, and provision for its inclusion is solely in the interest of enabling the user to enter commands in a format consistent with that of various advanced assemblers.
V is the value of the immediate operand expressed in a form consistent with the explicit or implied type selected. The form and content of the value field for each type is as follows: T = B: V is a series of eight consecutive numeric characters which have the value zero or one.
Example: B'110001'. V is 11000111, quotes are optional.
T = Q or T omitted: V is a series of three consecutive numeric characters which have octal digit values of from 0 to 7.
Example: Q'307' V is 307, quotes are optional.
T=H: V is a pair of consecutive characters which have hexadecimal digit values from 0 to F.
Example: H'C7' V is C7, quotes are optional.
Photo 3: To illustrate the use of hexadecimal immediate values, this photo shows the operation of XRI H'C3'.
With the exception of the move immediate (MVI) command which requires a destination register, immediate commands are entered as the mnemonic opcode followed by the immediate operand in any of its valid forms.
Some "before and after"¯ examples of Educator-8080 commands are shown in photos 1 through . In each case, a command is typed into the keyboard of the computer, then the Educator-8080 display following the command is depicted.

Entering Commands

Commands are entered into Educator-8080 as a string of characters (eg: letters, numbers, spaces and punctuation) followed by a command termination character. As written, Educator-8080 assumes that the command termination character will be an ASCII carriage-return (octal 015). However, any other keyboard character code may be used as the command termination character by changing the value of the immediate operand in the instruction located at address <0>/341 which tests for command termination. (See listing 1.)
Since it is not uncommon to make errors when keying information into a computer, two provisions have been made in Educator-8080 for correcting or eliminating errors. The ASCII delete character code (octal 177) is used to delete the last remaining character in the input string. Since a deleted character is not considered to exist, N consecutive delete characters will delete the N preceding characters. For example, if the delete character is shown as a back arrow (←), RAX←L will be reduced to RAL and CQP←←MA will be reduced to CMA. Characters which have been keyed in are displayed after they have been tested. The display function uses the octal value 177 as a clear screen control code; therefore, character deletes are transformed into the back arrow before they are displayed and stored. Educator-8080 users with systems which have a back arrow (octal 033) key on their keyboards may use it as a character delete code and it will have the same effect as the delete key assumed in this version. Users who have neither of these keys can designate any keyboard character as the delete character code by changing the immediate operand in the instruction located at <0>/346 which tests for the delete character. (See listing 1). The other, and somewhat more drastic, method of eliminating keying errors is to delete the entire input line. This is usually done when an error is detected before the command termination character is input but several characters after the error occurred. The procedure for deleting an entire line is to enter an ASCII form feed code (octal 014) which is a "control L"¯ combination on typical ASCII keyboards. This will clear the input line and restart the command entry procedure. Like the command termination and the character delete codes, the line delete code can be made to be any keyboard character by changing the value of the immediate operand in the instruction at location <0>/334 which tests for the line delete code.
A very useful feature of Educator-8080 permits the user to execute the last command input several times. This is accomplished by simply keying the command termination character when the system calls for the entry of a new command. In order to provide this facility the input buffer is not cleared prior to calling for the entry of a new command, so the last previously entered command is still in the buffer. This feature is especially handy when demonstrating the effect of multiple executions of the rotate, increment, decrement, arithmetic and logical commands.
The general format for entering a command is as follows:
OPCODE[p OPERAND-1 [p OPERAND-2] ]
Where:
OPCODE is the mnemonic opcode for the command. For example; MOV XRI, etc.
p is any desired form of punctuation or a space, p is not required and, therefore, may be omitted entirely.
OPERAND-1 is the first or only operand required by an instruction. It may be a register Identification or an immediate value. See table 1 for the operand requirements.
OPERAND-2 is the second operand where required by a specific instruction. See table 1.
t is the command termination character, an ASCII carriage return in the listing 1 version of Educator-8080.
The brackets ([ ]) shown in the general format are used to indicate that the items within them are optional, since some commands do not require any operands (eg: RAL, STC, CMA, etc), some require one operand only (eg: ADI, CMP, XRA, etc), and some commands require two operands (eg: MOV and MVI).

Error Messages

In the process of entering and executing commands under Educator-8080 there are a number of errors which can occur. When this happens an error message is displayed on the output device. For the benefit of users with television displays, a delay of approximately two seconds occurs as the message is being displayed, to provide time to read it. After the two second delay the normal Educator-8080 display is generated and the command entry mode is reentered. Teletype or other hard copy users will probably wish to alter the error display routine slightly by eliminating the extraneous spaces which are used to center the error messages on the TV monitor screen.
The errors which can occur are listed in absolute octal form in table 3. The error numbers and extended explanations of conditions are as follows:
  1. INPUT TOO LONG: The input string exceeds 22 characters in length probably because too many characters were deleted since delete character codes count as input characters. Twenty two characters should be sufficient for any normal entry including punctuation and several character deletes.
  2. INVALID COMMAND: The input command mnemonic is not one of the ones implemented by Educator-8080.
  3. INVALID REGISTER: The operand register is not A, B or C for a command which requires a single register as an operand or it was not B for the INX or DCX commands which require register pairs as operands.
  4. INVALID IMMED TYPE: The type code for an immediate operand is not B, Q, or H, or if the default was attempted the first digit of the implied octal value was not a digit from 0 to 7.
  5. INVALID IMMED VALUE: One of the characters in the immediate operand value string was inconsistent with the immediate type code. For example, a digit in a binary input string was not a zero or a one. This can also be caused by not providing the correct quantity of digits for the immediate type specified; too few digits will possibly cause a problem. If too many digits are entered only the first N will be used (N=8 for binary, N=3 for octal and N=2 for hexadecimal).
  6. ERROR! This message should not occur unless a grave internal error occurs in Educator-8080.

Educator-8080 Program Listing1

The Educator-8080 program is presented in an assembly language format as listing 1. It was hand assembled and, therefore, some liberties were taken in the way it was presented. Addresses are shown in a split octal ("Intelese"¯) format of page and address within pag. Educator-8080 requires four contiguous 256 byte pages of memory (it just fits); to ease the implementation process all addresses and address sensitive bytes are shown with relative page numbers in the format <P>, where P is a 0,1, 2 or 3. A simple process of substitution as the program is being put into the machine will provide the ability to locate Educator-8080 in any four contiguous pages provided the program begins on a page boundary.
The assignment of three addresses is left to the user. These three addresses are shown symbolically in both the source and the object code. The first address is for the location of the STACK; insert the address of the stack in the command at location <0>/000. The stack should be capable of being at least 10 to 12 levels deep to function correctly. The second and third addresses are the addresses of the physical input and output routines which must be provided by the user. These routine addresses are shown symbolically as KEYBD and CHRPR in the source listing. The values are shown as 'XXX XXX' in the object code.
[The message formats are listed in absolute octal form in Table 4]

Table 5: Work Areas. The Educator-8080 program employs several work areas in programmable memory. These work areas are listed in this table, along with initial values where applicable, and commentary. Not shown in this table is one very important work area which is part of listing 1: the location XQTOP (address <2>/046) identifies a two byte area which must be programmable to allow an 8080 operation code to be "dummied in" and executed based upon the user’s input command.
Octal
AddressNameLengthInitial ValueCommentary
<3>/346PSWA2000 000Initial PSW and A values.
<3>/350BANDC2000 000Reference to B and C symbolically.
<3>/350CREG1Equivalent to BANDC, C value.
<3>/351BREG1Equivalent to BANDC+1, B value.
<3>/352BREG22Command work area, uninitialized.

Input and Output Routines

The Educator-8080 program references two subroutines for the purpose of executing IO operations. The KEYBD subroutine is used to read a single character of input from an ASCII keyboard device. The CHRPR subroutine is used to display (or print) a single character. These routines are not shown in the listings, but should be adapted from the routines normally used with the particular system in which the program is run. Both KEYBD and CHRPR use the accumulator (A) to pass a single character argument. KEYBD defines a value in A obtained from the input device. CHRPR displays the value in A on a device such as a video display or Teletype. All other registers of the 8080 processor should be left unchanged upon return from either of these routines. Entry to the 10 routines is shown using a CALL instruction in these listings. A corresponding RET instruction in the routine should return control when either operation is completed. An alternate method of entry would be to employ the 8080 RST instruction in place of CALL. If the Educator-8080 listings accompanying this article are used without reassembly, then the CALL instructions would be replaced by an RST and two single byte NOP instructions.
The keyboard entry routine KEYBD should accept the character from the keyboard, then force lower case letters to be upper case letters. In order to avoid interference with the special meanings of the values octal 200 to octal 377, the high order bit should be forced into a zero state by an AND operation with octal 177. After this processing, the input value should be left in the accumulator prior to return.
The character display routine, CHRPR, accepts a seven bit ASCII code which is passed from the calling routine in the accumulator. The characteristics of CHRPR will vary from device to device and it is the responsibility of the person using this program to provide an appropriate CHRPR. The original Educator-8080 program was designed to be used with a Digital Group TV-Monitor output device which displays 16 lines of 32 characters. This device automatically begins a new line whenever the previous line has been filled, so the user of a Teletype or a video display with line length greater than 32 should generate the equivalent of a carriage return and line feed at the end of each 32 character line. This can be done by setting a software counter to 32 at the start of a line, and decrementing every time a displayable character is reached. When the counter reaches zero, the line feed and carriage return codes are sent and the counter is reset to the starting value.
There is one special character value, octal 177, which must be detected by CHRPR and interpreted if necessary. This is the character used for clearing the screen of a video display, or doing a form feed operation on a printing device. For a Teletype device, the form feed operation can be simulated by spacing out the listing. Simply emit a carriage return followed by several line feeds. For a video display communications terminal, the ASCII form feed character, octal 014, is often interpreted as a command to clear the screen. For the Digital Group TV-Monitor display the screen is cleared then the screen address is set for the upper left hand corner.
The Educator-8080 is very useful to the novice. On the other hand, its implementation requires a skill level beyond that of the beginner, who might fare well to obtain the help of an advanced hobbyist in implementing the program.
For The Digital Group 8080 system, a version of this program is available on a cassette including documentation – contact The Digital Group Software Systems Inc, POB 1086, Arvada CO 80001.

1. Später fand ich der CP/M GROUP VOL 16 ein Listing, das für CP/M ergänzt wurde

Eingescanned von Werner Cirsovius
Dezember 2013
© BYTE Publications Inc.