The following article was printed in February 1977 of the magazine „BYTE".
A collection of useful system functions.

Add Some BARC to Your 8080

Charles Howerton
Digital Group Software Systems Inc
POB 1086
Arvada CO 80001
WARNING

The BARC routines listed here will not work in read only memory or in write protected memory, since they modify program code as part of execution.

The programming convenience of a computer system is greatly enhanced by using software to extend the functions provided by the basic instruction set of the machine. Software to accomplish complicated functions like moving character strings or doing data conversions help the user to program manipulations of data in an application situation. This article is written to describe and give the code for a set of utility routines for the 8080 which can be used to advantage on any system employing this chip. This set of BARC utility routines is designed to assist the 8080 programmer in developing programs which involve the manipulation and validation of characters and character strings. The acronym "BARC" stands for BAsic Resource Capability. Almost all programs require these functions to a greater or a lesser extent if they accept input or generate output in any format other than absolute machine codes.
In all cases these routines are entered using an 8080 call instruction and in most cases the call instruction is immediately followed by a series of parameters which identify the field or fields to be acted upon, the length of the field or fields and in some cases an immediate value which is used in the requested function. The exceptions to this rule are the single character validation functions which require that the argument character be loaded into the accumulator prior to the call. In all cases (except the symbolic move) the user's register contents, with the exception of the program counter and flags, are returned with the same contents as they held prior to the call; the symbolic move routine returns the length moved in the accumulator with all other registers except the program counter and flags containing their original contents.
These routines all use the stack of the user's program and in the worst case require 14 bytes in the stack including the two bytes used by the call which invokes the function routine.
In every case return is made to the byte immediately following the last parameter value (if any). The return address generated by the call is used as a parameter list pointer and is incremented by the function routines to effect a proper return upon completion of the requested function.
In addition to the specific function routines there are several support routines which are used by the function routines for entry and exit logic. These support routines can be used by the programmer in developing his or her own coded function routines provided that entry to the user coded function routines is identical in form to the function routine entry logic used in this package.
Whenever one sets out to design and develop a piece of software it is extremely important that the design parameters be defined in advance and that the tradeoffs be understood and evaluated. In the case of the BARC 8080 character and string manipulation utility routines, memory space was judged to be of greater importance than execution time. The design parameters for this software package were:
  1. To pack as many functionsas possible in as little space as possible regardless of the impact upon execution times.
  2. Not to use over 256 bytes.
  3. To provide as much flexibility as possible within the requirements of 1 and 2.
  4. To provide a high degree of user convenience.
LEGEND:

Throughout this narrative and program comments certain abbreviations have been utilized, hopefully with a high degree of consistency. Most of these abbreviations and symbols are self explanatory; however, in the interest of clarity they are explained below.

A(X)16 bit address of X.
DBData byte, 8 bits, operand is value.
DRXYDouble register pair XY.
DWData word, 16 bits, operand is value.
HOBHigh order byte of 16 bit address.
ICVAn immediate character value.
LOBLow order byte of 16 bit address.
PLADParameter list address.
SIZThe size/length of an operand.
SRXSingle register X.
TOSTop of stack.
UDRXYUser's double register pair XY contents.
USRRETReturn point in the user's program.
USRXUser's single register X contents.
X->YContents of X moved to Y.
xxx»
yyy» Arbitrary instructions.
zzz»
<*>Resident page number of the utility routines.

What follows is a description of the function and purpose of every usable function and support routine in the package and how to use each. The routines are described in alphabetical order by name. Listing 1 gives the code for all the routines, and table 1 summarizes the routines and entry points.

Scanned by Werner Cirsovius
September 2002
© BYTE Publications Inc.