Computer Technology 30
The Intel 8085 Microprocessor

GENERAL DESCRIPTION

The Intel 8085 microprocessor is an NMOS 8-bit device. Sixteen address bits provide access to 65,536 bytes of 8 bits each. Eight bi-directional data lines provide access to a system data bus. Control is provided by a variety of lines which support memory and I/O interfacing, and a flexible interrupt system. The 8085 provides an upward mobility in design from the 8080 by supporting all of the 8080’s instruction set and interrupt capabilities. At the same time, it provides cleaner designs by virtue of a greater on-device component density, and by requiring only a 5 volt supply. In addition, the 8085 is available in two clock speeds.

The 8085 comes in two models, the 8085A and the 8085A-2. The 8085A expects a main clock frequency of 3 MHz, while the 8085A-2 expects a main clock frequency of 5 MHz. In both cases, the clock is a single phase square wave. This single clock is generated within the 8085 itself, requiring only a crystal externally. This eliminates the need for an external clock generator device. In all other respects, the A and A-2 devices are identical.

The 8085 supports the interrupt structure of the 8080, including the RST instruction and the eight vectors. It extends these by the addition of four more interrupts, each with their own pins, three of which are maskable, and which use vector areas between the existing ones of the 8080. The 8085 is adaptable for use with the 8259 Priority Interrupt Controller, a programmable device. It is possible, upon an interrupt from this device, to jam either a RST instruction onto the data lines, or a CALL instruction to any location in RAM directly.

The 8085 has two pins dedicated to the generation or reception of serial data. While these do not constitute a complete serial I/O system, they do allow the MP to send and receive serial bits, albeit with a large software overhead. The 8085 therefore finds itself useful as a complete control device for remote control applications.

The 8085 supports the entire 8080 instruction set. In addition, two new instructions are added. These instructions permit software control over the extended interrupt capabilities of the ‘85, by making the new interrupts both maskable and interrogatable. The masks can be set, examined, etc.. The same instructions also allow investigation of the serial input line, and generation of conditions on the serial output line.

Unlike the 8080 which had discrete pins for the address and data busses, the 8085 make use of multiplexing of the lower 8 bits of the address with the data bits on the same 8 pins. This requires that the external circuitry be able to catch and hold the A0-A7 lines for later use. The upper 8 bits of the address have their own pins, however. Three primary control bus lines allow the device to identify whether the cycle in progress is for RAM or I/O, and whether it is a Read or a Write. Two status pins are provided, to allow advance knowledge of certain events in multiprocessor applications.

The internal timing of the device makes use of machine cycles in which, in almost every case, a bus cycle is involved. Each machine cycle consists of several T-states, which are defined by the clock input signal. Thus, many clock cycles are needed to effect one complete instruction. The 8085 has many new support devices to ease design work. These include the 8259 Programmable Interrupt controller, the 8202 Dynamic RAM controller, plus several new I/O devices with various amounts of RAM, ROM, parallel I/O, and timer-counters. The general approach was to make the device as compatible with the Multibus architecture as possible.

DATA FLOW

Locate the dataflow diagram in your reference manual. The dataflow of the 8085 is made up of the following units:

  1. A General Purpose Register Array, most of which is accessible by the programmer, and which forms the essential data manipulation ability of the system;
  2. An address generation system consisting of the Program Counter, Stack Pointer, address latches, and incrementer/decrementer. Two additional 8-bit latches are provided. The first, labeled Address Buffer, provides the upper byte of an address to the system address bus in a straight-through manner. The second, labeled Data/Address Buffer, provides the lower byte of the address early in a machine cycle; it is used later in the cycle to provide or accept an 8-bit data byte from the internal data bus of the MP to the system data bus, or from the system data bus to the MP’s data bus. This buffer therefore provides the AD0 - AD7 multiplexed address/data function mentioned above.
  3. A mathematical and logical subsystem composed of the Arithmetic Logic Unit (ALU) and asS0ciated registers, which handle the math and logic functions of the machine;
  4. An Instruction Register and decoder system which interpret the programmer’s instructions and implement them via nanocode;
  5. A timing and control package which provides the bodily functions of power and clock circuits, and handles the wait, interrupt, and hold functions of the system;
  6. An 8-bit internal data bus, which provides the data path between functional elements, and to the outside world via the Address/Data Buffer;
  7. Interrupt control interfacing which provides both the standard 8080 interrupt structure, and 4 new interrupts which are maskable under special program controls, these last via the internal data bus;
  8. Two serial data lines, Serial Input Data and Serial Output Data, which feed the internal data bus directly, and are serviced as part of the interrupt control structure mentioned above.

The General Purpose Register Array contains the B, C, D, E, H, and L registers, each 8 bits wide. The B and C, D and E, and H and L registers may be grouped into 16-bit register pairs. The H&L register pair may be used to store indirect addresses.

The array also contains the Program Counter (PC) and Stack Pointer (SP). These 16-bit registers contain the address of the next instruction part to be fetched, and the address of the top of the stack, respectively.

The GPR array also includes an Address Latch/Incrementer-Decrementer circuit, to make the address next required on the system address bus available to it, and to increment or decrement addresses or register contents as required.

The mathematical and logical function of the system are provided by an 8-bit Arithmetic-Logic Unit (ALU), which accepts two 8-bit arguments and generates an 8-bit result. It is fed by an Accumulator register and a Temporary register, both 8 bits wide; the result returns to the internal data bus for distribution. The ALU also has a Condition Flags register, for the storage of the conditions under which an operation ended, which may be used by following instructions. In all cases, the ALU, Accumulator, and Condition Flags function exactly as in the 8080.

The Instruction Register and Instruction Decoder accept the incoming byte from the data bus during the first machine cycle of an instruction, and interpret it by controlling the internal reS0urces of the MP as S0urces and destinations for bits and bytes. The 8085 is nanoprogram-controlled.

Acting under the direction of the instructions, the Timing and Control section of the 8085 generates the necessary timing pulses to synchronize their execution. The 8085 has its own internal oscillator, which requires only an external crystal to generate the clocks. The internal workings of the ‘85 require only a single phase clock, with a 50% duty cycle, which minimizes system timing requirements. This clock is made available to the outside world to allow external functions to be synchronized to the MP’s cycles.

Ready - Wait functions are provided in the ‘85. If a memory circuit’s response time is such that the MP will expect data before the RAM is ready to respond, the memory subsystem may request a Wait State (Tw) by pulling the Ready line low. This must be done prior to a certain point in the machine cycle. This function is important because the ‘85 is designed to work at 3 MHz, decreasing the time within which the RAM may respond.

The Timing and Control section of the ‘85 also provides several native signals, both inbound and outbound, which interface with the external world, and provide control signals and timing to the three-bus architecture. This makes way, then, for the multiplexing of the address and data on the AD0-AD7 lines. These lines include /Read, /Write, and I-O/M, which indicate whether the function to be performed is a input or an output, and whether it is addressed to memory or an I/O device; Address Latch Enable and two status lines so and S1, which advise the external world of the status of each machine cycle of the 8085; Hold and Hold Acknowledge, which allow the external I/O to ask for and receive a DMA cycle; and Reset In and Out, which provide the reset.

The 8085 also supports the interrupt structure of the 8080, with the Interrupt and Interrupt Acknowledge lines. In the ‘85, however, these lines are made available to the internal data bus of the MP instead of being connected directly to the Timing and Control logic. The external circuits see the operation of them as the same, however. In addition, four more interrupts are available, also connected to the data bus inside the MP, but these are under special software control with two OP codes. The reason for the placement of the interrupts onto the data bus will be shown later.

Two I/O lines are provided on the ‘85 which allow a single bit to be tested or presented directly by the MP. The Serial Data In (SID) and Serial Data Out (SOD) lines may be sensed or driven under program control via the same two instructions included for the new interrupt scheme. They allow the MP to treat them as either true serial data I/O, if programmed timing loops are included, or as simple single bit test or control ports for the sensing or control of external events. More will be shown on these later.

INTERFACING THE 8085

A brief description of the signals between the 8085 and the outside world follows. Refer to the reference manual for pin-outs and details.

  • Vcc & Vss: These are the power connections for +5 volts and ground, respectively.
  • SYSTEM TIMING

    Refer to the Reference Manual for diagrams and details on the system timing. This will be a general discussion to point out the highlights and guide the student through the essential information. The instructor will augment it with discussions of the timing diagrams.

    THE PROCESS0R CYCLE

    The time required by the 8085 to fetch and execute one machine language instruction is defined as an Instruction Cycle. As in the 8080, the instructions may be of different complexities, with the result that the more complicated instructions take longer to execute. The 8085’s method of instruction execution inside the MP is more organized, however, and so the time required to execute any instruction is more predictable and more regular.

    Each instruction is divided into one to five Machine Cycles. Each machine cycle is essentially the result of the need, by the instruction being executed, to access the RAM. The shortest instruction would require just one machine cycle, in which the instruction itself is obtained from RAM. The longest, of five machine cycles, would consist of five RAM accesses, the first to obtain the instruction byte itself, and the remaining four to be divided into fetching and saving other bytes. For example, cycles numbers 2 & 3 may be needed to fetch two more bytes of an address, while numbers 4 & 5 may be needed to save a 2-byte address somewhere else in RAM.

    The type of machine cycle being executed is specified by the status lines I-O/M, S0, and S1, and the control lines /RD, /WR, and /INTA. These six lines can define seven different machine cycle types as follows. Refer to the chart in the manual which defines the bit patterns of each.

    1. OP CODE FETCH: This is the first machine cycle of any instruction. It is defined with S0 and S1 asserted high, and I-O/M and /RD low. It is a read cycle from RAM to obtain an instruction byte.
    2. MEMORY READ: This is a normal read cycle of any byte except the OP code. It is defined with S0 and S1 set to 0, 1 respectively, and I-O/M and /RD low. It is a read cycle from RAM to obtain a data or address byte.
    3. MEMORY WRITE: This is a normal write cycle to memory. It is defined with S0 and S1 set to 1, 0 respectively, and I-O/M and /WR low. It is a write cycle to RAM to store one byte in the specified address.
    4. I/O READ: This is a normal read cycle from an I/O device. It is defined with S0 and S1 set to 0, 1 respectively, and with I-O/M high and /RD low. It is a read cycle which will bring one byte into the MP from the input device specified.
    5. I/O WRITE: This is a normal write cycle to an I/O device. It is defined with S0 and S1 set to 1, 0 respectively, and with I-O/M high and /WR low. It is a write cycle which will send one byte outbound from the MP to the specified output device.
    6. INTERRUPT ACKNOWLEDGE: This is a response to an interrupt request applied to the MP via the INTR line. It is defined with S0 and S1 set to 1, 1 respectively, I-O/M set high, and both /RD and /WR also high. The Interrupt Acknowledge pin is also held to a low asserted level. l It is neither a read nor write cycle, although the interrupting device will jam an interrupt vector onto the D0-D7 lines on the next machine cycle.
    7. BUS IDLE: This is an idle cycle in which no specific bus activity is defined. It occurs under three differently defined conditions:
      1. Double Add Instruction (DAD): This instruction requires enough execution time to merit its own Idle cycle. It is defined with S0 and S1 set to 0, 1 respectively, I-O/M set low, and neither /RD nor /WR asserted (both high). Since neither a read nor a write are specified, no bus action takes place.
      2. Acknowledge of Restart or Trap: This idle cycle allows time for the ‘85 to cope with a RST or Trap interrupt request. All bits are held high.
      3. Halt: This idle cycle indicates that the MP has executed a Halt instruction. The I-O/M, /RD, and /WR lines are all tristated, which would allow them to be controlled by other devices. INTA is held inactive, but not tristated. The Hold line is really the proper one to use for DMA or multiple processors.

    Each of the machine cycles defined above, during which an access of a RAM address or an I/O device is made (except the idle cycles), is further divided into T-states. Each T-state, for an ‘85 with a 3 MHz clock, will be about 333 nanoseconds in length. The first machine cycle, during which the OP code is being fetched, will be either 4 or 6 T-states in length. Whether 4 or 6 T-states are used depends upon whether the instruction needs further information from RAM, or whether it can be executed to completion straight away If multiple accesses are needed, the cycle will be 4 states long; if the execution can run to completion, 6 states are required. (Remember that the ‘85 is running with a faster clock, so that less time per T-state is available.)

    The number of T-states for the second and succeeding machine cycles will always be 3 for normal instructions. There are two exceptions to this general rule. The first exception is in response to the request for wait states from an external device which has pulled the Ready line low. This will cause the ‘85 to insert one or more Tw states between T2 and T3, as in the 8080. The second exception is when the ‘85 is placed into the Hold condition in response to a signal from an outside device applied to the Hold line. This will be an indeterminate amount of time during which the external device will be performing a DMA function.

    The documentation includes a small chart which specifies the actions of the major signals of the ‘85 during each of the 10 possible types of T-states. It may be summarized as follows:

    1. T1 STATE: This state is the first of any machine cycle. The chart shows that S0-S1 lines, I-O/M, A8-A15, and AD0-AD7 contains whatever would be appropriate for the type of instruction being executed. (The "X" in the chart is defined as "unspecified", which translates to "whatever is normal".) The S0-S1 and I-O/M lines will define, at this early point in the machine cycle, whether the MP is attempting to address a RAM location or an I/O device. The address lines will identify the location or I/O device to be dealt with. The Address Latch Enable (ALE) line will allow some sort of external circuitry to catch and hold the contents of the AD0-AD7 lines to be used as the low byte of the address.

      Note that while the S0 and S1 lines may safely be ignored for general purposes, they are provided to allow the engineer to obtain an advanced warning of the type of function that will be specified during T2, i.e., a read or a write. An engineer can monitor this lines with circuitry of his own to generate his own "Early Read" or "Early Write" if he needs it for slow peripheral devices or devices.

      The /RD, /WR, and /INTA lines are all negated at this time. Since the AD0-AD7 lines are being used to present an address byte, it would be inappropriate to move data on the data bus; besides, it’s too early to do so. It’s also too early for /INTA. ALE, however, is asserted, since this is the time that the AD0-AD7 contents will contain the lower address byte, which must be caught and held outside the ‘85 for use by the following T-states.
    2. T2 STATE: The chart indicates that all lines except ALE (which will be inactive for the rest of the machine cycle) will assume the proper level for the type of instruction in progress. The address lines retain the bit pattern selecting one byte from RAM or an I/O device; the AD0-AD7 lines will now prepare to either accept or present a data byte (they are in a state of transition during T2); I-O/M and the S0, S1 lines are still displaying the original settings of T1. Either /RD or /WR will assert during T2, to indicate the nature of the data transaction. /INTA will assert at T2 if an interrupt cycle has started.
    3. WAIT STATE: If the Ready line was negated during T2, a Tw is inserted to allow the external circuitry more time to prepare for data transmission. A specific point in T2 is defined, after which a late negation of Ready will not cause the Tw to be inserted. This corresponds to the same actions in the 8080 device. All signals set up during T2 will remain constant during Tw.
    4. T3 STATE: All lines set up during T2 will remain the same in T3, except the AD0-AD7 lines, which will be conducting data either into or out of the 8085. At the end of T3, the /RD or /WR line will negate to indicate the end of the active function. This will cause the data byte standing on AD0-AD7 to disappear.
    5. T4 - T6 STATES: These states are required for time to permit the 8085 to continue processing internally. No bus actions are required. The S0 & S1 lines are both asserted, while I-O/M is negated, which specifies that the ‘85 is involved in an 0P code fetch. Since T4 through T6 will exist only on the first machine cycle of an instruction, this corresponds correctly with the Machine Cycle chart. The AD0-AD7 lines are tristated; the A8-A15 retain their original setting; the /RD, /WR, and INTA lines are all negated.

    In addition to the T-states described above, the chart also indicates the conditions during states involved in Resets, Halts, and Holds. It must be kept in mind that during any of these, the MP clocks are still running, and the ‘85 is alive inside; it has simply shut itself off the buses to allow external events to occur. These states tristate the address, AD, I-O/M, /RD, and /WR lines to allow external devices to control them. The other lines are held at inactive levels except the S0 & S1 lines, which do indicate what type of machine cycle the system is in, i.e., whether it is a Reset, Hold, or Halt.

    TIMING DIAGRAMS

    Locate the figure in the Intel documentation labeled 8085A Basic System Timing. This diagram illustrates the events in an instruction of three machine cycles. The M1 cycle is four states long, and the events at each state are shown. Notice particularly the operation of the AD0-AD7 lines, which provide the lower address byte during T1, followed by data during the later part of T2 and all of T3. Observe that the ALE line corresponds to the presentation of this low address byte. Note also that in a machine cycle in which data is going to be read, the AD lines actually capture the incoming byte during the middle of T3, and may drift around in the later part of T2. Compare this to the case of a write, in which the ‘85 presents the data byte to be written early in T2, and holds it constant until the end of T3.

    Several other timing diagrams are included in the documentation which illustrate the details of each different cycle that the ‘85 can perform. These all conform nicely to the Basic System Timing diagram, with the addition of wait states, and of specific lines to perform specific functions. The Instructor will discuss these with you.

    HOLD AND HALT STATES

    The 8085 has provisions for the execution of a Halt instruction, which causes the system to go into T-halt states. During this time, the ‘85 is simply waiting for something to occur. There are three ways out of a Halt: A Reset, a Hold Request, and an enabled interrupt. If a Hold Request occurs during a Halt, the ‘85 will honor it by going into T-hold cycles as long as the Hold line remains asserted; it will return to the halt condition when Hold negates. If an interrupt occurs during a halt, the MP will go into an interrupt cycle if the interrupt was enabled; it will be ignored if it was not enabled. An enabled interrupt during a hold state will have to wait until the hold clears before being given control of the system. Two diagrams are included in the documentation to indicate the various combinations of hold, halt, and interrupts.

    INSTRUCTION SET

    The instruction set of the 8085 is identical to that of the 8080, with the exception of the addition of two instructions, RIM and SIM. The definitions of the OP codes, how they work, the operation of the condition flags, addressing modes, and the use of the H and L register pair for indirect addressing are all identical between the two processors.

    The Intel documentation shows many symbols used to describe the functions and relations of parts of instructions. These include the use of lower case letters, especially the "r", to indicate a register, "rp" to indicate a register pair, "addr" to indicate an address, "data" to indicate an 8-bit data byte, "data 16" to indicate a 16-bit data word, "rh" and "rl" to indicate the high-order register and the low-order register of a register pair, respectively, and the use of some upper case, such as "PC" for program counter and "SP" for stack pointer. Many graphics symbols are used, and the instructor will now discuss them with you at length, using the documentation as reference. Be sure you understand them before proceeding.

    FLAG REGISTER

    The Status Flags of the 8080 and 8085 are single bits which indicate the logical conditions that existed as a result of the execution of the instruction just completed. This allows instructions following to act accordingly, such as a branch as a result of two values comparing equal. The flags are:

    ZERO FLAG: This flag is set to a 1 by the instruction just ending if the A Register contains a result of all 0’s. Besides the obvious mathematical applications, this is useful in determining equality in a compare operation (a value subtracted from a second value with an answer of 0), or in logical AND or OR operations where the result left the A Register with no bit set to a 1 (the AND was not satisfied). If any bits were left set to a 1 in the A Register, the flag will be reset to a 0 condition.

    SIGN FLAG: This flag is set to a 1 by the instruction just ending if the leftmost, or highest order, bit of the A Register is set to a 1. The leftmost bit of a byte in signed arithmetic is the sign bit, and will be 0 if the value in the lower seven bits is positive, and 1 if the value is negative.

    PARITY FLAG: This flag is set to a 1 by the instruction just ending if the A Register is left with an even number of bits set on, i.e., in even parity. If the number of bits in the A Register is odd, the bit is left off. This may be useful in I/O operations with serial devices, or anyplace that error checking is to be done.

    CARRY FLAG: This flag is set to a 1 by the instruction just ending if a carry out of the leftmost bit occurred during the execution of the instruction. An example would be the addition of two 8-bit numbers whose sum was 9 bits long. The 9th bit would be lost, yielding an erroneous answer if the carry bit was not captured and held by this flag. This flag is also set if a borrow occurred during a subtraction or a compare operation.

    AUXILIARY CARRY FLAG: This flag is set to a 1 by the instruction just ending if a carry occurred from bit 3 to bit 4 of the A Register during the instruction’s execution. Because of the relationships of decimal in pure BCD to hexadecimal coding, it is possible to bring BCD values directly into the A Register and perform mathematical operations on them. The result, however, will be as if two hex characters are being processed. If the result must be returned to the program as BCD rather than as hex, the Decimal Adjust Accumulator (DAA) instruction can make that translation; the Auxiliary Carry Flag is provided to assist in this operation.

    INSTRUCTION ORGANIZATION

    The 8085’s instructions are made up of bytes. In microprocessor parlance, a byte is described as 8 contiguous binary bits treated as a unit. The least significant bit is on the right, and is labeled Bit 0. The most significant bit is on the left, and is Bit 7. Thus, the machine coding is "origin zero", unless noted otherwise. Note also that there is no parity bit, or provision for it, as would be found in larger systems.

    The 8085’s instructions are either one, two, or three bytes long. In all cases, the first byte contains the essential information, such as the OP code. The second and third bytes, if included, provide operand information that won’t fit in the first byte.

    A close look at the first byte of each instruction will reveal a very great similarity between the 8085’s instruction format and that of the PDP11 system by DEC. In many instances, the description of the instructions in the Intel documentation specifies that certain bits of the first byte (#2,1,0) be designated as the "source" operand, and others (#5,4,3) as the "destination" operand. In this manner, all of the major functional units available to the programmer are encoded into three bits, according to the chart below:

    DDD or SSSRegister Name
    111A
    000B
    001C
    010D
    011E
    100H
    101L

    Similarly, the registers may be defined as register pairs, and two bits within the first byte may then be used to define these:

    RP BitsRegister Pair
    00B-C
    01D-E
    10H-L
    11SP

    The similarity between PDP11 and 8085 instruction sets is interesting, but by no means rigid. Many differences exist, primarily due to the difference between the 8- and 16-bit architectures.

    ADDRESSING MODES

    The 8085 provides four different modes for addressing data, either in its registers or in memory. These are described below:

    DIRECT MODE - This mode creates instructions three bytes long. The first byte contains the operation to be performed. The second and third bytes contain the address in memory where the data byte may be found. Thus, the instruction directly specifies the absolute location of the data. Note that the second byte of the instruction contains the low order byte of the address, while the third byte contains the high order byte of the address. This illustrates the inverse addressing of the device.

    REGISTER MODE - This mode results in single-byte instructions. The byte contains bits which specify a register or register pair in which the data is located.

    REGISTER INDIRECT MODE - This mode results in single-byte instructions. The byte contains bits which specify a register pair, which in turn contains the address of the data in memory. Thus, the instruction indirectly specifies the address of the data by referring to a register pair for the absolute address. Note that the high order byte of the address is stored in the leftmost register of the pair, while the low order byte of the address is stored in the rightmost register of the pair. The address 3000H, therefore, would be stored in the HL register pair as 30 in H, and 00 in L.

    IMMEDIATE MODE - This mode results in a two or three byte instruction. The first byte contains the instruction itself. The second and third bytes contain the immediate data, either as a single 8-bit value, or as a 16-bit value. If the 16-bit value is used, the bytes are reversed as discussed previously, with the second byte containing the low order byte, and the third byte containing the high order byte.

    BRANCH INSTRUCTION TYPES

    Normal execution of instructions is in a straight line. Branch instructions are available to alter the course of execution flow. These instructions can specify the address of the next instruction to be executed, if it is not the one immediately following the branch, in two ways:

    DIRECT BRANCH - In this mode, the branch contains the address to be used, if the branch occurs, as two bytes following the instruction byte. The second byte contains the low order byte, while the third byte contains the high order byte.

    REGISTER INDIRECT BRANCH - In this mode, the branch specifies a register pair which will contain the address for the branch. This address must obviously be set up prior to the branch occurring. The register pair contains the high order byte of the address in the first, or right-most register of the pair, and the low order byte of the address in the second, or left-most register of the pair, in order to maintain alignment with the general addressing scheme.

    The Intel documentation divides the 8085’s instruction set into five groups. These are the Data Transfer Group, Arithmetic Group, Logical Group, Branch Group, and a Machine Control-I/O Group. These will now be discussed individually, with specific instructions mentioned for illustration in these notes. The entire set will be reviewed by the instructor as this section progresses.

    DATA TRANSFER GROUP

    This group of instructions provides the 8085 with the ability to move data around inside the RAM, between the RAM and the registers of the MP, and between registers within the MP. They are important because a good deal of moving must be done to offset the fact that in an 8-bit byte, there is insufficient room to define the operands as specifically as is done, for example, in the PDP11. These instructions do not affect the condition codes. A few comments on the OP code groups follow:

    MOV GROUP: These three instructions (MOV r1,r2, MOV r,M, and MOV M,r) are the general means of moving data between memory and registers. They move one byte with each execution. The second and third examples illustrate the use of the Register Indirect mode of addressing, in which the H&L registers of the MP contain an address, and the data is moved to or from that address. This saves space, in that the instruction is only one byte long. It requires, however, that the H&L registers be previously set up with the address required. The letter "M", when appearing as an operand in this description, specifies Register Indirect mode with H&L as the register to contain the address. No other register pair is used as such.

    MVI GROUP: These two instructions (MVI r,data, and MVI M,data) provide a means of loading a byte immediately into a register or a memory address. Note that the Register Indirect mode again is evident. The immediate data is stored as a byte directly below the instruction byte.

    LXI INSTRUCTION: This single instruction (LXI rp,data 16) provides a means of loading any register pair with a two-byte value. The second byte l of the instruction is loaded into the leftmost, or low-order, register of the pair, while the third byte is loaded into the rightmost, or high order, register of the pair.

    LDA & STA: The Load Accumulator Direct (LDA) and the Store Accumulator Direct (STA) instructions provide a means of moving a byte between the accumulator and a RAM address. This may also be done with the MOV OP code, but only indirectly, that is, with the help of the H&L registers. The address of the byte to be loaded or stored follows the instruction, again with the inverse addressing.

    LHLD & SHLD: The Load H&L Direct (LHLD) and Store H&L Direct (SHLD) instructions provide a means of moving two bytes between the HL register pair and a RAM address. Since the H&L register pair is heavily used in the Register Indirect mode, these instructions provide a quick means of loading the two bytes of an address into the pair in only one instruction. The two bytes following the instruction contain an address in RAM, again low-order in byte 2, and high-order in byte 3. For the LHLD, this address points to a single byte, which is obtained and loaded into the L register. The second byte from RAM is obtained from the address one higher than the RAM byte, and loaded into the H register. The SHLD simply stores as above, instead of loads.

    LDAX & STAX: The Load Accumulator Indirect (LDAX) and Store Accumulator Indirect (STAX) instructions provide a means of moving data between the U accumulator and a memory location indirectly, with the RAM address contained in either the BC or DE register pair. This is not the same as the MOV, which uses only the HL register pair. This instruction permits the accumulator to access groups of data bytes, as may be necessary with long precision arithmetic. Obviously, the BC or DE pair must be previously loaded with the address desired.

    XCHG INSTRUCTION: The Exchange (XCHG) instruction permits the HL register pair’s contents to be exchanged with the DE register pair’s contents. This allows an address to be built in the DE pair, then, when ready, to be transferred at once to the HL pair. This would be advantageous in complex data handling.

    ARITHMETIC GROUP

    This group provides the 8085 with mathematical ability to manipulate 8-bit data, and, by judicious use of the condition codes, to manipulate larger values. The A register (Accumulator) can perform true adds, subtracts, and compares. The other registers can only increment or decrement by 1. Unless otherwise indicated, all the condition code flags are affected. A few comments follow:

    ADD INSTRUCTIONS: The Add Register (ADD r) and Add Memory (ADD M) instructions add the byte specified, either in a register or in the address contained by the H&L registers, into the accumulator. They assume that the accumulator already has in it the other value to participate in the add. The sum will remain in the accumulator. If the answer resulted in a ninth bit, it is stored in the Carry flag of the PSW.

    ADD WITH CARRY: The Add Register with Carry (ADC r) and Add Memory with Carry (ADC M) instructions will add the specified byte, either in a register or in the address contained by the H&L registers, AND the value of the Carry bit, into the accumulator. By including the carry bit in the operation, mathematical operations on values longer than 8 bits are possible. As above, the first value must already be loaded in the A register prior to execution of these instructions. The sum remains in the accumulator. If the answer resulted in a ninth bit, it is stored in the Carry flag.

    ADD IMMEDIATES: The Add Immediate (ADI) and Add Immediate with Carry (ACI) instructions provide a means of adding a fixed value into the accumulator. These instructions assume that an initial value has already been loaded into the accumulator. The immediate data is provided by the second byte of the instruction. The ACI instruction adds the immediate value and the value of the Carry flag, while the ADI does not take the Carry flag into account. The sum remains in the accumulator. If the answer resulted in a ninth bit, it is stored in the Carry flag.

    SUBTRACT INSTRUCTIONS: The Subtract Register (SUB r) and the Subtract Memory (SUB M) instructions subtract the specified byte, in a register or in the address contained by the H&L registers, from the contents of the accumulator. The accumulator must have the first value already loaded , prior to the execution of the instructions. The subtract is accomplished by the complement-and-add technique, in which the two’s complement of the specified value is computed first, and then added to the contents of the A register. The Carry flag will be set to a 1 if a borrow was required during the subtraction.

    SUBTRACT WITH BORROW: The Subtract Register with Borrow (SBB r) and the Subtract Memory with Borrow (SBB M) instructions will subtract the specified byte, either in a register or in the address contained in the H&L registers, and the value of the Carry flag, from the contents of the A register. The first value must be loaded into the A register prior to the execution of the instructions. The subtract is accomplished by the complement-and-add technique. The Carry flag will be set to a 1 if a borrow was required during the subtraction.

    SUBTRACT IMMEDIATES: The Subtract Immediate (SUI data) and Subtract Immediate with Borrow (SBI data) instructions provide a means of subtracting a fixed value from the contents of the accumulator. The immediate value is provided by the second byte of the instruction. The first value must be loaded into the accumulator prior to the execution of the instructions. The subtract is accomplished by the complement-and-add technique. The SBI instruction will subtract both the immediate value and the contents of the Carry flag from the A register, while the SUI does not take the Carry flag into account. The Carry flag will be set at the end of the instruction if , a borrow was required during execution.

    INCREMENT INSTRUCTIONS: The Increment Register (INR r) and Increment Memory (INR M) instructions provide a quick means of adding one to the contents of a register or memory location. These instructions allow the programmer to create counting routines and reiterations. Note that the Carry flag is not affected by these instructions.

    DECREMENT INSTRUCTIONS: The Decrement Register (DCR r) and Decrement Memory (DCR M) instructions provide a quick means of subtracting one from the contents of a register or a memory location. These instructions allow the programmer to create counting routines and reiterations. Note that the Carry flag is not affected by these instructions.

    REGISTER PAIR INSTRUCTIONS: The Increment Register Pair (INX rp) and Decrement Register Pair (DCX rp) instructions provide a means of adding to, or subtracting from, a 16-bit value contained in a register pair. In the INX instruction, this means that the carry from the sum of the low order byte of the pair and the one will be added into the upper byte automatically. In the DCX instruction, this means that a borrow from the high-order byte, if required, will be allowed into the low-order byte, if the subtraction of one from the low-order byte demands it. Note that none of the flags are affected.

    D0UBLE ADD: The Add Register Pair to H&L (DAD rp) instruction adds a 16 bit value already existing in the BC or DE register pair into the 16-bit value contained in the H&L registers. The sum remains in the H&L registers. The Carry flag will be set if a carry occurred out of the high order byte; a carry from low- to high-order bytes within the add is taken into account automatically. This instruction allows a fixed index-like value to be added to the H&L registers for Register Indirect mode.

    DECIMAL ADJUST: The Decimal Adjust Accumulator (DAA) instruction converts the 8-bit value in the A register, which normally is assumed to be two 4bit hexadecimal values, into two 4-bit BCD values. This allows the programmer to accept input data as BCD, process it in the accumulator using essentially hexadecimal arithmetic, and then convert the result back into BCD. This may be done by virtue of the fact that the ten numbers of BCD (0 to 9) are coded in binary exactly as are the first ten of the sixteen numbers of binary coded hexadecimal. i.e., adding 3810 and 3816 are exactly the same. The conversion be may accomplished by the use of the Auxiliary Carry flag. If the contents of the low-order four bits of the A register is >9, or if the AC flag is set, a value of 6 is added to these bits. Then the high-order four bits of the A register are examined; again, if they contain a value >9, or if the Carry flag is on, a 6 is added to them. The Carry flag, of course, indicates that the hexadecimal value of the byte before the instruction, when translated to BCD, is too large to fit in one byte.

    LOGICAL GROUP

    This group of instructions provides the decision-making ability of the 8085, and includes some logically oriented utility instructions as well. By using these instructions, the condition flags may be set so that they can be tested by Jump-on-condition instructions. Unless otherwise noted, all the condition codes are affected. A few notes follow:

    AND INSTRUCTIONS: The And Register (ANA r) and And Memory (ANA M) instructions perform a logical And function between the specified byte, either in a register or in the address contained in the H&L registers, and the contents of the accumulator. The accumulator must first be loaded with an initial value. The And function occurs on a bit-by-bit basis. The low order bit of the specified byte is Anded with the low order bit of the A register; if both the bit from the outside byte AND the bit from the A register are a 1, the bit in the A register is left as a 1. If either the bit position of the outside byte or the bit position in the A register, or both, contained 0’s, that bit position in the A register is reset to 0. Identical actions occur on the other seven bit positions at the same time. The result, left in the accumulator, is a bit pattern which indicates, with 1’s left on, in which positions of the bytes both the A register and the outside byte contained 1’s. This is valuable for testing the conditions of specific bits within a byte, and reacting accordingly. All condition flags are involved, but the Carry flag is always cleared by an And.

    AND IMMEDIATE: The And Immediate (ANI data) instruction allows the programmer to match the byte in the accumulator with a fixed mask byte, contained in the second byte of the instruction. The A register must first be loaded with the byte to be tested. The Anding function occurs exactly as shown above. All condition flags are involved, but the Carry flag is cleared.

    OR INSTRUCTIONS: The Or Register (ORA r) and Or Memory (ORA M) instructions perform inclusive Or’s between the specified byte, either in a register or in the address contained in the H&L registers, and the contents of the accumulator. The A register must be loaded with the first , value prior to the execution of these instructions. The Or function occurs on a bit-by-bit basis. The low order bit of the outside byte is Ored with the low order bit of the A register; if either the bit from the outside byte OR the bit from the A register is a 1, or both, that bit position is set to a 1 in the A register. If neither bit position from the outside bit or the A register is a 1, a 0 is loaded into that bit position of the A register. (Note that this satisfies the "one, the other, or both" requirements of an inclusive Or.) Identical operations occur on the other seven bit positions of the bytes. The result, left in the accumulator, is a bit pattern in which a 1 exists in any bit position in which either of the bytes also had a bit set. All condition flags are affected, but the Carry and Auxiliary Carry flags are always cleared.

    OR IMMEDIATE: The Or Immediate (ORI data) instruction allows the programmer to match the contents of the accumulator against a fixed mask byte which is contained in the second byte of the instruction. The Or function occurs on a bit-by-bit basis, exactly as shown above. The first byte must be loaded into the A register prior to execution of the instruction. All condition flags are affected, but the Carry and Auxiliary Carry flags are always cleared.

    EXCLUSIVE OR INSTRUCTIONS: The Exclusive Or Register (XRA r) and D Exclusive Or Memory (XRA M) instructions perform exclusive Or functions between a specified byte, either in a register or in a byte contained in the address in the H&L register, and the contents of the accumulator. The A register must be loaded with the first byte prior to the execution of the instruction. The Exclusive Or occurs on a bit-by-bit basis. The low order bit of the outside byte is XOred with the low bit of the accumulator; if the bit in the outside byte is a 1 and the position in the A register is a 0, or if the bit in the outside byte is a 0 and the position in the A register is a 1, a 1 is set into that bit in the A register. If the bits are either both 1’s or both 0’s, the bit position is reset in the A register. (Note that this agrees with the "one, the other, but not both, and not neither" parameters of an Exclusive Or.) Identical operations occur on the other bit positions of the bytes at the same time. The results are left in the accumulator, which contains a bit pattern with 1’s set where there was a 1 in either the A register or the outside byte, and 0’s set where there was either 0’s in both bytes or 1’s in both bytes, in the same bit position. All condition flags are affected, but the Carry and Auxiliary Carry flags are always cleared.

    EXCLUSIVE OR IMMEDIATE: The Exclusive Or Immediate (XRI data) instruction allows the programmer to perform an Exclusive Or between a mask byte stored as the second byte of the instruction and the contents of the accumulator. The first byte must be loaded into the A register prior to the execution of the instruction. The Exclusive Or function occurs on a bit-by-bit basis exactly as outlined above. All the condition flags are affected, but the Carry and Auxiliary Carry flags are cleared.

    COMPARE INSTRUCTIONS: The Compare Register (CMP r) and Compare Memory (CMP M) instructions compare the contents of the specified byte, either in a register or in the address contained in the H&L registers, to the contents of the accumulator. This is accomplished by subtracting the outside byte from the contents of the accumulator. The contents of the accumulator remain unchanged, and the actual answer of subtraction is lost. The condition flags are all affected, and are set to indicate the conditions of the lost answer. Particularly, the Zero flag, if set on, will indicate that the two values compared are equal, since the result of subtracting one from the other is zero. Also, the Carry flag will be set if the value in the A reg is smaller than the outside byte. If neither the Z nor the C flags are left on, the value in the A register is larger than the outside byte.

    COMPARE IMMEDIATE: The Compare Immediate (CPI data) instruction compares the contents of the accumulator to a fixed value provided by the second byte of the instruction. The first value must be loaded into the A register prior to the execution of the instruction. The function occurs by a subtraction with lost answer, as described above. The contents of the A register are left unchanged. The condition codes act as above.

    ROTATE INSTRUCTIONS: The Rotate Left (RLC) and Rotate Right (RRC) instructions rotate the accumulator’s contents one bit position left or right, respectively. In the RLC, all the bits move one position to the left; the high order bit which is shifted out of the A register is moved around to the low order bit position. It is also moved to the Carry flag. In the RRC, all the bits move one position to the right; the bit shifted out of the low order position of the A register is moved around to the high order position. It is also moved to the Carry flag. Thus, the Carry flag in either case indicates whether a bit was shifted out of the accumulator. Only the Carry flag is affected by these instructions.

    ROTATE THROUGH CARRYS: The Rotate Left through Carry (RAL) and the Rotate Right through Carry (RAR) instructions rotate the accumulator’s contents one bit position left or right, respectively. Unlike the rotates above, however, these instructions use the Carry flag as a ninth bit in the circle. In the RAL, the bits in the A register are shifted left one position; the high order bit moved to the Carry flag; the Carry flag is moved to the low order position of the A register. In the RAR, the bits in the A register are shifted right one position; the low order bit is moved to the Carry flag; the Carry flag is moved to the high order position of the A register. Only the Carry flag is affected.

    COMPLEMENT ACCUMULATOR: The Complement Accumulator (CMA) instruction provides a 1’s complement of the 8 bits in the A register, i.e., the 1’s are set to 0’s, and the 0’s are set to 1’s. A two’s complement may be effected by following the CMA with an INR A instruction. No condition flags are affected.

    CARRY INSTRUCTIONS: The Complement Carry (CMC) and Set Carry (STC) instructions allow direct control of the Carry flag by the programmer. The CMC will change the flag from 1 to 0, or 0 to 1, depending upon its initial condition. The STC forces the flag to a 1, regardless of its previous state. No other flags are affected.

    BRANCH GROUP

    This group of instructions permits the programmer to alter the flow of program execution from a normal straight line. There are two major types of these instructions in the 8085. The first type is the Jump, in which the flow is altered with no intention of returning to the place where the Jump occurred. The second type is the Call, which provides linking, via the system stack, to save the address of the next instruction following the Call, proceed to a subordinate routine, and return to the saved address when that routine is completed.

    Further, both Jumps and Calls may be conditional or unconditional. An unconditional Jump or Call causes the function to be executed absolutely. The conditional Jump or Call causes the function to be executed if the conditions specified are met. In the first byte of these instructions, three bits labeled CCC will contain a code which specifies the conditions to be tested. These may be specified by the programmer in assembly language by putting together a mnemonic composed of a J, for Jump, or a C, J for Call, followed by one or two more characters which specify the conditions to be tested. The breakdown follows:

    MnemonicConditionCCC Bits
    NZNot Zero (Z=0)000
    ZZero (Z=1)001
    NCNot Carry (C=0)010
    CCarry (C=1)011
    POParity Odd (P=0)100
    PEParity Even (P=1)101
    PPlus (S=0)110
    MMinus (S=1)111

    JUMP INSTRUCTIONS: The Jump (JMP addr) and Jump Conditional (Jxx addr) instructions allow program flow to be altered by loading the contents of the two bytes following the instruction to be loaded into the Program Counter. The next instruction to be fetched, therefore, will the first of the new routine. The JMP instruction is unconditional; the Jump occurs absolutely. The Jxx instruction will alter program flow if the conditions specified by the "xx" bits are true; otherwise, program flow remains in a straight line. No condition codes are affected.

    CALL INSTRUCTIONS: The Call (CALL addr) and Call Conditional (Cxx addr) instructions allow linkage to permit a subroutine to be invoked, with the address of the next sequential instruction saved for later reference. The Call will move the high byte of the PC into the address pointed to by the Stack Pointer minus 1, and the low byte of the PC into the address below that. The SP is then decremented by two, to update it to the new stack position. The two bytes following the Call instruction will then be moved to the PC, with the second byte of the instruction containing the low order byte of the address, and the third byte of the instruction containing the high order byte of the address. Thus, the address of the instruction following the Call is saved on the system stack, and the address of the first instruction of the subroutine is fetched next. The Call Conditional executes exactly the same way, providing that the conditions specified by the CCC bits are true. None of the flags are affected.

    RETURN INSTRUCTIONS: The Return (RET) and Return Conditional (Rxx) instructions provide a means, at the end of a subroutine, of resuming program execution at the instruction following the Call instruction which invoked the subroutine. These instructions are placed at the end of the subroutine, not in the body of the main program. When encountered, the Return will move the byte pointed to by the Stack Pointer into the lower byte of the PC, the next byte higher in RAM to the higher byte of PC, and add 2 to the contents of SP. Thus, the address of the instruction following the Call, previously saved on the stack, is now in PC, and will be fetched next. Also, the stack pointer is updated accordingly. The Return Conditional executes exactly the same way, providing that the conditions specified by the CCC bits are true. None of the flags are affected.

    RESTART: The Restart (RST n) instruction provides part of the vectored interrupt system by which any one of eight different levels of interrupt may stop the execution of the program currently in progress, save the address of the next instruction onto the stack, and then jump to any one of eight different locations in low core, depending upon the contents of the bits marked NNN in the instruction. Thus, as many as eight different external events, i.e. I/O devices, etc., may ask for service; the place where the program left off is saved; and one of eight different interrupt handling routines may be entered, which correspond to the level of the interrupt. This will be fully explained in the section on interrupts.

    JUMP INDIRECT: The Jump H&L Indirect (PCHL) instruction moves the contents of the H&L registers, assumed to be a valid address, into the Program Counter. The contents of H&L must be previously built, and may be assembled by other parts of the program to the advantage of the writer. The original contents of the PC are destroyed, so this is a one-way jump.

    MACHINE CONTROL GROUP

    This group is a collection of miscellaneous instructions which control bodily functions of the MP, or provide utilities. Explanations follow:

    PUSH AND POP: The Push Register Pair (PUSH rp) and Pop Register Pair (POP rp) instructions allow programmers to manipulate the system stack. The Push will place the contents of the BC, DE, or HL register pairs onto the stack, and update the SP accordingly. The Pop instruction will return the last two items on the stack to the specified register pair, and update the SP. The condition flags are not affected; the SP register pair may not be specified, for obvious reasons.

    PSW INSTRUCTIONS: The Push Processor Status Word (PUSH PSW) and the Pop Processor Status Word (POP PSW) instructions will allow the programmer to save the contents of the A register and of the condition flags on the stack, or to retrieve them from the stack. The Processor Status Word (PSW) of the 8085 is defined as a "Flag Byte" which contains the condition flag bits in a specific sequence:

    S Z 0 AC 0 P 1 C

    In addition, the contents of the A register is also saved as part of the PSW. When the PUSH PSW is encountered, the contents of the A register is pushed onto the stack first, followed by the Flag byte. The SP is then updated. When the POP is executed, the Flag byte is retrieved first, and the bits are loaded into their proper flip-flops. The A register is then loaded with the next byte retrieved. This allows programmers to save conditions at the beginning of subroutines so that the execution of the instructions within the routines will not alter the conditions under which the original program was operating.

    EXCHANGE STACK TOP: The Exchange Stack Top with H&L (XTHL) instruction causes the contents of the H&L registers to be exchanged with the two bytes which are currently on the top of the system stack. These will be the last two bytes pushed. It is a two-way instruction; the stack receives the original contents of H&L, while H&L receives the two bytes from the stack. The contents of SP remain unchanged. No flags are affected.

    MOVE H&L TO SP: The Move H&L Register to Stack Pointer (SPHL) instruction will directly move the contents of the H&L registers into the Stack Pointer; the original contents of SP are destroyed. This may be used to permit multiple stacks to exist at one time in the system. No flags are affected.

    I/O INSTRUCTIONS

    The Input (IN port) and Output (OUT port) instructions allow the MP to communicate with the outside world. In both cases, the address byte of the device to be used is contained in the byte following the instruction. This byte is presented at once to both the upper and lower bytes of the A0-A15 address lines. In the case of IN, the byte accepted on the D0-D7 data lines by the MP is placed in the A register. For the OUT, the byte to be sent on the data lines is placed in the A register prior to execution of the instruction. No flags are affected.

    INTERRUPT INSTRUCTIONS: The Enable Interrupts (EI) and Disable Interrupts (DI) instructions allow the MP to permit or deny interrupts under program control. For the EI, the interrupts will be enabled following the completion of the next instruction following the EI. This allows at least one more instruction, perhaps a RET or JMP, to be executed before the MP allows itself to again be interrupted. For the DI, the interrupts are disabled immediately. No flags are affected.

    HALT and NO-OP: The Halt (HLT) and No-Operation (NOP) instructions serve general utility purposes. The Halt will stop the processor from further execution; it can be restarted again only by an interrupt. A reset signal applied to the MP will abort the Halt. The MP may enter a Hold state, as the result of another device wanting the bus, from a Halt, but will return to the Halt state when the Hold is canceled. The NOP is simply a one-byte long place holder, which is passed through automatically without any data motion or action of any kind. It is used primarily as a programmer’s aid in saving space within language programs for later use.

    The Read Interrupt Mask (RIM) and Set Interrupt Mask (SIM) instructions are used to service both the extended interrupt system of the ‘85 and the Serial Input Data (SID) and Serial Output Data (SOD) pins on the device. While these items are both serviced by the same instructions, they are not electrically or logically related, and should not be confused. The Interrupt Mask is a group of bits which can be accessed by these two instructions via the accumulator. A discussion of the two instructions follows.

    READ INTERRUPT MASK (RIM): This instruction permits the system to examine the interrupt mask by loading into the A register a byte which defines the condition of the mask bits for the maskable interrupts, the condition of the interrupts pending for the maskable interrupts, the condition of the Interrupt Enable flag, and the condition of the Serial Input Data (SID) pin on the MP. The format is:

    D7D6 D5D4 D3D2 D1D0
    SID I7.5 I6.5 I5.5 IE M7.5 M6.5 M5.5

    From the D0 end of the byte, the purpose of these bits are as follows:

    INTERRUPT MASK BITS D0, D1, D2: These bits indicate whether the interrupts for vectors 5.5, 6.5, and 7.5 are masked on or off. The bits are set to a 1 for disabled, and 0 for enabled. These bits allow the program to examine the mask and obtain the current status of it. It is a valuable tool, since one program section may not necessarily know what a second section is doing or expecting.

    INTERRUPT ENABLE BIT D3: This bit corresponds to the Interrupts Enabled, flip-flop in the 8080. It is set or reset by the Enable Interrupts or Disable Interrupts OP codes in the same manner as in the 8080. The interrupts involved are the standard 8 vectored interrupts, and it has no effect on those special to the 8085. However, in the case of a Trap interrupt (unmaskable), the status of bit 3 may be lost, so that Intel suggests that a RIM be executed as part of the Trap service routine to preserve the condition of the Interrupts Enabled flag prior to the occurrence of Trap. The flag is not affected by the other special interrupts.

    INTERRUPTS PENDING BITS D4, D5, D6: These bits indicate what interrupts have occurred since the last time that specific interrupt was serviced. If interrupts 5.5 or 6.5 are masked off by bits D0 or D1, bits D4 and D5 will not be set. Bit D6, which corresponds to the 7.5 interrupt, will be set on to indicate that an interrupt was requested, even if it was masked off.

    SERIAL INPUT DATA BIT D7: This bit provides the condition of the SID pin. It will be 1 if the pin is high, and 0 if it is low. The software examining this bit must have total ability to deal with whatever it finds there. The pin provides only a voltage level that exists at the time of the RIM execution.

    When the RIM instruction is executed, the status of all the lines indicated are sampled, and the resulting bit pattern is placed in the A register. The instruction simply provides these conditions for display; it has no affect on the bits themselves. The bits in the A register may then be examined directly by logical instructions, or moved to a register or memory location for safekeeping.

    SET INTERRUPT MASK (SIM): This instruction is the reverse of the RIM. While the RIM simply reads the status of various lines, the SIM sets various bits to form masks or generate output data via the SOD line. The conditions that the programmer wishes to set up must be set into the A register exactly as desired first, then the SIM Instruction is executed.

    The SIM will take the bit pattern it finds in the A register and loads it into the masks in the following format:

    D7 D6 D5 D4 D3 D2 D1 D0
    SOD S0E X R7.5 MSE M7.5 M6.5 M5.5

    RST MASKS BITS D0, D1, D2: These bits are the interrupt masks for the 5.5, 6.5, and 7.5 interrupts brought into the ‘85 on their own pins. The bits are 0 to enable and 1 to disable the interrupts. If bits D0 or D1 are disabled (set to 1), a signal applied to their respective pins cause no action. If D0 or D1 are set to 0 (enabled), their respective bits will be visible via the RIM instruction, and the call to the interrupt vector will occur. In the case of bit D2 for masking the 7.5 interrupt, the RIM instruction will indicate that a 7.5 interrupt is pending, but an automatic call will not occur.

    MASK SET ENABLE BIT D3: This bit permits bits D0, D1, and D2 to be changed. If a SIM is executed with this bit low, the condition of the mask bits will not change. If a SIM is executed with this bit set high, the mask bits will take on the same arrangement as those given in the lower bits of the A register. This permits accessing of the mask byte to deal with the interrupts without affecting SOD.

    RST 7.5 RESET BIT D4: This bit permits the SIM instruction to reset the interrupt pending flag indicated by bit D6 in the RIM instruction byte. Since the 7.5 interrupt is handled somewhat more importantly than the 5.5 and 6.5, it can indicate that it is pending via the RIM instruction even though it is masked off. This bit allows that pending request to be reset individually under program control.

    UNDEFINED BIT D5: This bit is unused.

    SOD ENABLE BIT D6: This bit works in conjunction with bit D7. If it is set to 1 when the SIM is executed, the condition of bit D7, high or low, is electrically loaded into the SOD latch, and in turn appears on the SOD pin of the ‘85. If bit D6 is low, the SIM’s execution has no affect on the bit D7. This, like bit D3, allows executing SIMs to service either interrupts or the serial I/O without affecting the other.

    SERIAL OUTPUT DATA BIT D7: This bit contains the voltage level (+5 volts = 1, 0 volts = 0) which should appear at the SOD pin of the ‘85. If the SIM instruction is executed and bit D6 is set to 1 (enabled), the level contained by D7 is forwarded to the SOD latch, which will in turn cause it to appear on the SOD pin. If bit D6 is low, the SIM instruction will have no affect on bit D7.

    The /RESET IN line affects the flags of the interrupt masks. First, the RST 7.5 latch which catches the rising edge of the 7.5 flip-flop and holds it for a RIM instruction is reset. Next, all three mask bits are set to a 1, which will disable all interrupts. Lastly, the SOD latch is reset to a 0. These will effectively allow the new instructions following the Reset to take full control of the MP, without interrupts causing immediate problems.

    The use of these instructions will be explained under Interrupts in the "Additional Information" section of the notes.

    ADDITIONAL INFORMATION

    This section details several interesting items to round out the 8085 discussion. These include the Reset function, the expanded interrupt facilities, the SID and SOD lines, and additional support devices. Refer to the manual for details and further information.

    RESET SYSTEM

    The 8085 generates its own Reset function upon receipt of an asynchronous /RESET IN signal from an external source. This signal is probably generated from two sources, a Reset switch of some kind accessible to the operator, and a Power-on Reset circuit which causes a reset when power is applied to system. Receipt of /RESET IN is latched by an internal flip-flop at the rising edge of the next clock pulse (low asserted). At the beginning of the state following the latch of /RESET IN, RESET OUT is generated to the outside world, and the MP enters T-reset cycles. These cycles continue until the /RESET IN line is released. The release is sensed at the rising edge of the next clock pulse. This, in turn, allows the rising edge of the clock pulse following to enter a T1 state for the first instruction after reset.

    The /RESET IN line should be held low for at least three T-states worth of time, to allow the ‘85 to fully synchronize itself and accomplish its tasks of resetting certain flip-flops and registers. Remember that the MP is very much alive during reset, and that it must have time in Reset mode to accomplish these tasks. The documentation mentions that certain of the control lines are tristated during reset, so that pull-up resistors are essential. When the /RESET IN line goes high, the MP will place the contents of the PC onto the address bus, and enter T1 of the M1 cycle for the next instruction. The PC was reset to all zeroes during the Reset cycle; therefore, the address appearing on the A0-A15 lines will be 0000H.

    The Reset cycle does not affect the contents of any register except PC, or the arrangement of the condition flags. The Intel documentation indicates that the occurrence of Reset is essentially asynchronous with respect to the execution of the program in process. Therefore, the results of a Reset are undetermined, and not guaranteed.

    The Reset cycle will reset, or turn off, the following items:

    The following items are turned on, or set, by the Reset cycle:

    Those items turned off, as listed above, will cause the MP to essentially become iS0lated from the possibilities of interrupts or any exterior interference until the new program, whatever was at 0000H, is underway. Turning on the mask bits effects the same thing, as these are on (set to 1) to disable the interrupts.

    INTERRUPT FACILITIES

    The 8085 contains three levels of interrupt capabilities. The first is essentially identical to that of the 8080 which technique it fully supports. The second technique involves the direct input pins 5.5, 6.5, and 7.5. These are maskable hardware interrupts. The third is Trap, which has its own pin and is non-maskable. Each will be discussed in detail.

    8080 TYPE INTERRUPTS

    The 8085 has facilities for servicing interrupts similar to the 8080. The functional items required are an Interrupt Request (INTR) pin, an Interrupt Acknowledge (INTA) pin, an Interrupt Enable (INTE) pin, eight interrupt vectors in low RAM, and the Restart instruction. These perform in the same way as the 8080 interrupt system. Here is a brief review:

    1. A program is running normally in the system. The 8214 Priority Interrupt Controller or similar circuit has its compare mask set to some priority level. The Interrupt Enable bit has been set on by some previous routine, enabling interrupts.
    2. A device wishes to interrupt the system. It raises its own line which connects directly to the 8214. The 8214 compares this request with the current status of the system. If the new request is higher in priority than the existing (if any), the interrupt will be allowed. If not, the interrupt will be latched for later use, but no further action is taken.
    3. The Interrupts Enabled line exiting the 8085 is high, indicating that interrupts are permitted. The 8214 raises the Interrupt line, which causes the MP to finish the current instruction, and then enter an interrupt service cycle. The MP generates the Interrupts Acknowledge line at the beginning of this cycle to permit the 8214 to proceed.
    4. Upon receipt of the INTA line, the 8214 along with an 8212 octal latch or similar circuit, generates a Restart instruction which it jams onto the data bus at T3 of the interrupt service cycle. The MP receives this, and removes from it the three-bit modulo-8 vector, which it then multiplies by 8 to find the vector in low RAM. This vector contains one or more instructions which can service the device causing the interrupt.
    5. The execution of the Restart instruction causes the address of the next normal instruction to be executed, obtained from PC, to be placed onto the stack. The next machine cycle will be the M1 of the instruction located in the vector in low RAM. This instruction can now guide the MP to the routine to service the interrupt.
    6. At the end of the interrupt service routine, a Return (RTN) instruction will cause the popping of the address off the stack which was of the next instruction to be serviced if the interrupt had not occurred.

    The system now finds itself back where it came from.

    There are three possible variations to the above scenario. First, unlike the 8080, the 8085 will permit the interrupt as described above as long as no other interrupts are pending which are of greater importance. These, of course, are the 5.5, 6.5, 7.5, and Trap. If any of these are pending, they will be serviced first.

    Secondly, while the 8214 was the original device to service interrupts on the 8080 system, the 8085 can work with the 8259A Programmable Interrupt Controller as well. This is a more complex device, programmable as to how it handles interrupts, and stackable to two levels, providing as many as 64 levels of interrupt for the ‘85. The 8259A, moreover, generates Call instructions as well as Restarts. This means that a Call may be jammed onto the data bus during T3 of the interrupt cycle, instead of Restart. While the Restart provides a vector to eight different places in low RAM, depending upon the modulo-8 bits it contains, the Call contains a full two-byte-wide address, which can effectively vector the MP to any-place within the 64K RAM address space. This obviously provides a vastly extended ability to handle interrupts more efficiently.

    The third item to be aware of is that the Interrupt Enable flip-flop of the 8080 is now observable as the IE bit #3 of the byte obtained by executing the RIM instruction. It hitherto has not been available, and its status must be remembered by the programmer. Now the bit may be checked with the RIM instruction, to aid in programming.

    MASKABLE INTERRUPTS

    Three maskable interrupts are provided in the 8085, each with their own pins. They are named RST 5.5, RST 6.5, and RST 7.5, respectively. To see where these names come from, study this chart:

    NAME: ADDRESS:
    RST 0 00H
    RST 1 08H
    RST 2 10H
    RST 3 18H
    RST 4 20H
    TRAP 24H
    RST 5 28H
    REST 5.5 2CH
    RST 6 30H
    RST 6.5 34H
    RST 7 38H
    RST 7.5 3CH

    Note in the chart that the items in light face are those with which we are already familiar. They are the normal vectors for the Restart instructions 0 through 7, as created by the 8214. They are 8 bytes apart, which is ample room for such jumps as are needled to obtain the interrupt servicing routines.

    Now look at the bold face items. These items have vector areas which are between the original vectors in RAM. 12he 5.5, for instance, is half way between the RST 5 and the RST 6 vectors, hence the ".5". If all the vectors were in use, those located above address 20H would each have only four bytes in which to locate and jump to the interrupt service routine. This should be enough room, however, if used wisely. Note also that the Trap interrupt is located at the 4.5 point in the vectors.

    The 5.5, 6.5, and 7.5 vectors have several items in common. First, they each have their own pin directly into the 8085. These pins will accept asynchronous interrupt requests without the need for any sort of external priority interrupt device. Secondly, these interrupts are individually maskable. This is accomplished via the Set Interrupt Mask instruction. This instruction allows bits to be set or cleared which will permit or deny an interrupt on one of these lines to force the ‘85 into an interrupt service cycle. When an input is received on one of these lines and its respective mask bit is enabled (set to 0), the processor will finish the current machine cycle, then enter a interrupt service cycle in which an automatic jam inside the MP will vector it to 2CH, 34H, or 3CH for 5.5, 6.5, or 7.5 respectively. Those locations will assumedly have been previously set to contain directions to the interrupt servicing routines.

    The RST 5.5 and RST 6.5 interrupts are "level sensitive" This means that the device wishing to interrupt will apply a steady high level to the appropriate pin and hold it there until the 8085 gets around to responding. When the ‘85 recognizes the applied high level, it will permit the interrupt to be serviced in the next machine cycle. The mask bits set by the SIM instruction will directly determine what the RIM instruction sees with respect to the 5.5 and 6.5 interrupt pending bits. If the mask bits are set high (to a 1), these interrupts are masked off. This means that a following RIM will not see them as pending. If the mask bits are set to 0 (enabled), a RIM will see the true condition in bits 4 and 5 of the mask byte.

    The RST 7.5 interrupt is "edge sensitive". This means that a pulse applied to this pin, requesting an interrupt, can come and go before the processor gets around to servicing it. This is possible because, unlike the 5.5 and 6.5, the 7.5 has a flip-flop just inside its pin which instantly registers the fact that an interrupt request, albeit short, was applied to the device. This flip-flop provides a bit which is read in RIM instruction as bit 6. This bit will indicate an interrupt pending if a quick pulse is applied to pin 7.5, even though bit 2 of the SIM instruction, the 7.5 mask bit, is turned on (disabled). Bit 2 of SIM byte, therefore, acts differently as a mask bit than does bits 0 and 1 for 5.5 and 6.5. Whereas bits 0 and 1 will mask off all indication of action on pins 5.5 and 6.5, bit 2 will allow the indication of a 7.5 interrupt pending, but will prevent the actual servicing of the 7.5 vector unless the mask is enabled for it. In this way, even though the mask set by the SIM prevents the MP from servicing a 7.5 interrupt, the fact that such an interrupt did occur, captured by the flip-flop, is indicated to whatever routine next executes a RIM instruction.

    While the normal interrupt and 5.5 and 6.5 interrupts’ enable bits are reset when these are serviced, the 7.5 interrupt flip-flop must be turned off individually. This may be accomplished by actually responding to the interrupt, just like the other interrupts above; by having the 8085 receiving a /RESET IN, which would also reset the whole system; or by executing a SIM instruction in which bit 4 of the SIM byte is set on. This bit 4 is the "Reset RST 7.5" bit, and will reset the flip-flop if it is on when a SIM is executed.

    NON-MASKABLE INTERRUPT

    The Trap instruction is a non-maskable interrupt provision for the 8085. There is no mask bit related to it, and no control bits of any kind. It is used for interrupts of a catastrophic nature, such as the impending doom of a power failure. It is essentially an edge-sensitive input, since its pin connects directly inside the ‘85 to a flip-flop to capture the fact that a request was made. However, the inside circuitry around the flip-flop requires that although the flip-flop is set, the asserted level be continually applied thereafter until the processor enters the service cycle. This is shown in a diagram in the documentation. The Trap, therefore, is called both edge-sensitive and level sensitive as well. The order of priority for all of the interrupts of the 8085, from least important to most important, are the Restart 0 through Restart 7, RST 5.5, RST 6.5, RST 7.5, and finally the Trap. Remember that through the use of the 8214, the RST 0 through 7 interrupts are also prioritized, with 0 as the least important and 7 as the most important. Collectively, the 8085 has a complete set of interrupt capabilities that should serve every need.

    SERIAL INTERFACING

    The 8085 is equipped with two pins which provide for sending and receiving of serial data. Actually, the pins simply accept or generate a voltage level out according to program control. Whether or not the timing of the highs and lows on these pins constitute real serial-by-bit data or not is determined by the programming and other components involved and surrounding the ‘85.

    Accepting single-bit serial data into the 8085 is accomplished by the use of the Serial Input Data (SID) line. A voltage from an outside source is applied directly to this pin. It may be sampled at any time by executing a RIM instruction. Upon completion of the RIM, bit 7 of the A register will contain either a 1 or 0, indicating the conditions existing on the SID pin at the time of the instruction’s execution. The arrival of a bit on SID or the change of the level applied to it between high and low in no way effects the interrupt system. No interrupts are generated, nor is any electrical indication of the activity on SID made in any way. Only the execution of a RIM, at the time desired by the program, will indicate the condition of the SID pin.

    Generating single-bit serial data out of the 8085 is accomplished by the use of the Serial Output Data (SOD) line. This pin has placed upon it a voltage high or low that is determined by the SOD flip-flop. This flip flop, in turn, is controlled by bits 6 and 7 of the interrupt mask byte loaded via the SIM instruction. If bit 7 is high and a SIM is executed, the SOD flip-flop is set high, and SOD pin will be high accordingly. If bit 7 of the mask byte is low and a SIM is executed, the SOD flip-flop is reset low, and pin contains a low output. Bit 6 of the mask byte acts as a permissive toggle. The contents of bit 7 will be transferred to the flip-flop if bit 6 is high. If bit 6 is low, the SIM instruction will have no affect on the SOD flip-flop. This permits independent execution of SIMs to service either SOD or interrupts without affecting the other.

    It is obvious that the SID and SOD controls are relatively dumb, and that sort of signals appear or are accepted by them are under control of the program to a great extent. This is important if a serial data transmission is in progress and interrupts must be serviced at the same time.

    SUPPORT DEVICES FOR THE 8085

    At the time of introduction of the 8085, several additional support devices were introduced to enable the ‘85 to be adapted to a great variety of system organizations. A few are listed here. The student is encouraged to look them up in the documentation and review their usage characteristics.

    In addition to these devices above, many Intel and non-Intel RAMs and ROMs have been developed to provide data storage to meet every conceivable need. Also, the Intel documentation lists many general purpose I/O devices, usually aimed at the Multibus configuration, which may be used with a variety of MPs. The astute technician will acquaint her/himself with these, as the use of LSI support devices is becoming very important.