Superbrain_Users_Manual_Sep80 Superbrain Users Manual Sep80

Superbrain_Users_Manual_Sep80 manual pdf -FilePursuit

Superbrain_Users_Manual_Sep80 Superbrain_Users_Manual_Sep80

User Manual: Superbrain_Users_Manual_Sep80

Open the PDF directly: View PDF PDF.
Page Count: 660

DownloadSuperbrain_Users_Manual_Sep80 Superbrain Users Manual Sep80
Open PDF In BrowserView PDF
USERS MANUAL FOR
INTERTEC'S

5UPE~BRAlNTM
VIDEO COMPUTER SYSTEM

.IMPORTANT NOTICE
This version of the SuperB rain Users Manual is intended for use with the
. SuperBrain or Sup~rBrain OD Video Computer Systems. However,.this manual is
applicable only for those unfts with .Revision-Ot of the· Keyboarq/d~u module,
and version 3.0 or.h ighe,rof the DOS and boot loader. If- ypu hav~ a Revision-OO :, ..
Keyboard/CPU module, then use only the First or Second Edition of this manual.
Docum~nt No.68~1010

.

. September 19?O

This is the fourth edition of this manual. Your warranty registration form must be
returned promptly to assure receipt of future revisions, if any, to this document.

*** IMPORTANT ***
Do not attempt to write or save programs on your system diskette. It has been 'write
protected' by placing a small adhesive aluminum strip over the notch on the right hand side
of the diskette. Such attempts will result in a 'WRITE' or 'BAD SECTOR' error.
Before using your SuperBrain please copy the System Diskette onto a new blank diskette an (ntertec 1121010 diskette. If you do not have such a diskette, contact you local dealer.
He should be able to supply you with one. If you have any questions concerning this
procedure please contact your dealer before proceeding. Failure to do so may result in
permanent damage to your System Diskette.
BEFORE APPLYING POWER TO THE MACHINE INSURE THAT NO DISKETTES ARE
INSERTED INTO THE MACHINE. NEVER TURN THE MACHINE ON OR OFF WITH
DISKETTES INSERTED IN IT. FAILURE TO OBSERVE THIS PRECAUTION WILL
MOST DEFINITELY RESULT IN DAMAGE TO THE DISKETTES.

CONFIDENTIAL
AND
PROPRIETARY INFORMATION
Information presented in this manual is furnished for customer reference only and
is subject to change.
This document is the property of Intertec Data Systems Corporation, Columbia,
South Carolina, and contains confidential and trade secret information. This
information may not be transferred from the custody or control of I ntertec
except as authorized by I ntertec and then only by way of loan for limited
purposes. It must not be reproduced in whole or in part and must be returned to
Intertec upon request and in all events upon completion of the purpose of the
loan.
Neither this document nor the information it contains may be used or disclosed
to persons not having a need for such use or disclosure consistent with the
pu rpose of the loan without the prior express written consent of I ntertec.
COPYRIGHT 1980
The following is a trademark of I ntertec Data Systems Corporation, Columbia,
South Carol ina:
SUPERBRAIN
INTERTEC DATA SYSTEMS CORPORATION
Columbia, South Carolina

THE SUPERBRAIN VIDEO COMPUTER SYSTEM

CONGRATULATIONS ON YOUR PURCHASE OF INTERTEC'S SUPERBRAIN
VIDEO COMPUTER SYSTEM

Your new SuperBrain Video Computer was manufactured at I ntertec's new 120,000 square
foot plant in Columbia, South Carolina under stringent quality control procedures to insure
trouble-free operation for many years. If you should encounter difficulties with the use or
operation of your terminal, contact the dealer from whom the unit was purchased for
instructions regarding the proper servicing techniques. I f service cannot be made available
through your dealer, contact Intertec's Customer S.ervice Department at (803) 798-9100.
As with all Intertec products, we would appreciate any comments you may have regarding
your evaluation and application for this equipment. For your convenience, we have enclosed
a customer comment card at the end of this manual. Please address your comments to:
Product Services Manager
I ntertec Data Systems Corporation
2300 Broad River Road
Columbia, South Carolina 29210
The SuperBrain is distributed worldwide through a network of dealer/OEM vendors and
through I ntertec's own marketing facilities. Contact us at (803) 798-9100 (TWX - 810666-2115) regarding your requirement for this and other I ntertec products.

Intertec's new one hundred and twenty thousand square foot corporate and manufilt'wriny fi}(:iliry in Columbia, South Carolina

WILL THE MICROCOMPUTER YOU BUY TODAY
STILL BE THE BEST MICROCOMPUTER BUY TOMORROW?
Probably the best test in determining how to spend your microcomputer dollar
wisely is to consider the overall versatility of your terminal purchase over the next
three to five years. In the fast-paced, ever-changing world·· of data
communications, new features to increase operator and machine efficiency are
introduced into the marketplace daily. We at Intertec are acutely aware of this
rapid infusion of new ideas into the small systems business. As a result, we have
designed the SuperBrain in such a manner as to virtually eliminate the possibility
of obsolescence.
Many competitive alternatives to the SuperB rain available today provide only
limited capability for high level programming and system expansion. Indeed, most
low-cost microcomputer systems presently available quickly become outdated
because of the inability to expand the system. Intertec, however, realizes that
increased demands for more efficient utilization of programming makes system
expansion capability mandatory. That means a lot. Because the more you use
your SuperBrain, the more you'll discover its adaptability to virtually any small
system requirement. Extensive use of "software-oriented" design concepts instead·
of conventional "hardware" designs assure you of compatibility with almost any
application for which you intend to use the SuperB rain.
Once you read our operator's manual and tryout some of the features described
herein, we are confident that you too will agree with our "top performance bottom dollar" approach to manufacturing. The SuperBrain offers you many
more extremely flexible features at a lower cost than any other microcomputer
we know of on the market today. The use of newly developed technologies,
efficient manufacturing processes and consumer-oriented marketing programs
enables us to be the first and only major manufacturer to offer such an incredible
breakthrough in the microcomputer marketplace.
Browse through our operator's manual and sit down in front of a SuperBrain for a
few hours. Then, let us know what you think about our new system. There is a
customer comment card enclosed in· the rear section of this manual for your
convenience.
Thank you for selecting the SuperBrain as your choice for a microcomputer
system. We hope you will be selecting it many more times in the future.

TABLE OF CONTENTS
INTRODUCTION

Section

1

MAJOR COMPONENTS

Section

2

SYSTEM OPERATION

Section

3

INTRODUCTION TO CP/M FEATURES & FACILITIES

Section

4

OPERATION OF THE CP/M CONTEXT EDITOR

Section

5

CP/M 2.0 USER'S GUIDE FOR CP/M 1.4 OWNERS

Section

6

OPERATION OF THE CP/M DEBUGGER

Section

7

OPERATION OF THE CP/M ASSEMBLER

Section

8

THE CP/M 2.0 INTERFACE GUIDE

Section

9

THE CP/M 2.0 SYSTEM ALTERATION GUIDE

Section

10

MICROSOFT BASIC 80 REFERENCE MANUAL

Section

11

Section

12

SERVICE INFORMATION

Section

13

HARDWAREADDENDUMS

Section

14

SOFTWAREADDENDUMS

Section

15

-

MICROSOFT UTILITY SOFTWARE MANUAL
I

•

INTRODUCTION

)

..

Page 6

INTRODUCTION
The SuperBrain Video Computer System represents the latest technological advances in the
microprocessor industry. The universal adaptability of the SuperBrain CP/M* Disk
Operating System satisfies the general purpose requirement for a low cost, high performance
microcomputer system.
From the standpoint of human engineering, the SuperBrain has been designed to minimize
operator fatigue through the use of a typewriter-oriented keyboard and a remarkably clear
display. The SuperBrain displays a total of 1,920 characters arranged in 24 lines with 80
characters per line. The video display is usually crisp and sharp due to Intertec's own
specially designed video driver circuitry. And, the high quality, non-glare etched CRT face
plate featured on every SuperBrain assures ease of viewing and uniformity of brightness
throughout the entire screen.
The SuperBrain's unique internal design assures users of exceptional performance for just a
fraction of what they would expect to pay for such "big system" capabilities. The
SuperBrain utilizes a single board "microprocessor" design which combines all processor,
RAM, ROM, disk controller, and communications electronics on the same printed circuit
board. This type of design engineering enables the SuperBrain to deliver superior,
competitive performance.
Standard features of every SuperBrain include: two double-density, single-sided
mini-floppies with a total of over 350,000 bytes formatted disk storage, 32K of dynamic
RAM memory - expandable to 64K (in one 32K increment), a universally recognized
CP/M* Disk Operating System featuring its own text editor, an assembler for assembly
language programming, a program debugger and a disk formatter. Also standard are dual
universal RS232 communications ports for serial data transmission between a host computer
network via modem or an auxiliary serial printer. A number of transmission rates up to
9600 baud are available and selectable under program control.
Other standard features of the SuperBrain include: special operator convenience keys, dual
"restart" keys to insure simplified user operation, a full numeric keypad complement, and a
high quality typewriter compatible keyboard. An optional low cost S-100 bus adaptor is
available to convert the Supel"Brain Z80A data bus into an S-100 data and address
compatible protocol. The S-100 adaptor accommodates one S-100 printed circuit board
which can be mounted internally.
For reliability, the SuperBrain has been designed around 4 basic modules packaged in an
aesthetically pleasing desk-top unit. These major components are: the Keyboard/CPU
module, the power supply module, the CRT assembly, and the disk drives themselves.
Failure of any component within the terminal may be corrected by simply replacing only
the defective module. Individual modules are fastened to the chassis in such a manner to
facilitate easy removal and reinstallation. Terminal down-time can be greatly minimized by
simply "swapping-out" one of the modules and having component level repair performed at
one of Intertec's Service Centers. Spare modules may be purchased from an Intertec
marketing office to support those customers who maintain their own "in-house" repair
faci Iities.
The SuperB rain's cover assembly is exclusively manufactured "in-house" by I ntertec. A
high-impact structural-foam material is covered with a special "felt-like" paint to enhance
the overall appearance. Since the cover assemblyrs injected-molded, there is virtually no
possibility of cracks and disfigurations in the cover itself. And, by manufacturing and
finishing the cover assembly in-house, Intertec is able to specify only high quality material
on the external and internal cover components of your SuperBrain to insure unparalleled
durability over the years to come.
'CP/M is a registered trademark of Digital Research

Page 7

INTRODUCTION (continued)
A wide variety of programming tools and options are either planned or available for the
SuperBrain. Standard software development tools available from I ntertec include Basic,
Fortran and Cobol programming languages. A wide variety of applications packages (general
ledger, accounts receivable, payroll, inventory, word processing, etc.) are available to
operate under SuperBrain CP/M Disk Operating System from leading software vendors in
the industry. Disk storage may be increased by adding SuperBrain's S-100 bus adaptor and
connecting other auxiliary disk devices, including hard disk drives. And, another model of
the SuperBrain - SuperB rain QD - features double density, double-sided disk drives which
provide over 700,000 bytes of formatted data.
The price/performance ratio of the SuperBrain has rarely been equalled in this industry. By
employing innovative design techniques, the SuperBrain is not only able to offer a
competitive price advantage but boasts many features found only in systems costing three to
five times as much. SuperBrain's twin Z80A microprocessors insure extremely fast program
execution even when faced with the most difficult programming tasks. And, each unit must
pass a grueling 48 hour burn-in before it is shipped to the Customer. By combining advanced
microprocessor technology with in-house manufacturing capability and stringent quality
control requirements, your SuperBrain should provide unparalleled reliability in any
application into which it is placed.

CUTAWAY VIEW SHOWING MOUNTING OF MAJOR SUBASSEMBLIES.

Page 8

SYSTEM SPECIFICATIONS
FEATURE
CPU
Microprocessors

DESCRIPTION

Twin Z80A's with 4MHZ Clock Frequency. One Z80A
(the host processor) performs all processor and screen
related functions. The second Z80A is "down-Ioaded"
by the host to execute disk I/O.

Word Size

8 bits

Execution Time

1.0 microseconds register to register

Mach ine Instructions

158

I nterrupt Mode

All interrupts are vectored and reserved.

Floppy Disk
Storage Capacity

Over 350K (700K + on
unformatted data on
Optional external hard
using the optional S-100

SuperB rain aD) total bytes of
two double density drives.
disk storage can be connected
bus adaptor.

Data Transfer Rate

250K bits/second

Average Access Time

250 milliseconds. 35 milliseconds track-to-track

Media

514 inch mini-disk

Disk Rotation

300 RPM

Internal Memory
Dynamic RAM

32K (64K on Superbrain aD) bytes dynamic RAM.
Expandable to 64K in one 32K increment. Optional
32K is socketed.

Static RAM

1 K bytes of static RAM is provided in addition to the
main processor RAM. This memory is used for program
and/or data storage for the auxiliary processor.

ROM Storage

2K bytes standard. Allows ROM "bootstrapping" of
system at power-on.

CRT
Display Size

12-i nch, P4 phosphor.

Display Format

24 lines x 80 characters per line.

Character Font

5x7 character matrix on a 7x 10 character field

Display Presentation

Light characters· on a dark background.
*Specifications subject to chango without notice or liability.

•

Page 9

SYSTEM SPECIFICATIONS (continued)
FEATURE

DESCRIPTION

Bandwidth

15 MHZ.

Cursor

Reversed image (block cursor)

Commu nications
Screen Data Transfer

Memory-mapped at 38 kilobaud. Serial transmission of
data at rates up to 9600 bps.

Main Interface

RS-232C asynchronous. Synchronous interface optional.

Auxiliary Interface

Simplified RS-232C asychronous. Synchronous interface optional.

Z80A Data Bus

40-pin Data Bus connector.

S-100 Bus

Connector provided for connection of optional S-100
bus adaptor.

Parity

Choice of even, odd, marking, or spacing - under
program control.

Transmission Mode

Half

Addressable Cursor

Direct Positioning by absolute x, yaddressing.

System Utilities
Disk Operating System
DOS Software

Optional Software
FORTRAN

or

Full

Duplex.

One

or

two

stop

bits.

CP/M 2.2
An 8080 disk assembler, debugger, text editor and file
handling utilities.

ANSI standard. Relocatable, random and sequential disk
access.

COBOL

ANSI standard. Relocatable, sequential, relative and
indexed disk access.

BASIC

Sequential and random
manipulation, interpreter.

Application Packages

Extensive software development tools are available from
leading software vendors including software for the
following applications: Payroll, Accounts Receivable,
Accounts Payable, Inventory Control, General Ledger
and Word Processing.

Keyboard
Alphanumeric Character Set

disk

access.

Full

string

Generates all 128 upper and lower case ASCII characters.
'Specifications subject to change without notice.

Page 10

SYSTEM SPECIFICATIONS (continued)
FEATURE

DESCRIPTION

Special Featu res

2-Key Rollover, Keyboard lock/unlock - under program
control.

Numeric Pad

0-9, decimal point, comma,
programmable function keys.

Cursor Control Keys

Up, down, forward and backward.

I nternal Construction
Cabinetry

minus

and

user-

Structural foam

Component Layout

Four board modular design. All processor related
functions and hardware are on a single printed circuit
board. All video and power related circuits on separate
single boards.

Mounting

All modules mounted to base. CRT in a rigid aluminum
frame. Disk Drive assemblies are mounted into special
bracket for ease of servicing.

Environment
Weight

Approximately 45 pounds.

Physical Dimensions

145/8" (H) x 21 3/8 (W) x 231/8 (D)

Environment

Operating: 0 0 to 400 C Storage: 0 0 to 85 0 C; 10 to
85% reI. humidity - non-condensing.

Power Requirements

115 VAC, 60 HZ, 3 AMP (optional 230VAC/50HZ
model available)
'Specifications subject to change without notice.

Page 11

OPTIONAL VERSUS STANDARD FEATURES
Since each SuperBrain is designed utilizing the latest advances in microprocessor technology,
many features which other system vendors offer as options are offered as standard features
on th.e SuperBrain.
The SuperBrain Video Computer is designed to satisfy the universal requirement for a low
cost, high performance small business system and, hence, there are virtually no options from
which to choose. Basically, available options for the SuperBrain include:
BASIC 80 FROM MICROSOFT - an extensive implementation of Basic language available
for Z80 microprocessors. In just three years of use, it has become the world's standard for
microcomputer Basic. Basic 80 gives users what they want from a Basic - ease of use plus all
of the features that make a micro perform like a minicomputer or large mainframe. Basic 80
meets the requirements of the ANSI subset standard for Basic and supports many unique
features rarely found in other Basics.
MICROSOFT FORTRAN 80 - comparable to Fortran compilers on large mainframes and
minicomputers. All of ANSI standard Fortran X3.9-1966 is included except the COMPLEX
datatype. Therefore, users may take advantage of the many application programs already
written in Fortran. Fortran 80 is unique in that it provides a microprocessor Fortran and
assembly language development package that generates relocatable object modules. This
means that only the subroutines and system routines required to run Fortran 80 programs
are loaded before execution. Subroutines can be placed in a system library so that users
develop a common set of subroutines that are used in their programs. Also, if only one
module of a program is changed, it is necessary to recompile only that module.
CENTRONICS-COMPATIBLE PARALLEL INTERFACE(1) - connects directly to
SuperBrain's 40 pin Z80A data bus connector and provides for a parallel output as required
for Centronics-compatible printers.
S-100 BUS ADAPTOR (2) - connects to SuperBrain's auxiliary Z80A data bus edge card
connector and provides for the connection of up to one standard sized S-100 bus board
inside the SuperBrain cabinet. Bus adaptor includes ribbon cables, S-100 conversion
circuitry, S-100 card guides and a metal mounting bracket to enable the S-100 bus adaptor
to be installed on the inside cover just to the right of SuperBrain's twin double-density disk
drives.
SYNCHRONOUS INTERFACE - enables synchronous transmission via the auxiliary RS232
serial communications port.
32K DYNAMIC RAM EXPANSION KIT - a set of sixteen 16K RAM chips which plug into
existing sockets on the SuperBrain Keyboard/CPU module to enable expansion of the
SuperB rain's dynamic memory from 32K to 64K. Also included with the RAM kit is an
additional CP/M DOS Diskette which reconfigures the SuperBrain's Operating System to
accommodate all 64K of RAM.

(1) Available June, 1980

(2) Available June, 1980

•

(

I

MAJOR COMPONENTS

Page 1

INTERNAL CONSTRUCTION
Perhaps the most remarkable feature of the SuperB rain is its modular construction using
only four major subassemblies which are clearly defined in their respective functions so as to
facilitate ease of construction and repair. These four subassemblies are shown in figure one
and described below.

isl< Drive Module

Keyboard/CPU Module

•

Page 2

INTERNAL CONSTRUCTION (continued)
KEYBOARD/CPU MODULE
The control section of the SuperB rain Video Computer is based upon the widely acclaimed
Z80A microprocessor. The result is far fewer components and the ability to perform a
number of functions not possible with any other approach. The Keyboard/CPU module
(figure two) contains the SuperBrain's twin Z80 microprocessors. One Z80A (the host
processor) performs all processor and screen related functions while the second Z8QA can be
"downloaded" to execute disk I/O handling routines. The result is extremely fast execution
time for even the most sophisticated programs.

In addition to containing the SuperBrain's microprocessor circuitry, the Keyboard/CPU
module contains 32K of dynamic RAM with sockets for an additional expansion capability
of 32K (see figure three). Also found on this module is: the character and keyboard encoder
circuitry, the "bootstrap" ROM, the disk controller and all communications electronics.
Power is supplied to and signals are transferred from this module via a single 22 pin ribbon
cable connected to the SuperBrain's main power supply module. Connection of this module
to the disk drive subassemblies is via a separate ribbon cable. Figure four shows the
connectors on the Keyboard/CPU module which are used for interconnecting this module
with the disk drive subassemblies, the main power supply and the optional parallel and/or
S-100 bus adaptor.

Figure 2 - SuperBrain Keyboard/CPU Module

Figure 3 - Dynamic RAM Section
Every SuperBrain is equipped with 32K dynamic
RAM - on board expandable to 64K. 16 sockets are
provided for the additional 32K of RAM.

Figure 4 - Keyboard/CPU Module Connectors
The 40 pin connector on the top edge of the card
is for connection to SuperBrain's optional parallel
and/or S100 bus adaptor. The 40 pin connector on
the right edge routes signals to and from the disk
drive assembly.

Page 3

INTERNAL CONSTRUCTION (continued)
CRT DISPLAY MODULE
The CRT Display Module consists of a 12 inch, high resolution, cathode ray tube mounted
in a rigid aluminum chassis. The faceplate of the CRT is etched in order to reduce glare on
the surface of the screen and provide uniform brightness throughout the entire screen area .
The CRT display presentation is arranged in 24 lines of 80 characters per line.
The CRT video driver circuitry is mounted in the base of the CRT chassis to facilitate ease
of removal and subsequent repair. I n this manner, either the CRT itself or the video
circuitry can be easily exchanged without disrupting any of the other major modules within
the terminal (see figu re five).

Figure 5 - SuperBrain CRT Display Module
This module is easily removed for service or replacement. A
single edge connector is provided for connection to
SuperBrain's Power Supply Module.

•

Page 4

INTERNAL CONSTRUCTION (continued)
MAIN POWER SUPPL V MODULE
The SuperBrain's power supply is a "solid-state, switching" design and employs switching
voltage regulators to provide many years of trouble-free service. This design reduces heat
dissipation and allows for efficient cooling of the entire terminal with a specially designed
whisper fan to reduce environment noise. The entire power supply can be easily removed by
unscrewing the three screws holding it into the base of the terminal. Included on the main
power supply module are the power off/on switch, the user brightness control and the main
and auxiliary RS232 serial ports. By combining the power supply section and external serial
communications connections on the same module, the total module count is able to be kept
to a minimum thus greatly facilitating ease of field service repair while at the same time
minimizing the number of modules required to be stocked to effect competent field repair
(refer to figure six).

Figure 6 - Main Power Supply

•

Page 5

INTERNAL CONSTRUCTION (continued)
DISK DRIVE MODULES
Figures seven and eight illustrate the left and right views of the SuperBrain's specially
designed double-density disk drive subassembly. Each SuperBrain contains two of these type
drives which are mounted conveniently just to the right of the CRT display module on a
rugged aluminum mounting bracket which supports the drives so that they are flush
mounted with the front "bezel" of the unit. Power to these drives is derived from the Power
Supply Module located just behind the drive assemblies themselves. Data to and from these
drives is routed via a single 34 pin ribbon cable connecting the drives to the Keyboard/CPU
module.

Figure 7 - Top View of SuperBrain Drive Assembly

Figure 8 - Bottom View of SuperBrain Drive Assembly

•

Page 6

INTERNAL CONSTRUCTION (continued)

The 8uperBrain can be configured to employ an optional module - the 8-100 bus adaptor.
This adaptor plugs into the 8uperBrain's Keyboard/CPU module and mounts internally on
the metal bracket supporting the disk drive assemblies. ,Figure nine shows the 8uperBrain
with the 8-100 bus adaptor and a single 8-100 printed circuit card. Figure ten shows the
same unit without the 8-100 bus module installed.
The 8-100 bus adaptor is offered as an optional feature on the 8uperBrain for those users
who desire to expand the units' capability with the addition of auxiliary disk devices
including the new, more popular Winchester-type drives.
A single 8-100 card can be easily inserted in the card guide supplied with each 8-100 bus
adaptor (as shown in figure eleven). NOTE: The 8-100 bus adaptor includes cabling,
connectors and circuitry to convert the 8uperBrain's Z80 data bus into the 8-100 bus. The
actual 8-100 compatible printed circuit board (as is shown in figure eleven) is supplied by
the user.

Figure 9 - 8uperBrain with 8-100 Bus Adaptor
and card installed.

Figure 10 - 8uperBrain with 8-100 Bus Adaptor
and card removed.

Figure 11 - SuperBrain S-100 Bus Adaptor
Includes adaptor, 100 pin S-100 connector, card guides,
mounting bracket and all necessary cabling. The S-100 card is
supplied by the user.

SYSTEM OPERATION

Page 1

THEORY OF OPERATION
The SuperBrain contains two Z80 microprocessors. (Reference Figure 3-1) uP1 is the master
processor. It communicates with the 64K RAM and the I/O devices (serial port, keyboard
encoder, interface controller, and CRT controller). Aside from these devices, it can also
access the 2K ROM and DATA BUFFER RAM in the FLOPPY DISK CONTROLLER. uP2
is slaved to uP1 and can only access the 2K ROM, DATA BUFFER, and the DISK
INTERFACE. This processor is used exclusively for disk control.
The 32/64 kilobyte main memory consists of up to thirty-two 16K x 1 bit dynamic RAMS.
These are divided in four banks (0-3) with each bank containing 16 kilobytes of storage. The
RAS-CAS timing sequence necessary for memory access is created by the memory timing
generator.
There are two devices that can access memory - uP1 and the CRT Controller. uP1 can read
and write to memory while the CRT Controller can only perform the read function. Because
each device runs at a different speed, two clock frequencies are required for memory timing.
The speed is determined by the selection of the control input to the timing generator. The
microprocessor functions require the faster clock.
The CRT-VI DEO CONTROLLER contains three main devices - the CRT Controller which
generates all the timing signals for data display; the video generator which produces the
character font; and the octal 80-bit shift register which stores one row of video data. (80
characters)
The CRT Controller generates all the timing necessary to display 24 rows of characters with
80 characters per row. Thus the screen can display a total of 1920 characters. These
characters are stored in the CRT refresh buffer which is the upper 2048 bytes (2K) of RAM.
Because the CRT buffer is not a separate buffer and the processor must also use the same
bus to access memory, this bus must be timeshared between the two. This is accomplished
by the CRT controller performing a direct memory access (DMA) cycle which is done at the
beginning of each scan row. Each scan row is divided into ten scan lines, therefore
during the first scan line time, the controller takes control of the processor bus by generating a bus request. After acquiring the bus, it reads 80 characters from the CRT buffer and
loads them into the 80 x 8 shift register. This data is then recirculated in the buffer for the
next nine scan lines to produce one row of video characters. Therefore, there are twentyfour DMA cycles performed per vertical frame.
There are also twenty-five interrupts generated - one for each row scan and one extra during
vertical blanking. During the first twenty-four, the processor sets or resets the video blanking
depending on whether that row is displayed or not. During the vertical blanking interrupt,
the address registers in the CRT controller are initialized to the correct top-of-page address
and the cursor register is also updated.
The Interface Controller is basically three 8 bit I/O ports (8255). Through this device, the
processor can obtain status bits from other devices and react to the status by setting/
resetting individual bits in the 8255.
The Keyboard Encoder scans the keyboard for a key depression, determines its position,
and generates the correct ASCII code for the key. The processor is flagged by the 'Data
Ready' signal via the Interface Controller. The character is then input by the processor.

•

Page 2

THEORY OF OPERATION (continued)
The remaining I/O device is the RS-232-C Serial I nterface Port. Presently, it operates only in
the asynchronous mode and adheres to a simplified standard protocol. The baud rate is set
to 1200 baud by the operating system (Refer to the Technical Bulletin enclosed at the end
of this manuaL)
As previously mentioned, uP1 has the capability of communicating with the RAM and ROM
in the FLOPPY DISK CONTROLLER. It does this to obtain the bootloader from ROM on
power-up and system reset and also when transferring disk parameters and data to/from the
Data Buffer RAM. Because the amount of main memory used is the maximum that the
processor addressing can support different 16K banks of main memory must be switched off
line when communicating with the disk RAM or ROM. In these cases Bank 0
(0000H-3FFFH) is switched out when communicating with the ROM, and Bank 2
(8000H-BFFFH) when communicating with the RAM.
The DISK CONTROLLER performs all disk related I/O functions upon command from the
main processor. These commands are:
•
•
•
•
•

Restore to track 0
Read sector
Write sector
Write sector with deleted data mark
Format

The parameters associated with drive, side, track, and sector numbers are loaded, a status
word is set at specified location in the disk RAM. When uP2 receives this status, it sets the
'disk busy' status bit and performs the indicated function. Upon completion, it resets the
'busy' bit thus allowing the main processor (uP1) to retrieve data and status from the RAM.

GENERAL SPECIFICATIONS
POWER

110/220 VAC 50/60 HZ
Dual Switching Power Supplies

MEMORY

32/64K bytes (dynamic)

MICROPROCESSOR

Two Z80's operating at 4MHZ

SERIAL PORTS

Two asynchronous 'simplified' RS-232-C, programmable ports

CRT SCREEN

24 lines, 80 columns
7 x 10 dot character field
5 x 7 dot character font
50/60 HZ refresh rate

FLOPPY DISKS

Two, 5-1/4", double density, MFM
Format (Soft sectored) - 512 Bytes/sector; 10 sectors/track
35/70 tracks/diskette
Capacity - 179K bytes formatted single sided, 35 tracks/diskette
358K bytes formatted single sided, 70 tracks/diskette

DOS

CP/M, Version 2.2

•

CRT- VID.EO CONTROLLER
~---------------------

--- '-1

~--------------

INTR
uFf

BUS REO

RAS

BUS AK

4MHZ ___

MAIIl MEMORY
64K x B

CAS

RAI~

i--=l

10.92 MHZ

16 MHZ

--1--+
J..ROCESSOR CONTROL

RAM AODRESS
17

__ CR!.CONTROL

... -..--

._.

·1-- ..1.... -~---

,
I

L

MEMORY BANK
INHIBI~_

.
;:;

+12 VOC

)

+5 VOC

>
>
)

._.__ -1--

~_

_ ____ ...-ADDRESS BUS

4P

RTS

..

f

,--J

-

INTERFACE

RX DATA

=f'"
SERIAL

>---

CTS

>-

DSR

>---

BUS AK

PORT

_._____

I

CONTROLLER

ASYNC

OTR

I
j

>

EXTERNAL
BUS

.--------+----------+---------~---------~

-5VD

IX DATA

A15

1/0
CONTROL

GNO

-12 VDC

DO - 07

+-- _____.J--___P.!lIiI..ill!?___-,--_ - - - - ---i----+-------- AO -

_. __.___ 1._

l,

CONTROL

..

. __ . _ _ . _ _

I

_______ ..J

_____ • _ _ _ _ _ _ _ _ _ •_ _ _ _

I

BUS REQ

---001

1.1>r
uP2

~

I

2 MHZ

- -,

,-

MH~ISK CONTROLLE

8!!L.

--------1

---l--.~..JlAIJL-

T11 - - - 1--1""-T'1

ADDRESS
CONTROL

----1

I

l~

1

I'

DATA BUFFER

2K x B

4MHZ

J
~

-~ OISK

I WRITE
I

DAT~ WRITE

PRECOI-IP

I

'--_ _.....-tIINTERFAC

RAM
lMHZ_

1-

!

I

-----+--

ROM
16

KEYBOARD

DISK BUSY
..

j

14MHZ

DATA R

KEYBOARD
DATA
ENCODER

LIGETT
8fIHZ

16MHZ
8MHZ 4MHZ 1MHZ
L

_ _ _I

FLOPPY DISK CONTROLLER

""lJ

Ql

10.92 MHZ

TIMING GENERATOR

-------

CO

CD

W

_._----

FIGURE 3-1 SUPERBRAIN KEYBOARD/CPU MODULE BLOCK DIAGRAM

•

Page 4

INSTALLATION AND OPERATING INSTRUCTIONS
UNPACKING INSTRUCTIONS
Be sure to use extreme care when unpacking your SuperBrain Video Computer System. The
unit should be unpacked with the arrows on the outside facing up. Once you have opened
the unit, locate the Operator's Manual which should be placed at the front of the terminal.
If you have ordered additional optional software with your system, it will most likely be
attached to the outside of the carton in a gray envelope. Extreme care should be used in
opening this envelope so as not to damage any of the delicate diskette media contained
inside. The MASTER SYSTEM DISKETTE is located inside the front cover of the
Operator's Manual. Be careful not to discard or misplace this diskette as it will be vital for
the operation of the equipment in later sections.
.
Now that you have located your Operator's Manual and system diskette you can proceed to
remove all packing material on the top and front of the terminal. Once this has been
accomplished, you may now remove the terminal from the shipping carton. In some
instances, you may notice that the terminal is somewhat difficult to remove from the
carton. This is due to the varying amounts of packing material that is placed in each carton.
If you should experience such difficulties, rotate the carton on its side. With the terminal on
its side, you should now be able to pull outward on the terminal and separate it from the
box. Once the terminal is out of the carton place it on a table and remove the protective
plastic bag which should be surrounding the terminal. DO NOT DISCARD THE SHIPPING
CARTON UNTI L YOU HAVE COMPLETELY CHECKED OUT THE TERMINAl.
SET UP
Now that you have removed your SuperBrain Video Computer System from its packing
carton, you are ready to begin to set up the system. The first step in this procedure is to
verify that your SuperBrain Video Computer System is wired for a line voltage that is
available in your area. This can be ascertained by looking on the serial tag located at the
right rear of the terminal. This tag should indicate that your unit is set up for either 110 or
for a 220 VAC operation. DO NOT ATTEMPT TO CONNECT THE SUPERBRAIN VIDEO
COMPUTER SYSTEM TO YOUR LOCAL POWER OUTLET UNLESS THE VOLTAGE AT
YOUR OUTLET IS IDENTICAL-TO THE ONE SPECIFIED ON THE BACK OF YOUR
TERMINAl. Should the voltages differ, contact your dealer at once and do not proceed to
connect the SuperBrain Video Computer System to the power outlet.
Before connecting the SuperBrain Video Computer System to the wall outlet, be sure that
the power switch located at the left rear corner is turned OFF. You may now proceed to
connect your computer system to the wall outlet. After completing this connection, turn
the power switch to the 'ON' position. At this time, you should hear a faint"whirring"
sound coming from the fan in the computer. After approximately 60 seconds the message
'INSERT DISKETTE INTO DRIVE A' will appear on the screen. If this message does not
appear on the screen after approximately 60 seconds, depress the RED key located on the
upper right hand corner of the numeric key pad. This key is the master system reset key and
should reinitialize the computer system thereby displaying the 'I NSE RT' message on the
scre~n. If, after several attempts at resetting the equipment you are unable to get this message
to appear on the screen, turn the unit off for approximately 3 to 5 minutes and then
reapply power to the unit. If you are still unable to get the appropriate message to appear
on the screen, contact you r I ntertec representative.
SYSTEM DISKETTE
Now that you have power applied to the machine and the 'INSERT DISKETTE' message
has been displayed in the upper left hand corner, you are ready to proceed with loading the
computer's operating system. This is accomplished by locating the small 5%" diskette that
was packed with the operator's manual. Once you have located this diskette you will notice

Page 5

INSTALLATION AND OPERATING INSTRUCTIONS (continued)
that a small adhesive aluminum strip has been placed over the notch on the right hand side
of the diskette. This aluminum strip is used to "WR ITE PROTECT" the diskette. Therefore,
you may only load and/or read programs off of this diskette. If you wish to write or save
programs on the system diskette it will be necessary to remove the small adhesive aluminum
strip from the diskette. This is NOT RECOMMENDED as it will subject your diskette to
accidental errors that may be induced by you while you are getting familiar with the
operating system.
You are now ready to proceed with inserting the system diskette into the machine. When
facing the front of the machine, you will notice that tliere are two small openings on the
right-hand side of the machine. The first opening (the one furtherest to the left) is
designated as DRIVE A. The second opening (the one on the right-hand side of the
terminal) is designated as DRIVE B. This distinction is extremely important since the disk
operating system can only be loaded from DRIVE A.
Now that you have located the two disk drives on the system, open the disk drive door on
DRI VE A (opening closest to your left). The drive can be opened by applying a very slight
pressure outward on the small flat door located in the center of the opening. Once the Drive
door has been opened, you are now ready to insert the Operating System Diskette. As noted
previously, this is the diskette which was packed with your Operator's Manual. The front of
the diskette should contain a small white sticker located in the upper left hand corner of the
diskette. This diskette should contain a message indicating that it is the SuperBrain DOS
Diskette with CP/M Version 2.0. Once you have located this diskette you may insert it into
the machine. Be careful to insure that (1) the small aluminum write protect strip is
orientated towards the top edge of the diskette and that (2) the label located in the upper
left hand corner of the operating system diskette is facing AWAY from the screen towards
the right-hand side of the terminal. Once you have orientated the diskette in this fashion,
you may now insert it into the terminal. It is EXTREMELY important that the diskette be
properly orientated before inserting it into the machine since improper orientation will not
allow the operating system to properly load. Once the diskette has been placed in the
machine, be sure that it has been inserted all the way by applying a gentle pressure on the
rear edge of the diskette. Once you are certain that the diskette is fully inserted, you may
close the disk drive door. This can be accomplished by applying a slight pressure on the door
pulling it back into the direction from which it was originally opened. Once you have closed
the door, you will notice a small "swishing" sound. This sound is normal and indicates that
the computer is now attempting to load the operating system. Some drives are quieter than
others and therefore this noise may not be audible in some cases.
After closing the door the following message should appear in the upper left-hand corner of
the screen:
XXK SUPERBRAIN DOS VER X.X
A"?
If this message does not appear on the screen, try depressing the two RED keys located on
either side of the keyboard. This should reset the terminal and thereby attempt to reload
the operating system. If after several seconds, the message does not appear on the screen, try
depressing the RED keys several more times. If repeated depressions of the RED keys do
not bring up the indicated message, then open the door on the disk drive A and remove the
system diskette and check to see if it was properly inserted. It is extremely important that
the diskette be in the proper orientation before attempting to load the operating system. If
you are unsure as to the proper orientation of the diskette, please contact the representative
from whom you originally purchased your equipment.

Page 6

INSTALLATION AND OPERATING INSTRUCTIONS (continued)
After you have checked the orientation of the diskette try reinserting it into DRIVE A (do
NOT insert the system diskette into DRIVE B as it will not load from DRIVE B). Once the
diskette has been reinserted, close the door on DRIVE A and depress the RED key. If after
several repeated depressions of the RED keys the message XXK SUPERBRAIN DOS VER
X.X does not appear on the terminal then contact your dealer.
REVIEWING THE SYSTEM DISKETTE
Now that you have successfully loaded the System Diskette and Disk Operating System,
(DOS), the SuperBrain is ready to accept your disk operating system commands. At this
time we will review several of the commands in the operating system. However, it is
recommended that you refer to the appropriate section in this Manual for a detailed
description of all such commands (Section 4 - Introduction to CP/M Features and
Facilities). The most used system command is the DI R command. This command directs the
operating system to display the directory of all programs contained on the system diskette.
You may enter this command by simply typing the letters DI R on the keyboard. After you
have typed these letters, it is necessary to depress the RETURN key. Depressing this key
instructs the computer to process the line of data that you have just typed. After you
depress the RETURN key the computer should respond by displaying all of the programs on
the system diskette. These programs will appear in the following form:
A:
A:
A:
A:
A:

ED.COM
DDT.COM
ASM.COM
LOAD.COM
DUMP.COM

A:
A:
A:
A:

SYSGEN:COM
PIP.COM
STAT.COM
SUBMIT.COM

To obtain a better understanding of just what this information means, lets take a look at the
first line:
A: ED.COM
The first letter on this line is a letter A. This tells you that the information following this
letter is located on DRIVE A. The colon serves as a separator between the Drive designator
("A") and the file NAME and file TYPE. The file NAME is, in this case, "ED" and the file
TYPE is "COM". As such, this line tells the operator that a program called ED (the disk
operating system text editor) is located on the "A" drive and is a COM type of file. A more
detailed treatment of this information can be found in section 4 of this manual.
IMPORTANT NOTE: Some of the disk utility programs have a two digit number suffixed to
the File name (i.e. PIP 22). This suffix is used to indicate the actual revision and/or version
level of the program.
DUPLICATING THE OPERATING DISKETTE
Now that you have successfully loaded the Disk Operating System on Drive A, it is
important to duplicate this diskette onto another disk. This is necessary in order to preserve
the original copy of the diskette and guard against any possible damage to the original
media. To generate a copy of the operating system you will first need a NEW BLANK
DISKETTE. We recommend an Intertec 1121010 diskette for this purpose. If you do not
have any blank diskettes of similar quality, please contact the representative from whom
you purchased your equipment. He should be able to supply you with an ample quantity of
these diskettes.
Once you have located a new blank diskette, insert it into DRIVE B. Follow the procedures
outlined in the previous paragraphs regarding the insertion of the operating system diskette.
The only difference is that you will be inserting the new blank diskette into DRIVE B. Be
sure and leave the system diskette installed on DRIVE A.

•

Page 7

INSTALLATION AND OPERATING INSTRUCTIONS (continued)
Once you have installed the new blank diskette on DRIVE B, you are now ready to
"FORMAT" the new diskette. It is necessary to format all new previously unused diskettes
before attempting to' transfer data to them. This is necessary because all information is
stored on diskettes in what is known as the SOFT SECTORED FORMAT which necessitates
the writing of certain information on the disks before user programs can be stored on them.
To format the disk in DRIVE B enter the command 'FORMAT' at the keyboard. Remember
·to depress the key marked RETURN after typing the words FORMAT. The operating
system should now respond by asking you to select the type of diskette being formatted (S
or D). This question asks whether the diskette to be formatted is single sided or double
sided. Unless you have ordered our new Quad Density SuperBrain QD, the response to this
question should be the letter "S" indicating a single sided diskette. After entering the'S'
depress the RETURN key. The operating system will now ask you whether you have a 64K
(6) or 32K (3) disk operating system. In most cases, the answer to this question will be 3
(32K). After you have entered the appropriate response to this question the operating
system will respond by telling you to place a blank diskette on DRIVE B. Since this has
already been done, we are now ready to proceed with formatting the diskette and may
do so by entering the letter "F". At this point and time you will hear the disk drive reset to
track a and begin the formatting process. When a disk is formatted the read/write head
positions to track a and rewrites each track (there are a total of 35 on each diskette). The
screen will also display the current track which is being formatted. This number should
range from a to 34 for a total of 35 tracks.
After the disk has been completely formatted, the operating system will respond by asking
you whether to "REBOOT" the operating system or whether you wish to format another
disk. If you wish to format another disk, remove the newly formatted disk from DRIVE B
and insert a new blank diskette into DRIVE B. You may now proceed to format this new
diskette by once again entering the letter "F". If you do not wish to format any more
diskettes, simply enter a RETURN.
The Operating System should now reload and once again be ready to accept new commands.
Since the intent of this procedure was to copy the original disk operating system we are now
ready to begin that procedure. This can be accomplished by entering the following
command on the keyboard:
2~

V

PIP B: =*.*
After you have entered the above command at the keyboard depress the return key.
The system will now begin to copy all of the programs on DRIVE A over to DRIVE B. As
each program is copied, its name will be displayed on the screen. This procedure takes
approximately 5 to 10 minutes. After the procedure completes, the control of the operating
system will be returned to the user.

.•

Now that you have completed copying the operating system's programs from the A DR IVE
to the B DRIVE it is necessary to copy the disk operating system itself (which is located on
tracks 0, 1 and 2) onto the DRIVE B. This may be accomplished by entering the following
command at the keyboard:
SYSGEN 2..7-_
The SYSGEN command is used to generate an operating system and place it on the desired

•

Page 8

INSTALLATION AND OPERATING INSTRUCTIONS (continued)
disk. Once you have entered this command at the keyboard and typed RETURN, the disk
operating system will ask you to select which drive that you want to take the source from.
The correct answer to this question is the letter "A". After entering "A" depress the
RETURN.
The next question the program will ask is where do you want the source to be placed (the
destination drive). The correct answer to this is the letter "B" indicating DRIVE B. Once
you have entered this, the operating system will be copied from DRIVE A onto DRIVE B.
After this process has been completed the operating system will ask you whether you wish
to duplicate another copy or to reload the operating system. The correct response is to
simply enter a RETURN which will reload the operating system.
Once the operating system has been reloaded, you may now remove the master disk
operating system in DRIVE A. Once this disk has been removed store it in a safe place as
you may need it later to generate additional copies of the disk operating system and its
programs.
At this point you should have removed the master disk from DRIVE A. Now remove the
copy from DRIVE B and reinstall it on DRIVE A and close the door on DRIVE A. After
you have completed this, depress the RED reset keys located on either side of the keyboard.
This will reset the machine and reload the newly installed operating system off of your new
diskette.
IMPORTANT: If random garbled information is displayed on the screen at this time, this
indicates that you have made an error in the use of the "SYSGEN" program. If this is
indeed the case, then remove the new diskette from DRIVE A and reinstall the original
master system diskette and repeat the previously outlined procedure for generating a new
disk operating system. If you still encounter difficulties, please refer to Section 4 of this
manual for more detailed information concerning this procedure.
Now that you have successfully completed the generation of a new system diskette please
refer to Section 4 of this manual for a complete description of all of the operating systems
utility programs (DDT.COM, PIP.COM, SUBMIT.COM, etc.).
OPTIONAL SOFTWARE
Numerous optional software packages are available for use with your SuperBrain Video
Computer System. Currently available directly from Intertec are such software packages as
Microsoft's BASIC, FORTRAN and COBOL. If you would like additional information on
these packages please contact you r local Intertec representative.
NEWLY RELEASED SYSTEM PROGRAMS
From time to time, Intertec will be releasing additional 'standard' system programs. Listed
below is a brief description of several such programs. A complete description of these and
other similar programs can be found in the "software addenda" section of this manual.
FORMAT.COM

Allows the user to format blank diskettes. This program must be run on
all new diskettes which have not been previously formatted on a
SuperBrain Video Computer System. It is important to note that
although you may have formatted these diskettes on other systems, this
does not necessarily imply that they will work on a SuperBrain unless
they have been formatted on a computer of this type. Therefore, in
order to insure complete compatibility please format all new diskettes on
a SuperBrain Video Computer System before using.

Page 9

INSTALLATION AND OPERATING INSTRUCTIONS (continued)
RAMTST.COM

This program runs an extensive test on main memory by writing and
reading all possible patterns into all locations in the RAM. This program
takes approximately 4 to 5 minutes to complete on 32K machines and 8
to 10 minutes on 64K machines. Since different amounts of RAM are
contained in the 32 and 64K machines, we have included two RAM test
programs. These are: RAMTST32.COM and RAMTST64.COM which are
for testing 32 and 64K versions of the SuperBrain Video Computer
System. It is important to note that the 64K RAM test program will not
execute properly on a 32K machine.
At the end of the RAM test program, the message RAM OK will appear
on the screen if the test was completed successfully. If any errors were
detected during the test, the computer's bell will turn on and continue in
a continuous tone manner until the RED reset key is depressed. If a
continuous tone such as this is heard on the computer when executing
the RAM test, depress the RED reset and try executing the program
several times. If the program continues to produce the audible tone, then
please contact the I ntertec Service Department.

CONFIGUR.COM This program allows the user to configure all parameters for the RS232
MAIN and AUXILIARY serial port. The selected configuration is then
permanently stored on the disk along with the disk operating system. As
such, the system will be completely reconfigured each time power is
applied to the machine or the RED reset key is depressed.
A complete description of all of these programs can be found in the software addenda
section of this manual. In addition to the descriptions contained therein, most newly
released system programs will contain a description program along with the actual COM file.
This program will be in the form of FILE NAME.DES. As an example of such a program
would be 'FORMAT.DES'. This program .would contain a description of how the format
program operates. Therefore, if you are unable to find an adequate description in the
software addenda section of this manual for a program on the disk, please check for a DES
version of the program on your disk. If such a program exists, you may display the
instructions by simply typing the following command: TYPE FI LENAME.DES.
VIDEO DISPLAY FEATURES AND CONTROL CODES
Various screen control features are available to the operator through the use of 'ESCAPE'
sequences. Among these are the following:
Absolute cursor addressing

[ESC] [Y] [row] [column] The cursor is positioned to
the row and column specified. Refer to the SuperBrain
screen layout for specific screen formatting information.

Erase to end of line

[ESC] [en] [K] Data is erased from cursor position to the
end of the current line.

Erase to end of page

[ESC] [en] [k] Data is erased from cursor position to the
end of the screen.

Display control characters

[ESC] [en] [E] Enable transparent mode. Control
characters received are displayed on the screen and are
not executed.

•

Page 10

INSTALLATION AND OPERATING INSTRUCTIONS (continued)
Disable control character display [ESC]

[U')]

[D] Disable the transparent mode.

Other features are also available using the 'CONTROL' key. They a-re the following:
CONTROL
CONTROL
CONTROL
CONTROL
CONTROL
CONTROL
CONTROL

[A]
[F]
[G]
[I]
[K]
[L]
[U]

- Home cursor (Row 1, Column 1)
- Cursor forward
- Ring Bell
- Tab
- Cursor Up
- Clear Screen
- Cursor Back

MASTER RESET FEATURE
A Master Reset of all terminal hardware may be accomplished by depressing the solid
colored RED key located on the upper right hand corner of the numeric keypad. It is
important to note that on some versions of the SuperBrain, this reset feature may involve
the depression of two RED keys. If this is the case on your computer system, you will
notice that the two RED keys are located on the right and left corners of the alphameric
section of the keyboard.
CURSOR CONTROL KEYS
There are three to four cursor control keys located on every SuperBrain Video Computer
System. These keys are located on the right-hand side of the numeric keypad. If your
computer has a single RED key (keyboard layout A), it will be located in the upper right
hand corner of the numeric keypad thereby leaving only three cursor position keys. If your
computer is configured with two RED keys (keyboard layout B - one RED key located on
each side of the alphanumeric keyboard cluster), then you will have a total of four cursor
position keys on the right hand side of the numeric keypad. In either case, these keys will
transmit codes to any program running on the SuperBrain. These codes may in-turn be
interpreted by the program to result in cursor movement on the screen. It is important to
know that these keys will not produce cursor movement when you are in the operating
system mode. The reason for this is that CP/M does not define any use of cursor positioning
on the screen. As such, depression of these keys while in the operating system mode will
result in the control codes assigned to the individual keys being displayed as control codes
on the screen.

Page 11

INTERFACING INFORMATION
RS-232-C Serial Interface
The following chart illustrates the pinouts for the MAIN and AUXI LlARY serial ports and
the direction of signal flow.
SUPERBRAIN SERIAL PORT PIN ASSIGNMENTS
(For use with Revision 3.0 DOS software or higher
and Keyboard/CPU Module Revision 1.0 or higher)
MAIN PORT
PIN #

1 \3UJ

.2
3

4
5
6
7

1"3K'I'\

BLI\
\'1,,):(
Gr~!
0\((,

\,UHT

15 CRI,)
17 YEL
20 IZE"fJ
22 F;:'I--I_
241.,\3'[;;1-)

ASSIGNMENT

GND
Transmitted Data
Received Data
Request to Send
Clear to send
Data Set Ready
GND
Transmit Clock
Receive Clock
Data Terminal Ready
Ring Indicator
Clock

DIRECTION

(From SB)
(To SB)
(From SB)
(To SB)
(To SB)
(To SB)
(To SB)
(From SB)
(ToSB) _
(From 58)

AUXI LlARY PORT
PIN #

1
2

3
7
20

ASSIGNMENT

GND
Received Data
Transmitted Data
GND
Data Terminal Ready

DIRECTION

(To SB)
(From SB)
(ToSB)

Bus Adaptor Interface
The SuperBrain contains a Z80 bus interface to the main processor bus. These signals are
shown in the chart on the following page.
When using this interface, it is recommended that all signals be buffered so as not to
excessively load the main processor bus. The external bus should ONL Y be utilized for I/O
devices using addresses 80H to FFH. Memory mapped I/O is NOT possible since the
SuperBrain is internally configured for 64K of RAM.

Page 12

PIN CONNECTIONS FOR EXTERNAL BUS

PIN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

SIGNAL
NAME
SYSRES*

A10
A12
A13
A15
GND
A 11
A14
A8
OUT*
WR*
RD*
A9
D4
IN*
D7
D1
D6
A0
D3
A1
D5
GND
D0
A4
D2
A3
A5
A7
GND
A6
+5V
A2

DESCRIPTION
SPARE
System Reset Output, Low During Power Up Initialize or
Reset Depressed
SPARE
Address Output
Address Output
Address Output
Address Output
Signal Ground
Address Output
Address Output
Address Output
Peripheral Write Strobe Output
Memory Write Strobe Output
SPARE
Memory Read Strobe Output
SPARE
Address Output
Bidirectional Data Bus
Peripheral Read Strobe Output
Bidirectional Data Bus
SPARE
Bidirectional Data Bus
SPARE
Bidirectional Data Bus
Address Output
Bidirectional Data Bus
Address Output
Bidirectional Data Bus
Signal Ground
Bidirectional Data Bus
Address Bus
Bidirectional Data Bus
SPARE
Address Output
Address Output
Address Output
Signal Ground
Address Output
5 Volt Output (Limited Current)
Address Output

NOTE: * implies negative (Logical "0"') true, Input or Output

Connection points for External Bus

•

NUMERIC KEYPAD

.

ESC

!

@

#

1

2

.3

TAB

Q

CTRL

CAPS
LOCK

SHIFT

W

E

i
S

A

Z

$
4

i

R

D

X

%
5

&

6

7

T

V

B

H

B

J

N

(

)

9

0

0

I

U

Y

G

F

C

A

(with cursor keys)

M

<

[

=
I
I

"-

...

:
;

>

+

1

P

L

K

-

7
/

SHIFT

-,

BACK
SPACE

LINE
FEED

I
I

DEL

RETURN
HERE
IS

BREAK·

7

B

9

,

RESTART

4

5

6

-

-..

1

2

3

0

E
N
T

E
R

,
t

- - - - - - -

SPACE BAR

SUPERBRAIN KEYBOARD LAYOUT A

NUMERIC KEYPAD
(with cursor keys)
ESC

!
1

TAB

Q

CTRL

CAPS
LOCK

RESTART

t

SHIFT

@

#

2

3

W

$
4
E

S

A

Z

1\

&

.

(

)

5

6

7

B

9

0

R

C

I

Y

T

F

D

X

%

H

G

V

B

K

J

N

SPACE BAR

0

I

U

M

+
:

[

"

..

:
;

>

I
I

1

P

L

<

-

7
/

SHIFT

~

,

BACK
SPACE

LINE
FEED

I
I

BRK

DEL

RETURN
REHERE
IS
START

7

B

9

I

4

5

6

-

1

2

3

0

I

Special "re-start" sequence key used in
conjunction with other re-start key on
right side of keyboard wi \I re-Ioad
SuperBrain's Disk Operating System_ A
two-key re-start sequence is used to
minimize chance of operator error when
system is in operation. Both keys must
be depressed simultaneously to reload
the operating system.

SUPERBRAIN KEYBOARD LAYOUT B

II

E
N
T

E
R

.-

...
t

-I
,

I

SUPERBRAIN SCREEN LAYOUT
1 2 3 4

Ii 8 7 8 II 0

1 2 3

2
4 5 Ii 7 890

!

1 2 3 4 Ii 8 7 8 9 0.1

2 3 4

4
5 6 7 8 9 0

1 2 3 4 5

6 7 8

5
6
9 0 1 2 3 456 7 8 901

"-1' I"I"I-I~I-I' 1'1'1'1+1· H·1/1'1' 1'1' 1'1'1-1'1-1'1·1·1+1' 1'1·1'1'1' 1'1 'l'I'I4ft'1 '1'1 'l'I'I'j
2~

f f.+

W

x

Y

z

7
2 3 4 5 6 7 8 9 0 1 2 3 4 5 6

9 0

Cl'

-i

I

2

I

3

3 "

4

4

It

5

5
~

6

6

88-

8

/'

9U-

80 Characters

9

This Screen Format of the lntertube's display area provides
an easy method of locating and addressing specific screen positions.

10

24
lines

11 •

Using the ESC, Y, r, c command,locate both the row character (r
and the column (c = 1 ·80) characters. Example:

SCREEN DISPLAY

COLUMN

ROW

12 +

10

1 - 24)

COMMAND

1 (Home)

ESC Y SP sp

2

13

=

50

20

ESC Y

S

ESC Y 3

Q

13

An application programmer may find it helpful to maintain a table of
row and column numbers with their respective addressing characters
as shown on this Screen Format. This will provide quick and easy
access to specific screen positions.

14 15
16

,

14
15
16

J

17 0
18 I

18

111 I

19

201

20

2114~

21

22 IS

22

I23

2311

:14 11
I

t

I I I

I

I I

2 3 4 Ii I

I I

I

I

7 8 II 1

o

I

I

I I

I

1 2 3 4 Ii I

I

I I I I I I I I I I I I I I I I I I I I I I I I I I I

7 8 9 Z 1 2 3 4 Ii 8 7 8 II :I 1 2 3 4 Ii 8 7 8 9 4
0
0
0

1 2 3 4

I

I
5

I

I

I

I

I

I

I

6 7 8 9 5 1 2 3
0

I

I

I

I-

4 5 6 "

8 9 6
0

1 2 3 4

5 6 7 8 9 7 1 2 3
0

4

5 6 7 8 9 8
0

'4 '"tl
Ql

to

CD
-"

01

Page 16

INTERPRETING THE ASCII CODE CHART
The figure below illustrates a conventionally arranged ASCII code chart divided into three
sections corresponding to control codes (columns 0 and 1) upper case characters (columns
2,3,4, and 5), and lower case characters (columns 4 and 5) .

.

.
.

~

~b5
B.
It

s

b
4

~
0
0
0
0
0
0
0
0
1
1
1
1

1
1
1
1

~
~

a
a
a
0
1
1
1
1
0
0
0
0
1
1
1
1

~
~

0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1

~
·1
0
1

00

10

01

1

1

10
0

1
01

4

5

1
10

111

6

7

,

p

column

~
a

a

1
2

1

3

0
1

4
5

0
1
0
1

6
7
8
9

0
1

10
11
12
13
14
15

0
1
0
1

0

00
0

a
NUL
SOH
STX
ETX
EOT
ENO
ACK
BEL
BS
HT
LF

VT

1
DLE
DCI
DC2
DC3

DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS

2
SP

!
"
/I
$
%
&
(

.
)

3
0
I
2
3
4
5

6
7
8
9

+

@

P

A
B
C
D
E
F
G
H
I

0

a

A
S
T

b

c
d

U

e

V

f

W
X
Y

9

J

Z

i
j

K

I:

k

h

<

L

\

-

=

M.

so

GS
AS

J

N

1\

SI

US

/

<
?

L
m
n

0

-

0

FF
CA

q
r

s
t
u
v

w
x
y

z
I

I
I
I

I

I

DEL

Control codes are not displayable unless in the transparent mode. Some of these codes
affect the state of the terminal when they are received by the display electronics. For
example, the code SOH causes the cursor to go to the home position, and code DC2 turns
on the printer port. Codes which have no defined function in the Super8rain software are
ignored if received. The set of 64 upper case alphanumeric characters is sometimes referred
to as "compressed ASCII".
If the terminal is set for upper case operation only (CAPS LOCK), lower case alpha
characters from the keyboard are automatically translated and displayed as their upper case
equivalents (columns 4 and 5). If the DE L code is received, it is ignored. Lower case
characters received from the input RS-232C port are displayed as lower case.
The seven-bit binary code for each character is divided into two parts in this chart. A
four-bit number represents the four least significant bits (81, 82, 83, 84) and a three-bit
number represents the three most significant bits (85, 86, 87). The chart above also is
divided into 8 columns and 16 rows. This offers two ways of indicating a particular
character's code. The character code is indicated as either a seven-bit binary number or as a
column/row number in decimal notation. For example, the character M is represented by
the binary number 1001101 or the alternative 4/15 notation. Similarly, the control code VT
is represented by the code 00001011 or the alternative 0/11 notation.

I
INTRODUCTION TO
CP/M FEATURES & FACILITIES

01

[)~[j~Tfll

RESEflRl:tI

Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896

AN INTRODUCTION TO CP/M FEATURES AND FACILITIBS

COPYRIGHT (c) 1976, 1977, 1978
DIGITAL RESEARCH

REVISION OF JANUARY 1978

Copyright (c) 1976, 1978 by Digital Research. All rights
reserved. No part of this publication may be reproduced,
transmitted, transcribed, stored in a retrieval system, or
translated into any language or computer language, in any
form or by any means, "electronic, mechanical, magnetic,
optical, chemical, manual or otherwise, without the prior
written permission of Digital Research, Post Office Box 579,
Pacific Grove, California 93950.
Disclaimer
Digital Research makes no representations or warranties with
respect to the contents hereof and specifically disclaims any
implied warranties of merchantability or fitness for any
particular purpose. Further, Digital Research reserves the
right to revise this publication and to make changes from
time to time in the content hereof without obligation of
Digital Research to notify any person of such revision or
changes.

Table of Oontents
Page

Section
1.

INTRODUcrIOO

2.

FUNCTIOR~

2.1.
2.2.

• •••••••••••••••••••••••••••••••••••••• 1

DESCRIPTIOO OF CP/M ••••••••••••••••••••• 3
General Command Structure ••••••••••••••••• ~ •• 3
3
File References • • • • • • • • • • • • • • • • • • • • • • • • • • • •
e~

3.

SWITCHING DISKS • •••••••••••••••••••••••••••••••••••

6

4.

THE FORM OF BUILT-IN CDMMANOO ••••••••••••••••••••••
4.1. ERA afn cr •••••••••••••••••••••••••••••••••••
4.2. DIR afn cr .........•......•.•••.• ...........
4.3. REN ufn1=ufn2 cr .............................
:t.4. SAVE n ufn cr ••••••••••••••••••••••••••••••••
4.5. TYPE ufn cr ••••••••••••••••••••••••••••••••••

7
7
8
8
9
9

~

5.

LINE EDITING AND OUl'pur CDNTROL ••••••••••••••••••••• 11

6.

TRlINSIENT CDMMANOO • ••••••••••••••••••••••••••••••••
6.1. STAT cr ••••••••••••••••••••••••••••••••••••••
6.2. As.1 ufn cr • ••••••••••••••••••••••••••••••••••
6.3. LCN) ufn cr ••••••••••••••••••••••••••••••••••
6.4. PIP cr •••••••••••••••••••••••••••••••••••••••
6.5. ED ufn cr • •••••••••••••••••••••••••••••••••••
6.6. SYSGEN cr ••••••••••••••••••••••••••••••••••••
6.7. SUBMIT ufn parm#l ••• parm#n cr ••••••••••••••
6.8. DUMP ufn cr ......•.•........................
6.9. IDVCPM cr ••••••••••••••••••••••••••••••••••••

12
13
16
17
18
25

7.

BOOS ERROR MESSAGES

33

8.

OPERATION OF CP/M ON THE MOO

.

••••••••••••••••••••••••••••••••

• ••••••••••••••••••••••

27

28
30
30

34

•

1.

INTRODUcrION.

CP/M is a ITOnitor control program for microcomputer system development
which uses IBM-compatible flexible disks for backup storage. using a computer
mainframe based u};X:>n Intel's 8080 microcomputer, CP/M provides a general
environment for program construction, storage, and editing, along with
assembly and J;.t'ogram check-out facilities.
An im};X:>rtant feature of CP/M is
that it can be easily altered to execute with any computer configuration which
uses an Intel 8080 (or Ziloq Z-80) Central Processing Unit, and has at least
16K bytes of main rrernory with up to four IBM-compatible diskette drives. A
detailed discussion of the ITOdifications required for any particular hardware
environment is given in the Digital Research doclUllent entitled "CP/M System
Alteration Guide." Although the standard Digital Research version operates on
a single-density Intel MIS 800, several different hardware manufacturers
support their own input-output drivers for CP/M.
The CP/M m::mitor provides rapid access to programs through a
The file subsystem supports a named
comprehensive file management package.
file structure, allowing dynamic allocation of file space as well as
sequential and random file access. Using this file system, a large number of
distinct programs can be stored in both oource and machine executable form.
CP/M also sup};X:>rts a powerful context editor, Intel-compatible assembler,
and
debugger
subsystems.
Optional
software
includes
a
powerful
Intel-compatible macro assembler, symbolic debugger, along with various
high-level languages. When coupled with CP/M's Console Command Processor, the
resulting facilities equal or excel similar large computer facilities.
CP/M is logically divided into several distinct parts:
BIOS

Basic I/O System (hardware dependent)

BOOS

Basic Disk Operating System

CCP

Console Command Processor

TPA

Transient Program Area

The BIOS provides the primitive operations necessary to access the
diskette drives and to interface standard peripherals (teletype, CRr, Paper
Tape Reader/Punch, and user-defined peripherals), and can be tailored by the
user for any particular hardware environment by "patching" this JX>rtion of
CP/M.
The BOOS provides disk management by controlling one or rrore disk
drives containing independent file directories.
The BOOS implements disk
allocation strategies \'.hich provide fully dynamic file construction while
minimizing head rrovement across the di sk dur ing access. Any particular· file
may contain any number of records, not exceeding the size of any single disk.
In a standard CP/M system, each disk can contain up to 64 distinct files. The

1

•

BIXlS has entry p::>ints \\bich include the following
can be p[ogrammatically accessed:

pI' imi tive

operations which

SEARCH

Look for a particular disk file by name.

OPEN

Open a file for further operations.

CLOSE

Close

. RENAME

a

file after pcocessing.

Change the name of a particular file •

READ

Read a record from a particular file.

WRITE

write a record onto the disk.

SELEcr

Select a particular disk drive for further
operations.

The CCP provides symbolic interface between the user's console and the
remainder of the CP/M system. The CCP reads the console device and processes
commands \\bich include listing the file directory, pr inting the contents of
files, arid controlling the operation of transient programs, such as
assemblers, editors, and debuggers. The standard commands which are available
in the CCP are listed in a following section •
. The last s~ment of CP/M is the area called the Transient Program Area
(TPA) • The TPA holds programs which are loaded from the disk under command of
the CCP.
Durinq p:-ogram editing, for example, the TPA holds the CP/M text
edi tor ITB.chine code and data areas.
Similarly, programs created under CP/M
can be checked out by loading and executing these programs in the TPA.
It should be mentioned that any or all of the CP/M comp::ment subsystems
can be "overlayed" by an executing program. That is, once a user's program is
loaded into the TPA, the CCP, BOOS, and BIOS areas can be used as the
program's data area.
A "bootstrap" loader is programmatically accessible
whenever the BIOS p::>rtion is not overlayed: thus, the user p[ogram need only
branch to the bootstrap loader at the end of execution, and the complete CP/M
monitor is reloaded from disk.
It should be reiterated that the CP/M operating system is partitioned
into distinct nodules, including the BIOS p::>rtion \\tlich defines the hardware
environment in \\bich CP/M is executing.
Thus, the standard system can be
easily nodified to any non-standard environment by dlanging the peripheral
drivers to handle the custom system.

2

2.

ruN:TIONAL DESCRIPI'ION OF CP/M.

The user interacts with CP/M primarily through the CCP, \>thich reads and
interprets commands entered through the console.
In general, the CCP
addresses one of selTeral disks \>thich are online (the standard system crldresses
up to four different disk drives).
These disk drives are labelled A, B, C,
and D. A disk is "logged in" if the CCP is currently crldressing the disk. In
order to clearly irrlicate \>thich disk is the currently logged disk, the CCP
always prompts the ~erator wi th the disk name followed by the symbol ")"
indicatinj that the CCP is ready for another canmand.
Upon initial start up,
the CP/M system is brought in from disk A, and the CCP displays the message
xxK CP/M VER m.m
where xx is the rremory size (in kilobytes) which this CP/M system manages, and
m.m is the CP/M version number. All CP/M systems are initially set to operate
in a 16K .memory space, but can be easily reconfigured to fit any memory size
on the host system (see the IDVCPM transient command).
Followinj system
signon, CP/M automatically logs in disk A, prompts the user wi th the symbol
"A)" (indicating that CP/M is currently addressing disk "A"), and waits for a
command. The commands are implemented at two levels:
built-in commands and
transient commands.
2.1.

GENERAL CDMMAND STRUCI'URE.

Built-in commands are a part of the CCP program itself, \>thile transient
commarrls are loaded into the TPA from disk and executed.
The built-in
commands are

ERA

Erase specified files.

DIR

List file names in the directory.

REN

Rename the specified file.

SAVE

Save memory contents in a file.

TYPE

Type the contents of a file on the logged disk.

Nearly all of the commands reference a particular file or group of files.
form of a file reference is specified below.

The

2.2. PI LE REFERENCES.
A file reference identifies a particular file or group of files on a
particular disk attached to CP/M.
These file references can be either
"unambigoous" (ufn) or "ambiguous" (afn).
An unambiguous file reference
uniquely identifies a single file, \>thile an ambiguous file reference may be

3

satisfied by a number of different files.
File references consist of two parts: the primary name and the secondary
name. Although the secondary name is optional, it usually is generic; that
is, the secondary name "ASM," for example, is used to denote that the file is
an assembly language source file, mile the primary name distinguishes each
particular source file. The two names are separated by a "." as shown below:
PPPPPPPP.sss
where pppppppp represents the lX'irnary name of eight characters or less, and
sss is the secondary nane of no trore than three characters.
As Irentioned
above, the name
pppppppp
is also allowed am is Equivalent to a secondary name consisting of three
blanks.
The characters used in s~cifying an unambiguous file reference
cannot contain any of the special characters

[

<>.,;:= ? * [ ] ]

while all alphanumerics and remaining

s~cial

characters are allowed.

An ambigoous file reference is used for directory search and pattern
matching.
The form of an ambiguous file reference is similar to an
unambigoous reference, except the symbol "?" may be interspersed throughout
the 12' irnary and secondary names. In various canrnands throughout CP/M, the "?"
symbol matches any character of a file name in the "?" position. Thus, the
arnbigoous reference

X?Z.C?M

is satisfied by the unarnbigoous file names
XYZ.OOM

and
X3Z.CAM

Note that the ambigoous reference

*.*
is Equivalent to the ambigoous file reference

............

???????? ???

while

4

and

PPPPPPPP.*
*.sss

are abbreviations for
PPPPPPPP.???
and
???????? .sss
respectively.

As an example,

DIR *.*

is interpreted by the CCP as a canmand to list the names of all disk files in
the directory, While

DIR X.Y
searches only for a file by the name X.Y

Similarly, the command

DIR X?Y.C?M

causes a search for all (unambiguous) file names on the disk Which satisfy
this ambiguous reference.
The fOllowing file names are valid unambiguous file references:

x

XYZ

GAMMA

X.Y

XYZ.CDM

GAMMA. I

As an crlded convenience, the programmer can generally specify the disk
drive name along with the file name. In this case, the drive name is given as
a letter A through Z follow=d by a colon (:). The specified drive is then
"logged in" before the file operation occurs. Thus, the fOllowing are valid
file names with disk name prefixes:
A:X.Y

B:XYZ

C:GAMMA

Z:XYZ .CDM

B:X.A?M

C:*.ASM

It should also be noted that all alphabetic lower case letters in file
and drive names are always translated to upper case \>A1en they are T;rocessed by
the CCP.

5

3.

SWITCHING DISKS.

The cperator can switch the currently logged disk by typing the disk
drive nane (A, B, C, or D) followed by a colon (:) when the CCP is waiting for
console irput. Thus, the sequence of pranpts and canrnands shown below might
occur after the CP/M system is loaded from disk A:
16K CP/M VER 1.4
A>DIR

List all files on disk A.

SAMPLE

AStf

SAMPLE

PRN

A>B:

Switch to disk B.

B>DIR *.ASM

List all "ASM" files on B.

DUMP
FILES

B>A:

Switch back to A.

6

4.

THE FORM CF BUILT-IN CDMWoNOO.

The file arrl device reference forms described above can now be used to
fully st:ecify the structure of the built-in canmands.
In the description
below, assume the followin;J abbreviations:
ufn

unambiguous file reference

afn

ambiguous file reference

cr

carriage return

Fur ther, recall that the CCP always translates lower case characters to u];:.Per
case characters internally. Thus, lower case alphabetics are treated as if
they are upper case in command names arrl file references.

4.1

ERA afn cr

The ERA (erase) canmand ranoves files fran the currently logged-in disk
(i.e., the disk nane currently pranpted by CP/M precedin;J the ">"). The files
which are erased are toose \\hich satisfy the ambiguous file reference afn.
The followil'lJ examples illustrate the use of ERA:
ERA X.Y

The file named X.Y on the currently logged disk
is ranoved fran the disk directory, and the space
is returned.

ERA X.*

All files wi th pr imary name X are removed fran
the current disk.

ERA *.ASM

All files. wi th secondary name ASM are removed
fran the current disk.

ERA X?Y.C?M

All files on the current disk Which satisfy the
ambiguous reference X?Y.C?M are deleted.
Erase all files on the current disk (in this case
the CCP pranpts the console with the message
"ALL FILES (Y!N)'?"

Which requires a Y response before files are
actually removed).
ERA B:*.PRN

All files on drive B Which satisfy the ambiguous
reference ????????PRN are deleted, independently
of the currently logged disk.

7

•

4.2. OIR afn cr
The orR (directory) canmand causes the names of all files \>tlich satisfy
the anbiguous file name afn to be listed at the console device. As a s};:ecial
case, the canmand
OIR
lists the files on the currently logged disk (the canmand "OrR" is Equivalent
to the canmand "OIR *.*"). Valid orR canmands are shown below.
orR X.Y
OIR X?Z.C?M
orR ??Y
Similar to other CCP canmands, the afn can be J;receded by a drive name.
The followirq OIR canmands cause the selected drive to be crldressed before the
directory search takes place.
OIR B:
orR B:X.Y
OIR B:*.A?M
If no files can be found on the selected diskette \>tlich satisfy the
directory request, then the IIEssage "Nor FOUND" is ty};:ed at the console.

4.3. REN ufnl=ufn2

cr

The REN (rename) canmand allows the user to change the names of files on
disk. The file satisfyin;J' ufn2 is chan;J'ed to ufnl. The currently logged disk
is assumed to contain the file to rename (ufnl). The CCP also allows the user
to ty};:e a left-directed arrow instead of the equal sign, if the user' s console
supports this graphic character. Examples of the REN canmand are
REN X.Y=Q.R

The file Q.R is changed to X. Y.

REN XYZ.OOM=XYZ.XXX

The file XYZ.XXX is changed to XYZ.(X)M.

The operator can p::ecede either ufnl or ufn2 (or both) by an optional
drivecrldress.
Given that ufnl is preceded by a drive name, then ufn2 is
assumed to exist on the same drive as ufnl. Similarly, if ufn2 is J;receded by
a drive nane, then ufnl is assumed to reside on that drive as ~ll.~;~rf both
ufnl am ufn2 are preceded by drive names, then the same drive must be

8

sp:!cified in both cases.

The following REN canmands illustrate this format.

REN A:X.ASM = Y.ASM

The file Y.ASM is changed to X.ASM on
drive A.

REN B:ZAP.BAS=ZOT.BAB

The file ZOT.BAB is changed to ZAP.BAS
on drive B.

REN B:A.ASM = B:A.BAK

The file A.BAK is renamed to A.ASM on
drive B.

If the .file ufnl is already IXesent, the REN canmand will respond with ~:~
the error "FILE EXISTS" and not p.=rform the change. If ufn2 does not exist on
the sp2cified diskette, then the rressaqe "NOI' roUND" is pr inted at the
console.

4.4. SAVE

n

ufn cr

The SAVE canmarrl places n pages (256-byte blocks) onto disk fran the TPA
and nanes this file ufn. In the CP/M distribution system, the TPA starts at
HH!JH (hexadecimal), mich is the second page of memory. Thus, if the user's
program occupies the area fran l00H through 2FFH, the SAVE command must
specify 2 pages of rremory. The machine code file can be subsequently loaded
and executed. Examples are:
SAVE

3 X.CDM

COpies l00Hthrough 3FFH to X.CDM.

SAVE

40

COpies l00H through 28FFH to Q (note
that 28 is the page count in 28FFH,
and that 28H = 2*16+8 = 40 decimal).

SAVE

4 X.Y

Q

COpies l00H through 4FFH to X.Y.

The SAVE canmand can also sp2cify a disk drive in the afn p::>rtion of the
canmand, as shown below.
SAVE

10 B:ZOT.CX)M

Copies 10 pages (100H through 0AFFH) to
the file ZOT.OOM on drive B.

4.5. TYPE ufncr
'l~

The TYPE canmand displays the contents of the ASCII source file ufn on

I'~'\,the rurrently logged disk at the console device. Valid TYPE canrnands are
TYPE

X.Y

9

~'f
'Ii

TYPE

X.PJ:M

TYPE

XXX

The TYPE canrnarrl expands tabs (clt-I characters), assumming tab lX>sitions
are set at fNery eighth colUIm. The ufn can also reference a drive name as
shown below.
TYPE

B:X.PRN

The file X.PRN from drive B is displayed.

Ie,

5.

LINE EDITING AND OUl'PUl' rtion of CP/M. Thus, the logical RDR: device,
for example, could actually be a high speed reader, Teletype reader, or
cassette tape.
In order to allow rome flexibility in device naming and
assignment, several physical devices are defined, as shown below:

14

T'lY:

Teletype device (slow speed console)

CRr:

Cathode ray tube device (high speed console)

BAT:

Batch processing (console is current RDR:,
output qoes to current LST: device)

UCl:

User-defined console

Pl'R:

Paper tape reader (high speed reader)

URI:

User-defined reader #1

UR2:

User-defined reader #2

Pl'P:

Paper tape punch (high speed punch)

UPl:

User-defined punch #1

UP2:

User-defined punch #2

LPl':

Line printer

ULl:

user-defined li.st device #l

•

It must be emphasized that the physical device names mayor may not
actually corres~nd to devices which the names imply.
That is, the PTP:
device may be implemented as a cassette write operation, if the user wishes.
The exact corres~ndence and driving subroutine is defined in the BIOS portion
of CP/M.
In the standard distribution version of CP/M, these devices
correspond to their names on the MDS 800 development system.
The p:>ssible logical to physical device assignments can be displayed by
typing
STAT VAL: cr

7~'"

The STAT pr ints the p::>ssible values which can be taken on for each logical
device:
fiN.

RDR:
PUN:
LST:

= TTY:
= TTY:
= TTY:
= TTY:

CRr:
Pl'R:
PI'P:
CRr:

BAT:
URI:
UPl:
LPI':

UCl:
UR2:
UP2:
ULl:

In each case, the logical device shown to the left can take any of the four
physical assignments shown to the right on each line. The current logical to
physical mapping is displayed by typing the command
STAT lEV: cr

15

~:(

which produces a listing of each logical device to the left, and the current
corresponding physical device to the right.
For example, the list might
appear as follows:
CON: = CRr:

RDR: = URI:
PUN: = PI'P:
LST:
..;!~
,1

= TTY:

The current logical to physical device assignment can be changed by typing a
STAT command of the form
STAT ldl = pdl, ld2 = pd2 , ••• , ldn = pdn cr
where ldl
compatible
the "VAL:"
change the

through ldn are logical device names, and pdl through pjn are
physical device names (i.e., ldi and pji appear on the same line in
canmand shown above). The following are valid STA'I' canrnands which
current logical to physical device assignments:

STAT CDN:=CRl': cr
STAT PUN: = TTY: ,IST:=LPl':, RDR:=TTY: cr

6.2. ASM ufn cr

The ASM canrnand loads and executes the CP/M 8080 assembler.
The ufn
specifies a s::>urce file containing assembly language statements where the
secondary name is assumed to be ASM, and thus is not specified. The following
ASM canmands are valid:
ASM X
ASM GAMMA

The two-pass assembler is automatically executed.
If assembly errors occur
during the second pass, the errors are printed at the console.
~~!
1.'+

The assembler produces a file
x.PRN

where x is the pr imary name specified in the ASM command.
The PRN file
contains a listing of the source program (with imbedded tab characters if
present in the s::>urce program), along with.the machine code generated for each
statement and diagnostic error messaqes, if any. The PRN file can be listed

16

at the console usi~ the TYPE canmand, or sent to a }:eripheral device using
PIP (see the PIP canmand structure below).
Note also that the PRN file
contains the original s:>urce program, augmented by miscellaneous assembly
information in the leftIoost 16 columns (program crldresses and hexadecimal
machine code, for example). Thus, the PRN file can serve as a backup for the
original source file: if the s:>urce file is accidently removed or destroyed,
the· PRN file can be edited (see the ED operator's guide) by removing the
leftIoost 16 characters of each line (this can be done by issuing a single
editor "nacro" canmand).
The resulting file is identical· to the original
source file and can be renamed (REN) fran PRN to ASM for subsequent editing
and assembly. The file
x.HEX
is also produced \'thich contains 8080 machine language in Intel "hex" format
sui table for sli:>sequent loading and execution (see the LON) canrnand).
For
canplete details of CP/M's assembly language program, see the "CP/M Assembler
language (ASM) User's Guide."
Similar to other transient canrnands, the S)urce file for assembly can be
taken fran an a..ternate disk by prefixing the assembly language file name by a
disk drive name. Thus, the canmand
ASM

B:ALPHA cr

loads the assembler fran the currently logged drive and operates up:m the
source program ALPHA.ASM on drive B. The HEX and PRN files are also placed on
drive B in this case.
6.3.

LQl\J)

ufn cr

The LON) canmand reads the file ufn, \\hich is assumed to contain "hex"
format machine code, and produces a memory image file \'thich can be
subsequently executed. The file name ufn is assumed to be of the form
x.HEX
and thus only the name x need be specified in the canmand.
creates a file named

x.CDM
which narks it as containing nachine executable code. . The file is actually
loaded into memory and executed \'then the user types the file name x
inunediately after the pranptingcharacter ")" printed by the CCP.
In general, the .CCP reads the name x following the pranpting character
and looks for a built-in fmction name. If no fmction name is found, the CCP
searches the system disk directory fora file by the name

17

x.Q)M
If found, the machine code is loaded into the TPA, and the program executes.
Thus, the user need only LOAD a hex file once:
it can be subseg:uent1y
executed any number of times by simply typing the primary name. In this way,
the user can "invent" new ccrnrnands in the CCP.
(Initialized disks contain the
transient canmands as CDM files, which can be deleted at the user's option.)
The operation can take place on an alternate drive if the file name is
prefixed by a drive name. Thus,
LOAD B:BETA
brings the LOAD program into the TPA from the
operates upon drive B after execution begins.

currently logged disk

and

It must be noted that the BETA.HEX file must contain valid Intel format
hexadecimal machine code records (as produced by the ASM program, for example)
which beqin at 100H, the beginning of the TPA. Further, the addresses in the
hex records must be in ascending order: gaps in unfilled memory regions are
filled with zeroes by the LOAD ccrnrnand as the hex records are read. Thus,
?~~LOAD must be used only for creating CP/M standard "Q)M" files which operate in
the TPA. Proqrams v.hich occupy regions of memory other than the TPA can be
loaded under DDI'.

6.4. PIP cr
PIP is the CP/M Peripheral Interchange Program which implements the basic
media conversion operations necessary to load, print, punch, copy, and combine
disk files. The PIP program is initiated by typing one of the following forms
(1) PIP cr
(2) PIP "canmand line" cr
In both cases, PIP is loaded into the TPA and executed.
In case (1), PIP
reads command lines directly from the console, prompted with the "*,,
character, until an empty command line is typed (i.e., a single carriage
return is issued by the operator). Each successive ccrnrnand line causes rome
media conversion to take place according to the rules shown below. Form (2)
of the PIP command is equivalent to the first, except that the single command
line given with the PIP command is automatically executed, and PIP terminates
immediately wi th no further prompting of the console for input command lines.
The form of each command line is
destination

= source#l,

rource#2, ••• , rource#n cr

where "destination" is the file or peripheral device to receive the data, and

18

"oource#l, ••• , source#n" represents a series of one or rrore files or devices
which are copied from left to right to the destination.
When multiple files are given in the canmand line (i.e, n > 1), the
individual files are assumed to contain ASCII characters, with an assumed CP/M
end-of-file character (ctl-Z) ~t the end of each file (see the 0 parameter to
override this assumption).
The equal symbol (=) can be replaced by a
left-oriented arrow, if your console supports this ASCII character, to improve
readability. Lower case ASCII alphabetics are internally translated to upper
case to be consistent with CP/M file and device name conventions. Finally,
the -total command line length cannot exceed 255 characters (ctl-E can be used
to force a physical carriage return for lines Which exceed the console width) •
The destination and source elements can be unambiguous references to CP/M
source files, with or without a precedirtJ disk drive name. That is, any file
can be referenced with a freceding drive name (A:, B:, C:, or D:) which
defines the particular drive Where the file may be obtained or stored.
When
the drive name is not included, the currently logged disk is assumed.
Further, the destination file can also appear as one or rrore of the oource
files, in which case the source file is not altered until the entire
concatenation is canplete.
If the destination file already exists, it is
removed if the command line is properly formed (it is not removed if an error
condi tion arises).
The following canmand lines (with explanations to the
right) are valid as input to PIP:

x = Y cr

Copy to file X from file Y,
Where X and Yare unambiguous
file names; Y remains unchanged.

X = Y,Z cr

Concatenate files Y and Z and
copy to file X, with Y and Z
unchanged.

·X.ASM=Y.ASM,Z.ASM,FIN.ASM cr

Create the file X.ASM from the
concatenation of the Y, Z, and
FIN files with type ASM.

NEW.ZOT = B:OLD.ZAP cr

Move a copy of OLD.ZAP from drive
B to the currently logged disk;
name the file NEW.ZOT.

B:A.U = B:B.V,A:C.W,D.X cr

Concatenate file B. V from drive B
with C.W from drive A and D.X.
from the logged disk; create
the file A.U on drive B.

For rrore convenient use, PIP allows abbreviated commands for transferring
files between disk drives. The abbreviated forms are

19

•

PIP x:=afn cr
PIP x:=y:afn cr
PIP ufn = y: cr
PIP x:ufn = y: cr
The first form copies all files from the currently loqged disk which satisfy
the afn to the same file names on drive x (x = A••• Z) • The second form is
equivalent to the first, where the source for the copy is drive y (y = A•••
Z) •
The third form is equivalent to the command "PIP ufn=y: ufn cr" which
copies the file given by ufn from drive y to the file ufn on drive x.
The
fourth form is equivalent to the third, where the source disk is explicitly
given by y.
Note that the source and destination disks must be different in all
these cases. If an afn is specified, PIP lists each ufn which satisfies
afn as it is beinq copied.
If a file exists by the same name as
destination file, it is renoved uron successful completion of the copy,
replaced by the copied file.
The followinq
operations:

PIP

commands

qive

examples of valid disk-to-disk

of
the
the
and

copy

B:=*.CDM cr

Copy all files which have the
secondary name "ooM" to drive B
from the current drive.

A:=B:ZAP.* cr

Copy all files which have the
primary name "ZAP" to drive A
from drive B.

ZAP.ASM=B: cr

Equivalent to ZAP.ASM=B:ZAP.ASM

B:ZOT.mM=A: cr

Equivalent to B:ZOT.OOM=A:ZOT.ooM

B:=GAMMA.BAS cr

Same as B:GAMMA.BAS=GAMMA.BAS

B:=A:GAMMA.BAS cr

Same as B:GAMMA.BAS=A:GAMMA.BAS

PIP also allows reference to physical and logical devices which are
attached to the CP/M system. The device names are the same as given under the
STAT command, along with a number of specially named devices.
The ICXJical
devices given in the STAT command are
ooN: (console), RDR: (reader), PUN: (punch), and IST: (list)
while the physical devices are

20

TTY: (console, reader, pLmch,
CRr: (console, or list) ,
PI'R: (reader) , URI: (reader),
PI'P: (pLmch) , UPl: (pLmch),
UIJ.: (list)
LPl': (list) ,

or list)
UCl: (console)
UR2: (reader)
UP2: (punch)

(Note that the "BAT:" physical device is not included, since this assignment
is used only to indicate that the RDR: and 1ST: devices are to be used for
console input/output.)
The RDR, 1ST, PUN, and OON devices are all defined wi thin the BIOS
portion of CP/M, and thus are easily altered for any particular I/O system.
(The current physical device mapping is defined by IOBYI'E; see the "CP/M
Interface Guide" for a discussion of this function).
The destination device
must be capable of receiving data (i.e., data cannot be sent to the pLmch),
and the source devices must be capable of generating data (i.e., the LST:
device cannot be read).

•

The additional device names which can be used in PIP commands are
NUL:

Send 40 "nulls" (ASCII 0 's) to the device
(this can be issued at the end of pLmched output).

EOF:

Send a CP/M end-of-file (ASCII ctl-Z) to the
destination device (sent automatically at the
end of all ASCII data transfers through PIP) •

INP:

Srecial PIP input source which can be "patched" ~
into the PIP program itself: PIP gets the input
data character-by-character by CALLing location
103H, with data returned in location 109H (parity
bit must be zero).

\)St;P

it\)

(' ON (l &>4",.
COM fH,~<:r

Tt'Q.()4.rQ

our:

Srecial PIP output destination which can be
patched into the PIP program: PIP CALLs location
106H with data in register C for each character
to transmit. Note that locations 109H throuqh
IFFH of the PIP memory image are not used and
can be replaced by special purpose drivers using
DDT (see the DDT operator's manual).

PRN:

Same as LST:, except that tabs are expanded at
every eighth character position, lines are
numbered, and page ejects are inserted every 60
lines, with an initial eject (same as [tBnp]).

File and device names can be intersrersed in the PIP commands.
In each
case, the sp:!cific device is read Lmtil end-of-file (ctl-Z for ASCII files,
and a real end of file for non-ASCII disk files). Data from each device or
file is concatenated from left to riqht until the last data source has been

21

-Ie

r.

read.
The destination device or file is written using the data from the
source files, and an end-of-file character (ctl-Z) is appended to the result
for ASCII files. Note if the destination is a disk file, then a temtx>rary
file is created ($$$ secondary name) which is chanqed to the actual file name
only up::m soccessful completion of the copy. Files with the extension "CDM"
are always .assumed to be non-ASCII.
The copy operation can be aborted at any time by depressing any key on
the keyboard (a rubout suffices). PIP will respond with the message "AOOro'EDII
to indicate that the operation was not completed. Note that if any operation
is aborted, or if an error occurs dur inq processing, PIP removes any };Ending
commands which were set up while usinq the SUBMIT command.
It sh:>uld also be noted that PIP performs a sp:cial function if the
destination is a disk file wi. th type "HEX" (an Intel hex formatted machine
code file), and the source is an external p:ripheral device, such as a paper
tape reooer.
In this case, the PIP program checks to ensure that the source
file contains a {Xoperly formed hex file, with legal hexadecimal values and
checksum records. When an invalid input record is found, PIP reports an error
message at the console and waits for corrective action.
It is usually
sufficient to open the reader and rerun a section of the tape (pull the tape
back about 20 inches). When the tape is ready for the re-read, type a single
carriage return at the console, and PIP will attempt another read.
If the
tape lX'sition cannot be properly read, simply continue the read (by typing a
return followin:J the error message), and enter the record manually wi th the ED
program after the disk file is constructed. For convenience, PIP allows the
end-of-file to be entered fran the console if the source file is a RDR:
device.
In this case, the PIP program reads the device and rronitors the
keyboard.
If ctl-Z is typed at the keyboard, then the read operation is
terminated normally.
Valid PIP commands are shown below.
PIP 1ST: = X.PRN

Copy X.PRN to the 1ST device and
terminate the PIP program.

cr

PIP cr
*CDN:=X.ASM,Y.ASM,Z.ASM

Start PIP for a sequence of
commands (PIP prompts with "*").
Concatenate three ASMfiles and
copy to the CON device.

cr

*X.HEX=CON:,Y.HEX,PTR: cr

Create a HEX file by readinq the
CDN (until a ctl-Z is typed), followed by data fran Y.HEX, followed
by data from PTR until a ctl-Z is
encountered.

*cr

Single carriage return stops PIP.

22

Send 4~ nulls to the punch device:
then copy the X.ASM file to the
punch, followed by an end-of-file
(ctl-Z) and 4~ more null characters.

PIP PUN:=NUL:,X.ASM,EOF:,NUL: cr

The user can also specify one or trore PIP parameters, enclo!:!ed in left
and right square brackets, separated by zero or IlPre blanks. Each parameter
affects the copy operation, and the enclosed list of parameters must
immediately follow the affected file or device. Generally, each parameter can
be followed by an q:>tional decimal integer value (the Sand 0 parameters are
exceptions). The valid PIP parameters are listed below.
B

Block mode transfer: data is buffered by PIP until an ASCII
x-off character (ctl-S) is received from the source device.
This allows transfer of data to a disk file from a continuous
reading device, such as a cassette reader. Upon receipt of
the x-off, PIP clears the disk buffers and returns for trore
input data. The amount of data which can be buffered is dependent upon the memory size of the host systew (PIP will
issue an error message if the buffers overflow).

On

Delete characters which extend past column n in the transfer
of data to the destination from the character source. This
parameter is used IlPst often to truncate long lines which are
sent to a (narrow) printer or console device.

E

Echo all transfer operations to the console as they are being
performed.

F

Fi! ter form feeds from the file. All imbedded form feeds are
removed. The P parameter can be used simultaneously to
insert new form feeds.

H

Hex data transfer: all data is checked for proper Intel hex
file format. Non-essential characters between hex records
are removed during the copy operation. The console will be
prompted for corrective action in case errors occur.

I

Ignore 1t:~~1t records in the transfer of Intel hex format
file (the I parameter automatically sets the H parameter).

L

Translate upper case alphabetics to lower case.

N

Add line numbers to each line transferred to the destination
starting at one, and incrementing by 1. Leading zeroes are
suppressed, and the number is followed by a colon. If N2
is specified, then leading zeroes are included, and a tab is
inserted followirg the number. The tab is expanded if T is

23

set.

o

Object file (non-ASCII) transfer:
file is ignored ..

Pn

Include page ejects at every n lines (with an initial page
eject). If n = 1 or is excluded altogether, page ejects
occur every 60 lines. If the F parameter is used, form feed
suppression takes place before the new page ejects are
inserted.

Qstz

Quit copying from the source device or file when the
string s (terminated by ctl-Z) is encountered.

Sstz

Start copying from the source device when the string s is
encountered (terminated by ctl-Z). The Sand Q parameters
can be used to "abstract" a particular section of a file
(such as a subroutine). The start and quit strings are always included in the copy operation.

the normal CP/M end of

NOTE - the strings following the s and q parameters are
translated to upper case by the CCP if form (2) of the
PIP canmand is used. Form (1) of the PIP invocation, however, does not perform the automatic upper case translation.
(1) PIP cr
(2) PIP "command line" cr
Tn

Expand tabs (ctl-I characters) to every nth column during the
transfer of characters to the destination from the source.

U

Translate lower case alphabetics to upper case during the
the copy operation.

V

verify that data has been copied correctly by rereading
after the write operation (the destination must be a disk
file) •

Z

Zero the parity bit on input for each ASCII character.

The following are valid PIP commands which specify parameters in the file
transfer:
PIP X.ASM=B: [v] cr

Copy X.ASM from drive B to the current drive
and verify that the data was properly copied.

PIP LPT:=X.ASM[ntSu] cr

Copy X.ASM to the LPT: device; number each
line, expand tabs to every eighth column, and
translate lower case alphabetics to upper
case.

24

PIP PUN:=X.HEX[i] ,Y.ZOT[h] cr
First copy X.HEX to the PUN: device and
ignore the trailing ":00" record in X.HEX:
then continue the transfer of data by reading
Y.ZOT, which contains hex records, including
any ":00" records which it contains.
PIP X.Lm = Y.ASM [ sSUBRl:t z qJMP L31'z ] cr
Copy from the file Y.ASM
into the file X.LIB. Start the copy when the
string "SUBRl:" has been found, and quit copyin:} after the string "JMP L3" is encountered.
PIP PRN:=X.ASM[p50]

6.5.

Send X.ASM to the 1ST: device, with line numbers, tabs expanded to every eighth column,
and page ejects at every 50th line. Note that
nt8p60 is the assumed parameter list for a PRN
file: p50 overrides the default value.

ED ufn cr

The ED program is the CP/M system context editor, ¥.bich allows creation
and alteration of ASCII files in the CP/M environment. Complete details of
operation are given the ED user's manual, "ED: a Context Editor for the CP/M
Disk System."
In general, ED allows the operator to create and operate up:m
source files \\hich are organized as a sequence of ASCII characters, separated
by end-of-line characters (a carriage-return line-feed sequence). There is no
practical restriction on line length (no single line can exceed the size of
the worki~ memory), \\hich is instead defined by the number of characters
typed between cr's.
The ED program has a number of commands for character
string searching, replacement, and insertion, ¥.bich are useful in the creation
and correction of programs or text files Lmder CP/M. Although the CP/M has a
limited memory work space area (approximately 5000 characters in a 16K CP/M
system), the file size ¥.bich can be edited is not limited, since data is
easily "paged" through this work area.
Upon initiation, ED creates the s:p=cified source file, if it does not
exist, and opens the file for access. The programmer then "appends" data from
the oource file into the work area, if the source file already exists (see the
A canrnand), for editing. The appended data can then be displayed, altered,
and written from the work area back to the disk (see the W command).
Particular p:>ints in the program can be automatically paged and located by
context (see the N command), allowin:} easy access to particular }X)rtions of a
large file.
Given that the operator has typed
ED X.ASM cr

25

the ED program creates an intermediate work file with the name
X.$$$
to hold the edited data during the ED run. Upon canpletion of ED, the X.ASM
file (original file) is renamed to X.BAK, and the edited work file is renamed
to X.ASM. Thus, the X.BAR file contains the original (unedited) file, and the
X.ASM file contains the newly edited file. The operator can always return to
the previous version of a file by ranoving the fOC)st recent version, and
renamim the .,;revious version.
Suppose, for example, that the current X.ASM
file was improperly edited: the sequence of CCPI camnand shown below would
reclaim the backup file.
DIR X.*

Check to see that BAR file
is available.

ERA X.ASM

Erase fOC)st recent version.

REN X.ASM=X. BAK

Rename the BAK file to ASM.

Note that the operator can abort the edit at any };X)int (reboot, };X)wer failure,
ctl-C, or Q canmand) without destroying the original file. In this case, the
BAR file is not created, and the original file is always intact.
The ED program also allows the user to "ping-pong" the oource and create
backup files between two disks. The form of the ED canmand in this case is
ED ufn d:
where ufn is the nane of a file to edit on the currently logged disk, and d is
the nane of an alternate drive. The ED program reads and processes the oource
file, and writes the new file to drive d, using the name ufn. Upon canpletion
of processing, the original file becomes the backup file.
Thus, if the
operator is addressing disk A, the following canmand is valid:
ED X.ASM B:
which edits the file X.ASM on drive A, creating the new file X.$$$ on drive
B. Upon canpletion of a successful edit, A:X.ASM is renamed to A:X.BAK, and
B: X. $$$ is renamed to B: X.ABM.
For user convenience, the cur rentl y logged
disk becanes drive B at the end of the edit. Note that if a file by the name
B:X.ASM. exists before the editing begins, the message
FILE EXISTS
is printed at the console as a precaution aqainst accidently destroying a
source file. In this case, the operator must first ERAse the existing file
and then restart the edit operation.

26

Similar to other transient canmands, editing can take place on a drive
different fran the OJrrently l03ged disk by preceding the rource file name by
a drive mme. Examples of valid edit requests are soown below
ED A:X.ASM

Edit the file X.ASM on drive A, with
new file and backup on drive A.

ED B:X.ASM A:

Edit the file X.ASM on drive B to the
temporary file X.$$$ on drive A. On
termination of editing, change X.ASM
on drive B to X.SAK, and chanqe X.$$S
on drive A to X.ASM.

6.6. SYSGEN cr
The SYSGEN transient command allows generation of an initialized diskette
containing the CP/M operating system. The SYSGEN program prompts the console
for commands, with interaction as shoWn below.
SYSGEN cr

Initiate the SYSGEN program.

SYSGEN VERSION m.m

SYSGEN

sign~on

message.

SOURCE IlUVE NAME (OR RETURN TO SKIP)
Respond with the drive name (one
of the letters A, B, C, or D) of
the disk containing a CP/M system: usually A. If a copy of
CP/M already exists in memory,
due to a MOVCPM command, type a
cr only. Typing a drive name
x will cause the response:
SOURCE ON x THEN TYPE REI'URN

Place a diskette containing the
CP/M operating system on drive
x (x is one of A, B, C, or D).
Answer with cr when rea9Y.

FUNCTION OOMPLETE

System is copied to memory.
SYSGEN will then prompt with:

DESTINATION mIVE NAME (OR RETURN TO REBOOI')
If a diskette is being initialized, place the new disk
into a drive and answer with
the drive name. Otherwise, type
a cr and the system will reboot
from drive A. Typing drive name
x will cause SYSGEN to pr ompt

27

with:
DESTINATION ON x THEN TYPE RETURN Place new diskette into drive
x: type return when ready.
New diskette is initialized
in drive x.

FUNCTION CDMPLETE

The "DESTINATION" pranpt will be repeated tntil a single carriage return is
typed at the console, so that more than one disk can be initialized.
Upon canpletion of a successful system generation, the new diskette
contains the operating system, and only the built-in canmands are available.
A factory-fresh IBM-compatible diskette appears to CP/M as a diskette with an
empty directory: therefore, the operator must copy the appropriate OOM files
fran an existing CP/M diskette to the newly constructed diskette using the PIP
transient.
The user can copy all files fran an existing diskette by typing the PIP
canmand
PIP B:

= A:

*.*[vJ cr

which copies all files fran disk drive A to disk drive B, and verifies that
each file has been copied correctly. The name of each file is displayed at
the console as the copy operation proceeds.
It should be noted that a SYSGEN does not destroy the files which already
exist on a diskette: it results only in construction of a new operating
system. Further, if a diskette is being used only on drives B through D, and
will never be the source of a bootstrap operation on drive A, the SYSGEN need
not take place. In fact, a new diskette needs absolutely no initialization to
be used with CP/M.
.

6.7. SUBMIT ufu parm#! ••• parm#n cr
The 9.JBMIT canmand allows CP/M canmands to be batched toqether for
autanatic trocessing.
The ufn given in the SUBMIT cormnand must be the
filename of a file which exists on the currently logged disk, with an assumed
file type of "SUB.
The SUB file contains CP/M prototype canmands, with
possible parameter stDstitution. The actual. parameters parm#! ••• parm#n are
substituted into the lX'ototype canmands, and, if no errors occur, the file of
substituted commands are processed sequentially by CP/M.
II

28

The prototype canrnand file is created
interspersed "$" parameters of the form
$1

$2

$3

•••

using

the

ED program,

with

$n

correspondin;J to the number of actual parameters which will be included when
the file is smmi tted for execution. When the SUBMIT transient is executed,
the actual parameters parmU ••• parm#n are paired with the formal parameters
$1 ••• $n in the prototype canrnands.
If the number of formal and actual
parameters does not correspond, then the submit ftmction is aborted with an
error message at the console.
The SUBMIT ftmction creates a file of
substituted commands with the name
$$$.SUB
on the logged disk.
When the system reboots (at the termination of the
SUBMIT), this canmand file is read by the CCP as a oource of input, rather
than the console. If the SUBMIT function is ~rformed on any disk other than
drive A, the commands are not processed until the disk is inserted into drive
A and the system reboots. Further, the user can abort canmand processing at
any time by typirg a rubout when the camnand is read and echoed.
In this
case, the $$$.SUB file is removed, and the subsequent canrnands come from the
console. Command processing is also aborted if the CCP detects an error in
any of the commands. Programs which execute tmder CP/M can abort ~ocessing of
canrnand files when error conditions occur by simply erasing any existing
$$$.SUB file.
In order to introduce dollar signs into a SUBMIT file, the user may type
a "$$" which reduces to a single "$" wi thin the command file.
Further, an
up-arrow symbol "f" may precede an alphabetic character x, which produces a
single ctl-x character within the file.
The last command in a SUB file can initiate another SUB file,
allowing chained batch canrnands.
Su~se

thus

the file ASMBL.SUB exists on disk and contains the prototype

commands
A~

$1

DIR $1.*
ERA *.BAK
PIP $2:=$1.PRN
ERA $l.PRN
and the command
SUBMIT ASMBL X PRN cr
is issued by the operator.
The SUBMIT program reads the ASMBL.SUB file,
smstituting "X" for all occurrences of $1 and "PRN" for all occurrences of
$2, resulting in a $$$.SUB file containing the commands

29

•

A~

X

DIR
ERA
PIP
ERA

X.*
*.BAK
PRN:=X.PRN
X.PRN

which are executed in sequence by the CCP.
The SUBMIT function can access a SUB file \\hich is on an alternate drive
by trecedi~ the file name by a drive name. Sutmitted files are only acted
u!X)n, however, when they appear on drive A. Thus, it is !X)ssible to create a
submitted file on drive B \\hich is executed at a later time \\hen it is
inserted in drive A.
6.8. DUMP ufn cr

The DUMP program types the contents of the disk file (ufn) at the console
in hexadecimal form. The file contents are listed sixteen bytes at a time,
with the absolute byte address listed to the left of each line in
hexadecimal. Lorg typeouts can be aborted by pushing the rubout key dur ing
printout.
(The rource listing of the DUMP program is ~given in the "CP/M
Interface Guide" as an example of a program written for the CP/M environment.)

6.9. MJVCPM cr
The M)VCPM p:-ogram allows the user to reconfigure the CP/M system for any
particular rremory size.
Two optional parameters may be used to indicate (1)
the desired size of the new system and (2) the dist;X>sition of the new system
at p:-ogram termination. If the first parameter is anitted or a u*" is given,
the M)VCPM program will reconfigure the system to its maximum size, based u~n
the kilobytes of contiguous RAM in the host system (starting aat 0000H).
If
the second parameter is ani tted, the system is executed, but not permanently
recorded: if "*,, is given, the system is left in memory, ready for a SYSGEN
operation.
The M)VCPM program relocates a memory image of CP/M and places
this image in memory in preparation for a system generation operation.
The
canrnand forms are:
MOVCPM

cr

Relocate and execute CP/M for management of the current memory configuration (memory is examined for contiguous RAM, starting at l00H). Upon completion of the relocation, the new '
system is executed but not permanently
recordeq on the diskette. The system
which is constructed contains a BIOS
for the Intel MDS 800.

30

MOVCPM n cr

KlVCPM

Create a relocated CP/M system for
management of an n kilobyte system (n
must be in the range 16 to 64), and
execute the system, as described above.

**

cr

Construct a relocated memory image for
the current memory configuration, but
leave the memory image in memory, in
preparation for a SYSGEN operation.

*

cr

Construct a relocated memory image for
an n kilobyte memory system, and leave
the memory image in preparation for a
SYSGEN operation.

MOVCPM n

The canrnand
MOVCPM

* *

for example, constructs a new version of the CP/M system and leaves it in
memory, ready for a SYSGEN operation. The message
READY FOR "SYSGEN" OR
"SAVE 32 CPMxx.cDM"
is J;rinted at the console up:m completion, where xx is the current memory size
in kilobytes. The operator can then type
SYSGEN cr

Start the system generation.

SOURCE DRIVE NAME (OR RETURN TO SKIP)
Respond with a cr to skip
the CP/M read operation since the system
is already in memory as a result of the
previous MOVCPM operation.
DESTINATION [RIVE NAME (OR RETURN T0 REBOOI')
Respond with B to write new system
to the diskette in drive B. SYSGEN
will prompt wi th:
DESTINATION ON B, THEN TYPE RETURN
Ready the fresh diskette on drive
B and type a return when ready.
Note that if you respond with "A" rather than "B" above, the system will be
written to drive A rather than B. SYSGEN will continue to ~ the prompt:
DESTINATION [RIVE NAME (OR RETURN TO

REBOOr)

Lmtil the operator responds with a single carriage return, which stops the

31

SYSGEN program with a system reboot.
The user can then go through the reboot process with the old or new
diskette.
Instead of performinq the SYSGEN operation, the user could have
typed
SAVE 32 CPMxx.ffiM
at the canpletion of the M)VCPM function, ltilich would place the CP/M memory
image on the currently logged disk in a form which can be "ra tched." This is
necessary when operating in a non-standard environment ltilere the BIOS must be
altered for a particular peripheral device configuration, as described in
the"CP/M System Alteration Guide."
Valid MOVCPM commands are given below:
Construct a 48K verskon of CP/M and start
execution.

MOVCPM 48 cr
MOVCPM 48

*

cr

Construct a 48K version of CP/M in preparation for permanent recording; response is
READY FOR "SYSGEN" OR
"SAVE 32CPM48.ffiM"

MOVCPM

* *

cr

Construct a maximum memory version of CP/M
and start execution.

It is imrnrtant to note that the newly created system is serialized with
the number attached to the or ig inal di skette and is subject to the condi tions
of the Digital Research Software Licensing Agreement.

32

.(

7.

BDOS ERROR MESSAGES.

There are three error situations which the Basic Disk Operating System
intercepts dur ill3 file lXocesssill3. When one of these conditions is detected,
the BOOS prints the message:
BOOS ERR ON x: error
where x is the drive name, and "error" is one of the three error messages:
BAD SECl'OR
SELECI'

READ ONLY
The "BAD SECl'OR" message indicates that the disk controller electronics
has detected an error condition in readill3 or writing the diskette.
This
condition is generally due to a malfunctioning disk controller, or an
extremely worn diskette. If you find that your system reports this error more
than once a month, you should check the state of your controller electronics,
and the condition of your media.
You may also encounter this condition in
readill3 files generated by a controller produced by a different manufacturer.
Even ttnugh controllers are claimed to be IBM-canpatible, one often finds
small di fferences in recording formats. The MIl3-800 controller, for example,
requires two bytes of one's followill3 the data CRC byte, which is not required
in the IBM format. As a result, diskettes generated by the Intel MOO can be
read by almost all other IBM-canpatible systems, while disk files generated on
other manufacturer's equipment will produce the "BAD SECl'OR" message when read
by the MIl3.
In any case, recovery fran this condition is accomplished by
typill3 a ctl-C to reboot (this is the safest!), or a return, which simply
ignores the bad sector in the file operation.
Note, however, that typing a
return rey destroy your diskette integrity if the operation is a directory
write, so make sure you have adequate backups in this case.
The "SELEcr" error occurs when there is an attempt to address a drive
beyond the A through D r all3e.
In this case, the value of x in the error
message gives the selected drive. The system reboots following any input from
the console.
The "READ ONLY" message occurs men there is an attempt to write to a
diskette which has been designated as read-only in a STAT canmand, or has been
set to read-only by the BOOS. _In general, the operator should reboot CP/M
either by usill3 the v.e.rm start procedure (ctl-C) or by performing a cold start
whenever the diskettes are changed. If a changed diskette is to be read but
not wr itten, BOOS allows the diskette to be changed without the warm or cold
start, but internally marks the drive as read-only. The status of the drive
is subsequently charged to read/write if a v.e.rm or cold start occurs.
Upon
issuill3 this message, CP/M waits for input fran the console.
An automatic
warm start takes place following any input.

33

•

8.

OPERATION OF CP/M ON THE MrS.

This section gives cperating procedures for using CP/M on the Intel MIS
microcomputer development system.
A basic knowledge of the MIS hardware and
software systems is assumed.
CP/M is initiated in essentially the same manner as Intel's ISIS
operating system.
The disk drives are labelled 0 through 3 on the MrS,
corresp:mdi~ to CP/M drives A through D, respectively.
The CP/M system
diskette is inserted into drive 0, and the roar and RESE"I' switches are
depressed in sequence. The interrupt 2 light should go on at this pJint. The
space bar is then depressed on the device v.bich is to be taken as the system
console, and the light srould go out (if it does not, then check connections
and baud rates).
The roar switch is then turned off, and the CP/M signon
message srould appear at the selected console device, followed by the lOA>"
system p:-anpt.
The user can then issue the various resident and transient
commands
The CP/M system can be restarted (warm start) at any time by pushing the
INT 0 switch on the front panel.
The built-in Intel ROM monitor can be
initiated by pushing the INT 7 switch (which generates a RST 7), except v.hen
operating under DDT, in v.hich case the DDT program gets control instead.
Diskettes can be renoved from the drives at any time, and the system can
be shut down during operation without affecting data integrity.
Note,
however, that the user must not remove a diskette and replace it with another
. wi thout rebooting the system (cold or warm start), unless the inserted
diskette is "read only."
Due to hardware hang-ups or malfunctions, CP/M may type the message
BDOS ERR ON x: BAD SECl'OR
where x is the drive v.bich has a permanent error. This error may occur v.hen
drive doors are cpened and closed- randomly, followed by disk operations, or
may be due to a diskette, drive, or controller failure.
The user can
optionally elect to ignore the error by typing a single return at the
console. The error may produce a bad data record, requiring re-initialization
of up to 128 bytes of data. The operator can reboot the CP/M system and try
the cperation again.
Termination of a CP/M session requires no special action, except that it
is necessary to renove the diskettes before turning the {:Ower off, to avoid
random transients v.hich often make their way to the drive electronics.
It srould be noted that factory-fresh IBM-compatible diskettes should be
used rather than diskettes v.bich have previously been used with any ISIS
version.
In particular, the ISIS "FORMAT" cperation produces non-standard
sector numbering throughout the diskette.
This non-standard numbering
seriously degrades the performance of CP/M, and will operate noticeably slower

34

than the distribution version. If it becomes necessary to reformat a diskette
(which smuld not be the case for standard diskettes). a program can be
written mder CP/M v.hich causes the MI:6 800 controller to reformat with
sequential sector numbering (1-26) on each track.
Note: "MIS 800" aoo "ISIS" are registered trademarks of Intel Corporation •

•

I
OPERATION OF
THE CP/M CONTEXT EDITOR

01

[)~(j~Tf1l RE~Ef1Rr:H

Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896

ED: A CONTEXT EDITOR FOR THE CP/M DISK SYSTEM
USER'S MANUAL

COPYRIGHT (c) 1976, 1978
DIGITAL RESEARCH

Copyright (c) 1976, 1978 by Digital Research. All rights
reserved. No part of this publication may be reproduced,
transmitted, transcribed, stored in a retrieval system, or
translated into any lm;tguage or computer language, in any
form or by any means, 'electronic, mechanical, magnetic,
optical,' chemical, manual or otherwise,without the prior
written permission of Digital Research, Post Office Box 579,
Pacific Grove, California 93950.
Disclaimer
Digital Research makes no representations or warranties with
respect to the contents hereof and specifically disclaims any
implied warranties of merchantability or fitness for any
particular purpose. Further, Digital Research reserves the
right to revise this publication and to make changes from
time to time -in the content hereof without obligation of
Digital Research to .notify .any person of such revision or
changes.

Table of Contents

1.

ED TUTORIAL

. ... ..

.

···
····

1

1.1

Introduction to ED

1.2

ED Operation

1.3

Text Transfer Functions

1

1.4

Memory Buffer

5

1.5

Memory Buffer

1.6

Command Strings

7

1.7

Text Search and Alteration

8

1.8

Source Libraries .

·

1.9

Repetitive Command Execution • .

· . 12

. ..

1

. .· .

· ···
Organization
·
Operation
· ·· · . . · .

1

5

. 11

2.

ED ERROR CONDITIONS . .

3.

CONTROL CHARACTERS AND COMMANDS • • . • • • . 14

· . . . . . .13

ii

ED USER'S MANUAL

1.

ED TUTORIAL
1.1.

Introduction to ED.

ED is the context editor for CP/M, and is used to create
and alter CP/M source files.
ED is initiated in CP/M by
typing
{
ED



}

. 

In general, ED reads segments of the source file given.by
 or  into central memory,
where the file is manipulated by the operator, and subsequently written back to disk after alterations.
If the
source file does not exist before editing, it is created by
ED and initialized to empty. The overall operation of ED
is shown in Figure 1.
1.2.

ED Operation

ED operates upon the source file, denoted in Figure 1
by x.y, and passes all text through a memory buffer where
the text can be viewed or altered (the number of lines which
can be maintained in the memory buffer varies with the line
length, but has a total capacity of about 6000 characters
in a 16K CP/M system). Text material which has been edited
is written onto a temporary work file under command of the
operator.
Upon termination of the edit, the memory buffer
is written to the temporary file, followed by any remaining
(unread) text in the source file.
The name of the original
file is changed from x.y to x.BAK so that the most recent
previously edited source file can be reclaimed if necessary
(see the CP/M commands ERASE and RENAME). The temporary
file is then changed from x.$$$ to x.y which becomes the
reSUlting edited file.
The memory buffer is logically between the source file
and working file as shown in Figure 2.
1.3.

Text Transfer Functions

Given that n is an integer value in the range o through
65535, the following ED commands transfer lines of text
from the source file through the memory buffer to the temporary (and eventually final) file:

Figure 1.

Overall ED Operation

Source
Libraries

Source
File

Append

(R)

Write
(W)

(A)

Temporary
File

Memory Buffer

After
Edit

After
Edit

(E)

(E)

Type

Insert
(I)

(T)

Backup

New

File

Source
File

x.y

x.BAK

Note: the ED program accepts both lower and upper case ASCII
characters as input from the console. Single letter commands
can be typed in either case. The U command can be issued to
cause ED to translate lower case alphabetics to upper case as
characters are filled to the memory buffer from the console.
Characters are echoed as typed without translation, however.
The -u command causes ED to revert to "no translation" mode.
ED starts with an assumed-U in effect.

2

Figure 2.

Memory Buffer

Source File
1
2

3

.'

Hemory Buffer Organization

.,

Temporary File

1 .' First Line"

1

'\ F:irst Line"

-,,'Appended,"
. , , ,-

2 ~Buffered

~

2

"Text ",,"-

-7-."~'" -

' " -,-,'"

3

\ Processed' ,"
-"
'\"Text
'"
'-'\
-

F~rst

L~ne

"Lines"

,

~

,,2-

""-,-

Memory

TP

... -, '\""

Memo ry Buffer

---------
--------

current
line CL

------~------

last
line

--------

3

,

\ -'

Space
_______I

Logical Organization of Memory Buffer

first
line

\

Free File

Next
Write
L

Figure 3.

\

..

nA * -

append the next n unprocessed source
lines from the source file at SP to
the end of the memory buffer at MP.
Increment SP and MP by n.

nW

write the
buffer to
Shift the
MP to the
Increment

first n lines of the memory
the temporary file free space.
remaining lines n+l through
top of the memory buffer.
TP by n.

E

end the edit.
Copy all buffered text
to temporary file, and copy all unprocessed source lines to the temporary
file.
Rename files as described
previously.

H

move to head of new file by performing
automatic E command. Temporary file
becomes the new source file, the memory
buffer is emptied, and a new temporary
file is created (equivalent to issuing
an E command, followed by a reinvocation
of ED using x.y as the file to edit).

O

return to original file.
The memory
buffer is emptied, the temporary file
id deleted, and the SP is returned to
position I of the source file. The
effects of the previous editing commands
are thus nullified.

Q

quit edit with no file alterations,
return to CP/M.--

There are a number of special cases to consider.
If the
integer n is omitted in any ED command where an integer is
allowed, then I is assumed. Thus, the commands A and Wappend
one line and write I line, respectively.
In addition, if a
pound sign (#) is given in the place of n, then the integer
65535 is assumed (the largest value for n which is allowed).
Since most reasonably sized source files can be contained
entirely in the memory buffer, the command #A is often issued
at the beginning of the edit to read the entire source file
to memory.
Similarly, the command #Wwrites the entire buffer
to the temporary file. Two special forms of the A and W

* represents the carriage-return key
4

commands are provided as a convenience. The command OA fills
the current memory buffer to at least half-full, while OW
writes lines until the buffer is at least half empty.
It
should also be noted that an error is issued if the memory
buffer size is exceded. The operator may then enter any
command (such as W) which does not increase memory requirements.
The remainder of any partial line read during the
overflow will be brought into memory on the next successful
append.
1.4.

Memory Buffer Organization

The memory buffer can be considered a sequence of source
lines brought in with the A command from a source file.
The
memory buffer has an associated (imaginary) character pointer
CP which moves throughout the memory buffer under command of
the operator.
The memory buffer appears logically as shown
in Figure 3 where the dashes represent characters of the
source line of indefinite length, terminated by carr~e­
return «cr» and line-feed «If» characters, and cp
represents the imaginary character pointer.
Note that the
CP is always located ahead of the first character of the
first line, behind the last character of the last line, or
between two characters. The current line CL is the source
line which contains the CPo
1.5.

Memory Buffer Operation

Upon initiation of ED, the memory buffer is empty (ie,
CP is both ahead and behind the first and last character).
The operator may either append lines (A command) from the
source file, or enter the lines directly from the console
with the insert command
I
ED then accepts any number of input
terminates with a  (the  is
until a control-z (denoted by tz is
The CP is positioned after the last
sequence

lines, where each line
supplied automatically),
typed by the operator.
character entered. The

I
NOW IS THE
TIME FOR
ALL GOOD MEN
tz
leaves the memory buffer as shown below

5

NOW IS THE
TIME FOR
ALL GOOD MEN -

move CP to beginning of memory buffer
if +, and to bottom if -.

±nC -

move CP by ±n characters (toward front
of buffer if +), counting the 
as two distinct characters

±nD -

delete n characters ahead of CP if plus
and behind CP if minus.

±nK -

kill (ie remove) ±n lines of source text
using CP as the current reference.
If
CP is not at the begi~ning of the current
line when K is issuec, then the characters before CP remain if + is specified,
while the characters after CP remain if is given in the command.

±nL -

if n=O then move CP to the beginning .of
the current line (if it is not already
there) if nFO then first move the CP to
the beginning of the current line, and
then move it to the beginning of the
line which is n lines down (if +) or up
(if -). The CP will stop at the top or
bottom of the memory buffer if too large
a value of n is specified.

6

±nT - If n=O then type the contents of the
current line up to CPo
If n=l then
type the contents of the current line
from CP to the end of the line.
If
n>l then type the current line along
with n-l lines which follow, if +
is specified. Similarly, if n>l and
- is given, type the previous n lines,
up to the CPo The break key can be
depressed to abort long type-outs.
±n - equivalent to ±nLT, which moves up or
down and types a single line
1.6.

Command Strings

Any number of commands can be typed contiguously (up to
the capacity of the CP/M console buffer), and are executed
only after the  is typed. Thus, the operator may use
the CP/M console command functions to manipulate the input
command:
Rubout

remove the last character

Control-U

delete the entire line

Control-C

re-initialize the CP/M System

Control-E

return carriage for long lines
without transmitting buffer
(max 128 chars)

Suppose the memory buffer contains the characters shown
in the previous section, with the CP following the last
character of the buffer.
The command strings shown below
produce the results shown to the right
Command String

Effect

B2T

move to beginning
of buffer and type
2 lines:
"NOW IS THE
TIME FOR"

1.

2.

5COT

move CP 5 characters and type the
beginning of the
line
"NOW I"

7

Resulting Memory Buffer
L~NOW

l3?J TIME

IS THE
FOR

ALL GOOD MEN

NOW

I~~

~

S THE

•

3.

2L-T

NOW IS THE
move two lines down
and type previous
TIME FOR
line
"TIME FOR"
~ALL GOOD MEN

l5:J
4.

-L#K

move up one line,
delte 65535 lines
which follow

NOW IS THE

5.

I
TIME TO
INSERT
tz

insert two lines
of text

NOW IS THE

-2L#T

move up two lines,
and type 65535
lines ahead of CP
"NOW IS THE"

NOW IS THE

move down one line
and type one line
" INSERT"

NOW IS THE

6.

7.



C.2:J

TIME TO
INSERT ~
~

TIME TO

~

~

INSERT

TIME TO
INSERT

1.7.

~

~~

~

Text Search and Alteration

ED also has a command which locates strings within the
memory buffer. The command takes the form

where cl through ck represent the characters to match followed
by either a  or control -z*. ED starts at the current
position of CP and attempts to match all k characters. The
match is attempted n times, and if successful, the CP is
moved directly after the character ck.
If the n matches are
not successful, the CP is not moved from its initial position.
Search strings can include-rr (control-l), which is replaced
by the pair of symbols .

*The control-z is used if additional commands will be typed
following the tz.
8

The following commands illustrate the use of the F
command:
Command String
1.

B#T

Effect
move to beginning
and :type entire
buffer

Resulting Memory Buffer

.-6 NOW IS THE
~

TIME FOR
ALL GOOD MEN

2.

FS T

find the end of
the string ItS T"

NOW IS T@1 HE

3.

FltzOTT

find the next "I"
and type to the
CP then type the
remainder of the
current line:
"TIME FOR"

NOW IS THE
TI ~ME
FOR
cp
ALL OOD MEN

An abbreviated form of the insert command is also allowed,
which is often used in conjunction with the F command to make
simple textual changes.
The form is:

c 
n

where cl through c n are characters to insert.
If the insertion string is terminated by a tz, the characters cl through
c n are inserted directly following the CP, and the CP is
moved directly after character c n " The action is the same
if the command is followed by a  except that a 
is automatically inserted into the text following character
cn.
Consider the following command sequences as examples
of the F and I commands:
Command String
BITHIS· IS tz

Resulting Memory Buffer

Effect
Insert "THIS IS "
at the beginning
of the text

THIS

IS~OW

THE 

~
TIME FOR
ALL GOOD MEN

9

FTIMEtz-4DIPLACEtz

THIS IS NOW THE
PLACE ~ FOR
ALL GOOD MEN

find "TIME" and delete
it; then insert "PLACE"
3FOtz-3D5DICHANGESt

THIS IS NOW THE 
PLACE FOR

find third occurrence
of "0" (ie the second
"0" in GOOD), delete
previous 3 characters;
then insert "CHANGES"
-8CISOURCE

ALL

move back 8 characters
and insert the line
"SOURCE"

CHANGES~

~

THIS IS NOW THE
PLACE FOR
ALL SOURCE
~CHANGES

I.5:J

ED also provides a single command which combines .the F ·and
I commands to perform simple string substitutions. The command
takes the form

and has exactly the same effect as applying the command string

a total of n times. That is, ED searches the memory buffer
starting at the ~urrent position of CP and successively substitutes the second string for the first string until the
end of buffer, or until the substitution has been performed
n times.
As a convenience, a command similar to F is provided by
ED which automatically appends and writes lines as the search
proceeds. The form is

n N c l c 2 •.• c k { ctrz }
which searches the entire source file for the nth occurrence
of the string clc2 •.. ck (recall that OF fails if the string
cannot be found in the current buffer). The operation of the

10

~~

command is precisely the same as F except in the case that
the string cannot be found within the current memory buffer.
In this case, the entire memory contents is written (ie, an
automatic #W is issued).
Input lines are then read until
the buffer is at least half full, or the entire source file
is exhausted. The search continues in this manner until the
string has been found n times, or until the source file has
been completely transferred to the temporary file.
A final line editing function, called the juxtaposition
command takes the form

with the following action applied n times to the memory buffer:
search from the current CP for the next occurrence of the
string clc2 ... ck'
If found, insert the string d k d 2 ... ,dm,
and move CP to follow dm . Then delete all characters following
CP up to (but not including) the string el,e2, ... e q , leaving
CP directly after dm.
If el,e2, ... e q cannot be fOUnd, then
no deletion is made.
If the current line is
~

t:E.J

NOW IS THE TH1E

Then the cormnand
JW tzWHATtztl
Results in
NOW WHAT ~ 

l.91:l

(Recall that tl represents the pair  in search and
SUbstitute strings).
It should be noted that the number of characters allowed
by ED in the F,S,N, and J commands is limited to 100 symbols.
1. 8.

Source Libraries

ED also allows the inclusion of source libraries during
the editing process with the R command. The form of this
command is

11

where flf2 •• fn is the name of a source file on the disk with
as assumed filetype of 'LIB'. ED reads the specified file,
and places the characters into the memory buffer after CP,
in a manner similar to the I command. Thus, if the command
RMACRO
is issued by the operator, ED reads from the file MACRO. LIB
until the end-of-file, and automatically inserts the characters into the memory buffer.
1.9.

Repetitive Command Execution

The macro command M allows the ED user to group ED commands together for repeated evaluation. The M command takes
the form:

where clc2 .•. ck represent a string of ED commands, not including another M command. ED executes the command string n
times if n>l.
If n=O or 1, the command string is executed
repetitively until an error condition is encountered (e.g.,
the end of the memory buffer is reached with an F command).
As an example, the following macro changes all occurrences of GAMMA to DELTA within the current buffer, and
types each line which is changed:
MFGAMMAtz-SDIDELTAtzOTT
or equivalently
MSGAMMAtzDELTAtzOTT

12

2.

ED ERROR CONDITIONS

On error conditions, ED prints the last character read
before the error, along with an error indicator:

?

unrecognized command

>

memory buffer full (use one of
the commands D,K,N,S, or W to
remove characters), F,N, or S
strings too long.

#

cannot apply command the number
of times specified (e.g., in
F command)

o

cannot open LIB file in R
command

Cyclic redundancy check (CRC) information is written with
each output record under CP/M in order to detect errors on
subsequent read operations. If a CRC error is detected, CP/M
will type
PERM ERR DISK d
where d is the currently selected drive (A,B, ..• ). The operator can choose to ignore the error by typing any character
at the console (in this case, the memory buffer data should
be examined to see if it was incorrectly read), or the user
can reset the system and reclaim the backup file, if it
exists. The file can be reclaimed by first typing the contents of the BAK file to ensure that it contains the proper
information:
TYPE x.BAK
where x is the file being edited.
file:

Then remove the primary

ERA x.y
and rename the BAK file:
REN x.y=x.BAK
The file can then be re-edited, starting with the previous
version.

13

•

3.

CONTROL CHARACTERS AND COMHANDS

The following table summarizes the control characters
and commands available in ED:
Control Character

Function

tc

system reboot

te

physical  (not
actually entered in
conunand)

ti

logical tab (cols 1,8,
15, ... )

tl

logical  in
search and substitute
strings

tu

line delete

tz

string terminator

rubout

character delete

break

discontinue command
(e~g., stop typing)

14

Function

Co nun and
nA

append lines

±B

begin bottom of buffer

±nC

move character positions

±nD

delete characters

E

nF

end edit and close files
(normal end)
find string

H

end edit, close and reopen
files

I

insert characters

nJ

place strings in juxtaposition

±nK

kill lines

±nL

move down/up lines

nM

macro definition

nN

find next occurrence with
autos can

o
±nP

return to original file
move and print pages

Q

quit with no file changes

R

read library file

nS

substitute strings

±nT

type lines

± U

translate lower to upper case if U,
no translation if -u

nW

write lines

nZ

sleep

±n

move and type

15

(±nLT)

•

Appendix A:

ED 1.4 Enhancements

The ED context editor contains a number of commands which enhance its
usefulness in text editing. The improvements are found in the addition of line numbers,
free space interrogation, and improved error reporting.
The context editor issued with CP/M 1.4 produces absolute line number prefixes
when the "V" (Verify Line Numbers) command is issued. Following the V command,
the line number is displayed ahead of each line in the format:
nnnnn:
where nnnnn is an absolute line number in the range 1 to 65535. If the memory buffer
is empty, or if the current line is at the end of the memory buffer, then nnnnn appears
as 5 blanks.
The user may reference an absolute line number by preceding any command by
a number followed by a colon, in the same format as the line number display. In this
case, the ED program moves the current line reference to the absolute line number,
if the line exists in the current memory buffer. Thus, the command
345:T
is interpreted as "move to absolute line 345, and type the line." Note that absolute
line numbers are produced only during the editing process, and are not recorded with
the file. In particular, the line numbers will change following a deleted or expanded
section of text.
The user may also reference an absolute line number as a backward or forward
distance from the current line by preceding the absolute line number by a colon. Thus,
the command
:400T
is interpreted as "type from the current line number through the line whose absolute
number is 400." Combining the two line reference forms, the command
345::4"'0T for example, is interpreted as "move to absolute line 345, then type through absolute
line 4~0." Note that absolute line references of this sort can precede any of the
standard ED commands.
A special case of the V command, "0V", prints the memory buffer statistics in
the form:
free/total
where "free" is the number of free bytes in the memory buffer (in decimaI), and "total"
is the size of the memory buffer.

I

ED 1.4 also includes a "block move" facility implemented through the "X" (X fer)
command. The form
nX

transfers the next n lines from the current line to a temporary file called
X$$$$$$$.LIB
which is active only during the editing process. In general, the user can reposition
the current line reference to any portion of the source file and transfer lines to the
temporary file. The transferred line accumulate one after another in this file, and
can be retrieved by simply typing:
R

which is the trivial case of the library read command. In this case, the entire
transferred set of lines is read into the memory buffer. Note that the X command
does not remove the transferred lines from the memory buffer, although a K command
can be used directly after the X, and the R command does not empty the· transferred
line file. That is, given that a set of lines has been transferred with the X command,
they can be re-read any number of times back into the source file. The command
r1X

is provided, however, to empty the transferred line file.
Note that upon normal completion of the ED program through Q or E, the
temporary LIB file is removed. If ED is aborted through ctl-C, the LIB file will exist
jf lines have been transferred, but will generally be empty (a subsequent ED invocation
will erase the temporary file).
Due to common typographical errors, ED 1.4 requires several potentially disasterous commands to be typed as single letters, rather than in composite commands.
The commands
E (end), H (head), 0 (originaI), Q (quit)
must be typed as single letter commands.
ED 1.4 also prints error messages in the form
BREAK "x" AT c

w here x is the error character, and c is the com mand where the error occurred.

CP/M 2.0 USER'S GUIDE
FOR CP/M 1.4 OWNERS

I

01

[)~[j~Tfll

RESEflRl:tf

Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896

CP/M 2.0 USER'S GUIDE
FOR CP/M 1.4 OWNERS

COPYRIGHT (c) 1979
DIGITAL RESEARCH

•

Copyright
Copyright (c) 1979 by Digital Research. All rights reserved.
No part of this publication may be reproduced, transmitted,
transcribed, stored in a retrieval system, or translated into
any language or computer language. in any form or by any
means, electronic, mechanical, magnetic, optical, chemicaJ,
manual or otherwise, without the prior written permission of
Digital Research, Post Office Box 579, Pacific Grove,
California 93950.
Disclaimer
Digital R.esearch makes no representations or warranties with
respect to the contents hereof and specifica]Jy disclaims any
implied warranties of merchantability or fitness for any particular purpose. Further, Digital Research reserves the right
to revise this publication and to make changes from time to
time in the content hereof without obligation of Digital
Research to notify any person of such revision or changes.
TrRdemarks
CP/M is a registered trademark of Digital Research.
MAC, and SID are trademarks of Digital Research.

MP/M,

CP/M 2.0 USER'S GUIDE FOR CP/M 1.4 OWNERS

COQyright (c) 1979
Digital Researcn, aox 579
Pacific Grove, California

1.

An Overview of CP/M 2.0 Facilities

2.

User Interface

3.

Console Command Processor (CC?)

4.

S~AT

5.

PIP Enhancements

6.

8D Enhancements

7•

The XSU8 Function

8.

3DOS Interface Conventions • • .

9.

CP/M 2.0 Memory Organization

Enhancements

10. 3IOS Differences • . • . . . •

.

.

.

.

.

.

. 1
3

Intertace

• • .
• • •

• 4

• • 5

. • . 10
. . . . 11
• • 12
• 27

• • 28

1.

AL~

OVERVIEw OF cp/r-1 2.0 FACILI'rIES.

CP/M 2.0 is a high-performance single-console operating system
which uses table driven techniques to allow field reconfiguration to
match a wide variety of disk capacities. All of the fundamental, file
restrictions are removed, while maintaining upward compatibility from
previous versions of release 1. Features of CP/M 2.0 include field
specification of one to sixteen logical drives,eacn containing up to
eight megabytes. Any particular file can reach the full drive size
with the capability to expand to thirty-two megabytes in future
releases. The directory size can be field configured to contain any
reasonable number of entries, and each file is optionally tagged with
read/only and system attributes. Users of CP/M 2.0 are physically
separated oy user numbers, with facilities for file copy operations
from one user area to another. Powerful relative-record random access
functions are present in CP/M 2.0 whlch provide direct access to any
of the 65536 records of an eight megabyte file.
All disk-dependent portions of CP/M 2.0 are placed into a
BIOS-resident "disk parameter block" which is either hand coded or
produced
automatically using the disk definition macro library
provided with CP/M 2.0. The end user need only specify the maximum
number of active disks, the starting and ending sector numbers, the
data allocation size, the maximum extent of the logical disk,
directory size information, and reserved track values. The macros use
this information 'to generate the appropriate tables and
table
references for use during CP/M 2.0 operation. Deblocking information
is also provided wnich aids in assembly or disassembly of sector sizes
wnich are multioles of tne fundamental 128 byte data unit, and the
system. alteration manual includes qeneral~purpose subroutines which
use the tnis deblocking information to taKe advantage of larger sector
sizes. Use of these subroutines, together with the table driven data
access algoritnms, make CP/M 2.0 truly a universal data management
system.
File expansion is achieved by providing, up to 512 logical file
extents, where eaCh logical extent contains 16K bytes of data. CP/M
2.0 is structured, however, so that as much as 128K bytes of data is
addressed by a single physical extent (corresponding to a single
directory
entry), tnus maintaining compatibility with previous
versions while taking full advantage of directory space.
Random access facilities are present in CP/M 2.0 which allow
immediate reference to any record of an eight megabyte file. Using
CP/t1's unique data organization, data blocks are only allocated when
actually required and movement to a record oosition requires little
search time. Sequential file access is upward-compatible from earlier
versions
to
the
full ,eight megaoytes, while random access
compatibility stops at 5l2K byte files. Due to CP/M 2.0's simpler and
faster random access, application programmers are encouraged to alter
their programs to take full advantage of the 2.0 facilities.
Several CP/M 2.0 modules and utilities have improvements which
correspond to the enhanced file system. STA'r and PIP both account for
file attributes ~nd user areas, while the CCP provides a "login~
(All Information Contained Herein is Proprietary to Digital Researcn.)
1

I

function to change from one user area to anotner.
'i'he CCP also
formats directory displays in a more convenient manner and accounts
for both CRT and hard-copy devices in its enhanced line editing
functions.
The sections below point out the inaividual differences between
CP/M 1.4 and CP/M 2.0~ with the understanding that the reader is
either familiar with CP/M 1.4, or has access to the 1.4 manuals.
Additional information dealing with CP/M 2.0 I/O system alteration is
presented in the Digital Research manual ~CP/M 2.0 Alteration Gtiide. d

(All Information Contained Berein is proprietary to Digital Research.)
2

2.

USER INTERFACE.

Console line processing takes CRT-type devices into account with
three new control characters, shown with an asterisk in the list below
(the
symbol
"ctl" below indicates that the control key is
simultaneously depressed) :
rub/del
ctl-C
ctl-E
ctl-H
ctl-J
ctl-M
ctl-R
ctl-a
ctl-X

removes and echoes last character
reboot when at beginning of line,
physical end of line
oackspace"one cnaracter position*
(line feed) terminates current input*
(carriage return) terminates input
retype current line after new line
remove current line after new line
backspace to beginning of current line*

In ?articular, note that ctl-H produces the proper backspace overwrite
function (ctl-H can be changed internally to another character, such
as delete, through a simple single byte change). Further, the line
editor keeps track ot the current prompt column position so that· the
operator can properly align data input following a ctl-U, ctl-R, or
ctl-X command.

(All Information Contained Herein is Proprietary to Digital Research.)
3

•

3.

CONSOLE

COMMAI.~D

PROCESSOR (CCP) IN'fERFACE.

There are four functional differences between CP/M 1.4 and CP/M
2.0 at the console command processor
(CCP)
level.
'fheCCP now
displays directory information across the screen
(four elements per
line), the USER command is present to allow maintenance oiseparate
files in the same directory, and the actions of the "ERA *.*" and
"SAVE" commands have changed.
'l'he altered
DIR
format
is
self-explanatory, while the USER command takes the for~:
USER n
where n is an integer value in the range 0 to 15.
Upon cold start,
the operator is automatically "logged" into user area number 0, which
is compatible with standard CP/M 1.4 directories.
The operator may
issue the USER command at any time to move to another logical area
within
the same directory.
Drives which are logged-in while
addressing one user number are automatically active when the operator
moves to another user numoer since a 'user number is simply a prefix
which accesses particular directory entries on the active disks.
The active user number is maintained until changed by a
subsequent USER command, or until a cold start operation when user 0
is again assumed.
Due to the fact that user numbers now tag individual directory
entries,
the ERA *.* command has a different effect.
In version 1.4,
this command can be used to erase a directory whicn has "garbage"
information, perhaps resulting from use of a disKette under another
operating system (heaven forbid!).
In 2.0, however,
the ERA ~.*
command affects only the current user number. Thus, it is necessary
to write a simple utility to erase a nonsense disk (the program simply
writes the hexadecimal pattern E5 throughout the disk).
The SAVE command in. version 1.4 allows only a single memory save
operation, with the potential of destroying the memory image due to
directory operations following extent boundary changes.
Version 2.0,
nowever~ does not perform directory
operations in user data areas
after disk writes, and thus the SAVE operation can be used any number
of times without altering the memory image.

(All Information Contained Herein is Proprietary to Digital Research.)
4

4. STAT ENHANCEMENTS.
The STAT program has a number of additional functions which
allow disk parameter display, user number display, and file indicator
manipulation. The command:
s'rA'r VAL:
produces a summary of the available status commands, resulting in
output:

the

Temp RIO Disk: d:=R/o
Set Indicator: d:filename.typ $R/O $R/w $SYS $DIR
Disk status
DSK: d:DSK:
User Status
USR:
Iobyte Assign:
(list of possible assignments)
~hicn gives an instant summary of the possible
command form:
STAT d:filename.typ ~S

STAT

commands.

The

wnere "d:" is an optional dr ive name, and "filename.typ" is an
unambiguous or ambiguous file name, produces the output display
format:
Size Recs 3ytes Ext Acc
48
48
6k
1 Rio A:ED.COM
55
55
12k
1 RIO (A : f' I P • CO£'1)
65536
128
2k
2 R/W A:X.DA'l'
where tne $S parameter causes the "Size" field to be displayed
(without the $S, the Size field is skipped, but the remaining fields
are displayed). 'rhe Size field lists the virtual file size in
records, while the "Recs" field sums the number of virtual records in
each extent. For files constructed sequentially, the Size and Recs
fields are identical.
'rhe "Bytes" field lists the actual nUr.lber of
bytes allocated to the corresponding file.
The minimum allocation
unit is determined at configuration time, and thus tne number of bytes
corresponds to the record count plus the remaining unused space in the
last allocated block for sequential files. Random access files are
given data areas only when written, so the Bytes field contains the
only accurate allocation figure.
In the case of random access, the
Size field gives the logical end-ot-file record position and the Recs
field counts the logical records of each extent (each of these
extents, 11Owever, :nay contain unallocated "holes" even though they are
added into the record count). The "Ext" field counts the number of
logical 16K extents allocated to the file. Unlike version 1.4, the
Ext count does not necessarily correspond to the number of directory
entries given to the file,
since there can be up to 128K oytes (8
logical extents) directly addressed by a single directory entry,
de?ending upon allocation size (in a special case, there are actually
256K bytes which can be directly addressed by a physical extent).
'rhe .. Acc" field gives the RiO or R/W access mode, which is
changed using 'the commands shown below. Similarly, the parentheses
(All Intormation Contained Herein is Proprietary to Digital Research.)
5

shown around the PIP. COM file name indicate that it has the "system"
indicator set,
so that it will not be listed in OIR commands.
The
four command forms
STAT
STAT
STAT
STAT

d:filename.typ ~R/O
d:filename.typ $R/~
d:filename.typ $SYS
d:filename.typ $DIR

set or reset various ?ermanent file indicators.
The R/O indicator
places the file (or set of files) in a read-only status until changed
by a subsequent STAT command. The R/O status is recorded in the
directory with tne file so that it remains R/O through intervening
cold start operations.
The R/W indicator places the file
in a
?ermanent read/write status.
The SYS indicator attaches the system
indicator to the file,
while the DIR command removes the system
indicator. rrhe "filename. typ" may be ambiguous or unambiguous, but in
eitner case, the files whose attributes are changed are listed at the
console when the change occurs. The drive name denotea by "d:"
is
optional.
When a file is marked R/O, subsequent attempts to erase or write
into the file result in a terminal BOOS message
Bdos Err on d: File R/O
The BOOS then waits for a console input before performing a subsequent

warm start (a "return"

is sufficient to continue).

The command form

s'rAT d: DSK:

lists the drive characteristics of the disk named by "d:" which is in
the range A:,
B:, .•. , P:. The drive characteristics are listed in
the format:
d:
65536:
8192:
128:
0:
1024:
128:
58:
2:

Drive Characteristics
128 Byte record Capacity
Kilooyte Drive Capacity
32 Byte Directory Entries
Checked Directory Entries
Records/ Extent
Records/ Block
Sectors/ Track
Reserved Tracks

where "d:" is the selected drive,
followed by the total record
capacity
(65536 is an 8 megabyte drive),
followed by the total
capacity listed in Kilooytes.
The directorv size is listed next,
followed by the "checked" entries. The number of checked entries is
usually identical to the directory size for
removable media,
since
this mechanism is used to detect changed media during CP/M operation
without an intervening warm start.
For fixed media,
the number is
usually zero,
since the media is not changed without at least a cold
or warm start.
The number of records per extent determines the
addressing capacity of each directory entry (1024 times 128 bytes, or
(All Information Contained Herein is Proprietary to Digital Research.)
6

l28K in the exam?le above). The number of records oer block shows the
basic allocation size (in the example, 128 records/block times 128
bytes per record, or 16K oytes per block). The listing is then
followed by the number of physical sectors oer track and the number of
reserved tracks. For logical drives which share the same physical
disk, the number of reserved tracks may be quite large, since this
mechanism is used to sKio lower-numbered disk areas allocated to other
logical disks. The cbmm~nd form
s:rA'r DSK:
produces a drive characteristics table
drives. The final STAT command form is

for

all

currently

active

8'rAT USR:
which produces a list of the user numbers which have
currently addressed disk. The display format is:

files

on

the

Active User : 0
Active Files: 0 1 3
where the first line lists the currently addressed user number, as set
by the last CCP USER command, followed by a list of user numbers
scanned from the current directory. In the above case, the active
user number is 0 (default at cold start), witn three user numbers
whicn have active files on the current disk.
'fhe operator can
subsequently examine the directories of the other user numbers by
logging-in with USER 1, USER 2, or USER 3 commands, followed by a DIR
command at the CCP level.

(All Information Contained Herein is Proprietary to Digital Research.)
7

•

5.

PIP ENHAN'CEMEN'rs.

PIP provides three new functions which account tor the features
of CP/M 2.0.
All three functions take the form of file oarameters
which are enclosed in square brackets following the appr.opr late file
names. The commands are:
Gn

Get File from User number n
(n in the range 0 - 15)

w

write over R/O files without
console interrogation

R

Read system files

'rhe G command allows one user area to receive data files from another.
Assuming the operator has issued the USER 4 command at the CCP level,
the PIP statement
PIP X.Y = X.Y[G2]
reads file X. Yfrom user number 2 into user
command
PIP A:=A:*.*[G2]

area

number

4.

'rhe

copies all of the files from the A drive directory for user number 2
into the A drive directory of the currently logged user number~ Note
that to ensure file security, one cannot copy files into a different
a-rea than the one which is currently a,ddressed by the USER command.
Note also that the PIP program itself is initially copied to a
user area (so that subsequent files can be copied) using the SAVE
command. The sequence of operations shown below effectively moves PIP
from one user area to the next.
login user 0
load PIP to memory
DDT PIP. COM
(note PIP size s)
return to CCP
G0
login user 3
USER 3
SAVE s PIP. CO£¥l

USER '"

where s is the integral number of memory "pages" (256 byte segments)
occupied by PIP.
The number s can be determined when PIP. COM is
loaded under DDT, by referring to the value under the "NEXT"
display.
If for example, the next available address is 1000, then PIP.COM
requires lC hexadecimal pages (or 1 times 16 + 12 = 28 pages), and
thus the value of s is 28 in the subsequent save. Once PIP is cooied
in this manner, it can then be copied to another disk belonging to"the
same user number through normal pip transfers.
Under normal operation, PIP will not overwrite a file which is
set to a permanent R/O status. If attempt is made to overwrite a R/O
file, the prompt
.

(All Information Contained Herein is proprietary to Digital Research.)
8

nRSTINATION FILE IS R/O, DELETE (YIN)?
is issued. If the operator responds with the character "y"
file is overwritten. Otherwise, the response

then

the

** NOT DELETED **
is issued, the file transfer is skippped, and PIP continues with the
next operation in sequence. In order to avoid the prompt and response
in the case of RiO file overwrite, the command line can include the w
parameter, as shown below
PIP A:=B:*.COM[W]
which copies all non-system files to. the A drive from the B drive, and
overwrites any R/O files in the process. If the operation involves
several concatenated files, the w parameter need only be included with
the last file in the list, as shown in the following example
PIP A.DAT = B.DAT,F:NEW.DAT,G:OLD.DAT[W]
Files with the system attribute can be included in PIP transfers
if the R parameter is included, otherwise system files are not
recognized. The command line
PIP ED. COM = B:ED.COM[R]
for example,: reads the ED.COM file from the B drive, even if it has
been marked as a R/O and system file. The system file attributes are
copied, if present.

It should be noted that downward compatibility with previous
versions of CP/M is only maintained if the file does not exceed one
megabyte, no file attributes are set, and the file is created by user
0.
If compatibility is required with non-standard (e.g., "double
density") versions of 1.4, it may be necessary to select 1.4
compatibility mode when constructing the internal disk parameter block
(see the '"CP/M 2.0 Alteration Guide," and refer to Section 10 which
describes BIOS differences).

(All Information Contained Herein is Proprietary to Digital Research.)
9

6.

ED ENHANCEMENTS.

The CP/M standard orogram editor provides several new facilities
in the 2.0 release. Experience has shown that most operators use the
relative line numbering feature of ED, and thus the e~itor has the "v"
(Verify Line) option set as an initial value. The operator can, of
course, disable line numbering by typing the "-v" command. If you are
not familiar with the ED line number mode, you may wish to refer to
the Appendix in the ED user's guide, where the "v" command is
described.
ED also takes file attributes into account.
attempts to edit a read/only file, the message

** FILE IS

READ/ONL~

If

the

operator

**

appears at the console. The file can be loaded and examined, but
cannot be altered in any way. Normally, the operator simply ends the
,edit session, and uses STAT to change the file attribute to R/W.
If
the edited file has the "system" attribute set, the message
"SYSTEM" FILE NOT ACCESSIBLE
is displayed at the console, and the edit session is aborted.
Again,
the STA;f program can be used to change the system' attribute, if
desired.
Finally, the insert mode ("i") command allows CRT
functions, as described in Section 2, above.

line

editing

(All Information Contained Herein is proprietary to Digital Research.)

1"

7.

THE XSUB FUNCTION.

An additional utility program is supplied with version 2.0 of
CP/M, called XSUB, which extends the power of the SUBMIT facility to
include line input to programs as well as the console command
processor.
The XSUB command is included as the first line of your
submit file and, when executed, self-relocates directly below the CCP.
All subsequent submit command lines are processed by XSUB, so that
programs which read buffered console input (BOOS function 10)
receive
their input directly from the submit file.
For example, the file
SAVER.SUB could contain the submit lines:
XSUB
DDT
I$l.HEX
R

G0

SAVE 1 $2.COM
with a subsequent SUBMIT command:
SUBMIT SAVER X Y
which substitutes X for $1 and Y for $2 in the command stream.
The
XSUB program loads, followed by DD'r which is sent the command lines
"IX.HEX" "R" and "G0" thus returning to the CCP.
The final command
"SAVE 1 Y.COM" is processed by the CCP.
The XSUB program remains in memory, and prints the message
(xsub active)
on each warm start operation to indicate its presence.
Subsequent
submit command streams do not require the XSUB, unless an intervening
cold start has occurred. Note that XSUB must be loaded after DESPOOL,
if both are to run simultaneously.

(All Information Contained Herein is Proprietary to Digital Research.)
11

8.

BOOS INTERFACE CONVENTIONS.

CP/M 2.0 system calls take place in exactly the same manner as
earlier versions,
with a call to location 0005H, function number in
register C, and information address in register pair DE.
Single byte
values are returned in register A, with double byte values returned in
HL
(for reasons of compatibility, register A = L and register B = H
upon return in all cases). A list ot CP/M 2.0 calls is given below,
with an asterisk following functions which are either new or revised
from version 1.4 to 2.0.
Note that a zero value is returned for
out-of range function numbers.
0

1
2
3

4
5

6*
7
8
9

10*
11
12*
13
14
15*
16
17*
18*

System Reset
Console Input
Console Output
Reader Input
PunCh Output
List Output
Direct Console I/O
Get I/O Byte
Set I/O Byte
Print String
Read Console Buffer
Get Console Status
Return Version Number
Reset Disk System
Select Disk
Open File
Close File
Search for First
Search for Next

19*
20
21
22*
23*
24*
25
26
27
28*
29*
30*
31*
32*
33*
34*
35*
36*

Delete f"ile
Read Sequential
write Sequential
Make File
Rename File
Return Login Vector
Return Current Disk
Set DMA Address
Get Addr (Alloc)
Write Protect Disk
Get Addr(R/O Vector)
Set File Attr ibutes
Get Addr(Disk Parms)
Set/Get User Code
Read Random
~vr i te Random
Comoute File Size
Set Random Record

(Functions 28, 29, and 32 should be avoided in application programs to
maintain upward compatibility with MP/M.) The new or revised functions
are described below.

Function 6: Direct Console I/O.
Direct Console I/O is supported under CP/M 2.0 for those
applications where it is necessary to avoid the BOOS console I/O
operations.
Programs whiCh currently perform direct I/O through the
BIOS should be changed to use direct I/O under BOOS so that they can
be fully supported under future releases of MP/M and CP/M.
Upon entry to function 6, register E either contains hexadecimal
FF, denoting a console input request, or register E contains an ASCII
Character.
If the input value is FF, then function 6 returns A = 00
if no character is ready, otherwise A contains the next console input
character.
If the input value in E is not FF, then function 6 assumes

that

E contains a valid ASCII character whiCh is sent to the console.

(All Information Contained Herein is Proprietary to Digital Research.)
12

Function 10: Read Console Buffer.
The console buffer read operation remains unchanged except that
console line editing is supported, as described in section 2.
Note
also that certain functions which return the carriage to the leftmost
position (e.g., ctl-X)
do so only to the column position where the
prompt ended (previously, the carriage returned to the extreme left
margin).
'rhis new convention makes operator data input and line
correction more legible.

Function 12: Return Version Number.
Function 12 has been redefined to orovide information which
allows version-independent programming (this was previously the "lift
head" function which returned HL=0000 in version 1.4, but performed no
operation). The value returned by function 12 is a two-byte value,
with H = 00 for the CP/M release (H = 01 for MP/M), and L = 00 for all
releases previous to 2.0.
CP/M 2.0 returns a hexadecimal 20 in
register L, with subsequent version 2 releases in the hexadecimal
range 21,
22,
through 2F.
Using function 12, for example, you can
write application programs which provide both sequential and random
access functions,
with random access disabled when operating under
early releases of CP/M.
In the file operations described below, DE addresses a file
control block (FCB).
Further, all directory operations take place in
a reserved area which does not affect write buffers as was the case in
version 1.4, with the exception of Searcn First and Search Next, where
compatibility is required.
The File Control Block (FCB) data area consists of a sequence of 33
bytes for sequential access, and a series of 36 bytes in the case that
the file is accessed randomly.
The default file control block
normally located at 005CH can be used for random access files,
since
bytes 00708,
007EH, and 007FH are available for this purpose.
For
notational purposes, the FCB format is shown with the following
fields:

(All Information Contained Herein is Proprietary to Digital Research.)

13

•
'

Idrlfllf21/ /lf8Itllt2It3Iexlslls2Ircld01/ /ldnlcrlr0lrllr21
00 01 02 ••• 08 09 10 11 12 13 14 15 16 ••• 31 32 33 34 35
where
dr

drive code (0 - 16)
o => use default drive for file
1 => auto disk select drive A,
2 => auto disk select drive B,
16=> auto disk select drive P.

fl ••. f8

contain the file name in ASCII
upper case, with high 'bit = 0

tl,t2,t3

contain the file type in ASCII
upper case, with high bit = 0
tIl, t21, and t3 1 denote the
bit of these positions,
tIl = 1 => Read/Only file,
t2' = 1 => SYS file, no DIR list

ex

contains the current extent number,
normally set to 00 by the user, but
in range 0 - 31 during file I/O

sl

reserved for internal system use

s2

reserved for internal system use, set
to zero on ~all to OPEN, MAKE, SEARCH

rc

record count for extent "ex,"
takes on values from 0 - 128

d0 ••• dn

filled-in by CP/M, reserved for
system use

cr

current record to read or write in
a sequential file operation, normally
set to zero by user

r0,rl,r2 optional random record number in the
range 0-65535, with overflow to r2,
to,rl constitute a 16-bit value with
low byte r0, and high byte rl

Function 15: Open File.
Tne Operi File operation is identical to previous definitions,
with the exception that byte s2 is automatically zeroed. Note that
previous versions of CP/M defined this byte as zero, but made no
(All Information Contained Herein is Proprietary to Digital Research.)
\

14

cnecks to assure compliance.
Thus, the byte is cleared to ensure
upward compatibility with the latest version"where it is required.

Function 17: SearCh for First.
Search First scans the directory for a match with the file given
by the Fca addressed by DE.
The value 255
(hexadecimal FF)
is
returned if the file is not found, otherwise a value of A equal to 0,
1, 2, or 3 is returned indicating the file is oresent.
In the case
that the file is found, the current DMA ad~ress is filled with the
record containing the directory entry, and the relative starting
position is A ~ 32 (i.e., rotate the A register left 5 bits, or ADD A
five times). Altnough not normally required for application programs,
the airectory information can be extracted from the buffer at this
position.
An ASCII question mark
(63 decimal,
3F hexadecimal)
in any
position from fl
through ex matches the corresponding field of any
directory entry on the default or auto-selected disk drive.
If the dr
field contains an ASCII question mark, then the auto disk select
function is disabled, -the default disk is searched, with the search
function returning any matched entry, allocated or free, belonging
to
any user number.
This latter function is not normally used by
application ~rogr&~s, out does allow complete flexibility to scan all
current directory values.
If the dr field is not a question mark, the
s2 byte is automatically zeroed.

Function 18: Search for Next.

The Search Next function is similar to the Search First
function,
except that the directory scan continues from the last
matched entry. Similar to function 17, function 18 returns the
decimal value 255 in A when no more directory items match.

Function 19: Delete File.
The Delete File function removes files which match the FCB
addressed by DE.
The filename and type may contain ambiguous
references (i.e., question marks in various positions), but the drive
select code cannot be ambiguous,
as in the Search and Search Next
functions.
.
Function 19 returns a decimal 255 if the reference file or files
could not be found, otherwise a value in the range 0 to 3 is returned.

(All Information Contained Herein is Proprietary to Digital Research.)

15

•

Function 22: Make File.
The Make File operation is identical to previous versions
CP/M, except that byte s2 is zeroed upon entry to the BOOS.

of

Function 23: Rename File.
The Actions of the file rename functions are the same as
previous releases except that the value 255 is returned if the rename
function is unsuccessful (the file to rename could not be found),
otherwise a value in the range 0 to 3 is returned.

Function 24: Return Login Vector.
The login vector value returned by CP/M 2.0 is a 16-bit value in
HL, where the least significant bit of L corresponds to the first
drive A, and the high order bit of H corresponds to the sixteenth
drive, labelled P. Note that compatibility is maintained with earlier
releases, since registers A and L contain the same values upon return.

Function 28: write Protect Current Disk.
The
disk write protect function provides tem90rary write
protection for the currently selected disk. Any attem9t to write to
the disk, before the next cold or warm start operation produces the
message
Bdos Err on d: R/O

Function 29: Get R/O Vector.
Function 29 returns a bit vector in register pair HL which
indicates drives which have the temporary read/only bit set.
Similar
to function 24, the least significant bit corresponds to drive A,
while the most significant bit corresponds to drive P. The R/O bit is
set either by an explicit call to function 28, or by the automatic
software mechanisms within CP/M which detect changed disks.

Function 30: Set File Attributes.
The
Set
File
Attributes function allows programmatic
manipulation
of
permanent indicators attached to file~.
In
particular, the R/O and System attributes (tl' and t2' above)
can be
s~t or reset.
The DE pair addresses an unambiguous file name with the
appropriate attributes set or reset.
Function 30 searches for a
(All Information Contained Herein is Proprietary to Digital Research.)

16

match, and chanqes the matched directory entry to contain the selected
inaicators. Indicators fl' through f4' are not ~resently used, but
may be useful for applications programs, since they are not involved
in the matching process durin9 file open and close operations.
Indicators £5'
tnrough f3'
and t3' are reserved for future system
exr;>ans ion.

Function 31: Get Disk Parameter Block Address.
~he address
of the BIOS resident disk parameter block is
returned in HL as a result of this function call. This address can be
used for either of two purposes. First, the disk parameter values can
be extracted for display and space .computation purposes, or transient
programs can dynamically change the values of current disk 1;)arameters
when the disk environment changes, if required. Normally, application
programs will not require this facility.

Function 32: Set or Get User Code.
An application program can change or interrogate the currently
active user number by calling function 32.
If register E = FF
nex3decimal, then tne value of the current user number is returned in
register A, where the value is in the range 0 to 31. If register E is
not FF, then the current user number is changed to the value of E
(modulo 32).

Function 33: Read Random.
'rhe Read Random function iss imi la r to the seguen t ial file read
operation of previous releases, exce1;)t that the read operation takes
place at a particular record number, selected by the 24-bit value
constructed from the three byte field following the FCB (byte
positions r0 at 33, rl at 34, and r2 at 35). Note that the sequence
of 24 bits is stored with least significant byte first (r0), middle
byte next (r1), and high byte last (r2). CP/M release 2.0 does not
reference byte r2, except in computing the size of a file (function
35). Byte r2 must be zero, however, since a non-zero value indicates
overflow past the end of file.
Thus, in version 2.0, the r0,rl byte pair is treated as a
double-byte, or "word" value, which contains the record to read. This
value ranges from 0 to 65535, providing access to any particular
record of the 8 megabyte file.
In order to orocess a file using
random access, the base extent (extent 0) must first be opened.
Although the base extent mayor may not contain any allocated data,
this ensures that the file is properly recorded in the directory, and
is visible in DIR requests. The selected record number is then stored
into the random record field (r0,rl), and the SDOS is called to read
the record. U1;)on return from the call, register A either contains an
(All Information Contained Herein is Proprietary to oigitalResearch.)
17

•

error code, as listed below, or the value 00 indicating the operation
was successful. In the latter case, the current DMA address contains
the randomly accessed record. Note that contrary to the sequential
read operation,
the record number is not advanced. ThuS, subsequent
random read operations continue to read the same record.
Upon each random read operation, the logical extent and current
record values are automatically set.
'rhus,
the file can
be
sequentially read or written,
starting from the current randomly
accessed position.
Note,
however,
that in this case,
the last
randomly read record will be re-read as you switch from random mode to
sequential read, and the last record will be re-written as you switch
to a sequential write operation.
You can, of course,
simply advance
the random record oosition following each ranaom read or write to
obtain the effect of a sequential I/O operation.
Error codes returned in register A following a random
listed below.
01
02
03
04
05
06

read

are

reading unwritten data
(not returned in random mode)
cannot close current extent
seek to unwritten extent
(not returned in read mode)
seek past physical end of disK

Error code 01 ana 04 occur when a random read operation accesses a
data block which has not been previously written, or an extent which
has not been created, which are equivalent conditions.
Error 3 does
not normally occur under proper system operation, but can be cleared
by simply re-reading, or re-opening extent zero as long as the disk is
not physically write protected.
Error code 06 occurs whenever byte r2
is non-zero under the current 2.0 release.
Normally, non-zero return
codes can be treated as missing data, with zero return codes
indicating operation complete.

Function 34: Write Random.
The Write Random ooeration is initiated similar to the Read
Random call, except that data is written to the disk from the current
DMA address.
Further, if the disk extent or data block which is the
target of the write has not yet been allocated, the allocation is
performed before the write operation continues. As in the Read Random
operation, the rando~ record number is not changed as a result of the
write.
The logical extent number and current record positions of the
file control block are set to correspond to the random record which is
being written.
Again,
sequential read or write operations can
commence following a random write, with the notation that the
currently addressed record is either read or rewritten again as the
sequential operation begins.
You can also simply advance the random
record position following each write to get the effect of a sequential
write operation. Note that in particular, reading or writing the last
record of an extent in random mode does not cause an automatic extent
(All Information Contained Herein is proprietary to Digital Research.)

18

switch
2.0.

as

it

does

in sequential mode under either CP/M 1.4 or CP/M

The error codes returned by a random write are identical to the
random read operation with the addition of error code 05, which
indicates that a new extent cannot be created due to directory
ove rflow.

Function 35: Compute

Fi~e

Size.

When computing the size of a
file,
the DE register pair
addresses an FCB in random mode format (bytes r0, rl, and r2 are
present).
The FCB contains an unambiguous file name which is used in
the directory scan.
Upon return, the random record bytes contain the
"virtual" file size which is, in effect, the record address of" the
record following
the end of the file.
if, following a call to
function 35, the high record byte r2 is 01, then the file contains the
maximum record count 65536 in version 2.0.
Otherwise, bytes r0 and rl
constitute a 16-bit value
(r0
is the least significant byte,
as
before) which is the file size.
Data can be appended to the end of an existing file by simply
calling function 35 to set the random record position to the end of
file, tnen performing a sequence of random writes starting at the
preset record address.
The virtual size of a file corresponds to the physical size when
the file is written sequentially.
If, instead, the file was created
in random mode and .. holes" exi s t in the allocation, then the file may
in fact contain fewer records
than the size
indicates.
If,
for
example,
only the last record of an eight megabyte file is written in
random mode (i.e., record number 65535),
then the virtual size
is
65536 records, although only one block of data fs actually allocated.

Function 36: Set Random Record.
The Set Random Record function causes the BOOS to automatically
produce the random record position from a file which has been read or
The function can be
written sequentially to a particular point.
useful in two ways.
First, it is often necessary to initially read and scan a
sequential file to extract the positions of various "key" fields.
As
each key is encountered, function 36 is called to compute the
random
record position for the data corresponding to this key.
If the data
unit size is 128 bytes, the resulting record position is placed into a
table with the key for later retrieval.
After scanning the entire
file and tabularizing the keys and their record numbers, you can move
instantly to a particular keyed record by performing a
random read
using the corresponding random record number which was saved earlier.
The scheme is easily generalized when variable record lengths are
(All Information Contained Herein is Proprietary to Digital Research.)
19

•

involved since the program need only store the buffer-relative byte
position along with the key and record number in order to find the
exact starting position of the keyed data at a later time.
A second use of function 36 occurs when switching from a
sequential read or write over to random read or write. A file is
sequentially accessed to a ~articular point in the file,
function 36
is called which sets the record number, and subsequent random read and
write operations continue from the selected point in the file.

This section is concluded with a rather extensive, but comolete
example of random access operation. The program listed below performs
the simple function of reading or writing random records upon command
from the terminal.
Given that the program has been created,
assembled, and placed into a file labelled RAl~DO!-1..C01'1, the CCl? level
command:
RAN DO£>1 X. DA'r
starts the test program. 'rhe program looks for a file by the name
X.DAT (in this particular case) and, if found, proceeds to prompt the
console for input. If not found, the file is created before the
prompt is given. Each prompt takes the form
next command?
and is followed by operator input, terminated by
The input commands take the form
nW

nR

a

carriage

return.

Q

where n is an integer value in the range 0 to 65535, and W, R, and Q
are simple command characters corresponding to random write, random
read, and quit processing, respectively: If the W command is issued,
the RANDOM program issues the prompt
type data:
The operator then responds by typing up to 127 characters, followed by
a carriage return. RANDOM then writes the character string into the
X.DAT file at record n.
If the R command is issued, RANDOM reads
record number n and displays the string value at the console. If the
Q command is issued, the X.DAT file is closed, and the program returns
to the console command processor. In the interest of brevity (ok, so
the orogram's not so brief), the only error message is
error, try again
The program begins with an initialization section where the
input file is opened or created, followed by a continuous loop at the
label "ready" where the individual commands are interpreted.
'rhe
default file control block at 005CH and the default buffer at 0080H
are used in all disk operations. The utility subroutines then follow,
(All Information Contained Herein is Proprietary to Digital Research.)
20

which contain the ?rincipal input line processor,
'I'h is ?ar ticular pr og ram shows the elements of
processing, and can be used as the basis for
deve lopmen t •

called "readc."
random
access
further program

,. ***************************************************
,.*
*
;* sample random access program for cp/m 2.0

,.*
0Hl0

.,

iiHHl5

=
=

reboot
bdos

egu
egu

00100h
01005h

;system reboot
;bdos entry point

01001
0002

=
=

coninp
conout
T?string
rstring
version
openf
closef
makef
readr
writer

egu
equ
egu
equ
egu
equ
egu
equ
egu
eau

1
113
12
15
16
34

;console input function
;console output function
;print string until '$'
;read console buffer
;return version number
;file open function
;close function
;make file function
;read random
;write random

fcb
ranrec
ranovf
buff

egu
egu
equ
equ

005ch
fcb+33
fcb+35
0080h

;default file control block
;randorn record position
;high order (overflow) byte
;buffer address

cr
If

egu
egu

0dh
0ah

;carriage return
;line feed

01000

00109 =
fHHJa =
tHic =

o

0100f
iO~10

0016
JI{j21
0022

1il05c
007d
01217f
013813

*

. ' .
*
,.***************************************************
org
100h
;base of tpa

=

=
=
=

=
=
=
=

=

00iOd =
000a =

2
9

22

33

;

;

,.***************************************************
., *
*
;* load SP, set-up file for random access
*
*
,.*
,.***************************************************
0100 31bc0
0103
0105
13108
!610a

lxi

sP,stack

version 2.1O?
mvi
c,version
call
bdos
cpi
.20h
;version 2.0 or better?
jnc
versok
bad version, message and go back
lxi
d,badver
print
call
jrno
reboot

0e0c
cd050
fe20
d2160

010d Illb0
0110 cdda0
0113 c3000
versok:

correct version for random access
(All Information Contained Herein is Proprietary to Digital Research.)
21

0116
10118
0llb
121 lIe
0llf

0e0f
11Se0
cd1350
3c
c2370

mvi
lxi
call
inr
jnz
"

121122
121124
0127
0l2a
I2Il2b

0e16
11Sc0
cd050
3c
c2370

;
;

·,

0l2e l13a0
13131 cdda0
0134 c31300

c,openf ;open default fcb
d,fcb
bdos
a
;err 255 becomes zero
ready

cannot open file, so create it
c,makef
mvi
d, fcb
lxi
call
bdos
inr
a
;err 255 becomes zero
jnz
ready
cannot create file, directory full
lxi
d,nospace
call
orint
jmp
reboot ;back to ccp

;

,.***************************************************
*
·, *
,.* loop back to "ready" after each command
*
,.*
*

,.*******w*******************************************
~

ready:
file is ready for processing
0137
0l3a
0l3d
12114121
0142
0144

cde50
227d0
217fl2l
360121
fe5l
c2S60

··,
,

liH47
121149
0l4c
I2Il4f
121150
121153

0ell1
11SctO
cd059
3c
cab99
c3090

call
snld
lxi
mvi
cpi
jnz

readcom ;read next command
ranrec ;store input record#
h,ranovf
m,0
;clear high byte if set
'Q'
; qui t?
notq

quit processing, close file
mvi
c,closef
lxi
d,fcb
call
bdos
inr
;err 255 becomes 121
a
jz
error
;error message, retry
jmp
reboot ; back to ccp

·,,• ***************************************************
.

,.*

*

;* end of quit command, process write

,.w

*
*

,.***************************************************

notq:

not the quit command, random write?
cpi
• ~v'
jnz
notw

0156 fe57
0158 c289121
;

!?l15b l14d0
0l5e cdda0

this is a random write, fill buffer until cr
d,datmsg
lxi
print
;data prompt
call

(All Information Contained Herein is proprietary to Digital Research.)
22

mvi
lxi

0161 eJe7f
0163 218010
r loop:
0166
i2J167
1iJ168
!.116b
016c
016d
016f

c5
e5
cdc20
el
cl

0172
10173
0174
0175

77
23
0d
c2660

fe~jd

ca780
~

c,127
~ul? to 127 characters
h,buff ~destination
~read next character to buff
puSh
b
~save counter
h
~next destination
l?ush
call
getchr ~character to a
pop
h
~restore counter
pop
b
:restore next to fill
cpi
cr
:end of line?
jz
er 1000
not end; store character
mov
m,a
inx
h
:next to fill
dcr
:counter goes down
c
jnz
rloop
:end of buffer?

erloop:
0178 3600

end of read loop, store 00
mvi
m,0

eJ17a
0.l7c
017f
10182
0183
0166

write the record to selected record number
mvi
c,writer
lxi
d,fcb
call
bdos
ora
:error code zero?
a
jnz
error
: message if not
jmp
ready
:for another record

0e22
115c0
cd0512J
b7
c2b90
c3370
:

,.*~~******~******~**********************************
,.*
*
:* end of write command, ~rocess read
*
,.*
*
,.***************************************************
notw:
0189 fe52
018b c2b9f2J

not a write command, read record?
'R'
Cl? i
jnz
error
:skip if not

0l8e
0190
0193
019"6
0197

read random record
mvi
c,readr
lxi
d,fcb
call
bdos
ora
:return code 00?
a
jnz
error

0e21
115c0
cd050
b7
c2b9!.1

read was successful, write to console
call
crlf
:new line
mvi
c,128
imax 128 characters
lxi
h,buff inext to get

f2J 19a cdcf0
019d k1e80
1c119f ./21800
wloop:
f2Jla2
01a3
f2Jla4
f2l1a6
01a9
01aa

7e
23
e67f
ca37f2J
c5
e5

mov
inx
ani
jz
push
push

a,m
h
7fh
ready
b
h

:next character
inext to get
imask parity
:for another command if 1210
:save counter
isave next to get

(All Information Contained Herein is Proprietary to Digital Research.)
23

01ab
131ad
01b0
01bl
II'lb2
01b3
01b6

fe20
d4c80
el
cl
13d
c2a20
c3370

cpi
cnc
pop
pop
dcr
jnz
jmp

·,

igraphic?
iskip output if not

putchr
h
b
c
wloop
ready

icount=count-l

,.******~***********************************~********
*
·, *
i* end of read command, all errors end-uD here
*
*
,.*
,

,
.***************************************************

error:
01b9 11590
01bc cdda0
01bf c3370

lxi
call

·

jmp

d,errmsg
print
ready

,
,.***************************************************
,.*
*
i* utility subroutines for console i/o
*
,.*
*

,.***************************************~***********

getchr:
; read next console character to a
c,coninp
mvi
call
bdos
ret

01c2 0e0l
01c4 cd050
01c7 c9
putchr:
01c8
01ca
01cb
01ce

iwrite character from a to console
mvi
c, conout
mov
e,a
icharacter to send
call
bdos
;send character
ret

0e02
5f
cd050
c9
i

cr If:
01cf
01dl
01d4
131d6
131d9

;send carr iage return line feed
mvi
a,cr
;carriage return
call
putchr
mvi
a,lf
;line feed
call
Dutchr
ret

3e0d
cdc80
3e0a
cdc80
c9
;

print:
01da
01db
elIde
01Cif
01el
01e4

;print the buffer addressed by de until $
push
d
call
crlf
pop
d
;new line
mvi
c, pstring
call
bdos
;print the string
ret

d5
cdcf0
dl
0e09
cd0513
c9
readcom:

(All Information Contained Herein is Proprietary to Digital Research.)
24

01e5
01e8
vJleb
itlled
eJlf0

116b0
cdda0
0e0a
117ali.l
cd050

01f3
01f6
01f9
01fa
01fb
01fc

210010
117c0
la
readc:
13
b7
c8

01fd d630
01£f fe0a
0201 d2130
0204 29
0205 4d
0206 44
0207 29
0208 29
0209 09
020a 85
0200 6t
o20c d2f90
~20t

24

11 210 c3f90

i read the next command line to the conbuf
lxi
d,prompt
call
TJrint
icommand?
c,rstring
mvi
lxi
d ,conbuf
call
bdos
iread command line
command line is present, scan it
lxi
h,0
istart with 0000
lxi
d,conlinicommand line
Idax
d
inext command character
inx
d
ito next command position
ora
a
icannot be end of command
rz
. ?
not zero, numerIC.
sui
'0 '
cpi
10
i car ry if numeric
jnc
endrd
add-in next digi t
i1(2
dad
h
mov
c,l
mov
b,h
ibC = value * 2
dad
h
i*4
dad
h
i*8
dad
b
i *2 + *8 = *110
add
1
i+digit
mov
l,a
jnc
readc
ifor another char
inr
h
ioverflow
jmp
readc
ifor another char

•

endrd:
end of read, restore value in a
adi
i command
• 0'
'a'
i translate case?
cui
rc
lower case, mask lower case bits
ani
101$111lb
ret

0213 c630
0215 fe61
I) 217 dS
0218 e65f
021a c9
i

,.***************************************************
,.*
*
i* string data area for console messages

*

,.*
*
,.***************************************************
nadver:
021b 536f79

o23a
o24d

db

'sorry, you need cp/m version 2$'

db

'no directory spaceS'

db

'type data: $'

db

'error, try again.S'

db

'next command? $'

nospace:
4e6f29
da tmsg:
547970
e r rmsg:

0259 457272
prompt:
026b 4e6570

(All Information Contained Herein is Proprietary to Digital Research.)
25

,.***************************************************
,.*
*
i* fixed and variable data area
*
,. *
*
,.***************************************************

027a 21
027b
027c
0021 =

conbuf:
consiz:
conlin:
conlen

029c

db
ds
ds
equ

conlen
1

ds

32

ilength of console buffer
iresulting size after read
ilength 32 buffer

32

$-consiz
i 16

level stack

stack:
02bc

end

(All Information Contained Herein is Proprietary to Digital Research.)
26

9•

CP/M 2.0 MEMORY ORGANIZA'rION.

Similar to earlier versions, CP /(\1 2. fZj is field-altered to fit
var ious memory sizes,
depending upon the host computer
memory
configuration.
Typical base addresses for popular memory sizes are
shown in the table below.
Module
CCP
BDOS
BIOS
'rop of Ram

20k
3400H
3C00H
4A00H
4FFFH

24k
4400H
4C00H
5A00H
5FFFH

32k
6400H
6C00H
7A00H
7FFFH

48k
A400H
AC00H
BA00H
BFFFH

64k
E40liJH
EC00H
FA00H
FFFFH

The distribution disk contains a CP/M 2.0 system configured for a
20k
Intel MDS-800 with standard IBM 8" floppy disk drives.
The disk
layout is shown below:
Sector
1
2
3
4
5
6

7
t5

Sl
Hl

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

'rrack 00
Module
(Bootstrap Loader)
3400H
CCP + 000H
3480H
CCP + 080H
3500H
CCP + 100H
3580H
CCP + 180H
3600H
CCP + 200H
3680H
CCP + 280H
37i:1I::lH
CCP + 300H
3780H
CCP + 380rl
3800rl
CCP + 400H
3880H
CCP + 4t30H
3900H
CCP + 500H
3980H
CCP + 580H
3A00H
CCP + 600H
3A80H
CCP + 680H
3B00H
CCP + 700H
3B80H
CCP + 780H
3C00H BDOS + 000H
3C80H BOOS + 080H
3D00H BOOS + 100H
3D80H BOOS + lB0H
3E00H BOOS + 200H
3E80H BOOS + 280H
3F00H BOOS + 300H
3F80H BOOS + 380H
4000H BOOS + 400H

Track
4080H
4100H
4180H
4200H
42d0H
4300H
4380H
4400H
4480H
4500H
4580H
4600H
4680H
4700H
4780H
4800H
4880H
4900H
4980H
4A00H
4A80H
4B00H
4B80H
4C00H
4C80H
4D00H

01
BDOS
BOOS
BOOS
BOOS
BOOS
BOOS
BOOS
BOOS
BDOS
BOOS
BOOS
BOOS
BOOS
BDOS
BOOS
BDOS
BOOS
BDOS
BOOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS

Module
480H
500H
580H
600H
6808
700H
780H
800H
880H
900H
980H
A00H
A80H
B00H
B80H
C00H
C80H
D00H
D80H
000H
080H
100H
180H
200H
280H
300H

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

In particular, note that the CCP is at the same position on the disk,
and occupies the same space as version 1.4.
The BOOS portion,
however, occupies one more 256-byte page and the BIOS portion extends
through the remainder of track· 01.
Thus, the CCP is 800H (2048
decimal) bytes in length, the BOOS is E00H (3584 decimal)
bytes in
length,
and the BIOS is up to 380H (898 decimal) bytes in length.
In
version 2.0, the BIOS portion contains the standard subroutines of
1.4,
along with some initialized table space, as described in the
following section.

(All Information Contained Herein is Proprietary to Digital Research.)
27

10. BIOS DIFFERENCES.
'rhe CP/M 2.0 Basic I/O System differs only slightly in concept
from its predecesssors. Two new jump vector entry points are defined,
a new sector translation subroutine is included, and a
disk
characteristics table must be defined. The skeletal form of these
changes are found in the program shown below.
org
maclio
jmp

1:

2:
3:
4:

;

5:
6:

7:
d:

9: bpb
10: rpb
11: maxb
12 :
13 :
14 :
15 :
16 :
17:
18:
19:
20:
21 :
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
410:
41 :
42:
43:
44:
45:
46:
47:

4000h
diskdef
boot

jmp
listst :list status
jmp
sectran :sector translate
disks
4
large capacity drive
equ
16*1024 :bytes per block
equ
bpb/128 :records per block
65535/rpb :max block number
equ
diskdef 0,1,58,3,bpb,maxb+l,128,0,2
diskdef 1,1,58, ,bpb,maxb+l,128,O,2
diskdef 2,0
disKdef 3,1

;

boot:

ret

listst: xra
ret

:nop

a

:nop

;

seldsk:
:drive number in c
lxi
h,0
:00010 in hI produces select error
mov
a,c
:a is disk number 0 ••• ndisks-l
cpi
ndisks :less than ndisks?
rnc
;return with HL = 0000 if not
proper disk number, return dpb element address
mov
l,c
dad
h
: *2
dad
h
;*4
dad
h
:*8
dad
h
: *16
lxi
d,dpbase
dad
d
:HL=.dpb
ret
selsec:
:sector number in c
lxi
h,sector
mov
m,c
ret
sectran:
:translate sector BC. using table at DE
xchg
:HL = .tran
dad
b
:single precision tran

(All Information Contained Herein is Proprietary to Digital Research.)
28

48:
49:
510:
51 :
52:

.,

dad b again if double precision tran
mov
1, m
ionly low byte necessary here
fill botn H and L if double precision tran
ret
iHL = 11ss

53: sector: as
54:
endef
55:
end

I

Referring to the program shown above, lines 3-6 represent the
BIOS entry vector of 17 elements (version 1.4 defines only 15 jum?
vector elements).
°rhe last two eleme"nts provide access to the
hLISTST"
(List Status) entry point for DESPOOL. The use of this
particular entry point is defined in the OESPOOL documentation, and is
no different than the previous 1.4 release.
It should be noted that
the 1.4 DESPOOL Drog'ram will not o?erate under version 2.0, but an
update version will be available from Digital Research in the near
fu tur e.
'rhe "SECTRAN" (Sector Number 'rranslate) entry shown in the jump
vector at line 6 provides access to a BIOS-resident sector translation
sUbroutine. This mechanism allows the user to specify the sector skew
factor and translation for a particular disk s~stem, and is described
below.
A macro library is shown in the listing,. called DISKDEF,
included on line 2, and referenced in 12-15. Although it is not
necessary to use the macro liorary, it greatly simplifies the disk
definition process.
You must have access to the MAC macro assembler,
of course, to use the DISKDEF facility, while the macrb library is
included with all CP/M 2.0 distribution disks.
(See the CP/M 2.0
Alteration Guide for formulas which you can use to hand-code the
tables produced by the DISKDEF library).
A BIOS disk definition consists of
macro statements:
!'1ACL IB

DISKDEF

DISKS
DISKDEF
DISKDEF

o , .••

· . . . ..

·.... .
DISKDEF
· .. . ..
ENOEF

the

following

sequence

of

n

1 , •..

n-l

where the MACLIB statement loads the DISKDEF.LIB file
(on the same
disk as your BIOS) into MAC's internal tables. The DISKS macro call
follows, which specifies the number of drives to be configured with
your system, where n is an integer in the range 1 to 16. A series of
DISKOEF macro calls then follow which define the characteristics of
each logical disk, 0 through n-l (corresponding to logical drives A
through P). Note that the DISKS and DISKOEF macros generate in-line
(All Information Contained Herein is Pro?rietary to Digital Research.)
29

•

fixed data tables, and thus must be placed in a non-executable ?ortion
of your BIOS, typically directly following the BIOS jump vector.
the
The remaining portion of your BIOS is defined following
DISKDEF macros,
with the ENDEF macro call immediately preceding the
(End of Diskdef)
macro generates the
END statement.
The ENDEF
necessary uninitialized RAM areas which are located above your BIOS.
The form of the DISKDEF macro call is
DISKDEf

dn,fsc,lsc, [skf] ,bls,dks,dir,cks,ofs, [0]

where
dn
fsc
Isc
skf
bls
dir
cks
ofs
[0 ]

is
is
is
is
is
is
is
is
is

the logical disk number, 0 to n-l
the first physical sector number (0 or 1)
the last sector number
the optional sector skew factor
the data allocation block size
the number of directory entries
the number of "checked .. directory entries
the track offset to logical track 00
an optional 1.4 compatibility flag

The value "dn" is the drive number being defined with this DISKDEF
mac ro invocation.
'rhe" f sc" pa r arne ter accoun ts for di f fer ing sector
number ing systems, and is usually 0 or 1.
The" Isc"
is the last
numbered sector on a track.
When present, the "skf" parameter defines
the sector skew factor which is used to create a sector translation
table according to the skew.
If the number of sectors is less than
256, a single-byte table is created, otherwise each translation table
element occupies two bytes.
No translation table is created if the
skf parameter is omitted
(or equal to 0).
The "bls" parameter
specifies the number of bytes allocated to each data block, and takes
on the values 1024, 2048,
4096,
8192, or 16384.
Generally,
performance increases with larger data block sizes since there are
fewer directory references and logically connected data records are
physically close on the disk.
Further, each directory entry addresses
more da ta and tl1e BIOS-resident r am space is reduced.
'rhe "dk s"
specifies the total disk size in "bls" units.
That is, if the bls =
2048 and dks = 1000, then the total disk capacity is 2,048,000 bytes.
If dks is greater than 255, then the block size parameter bls must be
g rea ter than 1024.
'rhe value of .. di r"
is the total number of
directory entries which may exceed 255,
if desired.
The "cks"
parameter determines the number of directory items to check on each
directory scan, and is used internally to detect changed disks during
system operation, where an intervening cold or warm start has not
occurred (when this situation is detected, CP/M automatically marks
the disk read/only so that data is not subsequently destroyed).
Normally the value of cks = dir when the media is easily changed, as
is the case with a floppy disk subsystem.
If the disk is permanently
mounted, then the value of cks is typically 0, since the probability
of changing disks without a restart is quite low. The "ofs" value
determines the number of tracks to· skip when this particular drive is
addressed, which can be used to reserve additional operating system
(All Information Contained Herein is Proprietary to Digital Research.)
30

space or to simulate several logical drives on a single large capacity
physical drive.
Finally, the [0]
parameter is included when file
compatibility is required with versions of 1.4 which have been
modified for higher density disks.
This parameter ensures that only
16K is allocated for each directory record, as was the case for
previous versions.
Normally, this parameter is not included.
For convenience and economy of table space, the special form
DISKDEF

i,j

gives disk i the same characteristics as a previously defined drive j.
A standard four-drive single density system, which is compatible with
version 1.4, is defined using the following macro invocations:
DISKS
DISKDEF
DISKDEF
DISKDEF
DISKDEF

4
0,1,26,6,1024,243,64,64,2
1,0
2,0
3,0

ENDEF
with all disks having the same parameter values of 26 sectors oer
track
(numbered 1 through 26), with 6 sectors skipped between each
access, 1024 bytes per data block, 243 data blocks for a total of 243k
byte disk capacity, 64 checked directory entries, and two operating
system tracks.
The definitions given in the program shown above
(lines 12
15)
provide access to the largest disks addressable by CP/M
2.0. All disks have identical parameters, except that drives 0 and 2
skip three sectors on every data access, while disks 1 and 3 access
each sector in sequence as the disk revolves (there may, however, be a
transparent hardware skew factor on these drives).
th~ough

The DISKS macro generates n "disk header blocks," starting at
address DPBASE which is a label generated by the macro.
Each disk
header block contains sixteen bytes, and correspond, in sequence,
to
each of the defined drives.
In the four drive standard system, for
example, the DISKS macro generates a table of the form:
DPBASE
DPE0:
OPEl:
DPE2:
DPE3:

EQU
OW
OW
OW
OW

$
XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0
XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSVl,ALVl
XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV2,ALV2
XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3

where the OPE (disk parameter entry) labels are included for reference
purposes to show the beginning table addresses for each drive 0
through 3. The values contained within the disk parameter header are
described in detail in the CP/M 2.0 Alteration Guide,
but basically
address the translation vector for the drive (all reference XLT0,
which is the translation vector for drive 0 in the above example),
(All Information Contained Herein is Proprietary to Digital Research.)
31

•

followed by three 16-bi t
"scratch"
addresses,
followed by
the
directory buffer address, disk parameter block address, check vector
address, and allocation vector address.
The check and allocation
vector addresses are generated by the ENDEF macro in the ram area
following the BIOS code and tables.
The SELDSK function is extended somewhat in version 2.0.
In
particular, the selected disk number is passed to the BIOS in register
C, as before,
and the SELDSK subroutine performs the appropriate
software or hardware actions to select the disk.
Version 2.0,
however,
also requires the SELDSK subroutine to return the address of
the selected disk parameter header (DPE0, DPEl, DPE2, or DPE3, in the
above example)
in register HL.
If SELDSK returns the value HL =
0000H, then the BDOS assumes the disk does not exist,
and prints a
select error ~esage at the terminal.
program lines 22 through 36 give
a
sample CP/M 2.0 SELDSK subroutine, showing only the disk parameter
header address calculation.
The subroutine SECTRAN is also included in version 2.0 which
performs the actual logical to physical sector translation.
In
earlier versions of CP/M, the sector translation process was a part of
the BDOS, and set to skip six sectors between each read.
Due
differing rotational speeds of various disks, the translation function
has become a part of the BIOS in version 2.0.
Thus, the BDOS sends
sequential sector numbers to SECTRAN, starting at sector number 0.
The SECTRAN subroutine uses the sequential sector number to produce a
translated sector number which is returned to the SOOS.
The BOOS
subsequently sends
the translated sector number to SELSEC before the
actual read or write is performed.
Note that many controllers have
the capability to record the sector skew on the disk itself, and thus
there is no translation necessary.
In this case, the "skf" parameter
is omitted in the macro call, and SEC/fRAN simply returns the same
value which it receives.
The table shown below,
for
example,
is
constructed when the standard skew factor skf = 6 is specified in ~he
DISKDEF macro call:
XLT0:

DB
OB

1,7,13,19,25,5,11,17,23,3,9,15,21
2,8,14,20,26,6,12,18,24,4,10,16,22

If SECTRAN is required to translate a sector, then the following
process takes place.
The sector to translate is received in register
pair BC.
Only the C register is significant if the sector value does
not exceed 255 (8 = 00 in this case).
Register pair DE addresses the
sector translate table for this drive, determined by a previous call
on SELDSK, corresponding to the first element of a disk parameter
header
(XL'l'0
in the case shown above).
The SECTHAN subroutine then
fetches the translated sector number by adding the input sector number
to the base of the translate taole, to get the indexed translate table
address (see lines 46, 47, and 48 in the above program).
The value at
this location is then returned in register L.
Note that if the number
of sectors exceeds 255, the translate table contains 16-bit elements
whose value must be returned in HL.
areas

Following the ENDEF macro call, a number of
uninitialized data
are defined.
These data areas need not be a part of the BIOS

(All Information Contained Herein is Proprietary to Digital Research.)
32

which is loaded upon cold start, but must be available between the
3IOS and the ena of memory. The size of the uninitialized RAM area is
determined by EQU statements generated by the ENDEF macro. For a
standard four-drive system, the ENDEF macro'might oroduce
4C72

=

4D8k1

=
=

013C

BEGDA'r EQU $
(data areas)
ENDDA'r EQO $
DATSIZ EQU $-BEGDAT

which indicates that uninitialized RAM begins at location 4C728, ends
at 4D80H-l, and occupies 0i3CH bytes. You must ensure that these
addresses are free for us~ after the system is loaded.
CP/M 2.0 is also easily adapated to disk subsystems
size is a multiple of 128 bytes. Information is provided
on sector write operations which eliminates the need
operations, thus allowing olocking and deblocking to take
BIOS level.

whose sector
by the BOOS
for pre-read
place at the

See the "CP/M 2.0 Alteration Guide" for additional details
concerning tailoring your CP/M system to your particular hardware •

•

(All Information Contained Herein is Proprietary to Digital Research.)
33

OPERATION OF
THE CP/M DEBUGGER

I

(

01

[)~[j~Tfll

RESEflR[H

Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896

CP/M DYNAMIC DEBUGGING TOOL
USER'S GUIDE

COPYRIGHT (c) 1976, 1978
DIGITAL RESEARCH

(DDT)

•

Copyright (c) 1976, 1978 by Digital Research. All rights
reserved. No part of this publication may be reproduced,
transmitted, transcribed, stored in a retrieval system, or
translated into any language or computer language, in any
form or by any means, electronic, mechanical, magnetic,
optical, chemical, manual or otherwise, without the prior
written permission of Digital Research, Post Office Box 579,
Pacific Grove, Califcrnia 93950.
Disclaimer
Digital Research makes no representations or warranties with
respect to the contents hereof and specifically disclaims any
implied warranties of merchantability or fjtness for any
particular purpose. Further, Digital Research reserves the
right to revise this publication and to make changes from
time to time in the content hereof without obligation of
Digital Research to notify any person of such revision or
changes.

Table of Contents
Section
I.
II.

Page

INrRODUcrION •
Dur OOMl'lAN'Il3
0

0 0 0

0

•

0 •• 0

0 ••• 0 0

0

0

0

0

0

0 •

0

0 •• 0

0 •••••••••••••••••••••••
•

0 •••••• 0 ••••••••••••

1.
20
3.

The A (Assemble) Command •••••••••••••••••••••
The D (Display) Command ••••••••••••••••••••••
The F (Fill) Command .0 •••••••••••••••••••••••
4. The G (Go) Command ••
50 The I (Input) Command .0 ••••••••••••••••••••••
6. The L (List) Command
7. The M (Move) Command • ••••••••••••••••••••••••
8. The R (Read) Command ••••••••
The S (Set) Command
10. The T (Trace) Command
110 The U (Untrace) Command ••• o.o • • • • • • • • • • • • • • ~.
12. The X (Examine) Command
III. IMPLEMENTATION NOTES ••
IV. AN EXAM.PLE o.
0 0 •

•

0 •

0 •••••••••••••••••••

• • • • • • • • 0000 • • • • • • • • • • • •

0

90

••••••••••••••••

0

0

0 0

•

0 0

•

0

3
3
4

4
4
5
6

6
6

.00 ••••••••••••••••••• 0.

7
7

00.0000 • • • • • • • • • • • • • • •

8
8

0000000000000000 •••• 0.0 •• 0

0

1

000 • • • • 0 • • • • • • • • • • • • • • • • • • •

9

•

10

0 ••••••••• 0 •••••••••••••••

•

CP/M Dynamic Debugging Tool (DDT)
User's Guide
I.

Introduction.

The DDT program allows dynamic interactive testing and debugging of
programs generated in the CP/M environment.
The debugger is initiated by
typing one of the following commands at the CP/M Console Comrrand level
DDT
DDr filename.HEX
DDr filename.COM
¥.here "filename" is the name of the program to be loaded and tested. In both
cases, the DDT program is brought into ·main memory in the place of the Console
Canmand Processor (refer to the CP/M Interface Guide for standard memory
organization), and thus resides directly below the Basic Disk Operating System
portion of CP/M. The BlX)S starting address, ¥.hich is located in the address
field of the JMP instruction at location 5H, is altered to reflect the reduced
Transient Program Area size.
The second and third forms of the DDT command shown above perform the same
actions as the first, except there is a subsequent automatic load of the
specified HEX or (X)M file.
The a.ction is identical to the sequence of
commands
DDr
Ifilename.HEX or Ifilename.COM
R

where the I and R canmands set up and read the specified program to test (see
the explanation of the I and R commands below for exact details).
Upon initiation, DDT' prints a sign-on message in the format
nnK Dor-s VER m.m
where nn is the IlErnary size (which must match the CP/M system being used), s
is the hardware system which is assumed, corresponding to the codes
D
M
I

o
S

Digital Research standard version
MUS version
IMSAI standard version
~on systems
Digital Systems standard version

and m.m is the revision number.

1

•

Following the sign on message, DDT prompts the operator with the character
"-" am waits for input canmaods from the console. The operator can type any
of several single character canmands, terminated by a carriage return to
execute the canmand. Each line of input can be line-edited using the standard
CP/M controls
rubout
ctl-U
ctl-C

remove the last character typed
remove the entire line, ready for re-typing
system reboot

Any commam can b~ up to 32 characters in lenqth (an automatic carriage return
is inserted as the 33rd character), where the first dlaracter determines the
comrnam type
A
D
F
G
I
L
M
R
S
T
U
X

enter assembly language mnemonics with operands
display memory in hexadecimal and ASCII
fill memory with constant data
begin execution with optional breakpoints
set up a standard input file control block
list memory usinq assembler mnemonics
move a memory segment fran source to destination
read program for subsequent testing
substitute memory values
trace program execution
untraced program monitoring
examine and optionally alter the CPU state

The canmam character, in some cases, is followed by zero, one, two, or three
hexadecimal values which are separated by canmas or single blank characters.
All DDT numeric output is in hexadecimal form. In all cases, the commands are
not executed until the carriaqe return is typed at the end of the command.
At any [X>int in the debuq run, the operator can stop execution of DIJI'
usinq either a ctl-C or G0 (jmp to location 0000H), am save the current
memory image usinq a SAVE canmand of the form
SAVE n filename.COM
where n is the number of p3ges (256 byte blocks) to be saved on disk. The
nwrber of blocks can be determined by taking the high order byte of the top
load address am converting this number to decimal.
For example, if the
highest address in the Transient Program Area is 1234H then the nurrber of
pages is l2H, or 18 in decimal. Thus the operator could type a ctl-C during
the debug run, returning to the Console Processor level, followed by
SAVE 18 X.COM
The memory image is saved as X.COM on the diskette, am can be directly
executed by simply typing the name X.
If further testing is required, the
memory image can be recalled bv typinq

2

DIJI' X.COM
which reloads p:eviously saved program from loaction l00H through p:ige 18
(12FFH) • The machine state' is not a part of the COM file, and thus the
program must be restarted from the beginning in order to properly test it.
I I • DIJI' CDMMANDS.
'l'he imi vidual canmands are given below in some detail. In each case, the
operator must wait for the prompt character (-) before entering the command.
If control is p:issed to a lXogram under test, and the program has not reached
a breakr:oint, control can be returned to DIJI' by executing a RST 7 from the
front p:inel (note that the rubout key should be used instead if the program is
executing a T or U canmand). In the explanation of each command, the command
letter is shown in rome cases with nurrbers separated by canmas, \\here the
nurrbers are represented by lower case letters.
These nurrbers are always
assumed to be in a hexadecimal radix, and from one to four digits in length
(longer numbers will be automatically truncated on the right).
Many of the canmands operate ur:on a "CPU state" which corresp:mds to the
program under test.
'I'he CPU state holds the registers of the program being
debugged, and initially contains zeroes for all registers and flags except for
the frogram counter (P) and stack r:ointer (S), which default to l00H.
The
program counter is subseguently set to the starting address given in the last
record of a HEX file if a file of this form is loaded (see the I and R
commands) •
1. The A (Assemble) Command. Dill' allows inline assembly language to be
inserted into the current memory image using the A command which takes the
form
As

where s is the hexadecimal starting cddress for the inline assembly.
DIJI'
prompts the console wi th the cddress of the next instruction to fill, and
reads the console, looking for assembly language mnemonics (see the Intel 8080
Assembly Language Reference Card for a list of mnemonics), followed by
register references and operands in absolut0 hexadecimal form. Each sucessive
load address is printed before reading the console. The A command terminates
when the first empty line is input from the console.
Upon canpletion of assembly language input, the operator can review the
memory segment using the DlJI'disassembler (see the L command).
Note that the assembler/disassembler ]Xlrtion of DIJI' can be overlayed by
the transient program being tested, in which case the DIJI' program restx>nds
wi th an error condition when the A and L commands are used (refer to Section
IV) •

3

•

2. The D (Display) Command.
The D command allows the operator to view
the contents of memory in hexadecimal and ASCII formats. The forms are
D

Ds
Ds,f
In the first case, memory is displayed from the current display address
(initially 100H), and continues for 16 display lines. Each display line takes
the fOrm shown below
aaaa bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb cccccccccccccccc
where aaaa is the display address in hexadecimal, and bb represents data
present in memory starting at aaaa. The ASCII characters starting at aaaa are
given to the right (represented by the sequence of c's), ¥.here non-graphic
characters are fr inted as a };Eriod (.) symbol. Note that both upper and lower
case alphabetics are displayed, and thus will appear as upper case symbols on
a console device that supports only ul;Per case. Each display line gives the
values of 16 bytes of data, except that the first line displayed is truncated
so that the next line begins at an address which is a multiple of 16.
The second form of the D canmand shown above is similar to the first,
except that the di splay address is first set to address s.
The third form
causes the display to continue frOm address s through address f.
In all
cases, the display address is set to the first address not displayed in this
command, so that a continuing display can be accomplished by issuing
successive D canmands with no explicit addresses.
Excessively long displays can be aborted by pushing the rubout key.

3.

The F (Fill) Command.

The F command takes the form

Fs,f,c
where s is the starting address, f is the final address, and c is a
hexadecimal byte constant. The effect is as follows: DDT stores the constant
c at address s, increments the value of s and tests against f. If s exceeds f
then the operation terminates, otherwise the operation is repeated. Thus, the
fill command can be used to set a memory block to a specific constant value.
4. The G (Go) Command. Pro:Jrarn execution is started using the G cornand,
with up to two optional breakpoint addresses. The G command takes one ot the
forms
G

Gs
Gs,b

4

Gs,b,c
G,b
G,b,c
The first form starts execution of the program under test at the current value
of the p::ogram counter in the current rrachine state, with no breakpoints set
(the only way to regain control in DO!' is through a RST 7 execution). The
current p::ogram counter can be viewed by typing an X or XP connnand.
The
second form is similar to the first except that the program counter in the
current rrachine state is set to address s before execution begins. The third
form is the same as the second, except that program execution stops when
address b is encountered (b must be in the area of the program under test).
The instruction at location b is not executed when the breakpoint is
encountered.
The fourth form is identical to the third, except that two
breakpoints are s~cified, one at b and the other at c. Encountering either
break~int causes execution to stop, and both breakpoints are subsequently
cleared. The last blo forms take the program counter fran the current machine
state, and set one and two break~ints, res~ctively.
Execution continues fran the starting address in real-time to the next
breakpoint. That is, there is no intervention between the starting address
and the break address by DO!'. Thus, if the program under test does not reach
a breakpoint, control cannot return to DO!' without executing a RST 7
instruction. Upon encountering a breakpoint, DO!' stops execution and types
*d

where d is the stop address. The rrachine state can be examined at this point
using the X (Examine) connnand o
The operator must s~cify break~ints which
differ fran the p::ogram counter address at the beginning of the G camnand.
Thus, if the current program counter is 1234H, then the commands
G,1234
and
G400,400

both produce an imrrediate breaktx>int,
whatsoever.

without executing

any

instructions

5. The I (Input) Comrrand. The I canmand allows the operator to insert a
file name into the default file control block at SCH (the file control block
created by CP/M for transient p::ograms is placed at this location; see the
CP/M Interface Guide). The default PCB can be used by the p:-ogram under test
as if it hcrl been passed by the CP/M Console Processor. Note that this file
name is also used by DO!' for reading additional HEX and COM files. The form
of the I command is

Ifilename
or

5

Ifilename.filetype
If the second form is used, and the filetype is either HEX or COM, then
subsequent R commands can be used to read the pure binary or hex format
machine code (see the R command for further details).

6. The L (List) Commando The L cormnand is used to list assembly language
mnemonics in a particular pr09'ram region. The forms are
L

Ls
Ls,f
The first canrnand lists twelve lines of disassembled machine code from the
current list address. The second form sets the list address to s, and then
lists twelve lines of code.
The 'last form lists disasserrbled code from s
through address f.
In all three cases, the list address is set to the next
unlisted location in preparation for a subsequent L command.
Upon
encountering an execution breakpoint, the list address is set to the current
value of the };r09'ram counter (see the G and T cormnands). Again, long type outs
can be aborted using the rubout key during the list process.
7. The M (Move) Command. The M command allows block movement of pr09'ram
or data areas from one location to another in memory. The form is

Ms,f,d
where s is the start address of the rove, f is the final address of the nove,
and d is the destination address. Data is first noved from s to d, and both
addresses are incremented.
If s exceeds f then the nove operation stops,
otherwise the rove operation is repeated.
8. The R (Read) Command. The R command is used in conjunction with the I
command to read COM and HEX files from the diskette into the transient pr09'ram
area in };reparation for the debug run. The forms are
R
Rb

where b is an optional bias address Vthich is added to each program or data
address as it is loaded.
The load qJeration must not overwrite any of the
system parameters from 000H through 0FFH (i.e., the first page of memory). If
b is ani tted, then b=0000 is assumed.
The R command requires a };revious I
command, specifying the name of a HEX or COM file. The load address for each
record is obtained from each individual HEX record, Vthile an assumed load
address of 100H is taken for COM files. Note that any number of R commands
can be issued following the I command to re-read the program tmder test,

6

assuming the tested program does not destroy the default area at SCH.
Further, any file s};ecified with the filetype "COM" is aSSLnned to contain
machine code in pure binary form (created with the LOAD or SAVE command), and
all others are assumed to contain machine code in Intel hex format (produced,
for example, with the ASM command).
Recall that the command
DDr

filename.filetype

which initiates the DD[' program is equivalent to the commands
DDr

-Ifilename.filetype
-R
Whenever the R command is issued, DDr responds with either the error indicator
n?n (file cannot be opened, or a checksLnn error occurred in a HEX file), or
with a load message taking the form

NEXT PC
nnnn PWP

where nnnn is the next address following the loaded program, and pppp is the
assumed program counter (100H for COM files, or taken from the last record if
a HEX file is s};ecified).
9. The 5 (Set) Command.
The 5 command allows memory locations to be
examined and optionally altered. The form of the command is
5s

where s is the hexadecimal starting address for examination and alteration of
memory. DDr resp:mds with a numeric prompt, giving the memory location, along
with the data currently held in the memory location. If the operator types a
carriage return, then the data is not altered. If a byte value is typed, then
the value is stored at the prompted address. In either case, DIJI' continues to
prompt with successive addresses and values until either a period (.) is typed
by the operator, or an invalid input value is detected.
10. The T (Trace) Command.
The T command allows selective tracing of
program execution for 1 to 65535 program steps. The forms are
T
Tn

In the first case, the CPU state is displayed, and the next program step is
executed.
The program terminates immediately, with the termination address

7

displayed as
*hhhh
where hhhh is the next address to execute. The display address (used in the D
command) is set to the value of Hand L, and the list address (used in the L
command) is set to hhhh.
The CPU state at program termination can then be
examined using the X command.
The second form of the T command is similar to the first, except that
execution is traced for n steps (n is a hexadecimal value) before a J;X"ogram
breakp::>int is occurs. A breakp::>int can be forced in the trace rode by typing
a rubout character.
The CPU state is displayed before each program step is
taken in trace rode.
The format of the display is the same as described in
the X canrnand.
Note that J;X"ogram tracing is discontinued at the interface to CP/M, and
resumes after return from CP/M to the program under test.
Thus, CP/M
functions which access I/O devices, such as the diskette drive, run in
real-time, avoiding I/O timing problems.
Programs running in trace rode
execute approximately 500 times slower than real time since DDI' gets control
after each user instruction is executed. Interrupt processing routines can be
traced, but it must be noted that canrnands which use the breakpoint facility
(G, T, and U) accomplish the break using a RST 7 instruction, which means that
the tested J;X"ogram cannot use this interrupt location.
Further, the trace
mode always runs the tested J;X"ogram with interrupts enabled, which may cause
problems if asynchronous interrupts are received during tracing.
Note also that the operator should use the rubout key to get control back
to DDI' dur ing trace, rather than executing a RST 7, in order to ensure that
the trace for the current instruction is completed before interruption.
11. The U (Untrace) Command. The U command is identical to the T command
except that intermediate lXogram steps are not displayed.
The untrace rode
allows from 1 to 65535 (0FFFFH) steps to be executed in monitored mode, and is
used J;X" incipally to retain control of an executing program while it reaches
steady state condi tions.
All conditions of the T command apply to the U
command.

12. The X (Examine) Command. The X command allows selective display and
alteration of the current CPU state for the program under test. The forms are
X

Xr
where r is one of the 8080 CPU registers
C
Z

Carry Flag
Zero Flag

(0/1)
(0/1)

8

M
E
I
A
B
D
H
S
P

Minus Flag
Even Parity Flag
Interdigit Carry
Accumulator
BC register pair
DE register pair
HL register p:lir
Stack Pointer
Program Counter

(0/1)
(0/1)
(0/1)
(0-FF)
(0-FFFF)
(0-FFFF)
(0-FFFF)
(0-FFFF)
(0-FFF'F)

In the first case, the CPU register state is displayed in the format

CfZfMfEfIf A=bb B=dddd D=dddd H=dddd S=dddd F--dddd inst
where f is a 0 or 1 flag value, bb is a byte value, and dddd is a double byte
quanti ty corresponding to the register pair.
The "inst" field contains the
disassembled instruction which occurs at the location addressed by the. CPU
state's program counter.
The second form allows display ?ind optional alteration of register values,
where r is one of the registers given above (C, Z, M, E, I, A, B, D, H, S, or
P) •
In each case, the flag or register value is first displayed at the
console. The DDT program then accepts input from the console. If a carriage
return is typed, then the flag or register value is not altered. If a value
in the proper range is typed, then the flag or register value is altered.
Note that SC, IE, and HL are displayed as register p:tirs. Thus, the operator
types the entire register pair when B, C, or the BC pair is altered.
I II. IMPLEMENTATION NarES.
The organization of DDT allows certain non-essential portions to be
overlayed in order to gain a larger transient program area for debugging large
programs. The DDT program consists of two parts:
the Dill nucleus and the
assembler/disassembler nndule.
'rhe DDT nucleus is loaded over the Console
Command Processor, and,
al though loaded wi th the DDT nucleus, the
assembler/disassembler is overlayable unless used to assemble or disassemble.
In particular, the BOOS address at location 6H (address field of the JMP
instruction at location 5H) is nndified by DDT to address the base location of
the DDT nucleus which, in turn, contains a JMP instruction to the BOOS. Thus,
progr ams v.hich use this address field to size !Ternory see the logical end of
memory at the base of the DDT nucleus rather than the base of the BOOS.
The asserrbler/disassembler nndule resides directly below the DDT nucleus
in the transient :program area. If the A, L, T, or X commands are used during
the debugging process then the DDT program again alters the address field pt
6H to include this nndule, thus further reducing the logical end of memory.
If a :program loads beyond the beginning of the assembler/disassembler JIDdule,
the A and L canmands are lost (their use produces a "?" in response), and the

9

•

trace am display (T and X) cormnands list the "instil field of the display in
hexadecimal, rather than as a decoded instruction.
IV.

AN EXM1PLE.

The followin:J example srows an edit, asserrt>le, and debug for a simple
program which reads a set of data values and determines the largest value in
the set. The largest value is taken from the vector, and stored into "IARGE"
at the termination of the p:ogram

; TO NEln ELEMENT
il10RE TO SCAtP 3
i

1

; .

2.~
i J

VEeT:
LEH
LARGE:

~*B0P
-,)

HFOUHD:

J

END OF SCAN .• STORE C"
iGET LARGEST VAL'IE
!iQY..
B..::.f
L -.
LARGE
.§.l8..
1
;REBOOT J
.JL
ill
l!,g

~
!.§.

SOU(Qe.

'P{~V().tM.. ~ l!w!e,(H4~

C~a (o.clef's 'bl'~c{

~ 1NCJ8Y"o.rYLm.e(
II II yePf~-h f{.1(fio j e.
J
(t-kt(1I\, .

TEST DATA
2 .. 0 .. 4,3,S,6 .. 1 .. 5 J
{-VECT
iLENGTHJ
~
iLARGEST

VALUE ON EXIT)

..ill!,2
ORG
"'VI

LOOP:

FOR A14 Q THE R.1

CV'l!ol-e

le0H
B,LEN

MYI

c,e

LXI

H.YECT
A.M

iSTART OF TRANSIENT AREA
iLEHGTH OF VECTOR TO SCAN
iLARGEST VALUE SO FAR
iBASE OF VECTOR
;GEl YALUE

MOY
SUB

C

i

JNC

NFOUHD

;JUMP IF LARGER VALUE NOT FOUND

LARGER YALLIE INC?

HEIII LARGEST VALUE, STORE I T TO C
MOil
C.' A
INX
H
;TO NEXT ELEMENT
DCR
B
iMORE TO SCAlP

JNZ

LOOP

; FOR AI40THER
10

END OF SCAN .. STORE C
MOY
A,C
;GET LARGEST VALUE
STA
LARGE
..IMP
(3
j REBOOT
VECT:
LEN

TEST DATA
2 .. 0,4 . 3,5,6 . 1 .. 5
DB
EQU
$-YECT
.;LENGTH

LARGE:

DS

ILARGE5T VALUE

ENII
'~~

Ot~

EX IT

~~d. of tdlt

4--

CP/M ASSEMBLER - VER 1.0
[11

22

002H LISE FACTOR
ENII OF ASSE~lBL'y'
TYPE SCAI4.

-

CodeW{~
e 10 €I

PRI~

Mo.~mt

J

( Sou(re ;RC8~GM

Cock

~

01130 BGes,)

ORG
~1Il I

0102 3E00

Mil I

0104 211901
0107 7E

un
LOOP:

MOil

0108 91

SUB

13109 D20DBl

.IN C

010C 4F
0UlD 23
010E 135

NEt"
~10 V

NFOUIH:

It4~:

nCR

;START OF TRANSIENT AREA
;LENGTH OF VECTOR TO SCAN
;LARGEST VALUE 50 FAR
ce
H, 'liE C 'T.
,; BI~SE OF VECTOR
I~,M
JGET VALUE
C
;LARGER VALUE IN C?
NFOUND ;JUMP IF LARGER VALUE NOT FOUND
LARGEST VALUE, STORE IT TO C
(:, A
H
;TO NEXT ELEMENT
B
;MORE TO SCAN?
LOOP
;FOR ANOTHER
100H

B)

LE I~

010F C20781

IN Z

0112 79
0113 3221B1
13116 C3~.~0~ I'

END OF SCAN, !::TORE C
MOV
A., C
.• LiET LARGEST VALUE
STA
LARGE
JMP
0
;REBOOT

CcJe./dak IU;\1Y1J

;

i"Yu«altcf "--"f;

TEST DATA

0119 B200040305YECT:

DB

2,0,4 .. 3 .. 5;6,1,5

003 8 =

LEN

0121

LARGE:

EQU
DS
END

$-VEeT
1

e 122

Fi>

<:2\
Va\ueq.J
fqLUrk

It

;LENGTH
;LARGEST YALUE ON EXIT

DDT SCAN. HEX

~

161< DDT VER 1.0
NEXT PC

~ ~ 21\1.....8_°_°_0_ _ lQ..lbt

lood CAdMe5~ -I- I

r-ktd-l~
-IfI e)(l ((Lit a.t

-~

f.

CeZ0MBE0I0 A=00 8=0080 D=@00e H=0000 8=0100 P=0000 OUT

-XP

7F

?CeO

~ ~J(o.W~ I(~l~~ loJOie de~"e> YU~

-J

p=ee0Et 1013

-~

C.!.Lttnjt

\.oJL at

-~J

'PC- -\0 lOO

.rPc. cLA"-~d.

VlslSb-6 qfJCt\;'"

C0Z0MBE010 A=00 B=0000 D=0000 H=0000 8=0100 F'=0 Hie MVI
-L100",

B,0S)

~ 1\t4vurkV\

0100

M'JI

B,€I8

0102

M'II I
LXI
MOl!

(:,00

0104
0107
010S
13109
0leC
el0D

SUB

JHC
MOil
I NX
DCR

-to 6ceack crl Pl~\OO

H .. 0119
A .• M

C
010D
CIA

1) ~~~!,J M/lc1.I~t
Code a~ l{X)~
~et 'StlJict l.L~h~

JHZ
MOil

H
B
0107
A .• C

i!t113

STA

€I12i

0116

JMP

0080

0119
011A

BTAX

B

NOP

011 B
13 1 1 C

:!~ ~

I NR
I N~:

B
B

~~~ ~. 0 1

€I 121

II CR
L XI

B
If, 2 2 1 H l ' u

13124

LXI

H,e200

li 1 €IE
e10F

e 112

O(~lSO~

-L

-~

a1 2 e

A lrlte. Wl)ye..

V'Aadt lYle Code.
(~ ~ t'(q9m YY\

e.wk, a1 l~c.o:Mn lib

_

\

UJl'UAQ~Up+oncooJ

.

. '

'.

e\\..Ie.i 'I\\l~ a~se~~~ \'nod~ 10 e~ 4t:Jt..tf ~ OOQ) I~ (). ~1 1, W~I(1
-R~T "'{
~ILl CclltSe, -tk Y{~YClY1A UVtdu -f-cot -to '(e.~VV\. it> nvr It \\b\4

-.!Ull
0116

-

o1 17~ 'L&.II~j~(
- L 11 3"

ust

l~ eVcw e~c.ukd.

rI

Ca'lyt'4jC

Ctxif

yttu.(\\ ~-toVS a~seW\1Je mod.eJ

at l\'3~ 40 dAtJ 4WJ ~'S11 was 1iY~c(~ \n~
~ I~ place cr J'M f

o1 1 3

ST A

€I1 2 1

0116

RST

B7",...-'

0117
8118
8119
ellA
ellB
BllC

HOP
NOP
STAl< B

NOP
IHR
IHX

B
B
,

-It ~

loct a\

VCj lst(S

C0Z0MBE010 A=00 B=00B0 D=B000 H=0000 8=0100

-Lt1

&ecu:1c ?vO~(a~ --f"

ceZ0M0E010 A=0B 8=00130

-l.J lrtu Odt -ip ~;\1 (M{

Oy\L

B.0S

J

H=0008 8=0100 P=0100 MY]

B.08*0102

aLCblJWlitL ~{~kpj)\~t

oru

,on ,g)
C0Z0MBE0I0 A=0B B=0800 D=0000 H=0000 8=0100

-L; IVtXe

MVI

i~L~1 CRu cs-ht-le.. ~erv(€ J J\ ~ecu.kd

"Skf.

D=~0B0

P~0100

P~0102

MYI

.J

C.00*0104

CIJo.~\f\ (\(~\~~ C ~~ d(1(A(tdJ

C0Z0M0E0I0 A=00 8=0800 D=0000 H=0000 8=0100 P=0104 LXI

H.0119*019?

-llr1\racl. 1"t1vt't ~k{1s
C0zeMBE010 A=Be 8=08130
cezeMBE0I0 A=B2 B=0800
C0Z0MEtE0Il A=Et2 B=08e0
-DI1Q'
~~.
--=-J 'OlSQto:1 Mt'MfH,S
'( ~
e 119 02 IHI 04- 03 05 06
0120 0S 1 1 BB 22 21 130
13130 C2 27 01 C3 03 29
0140 00 00 00 00 00 130
0150 00 00 00 0111 00 130
01613 130 09 00 00 00 90
01713 130 B0 00 e0 00 00
0180 00 00 00 013 00 130
019B 00 00 00 013 130 130
BIAe B0 00 00 013 130 00
e180 130 fJ0 00 eB 0e 00
Ble0 130 130 00 013 130 00

-x-J

Cu«~

D=0000 H=0119 8=@100 P=01B7 MOV
D=B000 H=01l9 S=01B0 P=0108 SUB
D=IH3e0 H=0119 8=01013 P=0109 JHC

7E
00
00
00
00
00
e0
130
8fJ
B13
€Ie

EB
90
013
130
013

0e
00
00
00
00
013

77 1 3 23 EB 0B

013
00
0fJ
0fJ
efJ
0fJ
00
00
00
013

0B e0 BB
00 00 00
00 130 B0
00 00 00
130 e0 e0
130 €Ie 00
00 00 130
Be fJ0 €Ie
00 fJ0 00
130 00 00

013
013

130
013

013
013
013
00
130

0111

00

€Ie D.~ ~ di~V~{d:
0

-us

A=02
R=02
A=B2
A=02
R=0B

0

of

0

0

ClI..((e..rt

B=08e0
B=08e0
8=07139
B=0700
8=8700

0

0

••

0

0

~

H

CPU sk.tc,

D=13 13 BB
D=B000
D=000e
D=0000
Il=B000

H=0119
H=011A
H=011A
H=011A
H=011A

8=0100
8=0100
S=0100
8=B100
8=0100

P=010D
P=010E
P=010F
P=01B7
P=0108

0

: :: : ::

0

CPu. 4.-\e, ),

-reate s stps ~y~

C0Z0MBE0Il
(:0Z0MBE0Il
C0Z0MBE0Il
C0Z0MBE011
C0Z0M0E011

: ::

o ~ 1AIt'ttr 11:I" •.
00 · l\t:
00
130 °l\A. ~ p~l"bo~
00 :v\o~:'-6"Op~~l:
00 elAoraUcf'$
B0 · ............ , ..
B0 · . . . . . . . . . . . . . .

C0ZEtM0E0Il A=02 8=0800 D=0e0B H=0119 8=0100 P=010D I N)<:
- T S"j

010D*010D

6.t.r\o~ buak'Po,rtr tA1 jOD~--'

crt IIqH.
01 ~~~D:~~~
02
00
0.0
00
00
00
130
00
fJ0
fJ0
fJ0

Ao' M
C

INX
DCR

JHZ
MOil
SUB

H
B

A~~-lti.

g"""i..ct

oI
A.M
C:to01B9

- I "tract \.iIl~~O\)-\ \lcfu~ ~\4.:b~.E!d ltdt, ~ks
0

ceZ1MBE111 A=00 B=871HI D=B000 H=011A 8=B100 P=0109 JHC

010D*0108

-K.J CPu. ~k ~t llA&of l.lS I
C0Z0MBE111 A=04 8=0680 D=B0Be H=011B 8=0100 P=0108 SliB

C

•

-§...;

* €I 1 i 6

- ~-i

\?Url

?rDjraY'\

-ttt:W\ CLtfYO.l-t 'Pc \Al\.-nl C/J~~le.hb~ (l~ ~-·h~e.)

YJtettk.poiJ Clt ll6~ J COJAf,ltl ~ ~-k~ R<5T 1 \~ ~lt(~e. &d~

C1u ~k at

ew)..

of p~~m

ceZlMBElIl A=00 8=0000 D=8000 H=@121
-

8=0100 P=0116 RST

07

~l l)c£l.~l~ o.vr1 C,\.wt~l 'Qf~~'()\ Col.t~te<

P=0116 IB0;

-X
-J
ceZlMBElIl A= €I 0 8 = 0 €I 0 €I II =1:1 €I 13 €I H=€I 1 21
-T10~

-rw

ltr
P:=fi~f'0

lO (k~~t) ~s ,fl~t dJ1 ~~tl\,{ ~~

C0Z1MBEIIl
C0Z1MBEIIl
C0Z1MBEIIl
C0Z1MBEIIl
ceZlMBElIl
C0Z0MBE011
C0zeMBE0Il
C0Z0MBE011
C0Z0MBE0Il
C0Z0MBE011
C0Z0MBE0Il
C0Z1MBEIIl
C0Z1MBEIIl
C0Z1MBEIIl
ceZ0M0El11
ceZBM0El11
-A109

R=1:I0
A=0e
A=00
A=00

A=@

A=82
A=B2
A=02
A=02
A=02
A=00
A=00
A=00
A=00
A=013
A=00

8=000€t
8=08013
8=080
B:- ~
=0-e
8=088e
8=0800
8=0800
9=07B13
8=07013
8=137"013
8=€I7B13
B=070e
8=07013
B=1l160e
8=06813

II=0
0
[I 800
=0000
II=
=0000
[I=Ba0e
['=0000
D=000e
II=000B
D=B0e0
II=000e
I'=0000
D=000e
II=€t000
D=0€100
It=0e00

i

S::: €I 1 €I 0 p:= III i 013 MV I ... B., ~8

H=0121 8- .le0
8=0100
8=0100
H=€1119 :::=0100
H=0119 8=0100
H=0119 8=0100
H=e119 8=e100
H=011A 8=0100
H=011A 8=01130
H=011A 8=01130
H=011A 8=0100
H=el1A S=€t100
H=el1A ::;=01013
H=011B 3=13100
H=€tl1B 3=0100
H=0118 S=13100

i6K DDT VER

- L 1 (

A=Be
A=00
A=0B
A=Bf:I
A
A=B2
A=B2
A=82
A=B2
A=B2
A=82
A=B0
A=FE
A=FE
A=FE
A=FE
B~

8=BeEtB
B=88BB
8=138BI:1
8=flSB0
B=e8B~

B SBEt
8=B BEt
8=8 B

D =8 €I

0~

H=000~

D=8f:10B
D=Eteee
D=8f:10B
D=Bee'3
D=Be
D- ee
D=8e0e
D=BeeB
D=B008
D=B0 ee
D=BB 0e
D=13 e ae

H=e0ee
H=IHHH3

H=0119
H=011A
H=011A
H=011A

B=97132
8=B7B2
H=~11A
8=8782
H=0i lA
8=8702 D=iHHH~ H=011A
8=8702 D=B00e H=0t18
8=8602 D=BIHtB H=€illB

s=e10e
8=Blt10
8=01ee
8=0100
S=01B0
8=0100
8=0100
~3=B100

:3=0100
:3=0108
:3=0100
8=0100

=i'11e0
P=B102
P=BIB4
p=131e7
P=i"H 08
P=BIB9
p=Blec
P='310D
P=B10E
P=018F
P=€'lB7
P=01B8
P=BIB9
P=8UH
P=81BE
P=8tBF

~R>~

CIZ0MBEIIl A=FE
-G .. 108 cl

B~06B2

12UV\ -f~M

D=0eee H=8118 8=Bla0 P=0107

CUtv(/A.t

'Pc.

aYlJ Iovettkpo~~

.
J~ex± ~J~

*0108

-K i

at

1'\',1}
/'1',1}

L XI
I'I0Y

~l~k

-J

J

c.; B0
H.• B119
R .• I'I

SUB
JC

C

I'I0Y

C.' A
H
B

INX
DCR
•...1

HZ

BleD

BIB7

!'lOY

Ad'!

SUB
JC
INX

C
01l!lD
H

DCR

B

JNZ

01137*0107

Jief Ib~
~OY

A,M

I~H

CIZEtMBEIIl A=84 8=8602 D =8 e 00 H=0118 8=13100 P=0108 SUB

-T

8 B8

sq fO( a. few ~d~

r

'"'

CIZ0M0EIIl A=Et4 B=0682. D=Beee H=01 i8 S=01e0 P=B1B8 SUB
-T

C*0189

C0ZEtl1BE0Il A=B2 8=8682 D=iHHI€1 H=01 i8 8=01013 P=€ili'19 JC

BleD.BleC

-tl

-X

-ti

CeZEtMBE0Il A=02 8=0682 D=BBe0 H=elll8 8=13100 P=010C MOY

- G;;
II:

t<~

-\0

C,A

&(r\pleh~

0116

-'!:..J
CeZlM0ElIl A=03 B=0083 D=6B08 H=0121 S=0100 P=0116
- .§.ll1~ look. tXt
\k).llU'cf 1\ LAf(;€ 1/

-t\Ae

8 1 21

83"

WV(ft'l'; \,Ulllt- /

RST

07

8123
8124 21.1
012500t

il 126 B 2J

t~d &-II.t S

/

c"MYIIO..J

01277E~~

-l100

-~

0100
0102
0104
0107
0108
0109
010C
e10D
010E
010F
0112

MYI
MVI

LXI

c,ee
H,0119

MOV

A .• M

SUB

C

JC
MOV

INX

el0D

c, A

~

DCR

H
B

JHZ

0107

MOV

-L
-J
0113
0116

STA
RST

0117

NOP
HOP

0118
0119

8121
87

STAX B

ellA

NOP

i311B

INR
INX

B
B

DCR

B
B,81
B

01lC

1311£1
011E
£1120

-xp

MYI
DCR

-~

P =0 1 1 6 1 £I €I

-J

Qeset ~e 'Pc.

-1.; S\~lt"S\w I

lb'ld

~d,l

dak

Vo..llt25

ceZ1M0EIIl A=e3 8=00133 D=0e00 H=0121 8=9100 P=0100 MVI
-T

8 .. 138*0102

C0Z1MeEII1 A=03 8=08133 D=B009 H=9121 S=0100 P=01(12 MVI
-T
COI.I.t\+ DDT S CAN. COM e7

16K DDT \o'ER 1. €I

NEXT

PC

£1200 e100

-~-

P=01

e0~

- .!:...!..l.§..?
0116
0117
0118
0119
0l1A

RBT

97

HOP
HOP

STAX B

look- a.t ~

HOP

(lO\\g

+0 ~e 'tf

i+

WCts

\'''D?&~ LDct&.ed

1h~Ou.t alo~t Ull~ YoJoM)

- (~~0Ckt)

- G., 1.1 () i

((U~ ~V{N\Il

lo()\.t +0

(tYl\vlt+l6~

HI116

-~~
Ci

loo~ Qt Cc,~ (c.ctLde~1 bpO)

~

. -15..i

loot a.t

C.fu. ~L

CIZIM0E111 A=06 B=0006 D=0000 H=0121 8=0100 P=0116 RST

-~~ loo~ at'"
0121

La'fjt.. 0

-

it afP(d{S +0 ~ Csrrtct

B6J

£1122 00 J

0123 22

e';

ED SCAN. ASM

---~-;

;LARGER VALUE IN C?
;LARGER VALUE IN C?
NFOUND

;JUMP IF LARGER VALUE NOT FOUND

NFOUND

iJUMP IF LARGER VALUE NOT FOUND

I 'i

07

til 22:

0€12H USE FACTOR
fN:O

OF

ASSEMBLY

i 61< II[1T "iER
IiE:X:T
PC
~j121
0000

1.

~3

-Ll1\;

o1 it:

,.11'1 P

£1119

STA~:

€lilA
NOP
(1118
INR
_. (y~)

-G100, i
>I;

(111 6

16,.,

\3 00 0
B

ckeck -\0

f.JASuVt

t~cllS <;-t-°lll

ttt II b~

8

Go -trCMA klj~""V\o\~j Wl~ IoY(tt~vo',~t t4± ewi

loveo.~P{)l~ r!O.C~ed

:::~ ~2~:~ E~~7CA:7~

EB 08 78

B1

0130 C2 27 01 C3 03 29 00 00 00 00 00 o €i 8€1 0E! t10 00
0140 00 00 00 00 00 00 00 00 00 00 00 00 813 0f:t I!:H} 00

- LYL'olo.l.lt)

.

~

"!
)

Ill. i .
)

..

,','

•

OPERATION OF
THE CP/M ASSEMBLER

UI

[]~[j~Tfll

RESEflR[H

Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896

CP/M ASSEMBLER

(ASM)

USER'S GUIDE

COPYRIGHT (c) 1976, 1978
DIGITAL RESEARCH

Copyright (c) 1976, 1978 by Digital Research. All rights
reserved. No part of this publication may be reproduced,
transmitted, transcribed, stored ina retrieval system, or
translated into any language or computer language, in any
form or by any means, electronic, mechanical, magnetic,
optical, chemical, manual or otherwise, without the pritional decimal integer value representing the source
program line number, which is allowed on any source line to maintain
compatibili ty wi th the Processor Technology format.
In general, these line
nurrbers will be inserted if a line-oriented editor is used to construct the
original program, and thus ASM ignores this field if present.
The label field takes the form
identifier
or
identifier:
and is optional, except where noted in particular statement types.
The
identifier is a seguence of alphanumeric characters (alphabetics and numbers),
where the first character is alphabetic.
Identifiers can be freely used by
the programmer to label elements such as program steps and assembler
directives, but cannot exceed 16 characters in length.
All characters are
significant in an identifier, except for the embedded dollar symbol ($) which
can be used to improve readability of the name.
Further, all lower case
alphabetics become are treated as if they were upper case. Note that the ":"
following the identifier in a label is optional (to maintain compatibility
between Intel and Processor Technology)
Thus, the following are all valid
instances of labels
0

x
x:

xy

XIY2

Xlx2

yxl:

long$name
longer$named$data:
x234$5678$9012$3456:

The operation field contains either an assembler directive, or pseudo
operation, or an 8080 machine operation code.
The pseudo operations and
machine operation codes are described below.
The ·operand field of the statement, in general, contains an expression
formed out of constants and labels, along with arithmetic and logical
operations on these elements. Again, the complete details of properly formed
expressions are given below.
The canment field contains arbitrary characters following the .. i" symbol
until the next real or logical end-of-line.
'rhese characters are read,
listed, and otherwise ignored by the assembler.
In order to maintain
compatability with the Processor Technology assembler, the CP/M assembler also
treat statements v.hich begin with a "*" in column one as comment statements,
which are listed and. ignored in the assembly process o Note that the Processor

3

•

Technology assembler has the side effect in its operation of ignoring the
characters after the operand field has been scanned. This causes an ambiguous
situation when attempting to be compatible with Intel's language, since
arbi trary expressions are allowed in this case.
Hence, programs which use
this side effect to introduce corrunents, must be edited to place a "; before
these fields in order to assemble correctly.
II

The assembly language program is formulated as a sequence of statements of
the above form, terminated optionally by an END statement.
All statements
following the END are ignored by the assembler.
3.

~

FORMING THE OPERAND.

In order to completely describe the operation codes and pseudo operations,
it is necessary to first present the form of the operand field, since it is
used in nearly all statements.
Expressions in the operand field consist of
simple operands (labels, constants, and reserved words), combined in properly
formed subexpressions by arithmetic and logical operators.
The expression
computation is carried out by the assembler as the asserrbly proceeds.
Each
expression must produce a 16-bit value during the assembly.
Further, the
nurrber of significant digits in the result must not exceed the intended use.
That is, if an expression is to be used in a byte nove immediate instruction,
then the most significant 8 bits of the expression must be zero.
The
restrictions on the expression significance is given with the individual
instructions.
3.1.

labels.

As discussed above, a label is an identifier which occurs on a particular
statement.
In general, the label is given a value determined by the type of
statement which it precedes.
If the label occurs on a statement which
generates machine code or reserves memory space (e.g, a MOV instruction, or a
DS pseudo operation), then the label is given the value of the program address
which it labels. If the label precedes an EQU or SE'I', then the label is given
the value which results from evaluating the operand field. Except for the SET
statement, an identifier can label only one statement.
Wnen a label appears in the operand field, its value is substituted by the
assembler. 'l'his value can then be combined with other operands and operators
to form the operand field for a particular instruction.
3.2.

Numeric Constants.

A numeric constant is a l6-bi t value in one of several bases. The base,
called the radix of the constant, is denoted by a trailing radix indicator.
The radix indicators are
B

o

binary constant (base 2)
octal constant (base 8)

4

Q

o
H

octal constant (base 8)
decimal constant (base 10)
hexadecimal constant (base 16)

Q is an alternate radix indicator for octal nuOOers since the letter 0 is
easily confused with the digit 0.
Any numeric constant which does not
terminate with a radix indicator is assumed to be a decimal constant.

A constant is thus comp:>sed as a sequence of digits, followed by an
optional radix indicator, vvhere the digits are in the appropriate range for
the radix. That is binary constants must be composed of 0 and 1 digits, octal
constants can contain digits in the range 0 - 7, vvhile decimal constants
contain decimal digits. Hexadecimal constants contain decimal digits as well
as hexadecimal digits A (100), 8 (110), C (120), 0 (130), E (140), and F
(150) •
Note that the leading digi t of a hexadecimal constant must be a
decimal digi t in order to avoid confusing a hexadecimal constant with an
identifier (a leading 0 will always suffice).
A constant comp:>sed in this
manner must evaluate to a binary nurrber which can be contained within a 16-bit
counter, otherwise it is truncated on the right by the assembler. Similar to
identifiers, imbedded "$" are allowed wi thin constants to improve their
readabili ty.
Finally, the radix indicator is translated to upper case if a
lower case letter is encountered.
The following are all valid instances of
numeric constants

1234
1234H
33770
3.3.

12340
0FFEH
0fe3h

11008

1111$0000$1111$00008
33$77$22Q
0ffffh

33770
1234d

Reserved Words.

There are several reserved character sequences which have predefined
meanings in the operand field of a statement. The names of 8080 registers are
given below, which, when encountered, produce the value shown to the right
A

7

8
C

0
1
2
3
4

D

E
H

L

5

M

6
6
6

SP
PSW

(again, lower case names have the same values as their upper case
equivalents). Machine instructions can also be used in the operand field, and
evaluate to their internal codes. In the case of instructions which require
o-perands, where the s-pecific operand becomes a p3.rt of the binary bit pattern

5

oF- -rite instruction (e.g, IDV A,B), the value of the instruction (in this case
is the bit p3ttern of the instruction with zeroes in the optional fields
(e.g, IDV produces 40H).
When the symbol "$" occurs in the operand field (not irrbedded within
identifiers and numeric constants) its value becomes the address of the next
instruction to generate, not including the instruction contained wi thing the
current logical line.

MJV)

3.4.

String Constants.

String constants represent sequences of ASCII characters, and are
represented by enclosing the characters wi thin apostrophe symbols (').
All
strings must be fully contained within the. current physical line (thus
allowing "!" symbols wi thin strings), arrl must not exceed 64 characters in
length. The apostrophe character itself can be- included within a string by
representing it as a double apostrophe (the two keystrokes "), which becomes
In nost cases, the string
a single apostrophe when read by the assembler.
length is restricted to either one or two characters (the DB pseudo operation
is an exception), in which case the string becomes an 8 or 16 bit value,
respectively. Two character strings become a 16-bit constant, with the second
character as the low order byte, and the first character as the high order
byte.
The value of a character is its corresponding ASCII code.
There is no
case translation within strings, and thus both upper and lower case characters
can be represented.
Note however, that only graphic (printing) ASCII
characters are allowed within strings. Valid strings are
, c'

'AB'

, , , II '

a
'Walla Walla Wash. '
'She said "Hello" to me. '
'I said "Hello" to her.'
3.5.

Arithmetic and Logical Operators.

The cperands described above can be combined in normal algebraic notation
using any canbination of properly formed
operands,
operators, and
parenthesized expressions. Tqe operators recognized in the operand field are

a +b
a - b
+b

-b

a

*

b

a / b
a IDD b
Nor b

unsigned arithmetic sum of a and b
unsigned arithmetic difference between a and b
unary plus (produces b)
unary minus (identical to 0 - b)
unsigned magnitude multiplication of a and b
unsigned magnitude division of a by b
remainder after a / b
logical inverse of b (all 0's become l's, l's
become 0's), where b is considered a 16-bit value

6

a
a
a
a

AND b

OR b
XORb
SHL b

a SHR b

bit-by-bit logical and of a and b
bit-by-bit logical or of a and b
bit-by-bit logicl exclusive or of a and b
the value which results from shifting a to the
left by an amount b, with zero fill
the value which results from shifting a to the
right by an amount b, with zero fill

In each case, a and b represent simple operands (labels, numeric
constants, reserved words, and one or two character strings), or fully
enclosed parenthesized subexpressions such as
10+20
10h+37Q
Ll /3
(L2+4) SHR 3
('B' +B) OR (PSW+M)
( 'a' and 5fh) + '0'
(1+(2+c)) shr (A-(B+l))
Note that all canputations are ~rformed at assembly time as 16-bit lll1signed
operations. Thus, -1 is canputed as 0-1 which results in the value 0ffffh
(i.e., alII's).
The resulting expression must fit the O?eration code in ,
which it is used.
If, for example, the expression is used in a ADI (add7 ' ' 'J m.;Sr
immediate) instruction, then the high order eight bits of the expression mustS r;7~;" ,)/).:'be zero. As a result, the operation "ADI -I" produces an error message (-1 .!:?yrrt l0H. The statement defining TTY could be changed
to
TIY

EX;)U

FALSE

and, in this case, the p:ogram would assemble for a CRT based at port 20H.
4.6.

The DB Directive.

The DB directive allows the programmer to define initialize storage areas
in single p:ecision (byte) format. The statement form is
label

DB

e#l, e#2, ••• , e#n

v.here e#1 through e#n are either expressions which evaluate to 8-bit values
(the high order eight bits must be zero), or are ASCII strings of length no
greater than 64 dlaracters. There is no practical restriction on the nurrber
of expressions included on a single source line.
The expressions are
evaluated and placed sequentially into the machine code file following the
last program address generated by the assembler.
String characters are
similarly placed into memory starting with the first character and ending with
the last character. Strings of length greater than two characters cannot be
used as operands in more complicated expressions (i.e., they must stand alone
between the commas).
Note that ASCII characters are always placed in memory
with the p3.rity bit reset (0). Further, recall that there is no translation
from lower to u}:Per case wi thin strings. The C{)tional label can be used to
reference the data area throughout the remainder of the program. Examples of

11

valid DB statements are
data:

DB
DB

signon; DB
DB
4.7.

0',1,2,3,4,5
data and 0ffh,5,377Q,1+2+3+4
'please type your name',cr,lf,0
'AB' SHR 8, 'C', 'DE' AND 7FH

The DW Directive.

The DW statement is similar to the DB statement except double precision
(two byte) words of storage are initialized. The form is
label

DW

e#l, e#2, ••• , e#n

where e#l through e#n are expressions which evaluate to 16-bit results. Note
that ASCII strings of length one or two characters are allowed, but strings
longer than two cilaracters disallowed.
In all cases, the data storage is
consistent with the 8080 processor:
the least significant byte of the
'expression is stored forst in rremory, followed by the most significant byte.
Examples are
doub:

ow
DW

4.8.

0ffefh,doub+4,signon-$,255+255
'a', 5, 'ab', 'CD', 6' shl 8 or 110

'rheDS Directive.

'l'he DS statement is used to reserve an area of unini tialized memory, and
takes the form
label

os

expression

where the label is optional. The assembler begins subsequent code generation
after the area reserved by the DS.
'lhus, the DS statement given above has
exactly the same effect as the statement
label:

5.

EOU
ORG

$
iLABEL VALUE IS CURRENT mDE LOCATION
$+expression
iMOVE PAST RESERVED AREA

OPERATION cxmES.

Assembly language operation codes form the principal part of assembly
language programs, am 'form the operation field of the instruction.
In
general, AEM accepts all the standard mnemonics for the Intel 8080
microcomputer, Yilich are given in detail in the Intel manual "8080 Assembly
Language Programmim Manual." Labels are optional on each input line and, if
'included, take the' value of the instr;uction address immediately before the
instruction is issued.
The individual operators are listed breifly in the

12

following sections for completeness, although it is understood that the Intel
manuals should be referenced for exact operator details. In each case,
e3

represents a 3-bit value in the range 0-7
which can be one of the predefined registers
A, B, C, D, E, H, L, M, SP, or PSW.

e8

represents an 8-bit value in the range 0-255

e16

represents a l6-bit value in the range 0-65535

which can themselves be formed from an arbitrary combination of operands and
operators.
In some cases, the operands are restricted to p3.rticular values
wi thin the allowable range, such as the PUSH instruction. These cases will be
noted as they are encountered.
In the sections \'oihich follow, each operation codes is listed in its most
general form, along wi th a s};ecific example, wi th a short explanation and
special restrictions.
501.

Jumps, Calls, and Returns.

The Jump, Call, am Return instructions allow several di fferent forms
which test the condition flags set in the 8080 microcomputer CPU. The forms
are
JMP
JNZ
JZ
JNC
JC
J:EO
JPE
JP
JM

e16
e16
e16
e16
e16
e16
e16
e16
e16

JMP Ll
JMP L2
JMP l00H
JNC Ll+4
JC L3
Joo $+8
JPE L4
JP GAMMA
JM al

Jump
Jump
Jump
Jump
Jump
Jump
Jump
Jump
Jump

unconditionally to label
on non zero condition to label
on zero condition to label
no carry to label
on carry to label
on parity odd to label
on even parity to label
on positive result to label
on minus to label

CALL
CNZ
CZ
CNC
CC
CPE
CP
CM

e16
e16
e16
e16
e16
e16
e16
e16
e16

CALL Sl
CNZ S2
CZ
l00H
mc 81+4
CC
S3
COO $+8
CPE S4
CP GAMMA
CM bl$c2

Call
Call
Call
Call
Call
Call
Call
Call
Call

subroutine
subroutine
subroutine
subroutine
subroutine
subroutine
subroutine
subroutine
subroutine

RST

e3

RST

Programmed "restart", equivalent to
CALL 8*e3, except one byte call

COO

0

13

Lmconditionally
if non zero flag
on zero flag
if no carry set
if carry set
if parity odd
if parity even
if positive result
if minus flag

•

RET

Return
Return
Return
Return
Return
Return
Return
Return
Return

RNZ

RZ
RNC

RC
RPO

RPE
RP
RM

5.2.

from subroutine
if non zero flag set
if zero flag set
if no carry
if carry flag set
if parity is odd
if p3rity is even
if positive result
if minus flag is set

Immediate Operand Instructions.

Several instructions are available which load single or double precision
registers, or single precision memory cells, with constant values, along with
instructions which ~rform immediate arithmetic or logical operations on the
accumulator (register A) •
MVI e3,e8

t-lVI

ADI
ACI
SUI
SBI
ANI

ADI
ACI

B,255

Move immediate data to register A, B,
C, D, E, H, L, or M (memory)
I
Add immediate operand to A without carry
0FFH
Add immediate operand to A with carry
Subtract from A without borrow (carry)
L + 3
L N'JD 11B Subtract from A with borrow (carry)
$ AND 7FH Logical "and" A with immediate data
1111$0000B "Exclusive or" A with immediate data
L AND 1+1 Logical "or" A wi th immediate da ta
a
Compare A with immediate data (same
as SUI except register A not changed)

e8
e8
e8
e8
e8
XRI e8
ORI e8
CPI e8

CPI

LXI e3,e16

LXI B,100H

5.3.

SOl
SBI
ANI
XRI
ORI

Load extended immediate to register pair
(e3 must be equivalent to B,D,H, or SP)

Increment and Decrement Instructions.

Instructions are provided in the 8080 repetoire for incrementing or
decrementing single and double precision registers. The instructions are

5.4.

INR e3

INR E

OCR e3

OCR A

INX e3

INX SP

OCX e3

OCXB

Single precision increment register (e3
produces one of A, B, C, D, E, H, L, M)
Single precision decrement register (e3
produces one of A, B, C, D, E, H, L, M)
Double precision increment register pair
(e3 must be equivalent to B,D,H, or SP)
Double precision decrement register pair
(e3 must be equivalent to B,D,H, or SP)

Data Movement Instructions.

14

Instructions which rrove data from rremory to the CPU and from CPU to
memory are given below
r!{)V e3,e3

IDV A,B

LQl\X e3

LI:lPJ{

STAX e3

STAX D

LHLD el6

LHLD IJ.

SHLD e16

SHLD L5+x

LQl\ e16
STA e16
EOP e3

LQl\ Gamma.
STA X3-5
EOP PSW

PUSH e3

PUSH B

IN

e8

our e8

IN

B

0

our 255

XTHL
PCHL
SPHL
XCHG
5.5.

Move data to leftmost element from rightrrost element (e3 produces one of A,B,C
D,E,H,L, or M). IDV M,M is disallowed
Load register A from computed address
(e3 must produce either B or D)
Store register A to computed address
(e3 must produce either B or D)
Load HL direct from location e16 (double
precision load to Hand L)
Store HL direct to location e16 (double
precision store from Hand L to memory)
Load register A from address e16
Store register A into memory at e16
Load register pair from stack, set SP
(e3 must produce one of B, D, H, or PSW)
Store register pair into stack, set SP
(e3 must produce one of B, D, H, or PSW)
Load reqister A with data from port e8
Send data from register A to port e8
Exchange data from top of stack with HL
Fill program counter with data from HL
Fill stack pointer with data from HL
Exchange DE pair with HL pair

Arithmetic Logic Unit Operations.

Instructions which a'ct upon the single precision accumulator to perform
arithmetic and logic operations are
ADD e3

ADD B

e3
SUB e3

AOC

SBB

e3

SBB

ANA
XRA
ORA
CMP

e3
e3
e3
e3

ANA 1+1
XRA A
ORA B
CMP H

ADC

DI\A

CMA.
S'IC

L
SUB H
2

Add register given by e3 to accumulator
without carry (e3 must produce one of A,
B, C, D, E, H, or L)
Add register to A with carry, e3 as above
Subtract req e3 from A without carry,
e3 is defined as above
Subtract register e3 from A with carry,
e3 defined as above
IDgical "and" reg with A, e3 as above
"Exclusive or" with A, e3 as above
Logical "or" with A, e3 defined as above
Compare reqister with A, e3 as above
Deciroal adjust register A based upon last
arithmetic logic unit operation
Complement the bits in register A
Set the carry flag to 1

15

•

Complement the carry flag
Rotate bits left, (re)set carry as a side
effect (high order A bit becomes carry)
Rotate bits right, (re)set carry as side
effect (low order A bit becomes carry)
Rotate carry/A register to left (carry is
involved in the rotate)
Rotate carry/A register to right (carry
is involved in the rotate)

Cr.'C
RLC

RAL

RAR

mn e3
5.6.

:eN)

B

Double precision add register pair e3 to
HL (e3 must produce S, D, H, or SP)

Control Instructions.

The four remaining instructions are categorized as control instructions,
and are listed below
HLT
DI
EI

Halt the 8080 processor
Disable the interrupt system
Enable the interrupt system
No operation

NOP

6.

ERROR MESSAGES.

wnen errors occur within the assembly language program, they are listed as
single character flags in the leftmost tx>sition of the source listing. The
line in error is also echoed at the console so that the source listing need
not be examined to determine if errors are present. The error codes are
D

Data error: element in data statement cannot be
placed in the specified data area

E

Expression error: expression is ill-formed and
cannot be computed at assembly time

L

Label error: label cannot appear in this context
(may be duplicate label)

N

Not implemented: features which will appear in
future ASM versions (e.g., macros) are recognized,
but flagged in this version)

o

Overflow: expression is too complicated (i.e., too
many pending operators) to computed, simplify it

P

phase error: label does not have the same value on
two subsequent p3sses through the program

16

Several
conditions

7.

R

Register error: the value specified as a register
is not compatible with the operation code

v

Value error: operand encountered in expression is
improperly formed

error

message

are printed

which are

due

to

terminal

error

NO SOURCE FILE PRESENT

The file specified in the ASM command does
not exist on disk

NO DIRECTORY SPACE

The disk directory is full, erase files
which are not needed, and retry

SCXJRCE FI LE NAME ERROR

Improperly formed ASM file name (e.g., it
is specified with "?" fields)

SOURCE FILE READ ERROR

Source file cannot be read properly by the
assembler, execute a TYPE to determine the
"(;Dint of error

ourpur FI LE WR.I'rE ERROR

Output files cannot be written properly, most
likely cause is a full disk, erase and retry

CAt'mar CLOSE FI LE

Output file. cannot be closed, check to see
if disk is write protected

A SAMPLE SESSION.

The following session shows interaction with the assembler and debugger in
the development of a simple assembly language program o

17

•

ASMSORT~

CP/M ASSEMBLER - YER 1.0

~ 1 SC

\A4¥:t

£t 0 3 H

-Fre~ atl..d.vess
% of

USE FA CT(I R
END OF AS'SE t1 BL Y

+It~le

USeJ

00

To PF (~d.ecl~

)

DIRS 0 RT. *,;
SORT
ASH S;dW'(~ fll~
SORT
BA K Io~J~"" ltt~ ~~fSO R T
P R H 'P"'~
C(QII\:tul~ -fr;L,
S 0 R T H E X WIO..c.lc.,~ c:odL .h~

f,1tz

A}TVPE SORT.

clNu~)

PR~

S'~(t..l~

r~------~--------~'

waclu~ Cotk lo~
0109

i

.-J

k'

;
.

~~~~Ctde
0100 2146el~
SORT:
0103 3601
9105 2147'01
0le8 3600

COMP,

£IleA 7E
£1108 FEe9
€tIeD D219ili

SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE
START AT THE BEGINHING OF THE TRANSIENT PROGRAM AR
ORG
le9H
LXI

H. SW

Mill

11, 1

un

H, I

,ADDRESS

Mill

11, 13

; I = 0

COMPARE
MOV
CPI
JHC

I

;ADDRESS SWITCH TOGGLE
;SET TO 1 FOR FIRST ITERATION
INDEX

WITti -ARRAV SIZE

A, M

; A

N- 1

iCY S.E T IF I

CONT

REGISTER = I

<

( N -_1 )

,CONTINUE IF I <= ( N- 2 )

911£1 214601
0113 7'E87C29991

END OF OjiE PASS THROUGH DATA
LX I
H, Sill
; CHECK FOR ZERO SWITCHES
MOV A.M! ORA A! .JNZ SORT iEND OF SORT IF S lit =B

0118 FF

RST 7

C"·tll-ki
i

e119 5F1600214BCOtH,

e 121

4E792346

;GO TO THE DEBUGGER INSTEAD nF REi-

COHTI HUE THI S PASS
ADDRESSING I, SO LOAD AY ( I) INTO REGISTERS
MOV LA! MVI D,e! LXI Hd~V ! DAD D! DAD D
MOV C, M ! MOV A, C! lUX H! t'lOV B .. M
LOW ORDER BinE IN A AIH C, HIGH ORDER BYTE IH B

MOY HAND L TO ADDRESS AYCI+l)
0125 23

I I~ X

0126 965778239E

COMPARE VALUE WITH REGS CONTAINING AY(l)
SUB Ii! MOV D, A! MOV A, B! INX H! SB8 11
iSUBTRACT
BORRO~I

0128 DA3FBl

JC

H

IF AV(I+l) ) AV(I)
INCI
,SKIP IF IN PROPER ORDER

S~T

CHECK FOR EQUAL VALUES
012E

B2CA3F01

ORA D!

JZ

HIe!

iS~:IP

IF

AY(I)

= AY(J+t)

MOV It .. M! t1 0 II
MOV t1, C ! !lex

0132 56702B5E
0136 7128722873

11., B!
H!

DCX H!

110 'V

r'l. D !

MOV E, 11
D (;:.c: H! 11011

M. E

j

e13B 21460134

IHCREMENT SWITCH COUNT
LXI H,SlJ! IHR 11

013F 21470134C311'-1CI:

un

IHCREMENT I

9146 0e
9147

SW:
I:

0148 050064e01EAV:
eeeA =
N
e 15 C It.- e~ ~ va.tIAL
A >n'PE SORT. HEX..?

H.. I ! I NR M!

JMP CO t1P

DATA DEFINITION SECTION
DB
0
;RESERVE SPACE FOR SWITCH COUNT
DS
1
;SPACE FOR INDEX
Dhi
5.100,30.50,211, '7, 1!HHL 3'313 .. 1130. -3276'7
EQU
($-AV)/2
;CDMPUTE H IHSTEAD OF PRE
EHD

: 1001Be09214601360121470136007EFE09D2190140
rle0110002146017EB7C2B001FF5F16002148011988
: 10012B00194E79234623965778239EDA3F01B2CAA7
: 10e130ee3F0156702B5E712B722B732146013421C7
: 07014ee04?0134C30A01006E
: 10014800050064801E0B320014000700ESB32C01BB
:04015B0B640001B0BE
: 00IH:lf:J(1000Et
A> DD T S OR T. HEX; s-k~
'rUV\..

MI.(.,

161< DDT VER 1.

e

~;~6 0:~B dhwtt a&bess Ll'\6 addy~ ~

BJD

~-b..~(W.+)

-Xp.-)

1 Be~ CWJ.~e.

p = e0 13 0

-UFFFFJ

fe- -fo (00

a~ (;,;l4!-,

u..~~ -r~ 6~3')" s-te.ps

{yu.bot.Ct

CeZ0M13E010 A=00 8=00130 Ii=13ee9 H=0Et00 8=0100 P=0100 LXI
- T 10.,; -h-oa to c;+~f'S"
,I.
C0ZBI1BEeIe
CeZBM8E0Ie
CeZ(1MBEele
C0Z0M13E010
CeZ0M13E010
C0Z011BE010
CIZ0M1EeI0
CIZ0M1E010
CIZeM1EfJI0
CIZ0MIE010
C0zeMBEeI0
cezel1BE010
C0ZBMBE010
C0Z0MBEele
C0Z0MBE0I0
ceZ0M8E010

A=Bl
A=81
A=01
A=01
A=01
A=00
A=00
A=00

A=a0
A=01
A=el
A=01
A=Bl
A=Bl
A=01
A=01

8=0139£1
8=00130
8=001311,
8:::00813
8=00130
8:::IH300
8::00130
8=00130
B =0 €Ie e
8=09139
8=01380
8=130813
8=1391313
8=001313
8=013139
B:=13013·e

D=Seee
D=13a00
D=0a00
D=0 a 00
D=0900
D=0e00
D=13000
D=8 0 00
D=0 0 00
D=0ea8
D=13 a 130
D=1390e
D::::IHH3e
Ii =13 €I e0
D=13 0 e0
D=0 0 00

H=0146
H=0146
H=0146
H=0147
H=014?
H=014?
H=014?
H=0147
H=0146
H=0146
H=0146
H=0146
H=0146
H=0146
H::.0147
H::: 0.1 47

~A10D

91eD
01 10 ~

JC 11 9; c~~(.. -fc a .j'u-'1 On Ct1~

S=010e
8=0100
8=0100
8=,011210
8=0112113
8=@100
8=0100

p::010£1
P=0103
P::0105
P::0108
P::010A

S=0100
8=0100
S=0100
8=010'0
3=011210
3=0100
S=01e0

P:::0114
P::0115
p=010e
p=ele3

11 VI

P=0105

LXI

LXI

11 V I
LXI

MVI
NOll

P::0H1B CPI
P=01E1D ,..\ Ne
8=0100 P:::0110 LXI
8=01121121 P::0113 110 Ii

ORA
J

~~l

LXI

H.• 0 146:1< €I 1 iii 11

H,0146
11. 13 1
H.Et147
11, 0 €I
A, 11

09
(3 11 9
H.. 0146
A) 11

A

0100
H,0146
M) e 1
H.0147

P::0108 MV I

11, (1

P::01!~A

A)I1*010FJ

11011

€I

~d.rt.-J
I "'f3H

19

-XP;

P=010B 10~ ye~+ 1YOj~o.""," (\?~~ b~£.l-b

_Tie +nue ~-ttD~ -tw
J2
B=090'0
B=00130
B=0e9&
B=0000
B=00130
B=0080
B=0099
B=B0ge
B=0eee
B=801;0
8=0090
8=0900
B=0eee
B=00BS
B=eees
B=0e05

C0ZEcl19E010
C0Z0M9E0I0
C9Z0MBE0I0
C9Z0M9E9I0
C0ZBM0E0I0
C0Z0M0E0I0
C1 Z0 HI E010
C1Z0111E010
C1ZeM1E0I0
CIZ0111E0I0
CIZ0MIE919
.~ 9 Z e M1 Eel €I
020MIE010
C9Z0t11E0I9
C0Z0MIE0Ie
ceZ0MIE0Ie
-L lIH,21

A=00
A=0 €I
A=00
A=13e
A=B0
A=80
A=09
A=00
A=B0
A=IHl
A=8e
A=00
A=00
A=e0
A=135
A=B5

9100
9183
9105
911313
910A
918B
919£1
13119
0113
B 114
€I 1 15

H,e146
M, 131
H.0147
M,0e
A,M
99
0119
H,0146
A,M

LXI
MVI
LXI
MYI
MOV
CP I
JC
LXI
MOV
ORA

A

JNZ

13100

13118

RST

97

9119
9llA
BIle

MOV
11\11
LXI

E,A

(01-1

~e.J·lr'l~I~ cf-projra.vn..

S-kps

II=B099
D=ge90
D=8000
D=8000
D=13000
D=8€100
D=B00e
II=000€t
D=9000
D=0000
D=0009
D=9000
D=IHt'00
D=00013
D=1313ge
D=009B

H=0147
H=0146
H=0146
H=0147
H=0147
H=0147
H=0147
H=0147
H=0147
H=0147
H=0148
H=014B
H=@148
H=014B
H=014B
H=0149

8=0100
s= €I.100
S=eJl€10
$=0100
8=0100
S=eJl€10
8=0100
8=0100
8=0100
S=0100
5=0100
S='.3100
s=ei eH3
s=e100
5=0100
S=0100

P=0100
P::0103
P=0105
P=0108
P=010A
P::0108
P==1ZI10D
P==0119

LXI

H,Bl46

11 V I

LXI
MVI
110V

CPI
JC
110V

p,:allA MVI

P::011C un
P= €I 11 F DAII
p::e120 DAD
P=0121 t·l0\/

D
D

L r1

A,C:

P=0122 110V
P=0123 I NX

P=0124

H
B,M*012:5

MOV

~.

At.doy'\l\Q.~h c..
bf"~fO ~lA.t

t\St

S"OIM.C

code

~ lDOI-(

-L~

D.l39

H,9148

- abwf h~+ w~~ Y-(.A.L,~
- G, 1 t B;

'" 812 7

~L.l

r

~rl VY~V'I.1LU. -t (V~

'5-bpf1!6 w~~

- T4~ \ oo~

at loot'l~

C9Z9119E0I9
C0Z0MBE010
Ce20MBE019
C0Z0MBE010
-D148

A=38
A=38
A=00
A=00

Q.\.\..

~ -pc. (ol2-S"l-i) ClVl({ 'fulL

eK-\e.v~l \~YU.p+ 7

l'YOYAIM. l'" -\-vere rook "+

B=9964
8=0964
B=0064
8=13064

D=8906
[1=3806
D=3806
D=3806

H=0156
H=0156
H=0156
H=0157

.
l\.i\

V'eo-\

+.1VV\e -To II.t3H
I

-trtMA ~V'(AI\..+ ?c",~.e{ ('PY~Yl1w. was
lO'fll'lj

\Vvj~·h~l+e.~)

5=9109 P=0127 MOV
5=9199 P=0128 MOV
£=0100 P~0129 INK
8=0100 P~012A SBB

D,A
A,B
H
M*8128

~~+a. l~ sw-kd, b~ 'fyojY"aw Joes ~t s~ .

1;148 95 0e 97 09 14 90 1 E 00
0150 32 B0 64 09 64 90 2C 01 EB f1 3 B 1 813 09 'lie '210 09 2. D. D. , . . . . . . . . .
9169 013 130 00 08 00 00 00 00 00 I;:, !.I eo 00 00 1210 01~ 00 . . . . . . . . . . . . . .

20

-G"~
DDj

ye-t-u.('V\.

-h> CP/M.

SO R T . HEX J2

161<. DDT VER
HEXT
PC

ret 00.& -tke

memovj I fl'\A~

1. €I

else e(!leB

-xp

p =e0 13 e 1 €I

€I;

Sci "Pc.

-\0

bl?jl ~11:~

of t~Y1AXYt

l\..::k b~ Ofcod.t

- L 1 €I Djl

BleD JHC 0119/
0110 LXI
H,0146
- o.~+ ll~ IAI~~ fuloOt.l.t
- A 10 D;

el0D

a.S~wJo\L vte.w q'c.otle.
JC

11~

011~

- L 1B €I;

010e
B1e3
0105
13108

h~\- cs\u~ S'e~of 1vo:Jv-aw..
LXI
MYI
LXI
MYl

H,0146
M,a1
H,0147

•

MIEle

- /lloov\: l\st V\I~~ ~\'4\l.t

- A1€I 3;. dco.~· \~sw'l-hl/ ~IA.:-hjl~~ {, ¢r1

01133

HVI

H, 0~

01 I!! 5,2

_,., (; rl.-b..."" -10 ev/~ \Allkt, dr-£:. (G~ vJlN~
SAVE

"StAVe

1 SORT. COM;

1 fo~t

(1..t;b

r.e-S-\tt.vDDT SO RT. COM~

CIS

WE'

l...ave.

1)'0, w~

0'1'·

dis/£, \~ C"~L-

-to -re.lt)od. lcJ-ef'

So.IIl4 ~e.V'I\Ov~ \V"\~e

161( DDT VER 1. 0
NEXT
PC'
B2 e€I 0 1 €I €I "CoM" -ttll. a..lwo.js

-G.2 rlA"'--\"ke. 1'~"jyt:l1M
II<

0 11 a 1'V'Oc?fo."""VI'\t!cl

+nI'P\

.

s~v-ts Wl-t\,. o,.dJ.'«SI$ 1001-1

1'C-=loOI-{

~-\z,p (~S r 11

elile.o I).\'\.tu-ed

"'D148

014B 135 0e e7 00 14 B0' 1 E
13150 32 0e 64 13£1 64 as 2C €I 1 E.8
8160 Et0 00 013 00 1013 013 09 €Ie a8
13170 IH1 00 130 t:le 08 130 130 00 03

-G~ r~V'~ 40 C?X/M..

03 B 1 B0 00 lOB 00 ee 2. D. D.
..
GB [10 (10 1313 eEt 00 013
00 8e (lIj 00 013 130 00

)

. .

.

.

.

.

.

..

l{

;5ET TO 1 FOR FIRST ITERATION
;ADDRESS

INDEX

iZERO SUI

H I

iADDRESS

J

IHDE>:

;C6NTIHUE IF I

(=

eN-2)

CP/M ASSEMBLER - VER 1.0
f:t 1 5 C

~t aJt!ytt,S 10 as~"

B€t"3H USE FACTOR
EWD OF ASSEMBLY

11 DT SO RT . H~ KAi

M

-pv"'r~ cUCl~t.S

16K DDT VEl< 1.0
PC

NE:~T

015C O'HtB
- (; 1 0

€I,;

"'0118

r

- D148)

d6-~ 501'tal

914B 85 130 .137 e8 14 013 1 E 00 . . . . . . . .
13150 32 013 64 01l 64 80 2C 01 EB 03 9180

0160

ee

00

eo

ee

138130 ee.2.D.D.J . . . . . . . . .

00 00 013 00 00 00 130 09 00 00 130 00 80 . . . . . . . . . . . . . . . .

- tAbbY1: l.u\~rlAlo'v.t

22.

CP/M 2.~O
INTERFACE GUIDE
'~THE

Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896

CP/M 2.0 INTERFACE GUIDE

Copyright (c) 1979

DIGITAL RESEARCH

•

Copyright (c) 1979 by Digital Research. All rights reserved.
No ,part of this publication may be reproduced, transmitted,
transcribed, stored in a retrieval system, or translated into
any language or computer language, in any form or by any
means, electronic, mechanical, magnetic, optical,. chemical,
manual or otherwise, without the prior written permission of
Digital Research, Post Office Box 579, Pacific Grove,
California 93950.
Disclaimer
Digital Research makes no representations or warranties with
respect to the contents hereof and specifically disclaims any
implied warranties of merchantability or fitness for any particular purpose. Further, Digital Research reserves the right
to revise this publication and to make changes from time to
time in the content hereof without obligation - of Digital
Research to notify any person of such revision or changes.

CP/M 2.0 INTERFACE GUIDE

Copyright (c) 1979
Digital Research, Box 579
Pacific Grove, California

1.

Introduction • .

2.

Operating System Call Conventions

3.

A Sample File-to-File Copy Program

•

4.

A Sample File Dump Utility

• 34

5.

A Sample Random Access Program .

•

6.

System Function Summary

• • • 46

.

DOD

D

1

3

•

29

• 37

1.

INTRODUCTION.

This manual describes CP/M, release 2, system organization
including the structure of memory and system entry points. The
intention is to provide the necessary information required to write
programs which operate under CP/M, and which use the peripheral and
disk I/O facilities of the system.
CP/M is logically divided into four parts, called the Basic I/O
System
(BIOS), the Basic. Disk Operating System (BDOS), the Console
command processor (CCP), and the Transient Program Area (TPA).
The
BIOS is a hardware-dependent module which defines the exact low level
interface to a particular computer system which is necessary for
peripheral device I/O.
Although a standard BIOS is supplied by
Digital
Research, explicit instructions are provided for
field
reconfiguration of the BIOS to match nearly any hardware environment
(see the Digital Research manual entitled "CP/M Alteration Guide") •
The BIOS and BDOS are logically combined into a single module with a
common entry point, and referred to as the FDOS. The CCP is a
d i st inct prog r am wh ich uses the FDOS to pr ovide a human-or iented
interface to the information which is cataloged on the backup storage
device. The TPA is an area of memory (i.e., the portion which is not
used by the FDOS and CCP) where various non-resident operating system
commands and user programs are executed. The lower portion of memory
is reserved for system information and is detailed later sections.
Memory organization of the CP/M system in shown below:
high
memory
FDOS (BDOS+BIOS)
FBASE:

•

CCP
CBASE:

TPA
TBASE:
system

parameters

BOOT:
The exact memory addresses corresponding to BOOT, TBASE, CBASE, and
FBASE vary from version to version, and are described fully in the
"CP/M Alteration Guide.
All standard CP/M versions, however, assume
BOOT = 0000H, which is the base of random access memory. The machine
code found at location BOOT performs a system "warm start" which loads
and initializes the programs and variables necessary to return control
to the CCP. Th'us, transient programs need only jump to location BOOT
II

(All Information Contained Herein is Proprietary to Digital Research.)
1

to return control to CP/M at the command level.
Further, the standard
versions assume TBASE = BOOT+0l00H which is normally location 0l00H.
The pr incipal entry point to the FDOS is at location BOOT+0005H
(normally 00 05H) where a jump to FBASE is found.
The address field at
BOOT+0006H
(normally 0006H)
contains the value of FBASE and can be
used to determine the size of available' memory, assuming the CCP is
being overlayed by a transient program.
Transient programs are loaded into the TPA and executed as
follows.
The operator communicates with the CCP by typing command
Each command line takes one of the
lines following each prompt.
forms:
command
command f ilel
command filel file2
where "command" is either a built-in function such as DIR or TYPE,
or
the name of a transient command or program.
If the command is a
built-in function of CP/M, it is executed immediately. Otherwise, the
CCP searches the currently addressed disk for a file by the name
comma nd. COM
If the file is found, it is assumed to be a memory image of a program
which executes in the TPA, and thus implicitly originates at TBASE in
memory. The CCP loads the COM file from the disk into memory starting
at TBASE and possibly extending up to CBASE.
If the command is followed by one or two file specifications,
the CCP prepares one or two file control block (FCB) names in the
These optional FCB's are in the form necessary
system parameter area.
to access files through the FDOS,
and are described in the next
section.
The transient program receives control from the CCP and begins
execution, perhaps using the I/O facilities of the FDOS.
The
transient program is "called" from the CCP, and thus can simply return
to the CCP upon completion of its processing, or can jump to BOOT to
pass control back to CP/M.
In the first case, the transient program
must not use memory above CBASE, while in the latter case, memory up
through FBASE-I is free.
The transient program may use the CP/M I/O facilities to
communicate with the operator's console and peripheral devices,
including the disk subsystem. The I/O system is accessed by passing a
"function number" and an "information address" to CP/M through the
FDOS entry point at BOOT+0005H.
In the case of a disk read, for
example, the transient program sends the number corresponding to a
disk read, along with the address of an FCB to the CP/M FDOS.
The
FDOS, in turn, performs the operation and returns with either a disk
read completion indication or an error number indicating that the disk
read was unsuccessful. The function numbers and errOr indicators are
given in below.

(All Information Contained Herein is Proprietary to Digital Research.)
2

2.

OPERATING SYSTEM CALL CONVENTIONS.

The purpose of this section is to provide detailed information
for performing direct operating system calls from user programs. Many
of the functions listed below, however, are more simply accessed
through the I/O macro library provided with the MAC macro assembler,
and listed in the Digital Research manual entitled "MAC Macro
Assembler: Language Manual and Appl ications Guide. II
CP/M facilities which are available for access by transient
programs fall into two general categories: simple device I/O, and
disk file I/O. The simple device operations include:
Read a Console Character
write a Console Character
Read a sequential Tape Character
write a Sequential Tape Character
write a List Device Character
Get or Set I/O Status
Print Console Buffer
Read Console Buffer
Interrogate Console Ready
The FDOS operations which perform disk Input/Output are
Disk System Reset
Drive Selection
File Creation
File Open
File Close
Directory Search
File Delete
File Rename
Random or Sequential Read
Random or Sequential write
Interrogate Available Disks
Interrogate Selected Disk
Set DMA Address
Set/Reset File Indicators
As mentioned above, access to the FDOS functions is accomplished
by passing a function number and information address through the
primary entry point at location BOOT+0005H o
In general, the function
number is passed in register C with the information address in the
double byte pair DE. Single byte values are returned in register A,
with double byte values returned in HL (a zero value is returned when
the function number is out of range). For reasons of compatibility,
register A = L and register B = H upon return in all cases. Note that
the register passing conventions of CP/M agree with those of Intel's
PL/M systems programming language. The list of CP/M function numbers
is given below.

(All Information Contained Herein is Proprietary to Digital Research.)
3

•

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

System Reset
Console Input
Console Output
Reader Input
Punch Output
List Output
Di rect Console I/O
Get I/O Byte
Set I/O Byte
Pr int Str ing
Read Console Buffer
Get Console Status
Return Version Number
Reset Disk System
Select Disk
Open File
Close File
Search for First
Search for Next

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

Delete File
Read Sequenti.3.l
write Sequential
Make File
Rename File
Return Login Vector
Return Current Disk
Set DMA Address
Get Addr (Alloc)
write Protect Disk
Get R/O vector
Set File Attributes
Get Addr(Disk Parms)
Set/Get User Code
Read Random
write Random
Compute File Size
Set Random Record

(Functions 28 and 32 should be avoided in
maintain upward compatibility with MP/M.)

application

programs

to

Upon entry to a transient program,
the CCP leaves the stack
pointer set to an eight level stack area with the CCP return address
pushed onto the stack, leaving seven levels before overflow occurs.
Although this stack is usually not used by a transient program (Le.,
most transients return to the CCP though a jump to location 0000H), it
is sufficiently large to make CP/M system calls since the FDOS
swi tches to a . local stack at system entry. The following assembly
language program segment, for example, reads characters continuously
until an asterisk is encountered, at which time control returns to the
CCP (assuming a standard CP/M system with Boo'r = 0000H):
BDOS
CON IN
NEXTC:

EQU
EQU

0005H
1

j

ORG
MVI
CALL
CPI
JNZ
RET
END

0l00H
C,CONIN
BDOS

jBASE OF TPA
iREAD NEXT CHARACTER
jRETURN CHARACTER IN 
jEND OF PROCESSING?
jLOOP IF NOT
i RE'rURN TO CCP

I

*

I

NEXTC

STANDARD CP/M ENTRY
jCONSOLE INPUT FUNCTION
/'

CP/M implements a named file structure on each disk, providing a
logical organization which allows any particular file to contain any
number of records from completely empty, to the full capacity of the
drive.
Each drive is logically distinct with a disk directory and
file data area.
The disk file names are in three parts:
the drive
select code, the file name consisting of one to eight non-blank
characters, and the file type consisting of zero to three non-blank
characters. The file type names the generic category of a particular
file,
while the file name distinguishes individual files in each
category. The file types listed below name a few generic categories
(All Information Contained Herein is Proprietary to Digital Research.)
4

which have been established, although they are generally arbitrary:
ASM
PRN
HEX

BAS
INT
COM

Assembler Source
Pr inter Listing
Hex Machine Code
Basic Source File
Intermediate ,Code
CCP Command File

PLI
REL
TEX
BAK
SYM

$$$

PL/I Source File
Relocatable Module
TEX Formatter Source
ED Source Backup
SID Symbol File
Temporary File

Source files are treated as a sequence of ASCII characters, where each
"line" of the source file is followed by a carriage-return line-feed
sequence (0DH followed by 0AH). Thus one 128 byte CP/M record could
contain several lines of source text. The end of an ASCII file is
denoted by a control-Z character (lAH) or a real end of file, returned
by the CP/M read operation.
Control-Z characters embedded within
machine code files (e.g., COM files) are ignored, however, and the end
of file condition returned by CP/M is used to terminate read
operations.
Files in CP/M can be thought of as a sequence of up to 65536
records of 128 bytes each, numbered from 0 through 65535, thus
allowing a maximum of 8 megabytes per file.
Note, however,
that
although the records may be considered logically contiguous, they may
not be physically contiguous in the disk data area.
Internally, all
files are broken into 16K byte segments called logical extents, so
that counters are easily maintained as 8-bit values.
Although the
decomposition into extents is discussed in the paragraphs which
follow, they are of no particular consequence to the programmer since
each extent is automatically accessed in both sequential and random
access modes.
In the file operations starting with function number 15, DE
usually addresses a file control block (FCB). Transient programs
often use the default file control block area reserved by CP/M at
location BOOT+005CH (normally 005CH) for simple file operations. The
basic unit of file information is a 128 byte record used for all file
operations, thus a default location for disk I/O is provided by CP/M
at loca,tion BOOT+0080H (normally 0080H) which is the initial default
DMA address (see function 26). All directory operations take place in
a reserved area which does not affect write buffers as was the case in
release 1, with the exception of Search First and Search Next, where
compatibility is required.
The File Control Block (FCB) data area consists of
33 bytes for sequential access and a series of 36 bytes
that the file is accessed randomly. The default file
normally located at 005CH can be used for random access
the three bytes starting at BOOT+007DH are available for
The FCB format is shown with the following fields:

a sequence of
in the case
control block
files,
since
this purpose.

(All Information Contained Herein is Proprietary to Digital Research.)
5

•

-----------------------------------------------------------Idrlfllf21/ /lf8Ibllt2It3Iexlslls2Ircld01/ /ldnlcrlr0lrllr21
-----------------------------------------------------------00 01 02 ••• 08 09 10 11 12 13 14 15 16 ••• 31 32 33 34 35

where
dr

drive code (0 - 16)
o => use default drive for file
1 => auto disk select drive A,
2 => auto disk select drive B,

. ..

16=> auto disk select drive P.
fl ••• f8

contain the file name in ASCII
upper case, with high bit = 0

tl,t2,t3

contain the file type in ASCII
upper case, with high bit = 0
tl', t2', and t3' denote the
bit of these positions,
tl' = 1 => Read/Only file,
t2' = 1 => SYS file, no DIR list

ex

contains the current extent number,
normally set to 00 by the user, but
in range 0 - 31 during file I/O

sl

reserved for internal system use

s2

reserved for internal system use, set
to zero on call to OPEN, MAKE, SEARCH

rc

record count for extent "ex,"
takes on values from 0 - 128
filled-in by CP/M, reserved for
system use
current record to read or write in
a sequential file operation, normally
set to zero by user
.

d0 ••• dn
cr

r0,rl,r2 optional random record number in the
range 0-65535, with overflow to r2,
r0,rl constitute a 16-bit value with
low byte r0, and high byte rl
Each file being accessed through CP/M must have a corresponding
FCB which provides the name and allocation information for all
subsequent
file operations.
When accessing files, it is the
programmer's responsibility to fill the lower sixteen bytes of the FCB
and initialize the "cr" field. Normally, bytes 1 through 11 are set
to the ASCII character values for the file name and file type, while
all other fields are zero.
(All Information Contained Herein is Proprietary to Digital Research.)
6

FCB's are stored in a directory area of the disk, and are
brought into central memory before proceeding with file operations
(see the OPEN and MAKE functions).
The memory copy of the FCB is
updated as file operations take place and later recorded permanently
on disk at the termination of the file operation (see the CLOSE
command) •
The CCP constructs the first sixteen bytes of two optional FCB's
for a transient by scanning the remainder of the line following the
transient name, denoted by Iff ilel" and
f ile2" in the prototype
command line described above, with unspecified fields set" to ASCII
blanks.
The first FCB is constructed at location BOOT+005CH, and can
be used as-is for subsequent file operations. The second FCB occupies
the d0 ••• dn portion of the first FCB, and must be moved to another
area of memory before use.
If, for example, the operator types
II

PROGNAME B:X.ZOT Y.ZAP
the file PROGNAME.COM is loaded into the TPA, and the default FCB at
BOOT+005CH is initialized to drive code 2, file name "X" and file type
"ZOT".
The second dr ive code takes the defaul t value 0, which is
placed at BOOT+006CH, with the file name "Y" placed into location
BOOT+006DH and file type "ZAP" located 8 bytes later at BOOT+0075H.
All remaining fields through "cr" are set to zero. Note again that it
is the programmer's responsibility to move this second file name and
type to another area, usually a separate file control block, before
opening the file which begins at BOOT+005CH, due to the fact that the
open operation will overwrite the second name and type.
If no file names are specified in the original command, then the
fields beginning at BOOT+005DH and BOOT+006DH contain blanks.
In all
cases,
the CCP translates lower case alphabetics to upper case to be
consistent with the CP/M file naming conventions.
As an added convenience, the default buffer area at location
BOOT+0080H is initialized to the command line tail typed by the
operator following the program name. The first position contains the
number of characters, with the characters themselves following the
character count. Given the above command 1 ine, the area beg inning at
BOOT+0080H is initialized as follows:
Boo'r+0 0 8 0H :
+00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +10 +11 +12 +13 +14
14
B
X"
Z
0
Til.. ..
Y
Z..
A
P ..
II

I.

I.

11

I I . II

..

II.

U

U

It

It

II

I'

II

h i t . It

II

U

U

II

where
the characters are translated to upper case ASCII with
uninitiaiized memory following the last valid character. Again, it is
the responsibility of the programmer to extract the information from
this buffer before any file operations are performed, unless the
default DMA address is explicitly changed.
The individual functions are described in detail
which follow.

in

the

pages

(All Information Contained Herein is Proprietary to Digital Research.)
7

•

***************************************

*
*
*

*

*
*
***************************************
* Entry Parameters:
*
*

FUNCTION

fij:

Register

System Reset

C:

*

00H

***************************************
The system reset function returns control to the CP/M operating
system at the CCP level. The CCP re-initializes the disk subsystem by
selecting and logging-in disk drive A. This function has exactly the
same effect as a jump to location BOOT.

***************************************

*

*

* FUNc'rION 1: CONSOLE INPUT
*
*****************************************
*
*
*

*

*

Entry Parameters:
Register
C:

01H

Returned
Value:
Register
A:

ASCII Character

*

*
*
*
*

***************************************

The console input function reads the next console character to
register A.
Graphic characters, along with carriage return, line
feed, and backspace "(ctl-H) are echoed to the console. Tab characters
(ctl-I) are expanded in columns of eight characters. A check is made
for start/stop scroll
(ctl-S) and start/stop printer echo (ctl-P).
The FDOS does not return to the calling program until a character has
been typed, thus suspending execution if a character is not ready.

***************************************

*

*

FUNCTION 2:

*

*
.*

CONSOLE OUTPUT

*

***************************************

*
*
*

En t ry Par am e t e r s:
Register
C:
Register
E:

02H
ASCII Character

*

*
*
*
*

***************************************

The ASCII character from register E is sent to the console
device.
Similar to function 1, tabs are expanded and checks are made
for start/stop scroll and printer echo.

(All Information Contained Herein is Proprietary to Digital Research.)
8

***************************************

*

*
*

FUNCTION 3:

*
*

Entry Parameters:
Register
C:

*

Returned

*

*

READER INPUT

*

***************************************

*

*
*
*
*
*

03H

Value:

*
Register
A: ASCII Character
***************************************

The Reader Input function reads the next character from the
logical reader into register A (see the IOBYTE definition in the "CP/M
Alteration Guide").
Control does not return until the character has
been read.

***************************************

*
*

FUNCTION 4:

*
*

PUNCH OUTPUT

*

*

***************************************

*

*

*

Entry Parameters:
Register
C:
Register
E:

04H
ASCII Character

*

*
*
*

*

***************************************

The Punch Output function sends the character from register E to
the logical punch device.

***************************************

*
*

FUNCTION 5:

*
*

LIST OUTPUT

*

*

***************************************

*
*

*
*

Entry Parameters:
Register
C:
Register
E:

05H
ASCII Character

*
*
*
*

***************************************
The List Output function sends the ASCII character in register E
to the logical listing device.

(All Information Contained Herein is Proprietary to Digital Research.)

9

***************************************

*
*
* FUNCTION 6: DIRECT CONSOLE I/O
*
*
*
***************************************
* Entry Parameters:
*
Register
C: ~6H
*
*
Register
E:
~FFH
(input)
or
*
*
char (output)
*
*
*
** Returned Value:
*
Register
A: char or status *
*
(no value)
*
***************************************
Direct console I/O is supported under CP/M for those specialized
applications where unadorned console input and output is required.
Use of this function should, in general, be avoided since it bypasses
all of CP/M1s normal control character functions (e.g., control-S and
control-P).
Programs which perform direct I/O through the BIOS under
previous releases of CP/M, however, should be changed to use direct
I/O under BDOS so that they can be fully supported under future
releases of MP/M and CP/M.
Upon entry to function 6, register E either contains hexadecimal
FF, denoti~ a console input request, or register E contains an ASCII
character.
If the input value is FF, then function 6 returns A = ~~
if no character is ready, otherwise A contains the next console input
character.
If the input value in E is not FF, then function 6 assumes·
E contains a valid ASCII character which is sent to the console.

that

(All Information Contained Herein is Proprietary to Digital Research.)

10

***************************************

*

*

FUNCTION 7:

*
*
*

GET I/O BYTE

*

***************************************

*

*
*
*
*

Entry Parameters:
Register
C:
Returned
Value:
Register
A:

*

07H

*

*
*
I/O Byte Value

*

***************************************
The Get I/O Byte function returns the current value of IOBYTE in
register A. See the "CP/M Alteration Guide" for IOBYTE definition.

***************************************

*

*

FUNc'rION 8:

*

SET I/O BYTE

*
*

*

***************************************

*

*

Entry Parameters:
Register
C:
Register
E:

08H
I/O Byte Value

*
*
*
*

*
*
***************************************

The Set I/O Byte function changes the
that given in register E.

system

IOBYTE

value

to

~**************************************

*

*

FUNCTION 9:

*
*
*

PRINT STRING

*

***************************************

*
*

*
*

Entry Parameters:
Register
C:
Registers DE:

09H
Str ing Address

*

*

*

*

*******************~*******************

The Print String function sends the character string stored in
memory at the location given by DE to the console device, until a "$"
is encountered in the string. Tabs are expanded as in function 2, and
checks are made for start/stop scroll and printer echo.

(All Information Contained Herein is Proprietary to Digital Research.)
11

•

***************************************

*

*

FUNCTION 10: READ CONSOLE BUFFER

*

*

*
*

***************************************
* Entry Parameters:
*

*
*

*

*
*

Register
C:
Registers DE:

0AH
Buffer Address

Returned
Value:
Console Characters in Buffer

*

**

*
*

***************************************

The Read Buffer function reads a line of edited console input
into a buffer addressed by registers DE.
Console input is terminated
when either the input buffer overflows.
The Read Buffer takes the
form:
DE: +0 +1 +2 +3 +4 +5 +6 +7 +8

+n

Imxlnclcllc21c31c41c51c61c71

I??I

where "mx" is the maximum number of characters which the buffer will
hold
(1 to 255), "nc" is the number of characters read (set by FDOS
upon return), followed by the characters read from the console.
if nc
< mx, then uninitialized positions follow the last character, denoted
by
"??" in the above figure.
A number of control functions are
recognized during line editing:
rub/del
ctl-C
ctl-E
ctl-H
ctl-J
ctl-M
ctl-R
ctl-U
ctl-x

removes and echoes the last character
reboots when at the beginning of line
causes physical end of line
backspaces one character position
(line feed) terminates input line
(return) terminates input line
retypes the current line after new line
removes currnt line after new line
backspaces to beginning of current line

Note also that certain functions which return the carriage to the
leftmost position (e.g., ctl-X)
do so only to the column position
where the prompt ended (in earlier releases, the carriage returned to
the extreme left margin). This convention makes operator data input
and line correction more legible.

(All Information Contained Herein is Proprietary to Digital Research.)
12

***************************************

**
*

**

FUNC'rION 11: GET CONSOLE S'fATUS

*
***************************************
* Entry Parameters:
*

*
*

*
*

Register

C:

Returned
Value:
Register
A:

0BH
Console Status

*
*
*
*

***************************************

The Console Status function checks to see if a character has
been typed at the console. If a character is ready, the value 0FFH is
returned in register A. Otherwise a 00H value is returned.

***************************************

*
*
*
*
***************************************
* Entry Parameters:
*
*

*

*

*

*
*

FUNCTION 12: RETURN VERSION NUMBER

Register

C:

*

0CH

*
*

Returned
Value:
Registers HL:

Version Number *
***************************************

Function
12
provides
information which allows version
independent programming. A two-byte value is returned, with H = 00
designating the CP/M release·· (H = 01 for MP/M), and L = 00 for all
releases previous to 2.0.
CP/M 2.0 returns a hexadecimal 20 in
register L, with subsequent version 2 releases in the hexadecimal
range 21, 22, through 2F. Using function 12, for example, you can
write application programs which provide both sequential and random
access functions, wi th 'random access disabled when operating under
early releases of CP/M.
'

(All Information Contained Herein is Proprietary to Digital Research.)

13

•

***************************************

**

*
*

FUNCTION 13: RESET DISK SYSTEM

*
*
***************************************

*
*

Entry Parameters:
Register
C:

*
*
*

0DH

*

***************************************

The Reset Disk Function is used to programmatically restore the
file system to a reset state where all disks are set to read/write
(see functions 28 and 29), only disk drive A is selected, and the
default DMA address is reset to BOOT+0080H.
This function can be
used, for example, by an application program which requires a disk
change without a system reboot.

***************************************

*
*
*

FUNCTION 14: SELECT DISK

*

Entry Parameters:
Register
C:
Register
E:

*
*

*
***************************************

*
*
*

0EH
Selected Disk

*
*

*

*

***************************************

The Select Disk function designates the disk drive named in
register E as the default disk for subsequent file operations, with E
= 0 for drive A, 1 for drive B, and so-forth through 15 corresponding
to drive P in a full sixteen drive system. The drive is placed in an
"on-line H status which, in particular, activates its directory until
the next cold start, warm start, or disk system reset operation.
If
the disk media is changed while it is on-line, the drive automatically
goes to a read/only status in a standard CP/M environment
(see
function 28).
FCB's which specify drive code zero
(dr = 00H)
automatically reference the currently selected default drive.
Drive
code values between 1 and 16, however, ignore the selected default
drive and directly reference drives A through P.

(All Information Contained Herein is Proprietary to Digital Research.)

14

***************************************

*
*
*

FUNCTION 15: OPEN FILE

*
*
*

Entry Parameters:
Register
C:
Registers DE:

*
*
*

***************************************

**

Returned

*

0FH
FCB Address

*
*

*

*

Value:

*
Register
A: Directory Code *
***************************************

The Open File operation is used to activate a file which
currently exists in the disk directory for the currently adtive user
number.
The FDOS scans the referenced disk directory for a match in
positions 1 through 14 of the FCB referenced by DE (byte sl is
automatically zeroed), where an ASCII question mark (3FH) matches any
directory character in any of these positions.
Normally, no question
marks are included and, further, bytes "ex" and "s2" of the FCB are
zero.
If a directory element is matched,
the relevant directory
information is copied into bytes d0 through dn of the FCB, thus
allowing access to the files through subsequent read and write
operations.
Note that an existing file must not be accessed until a
sucessful open operation is completed. Upon return, the open function
returns a "directory code" with the value 0 through 3 if the open was
s uc c e s s f ul , o r (1 F F H ( 2 5 5 dec irn a 1 ) i f the f i 1 e can not be f 0 u n d • I f
question marks occur in the FCB then the first matching FCB is
activa ted.
Note that the cur rent record ("cr") must be zeroed by the
program if the file is to be accessed sequentially from the first
record.

(All Information Contained Herein is Proprietary to Digital Research.)
15

•

***************************************
*
*

*

FUNCTION 16: CLOSE FILE

*
*

*

***************************************

*
*
*
*

*

*

Entry Parameters:
Register
C:
Registers DE:

l0H
FCB Address

Returned
Value:
Register
A:

*
*
*
*

Directory Code

*

*

***************************************
The Close File function performs the inverse of the open file
function.
Given that the FCB addressed by DE has been previously
activated through an open or make function (see functions 15 and 22),
the close function permanently records the new FCB in the referenced
disk directory. The FCB matching process for the close is identical
to the open function. The directory code returned for a successful
close operation is 0, 1, 2, or 3, while a 0FFH
(255 decimal)
is
returned if the file name cannot be found in the directory. A file
need not be closed if only read operations have taken place.
If write
operations have occurred, however, the close operation is necessary to
permanently record the new directory information.

(All Information Contained Herein is Proprietary to Digital Research.)
16

***************************************

*
*
* FUNCTION 17: SEARCH FOR FIRST
*
*
*
***************************************
* Entry Parameters:
*
*
*

*
*
*

Reg i s t e r
C:
Registers DE:
Returned
Value:
Register
A:

*
*

11 H
FCB Address

*
*
*

Directory Code

***************************************

Search First scans the directory for a match with the file given
by the FCB addressed by DE.
The value 255
(hexadecimal FF)
is
returned if the file is not found, otherwise 0, 1, 2, or 3 is returned
indicating the file is present.
In the case that the file is found,
the current DMA address is filled with the record containing the
directory entry, and the relative starting position is A * 32 (i.e.,
rotate the A register left 5 bits, or ADD A five times). Although not
normally required for application programs, the directory information
can be extracted from the buffer at this position.
An ASCII question mark
(63 decimal,
3F hexadecimal)
in any
position from "fl" through "ex" matches the corresponding field of any
directory entry on the default or auto-selected disk drive.
If the
"dr" field contains an ASCII question mark, then the auto disk select
function is disabled,
the default disk is searched, with the search
function returning any matched entry, allocated or free, belonging to
any user number.
This latter function is not normally used by
application programs, but does allow complete flexibility to scan all
curr~nt
directory values.
If the "dr" field is not a question mark,
the "s2" byte is automatically zeroed.

***************************************

*

*

*

FUNCTION 18: SEARCH FOR NEXT

*
!
*
*

Entry Parameters:
Register
C:

12H

Returned
Value:
Register"
A:

Directory Code

*
*
*
***************************************

*
!
*
*

***************************************
The Search Next function is similar to the Search First
function,
except that the directory scan continues from the last
matched entry.
Similar to function 17, function 18 returns the
decimal value 255 in A when no more directory items match.

(All Information Contained Herein is Proprietary to Digital Research.)
17

•

***************************************

*
*

*
*

FUNCTION 19: DELETE FILE

*

*

***************************************

*
*

Entry Parameters:
Register
C:
Registers DE:

*

Returned
Value:
Register
A:

*
*

*

*
*

l3H
FCB Address

*

Directory Code

*
**

***************************************
The Delete File function removes files which match the FCB
addressed by DE.
The filename and type may contain ambiguous
references (i.e., question marks in various positions), but the drive
select code cannot be ambiguous, as in the Search and Search Next
functions.
Function 19 returns a decimal 255
files cannot be found, otherwise a
returned.

if the referenced file or
value in the range 0 to 3 is

***************************************
*
*

*
*

FUNCTION 20: READ SEQUENTIAL

*
*
*
*
*

Entry Parameters:
Register
C:
Registers DE:

*
*

***************************************

Returned

*

l4H
FCB Address

*
*
*
*

Value:

*
Register
A: Directory Code *
***************************************

Given that the FCB addressed by DE has been activated through an
open or make function
(numbers 15 and 22), the Read Sequential
function reads the next 128 byte record from the file into memory at
the current DMA address.
the record is read from position "cr" of the
extent, and the ncr" field is automatically incremented to the next
record position.
If the "cr" field overflows then the next logical
extent is automatically opened and the "cr" field is reset'to zero in
preparation for the next read operation. The value 00H is returned in
the A register if the read operation was successful, while a non-zero
value is returned if no data exists at the next record position (e.g.,
end of file occurs).

(All Information Contained Herein is Proprietary to Digital Research.)
18

***************************************

*
* FUNCTION 21: WRITE SEQUENTIAL
*
*
*
*
***************************************
* Entry Parameters:
*
*
Register
C:
ISH
*
*

*
*

*

Registers DE:
Returned
Value:
Register
A:

FCB Address
Directory Code

*
*
*
*

***************************************

Given that the FCb addressed by DE has been activated through an
open or make function
(numbers 15 and 22),
the Write Sequential
function writes the 128 byte data record at the current DMA address to
the file named by the FCB.
the record is placed at position ncr" of
the file, and the "cr" field is automatically incremented to the next
record position.
If the Iocr" field overflows then the next logical
extent is automatically opened and the hcr" field is reset to zero in
preparation for
the next write operation.
Write operations can take
place into an existing file,
in which case newly written records
overlay those which already exist in the file.
Register A = 00H upon
return from a successful write operation,
while a non-zero value
indicates an unsuccessful write due to a full disk.

***************************************

** FUNCTION 22: MAKE FILE
*
*
*
*
***************************************
* Entry Parameters:
*
Register
C:
16H
*
*
Registers DE:
FCB Address
*
*
*
*
*
*

Returned
Value:
Register
A:

Directory Code

*
*

***************************************
The Make File operation is similar to the open file operation
except that the FCB must name a file which does not exist in the
currently referenced disk directory (i.e., the one named explicitly by
a non-zero "dr" code, or the default disk if "dr" is zero).
The FDOS
creates the file and initializes both the directory and main memory
value to an empty file.
The programmer must ensure that no duplicate
file names occur,
and a preceding delete operation is sufficient if
there is any possibility of duplication.
Upon return, register A = 0,
1, 2, or 3 if the operation was successful and 0FFH (255 decimal)
if
no more directory space is available.
The make function has the
side-effect of activating the FCB and thus a subsequent open is not
necessary.

(All Information Contained Herein is Proprietary to Digital Research.)
19

•

***************************************

*
*

*

FUNCTION 23: RENAME FILE

*
*

*

***************************************

*
*

*
*
*
*

Entry Parameters:
Register
C:
Registers DE:

17H
FCB Address

Returned
Value:
Register
A:

Directory Code

*
*
*
*
*

*

***************************************

The Rename function uses the FCB addressed by DE to change all
occurrences of the file named in the first 16 bytes to the file named
in the second 16 bytes.
The drive code "dr" at position 0 is used to
select the drive, while the drive code for the new file name at
position 16 of the FCB is assumed to be zero. Upon return, register A
is set to a value between 0 and 3 if the rename was successful, and
0FFH
(255 decimal)
if the first file name could not be found in the
directory scan.

***************************************

*
*

FUNC'r ION 24: RETURN LOGIN VECTOR

*

*
*
*

***************************************

*
*
*
*
*

Entry Parameters:
Register
C:

18H

Returned
Value:
Registers HL:

Login Vector

*
*
*
*
*

***************************************

The login vector value returned by CP/M is a 16-bit value in HL,
where the least significant bit of L corresponds to the first drive A,
and the high order bit of H corresponds to the sixteenth drive,
labelled P. A "0" bit indicates that the drive is not on-line, while
a "I" bit marks an drive that is actively on-line due to an explicit
disk drive selection,
or _an implicit drive select caused by a file
operation
which specified a non-zero "dr" field.
Note that
compatibility is maintained with earlier release~, since registers A
and L contain the same values upon return.

(All Information Contained Herein is Proprietary to Digital Research.)

20

***************************************

*

*

* FUNCTION 25: RETURN CURRENT DISK *
*
*
***************************************
* Entry Parameters:
*
*
Register
C: 19H
*
*
*
* Returned Value:
*
*
Register
A: . Current Disk
*
I

****************************~**********

Function 25 returns the currently selected default disk ~umber
in register A. The disk numbers range from 0 through 15 corresponding
to dr ives A through P.

***************************************

*
*
* FUNCTION 26: SET DMA ADDRESS
*
*
*
***************************************
* Entry Parameters:
*
*
Register
C: lAH
*
*
Registers DE: DMA Address
*
*
*
***************************************

'IDMA" is an acronym for Direct Memory Address, which is often
used in connection with disk controllers which directly access the
memory of the mainframe computer to transfer data to and from the disk
subsystem. Al though many computer systems use non-DHA access
(i. e. ,
the data is transfered through programmed I/O operations), the DMA
address has, in CP/M, come to mean the address at which the 128 byte
data record resides before a disk write and after a disk read.
Upon
coid start, warm start, or disk system reset,
the DMA address is
automatically set to BOOT+0080H. The Set DMA function, however, can
be used to change this defaul t value to address another area of memory
where the data records reside. Thus, the DMA address becomes the
value specified by DE until it is changed by a subsequent Set DMA
function, cold start, warm start, or disk system reset.

(All Information Contained Herein is Proprietary to Digital Research.)
21

***************************************

*
*
*
* FUNCTION 27: GET ADDR(ALLOC)
*
*
***************************************
* Entry Parameters:
*
*

Register

*
*
*

Returned
Value:
Registers HL:

C:

*
*

IBH
ALLOC Address

*
*

***************************************

An "allocation vector" is maintained in main memory for each
on-line disk drive.
Various system programs use the information
provided by the allocation vector to determine the amount of remaining
storage (see the STAT program). Function 27 returns the base address
of the allocation vector for the currently selected disk drive. The
allocation information may, however, be invalid if the selected disk
has been marked read/only •
Although this function is not normally
used by application programs, additional details of the allocation
vector are found in the "CP/M Alteration Guide.
h

***************************************

*
*
*

FUNCTION 28: WRITE PROTECT DISK

*
*
*

Entry Parameters:
Register
C:

*
*

*

***************************************

*
*

ICH

*

***************************************

The
disk write protect function provides temporary write
protection for the currently selected disk. Any attempt to write to
the disk, before the next cold or warm start operation produces the
message
Bdos Err on d: R/O

(All Information Contained Herein is Proprietary to Digital Research.)
22

***************************************

*
*
*

FUNCTION 29: GET READ/ONLY VECTOR

*

*
*

***************************************

*
*
*
*
*

Entry Parameters:
Register
C:

IDH

Returned
Value:
Registers HL:

R/O Vector Value*

*

*
*

*

****************************~**********

Function 29 returns a bit vector in register pair HL which
indicates drives which have the temporary read/only bit set. Similar
to function 24, the least significant bit corresponds to drive A,
while the most significant bit corresponds to drive P. The R/O bit is
set either by an explicit call to function 28, or by the automatic
software mechanisms within CP/M which detect changed disks.

***************************************
*
*

*

*
*
***************************************
* Entry Parameters:
*
*
Register
C: IEH
*
FUNCTION 30: SET FILE ATTRIBUTES

*

*
*
*
*

Registers DE:
Returned
Value:
Register
A:

FCB Address

*

Directory Code

*
*
*

***************************************
The
Set
File
Attributes function allows programmatic
manipulation
of
permanent indicators attached to files.
In
particular, the R/O and Syst~ attributes (tl' and t2') can be set or
repet.
The DE pair addresses an unambiguous file name with the
appropriate attributes set or reset.
Function 30 searches for a
match, and changes the matched directory entry to contain the selected
indicators.
Indicators fl' through f4' are not presently used, but
may be useful for applications programs, since they are not involved
in the matching process during file open and close operations.
Indicators f5' through fS' and t3' are reserved for future system
expansion.

(All Information Contained Herein is Proprietary to Digital Research.)
23

•

***************************************

*

*

*
*
*
*
*

FUNCTION 31: GET ADDR(DISK PARMS)

*

*

*

***************************************

*

Entry Parameters:
Register
C:
Returned
Value:
Registers HL:

*

IFH

*

DPB Address

*
*

*

***************************************

The address of the BIOS resident disk parameter block is
returned in HL as a result of this function call. This address can be
used for either of two purposes.
First, the disk parameter values can
be extracted for display and space computation purposes, or transient
programs can dynamically change the values of current disk parameters
when the disk environment changes, if required. Normally, application
programs will not require this facility.

***************************************

*

*

*

*
*
*
***************************************
* Entry Parameters:
*
*
Register
C:
20H
*
*
Reg i s t e r
. E : 0 F F H (g e t) 0 r
*
*
*
*
*
*

FUNCTION 32: SET/GET USER CODE

User Code (set)

Returned
Value:
Register
A:

*

*
*

*
Current Code or
(no value)

*

***************************************
An application program can change or interrogate the currently
active user number by calling function 32.
If register E = 0FFH, then
the value of the current user number is returned in register A, where
the value is in the range 0 to 31.
If register E is not 0FFH,
then
the current user number is changed to the value of E (modulo 32).

(All Infdrmation Contairied Herein is Proprietary to Digital Research.)

24

**************************************~

*
* FUNCTION 33: READ RANDOM
*
*
*
***************************************
* Entry Parameters:
*
Reg i s t e r
C : 21 H
*
*
*
Registers DE: FCB Address
*

*

*

*
*

Returned
Value:
Reqister
A:

*
*
*

Return Code

***************************************

The Read Random function is similar to the sequential file read
operation of previous releases, except that the read operation takes
place at a particular record number,
selected by the 24-bit value
constructed from the three byte field following the FCB
(byte
positions rIO at 33, rl at 34, and r2 at 35). Note that the sequence
of 24 bits is stored with least significant byte first (rIO), middle
byte next (rl), and high byte last (r2). CP/M does not reference byte
r2, except in computing the size of a file (function 35).
Byte r2
must be zero, however, since a non-zero value indicates overflow past
the end of file.
Thus, the rIO, rl byte pair is treated as a double-byte, or "word"
value, which contains the record to read. This value ranges from 10 to
65535, providing access to any particular record of the 8 megabyte
file.
In order to process a file using random access, the base extent
(extent (0) must first be opened. Although the base extent mayor may
not contain any allocated data, this ensures that the file is properly
recorded in the directory, and is visible 'in DIR requests.
The
selected record number is then stored into the random record field
(rIO, rl), and the BDOS is called to read the record. Upon return from
the call, register A either contains an error code, as listed below,
or the value 010 indicating the operation was successful.
In the
latter case,
the current DMA address contains the randomly accessed
record. Note that contrary to the sequential read operation,
the
record number is not advanced.
Thus, subsequent random
read
operations continue to read the same record.
Upon each random read operation, the logical extent and current
record values are automatically set.
Thus, the file can
be
sequentially read or written, starting from the current randomly
accessed position.
Note,
however,
that in this case,
the last
randomly read record will be re-read as you switch from random mode to
sequential read, and the last record will be re-written as you switch
to a sequential write operation. You can, of course, simply advance
the random record position following each random read or write to
obtain the effect ofa sequential I/O operation.
Error codes returned in register A following a random
listed below.

read

are

(All Information Contained Herein is Proprietary to Digital Research.)
25

•

01
02
03
04
05
06

reading unwritten data
(not returned in random mode)
cannot c}ose current extent
seek to unwritten extent
(not returned in read mode)
seek past physical end of disk

Error code 01 and 04 occur when a random read operation accesses a
data block which has not been previously written, or an extent which
has not been created, which are equivalent conditions. Error 3 does
not normally occur under proper system operation, but can be cleared
by simply re-reading, or re-opening extent zero as long as the disk is
not physically write protected. Error code 06 occurs whenever byte r2
is non-zero under the current 2.0 release. Normally, non-zero return
codes can be treated as missing data, with zero return codes
indicating operation complete.

(All Information Contained Herein is Proprietary to Digital Research.)
26

***************************************
*
*
* FUNCTION 34: WRITE RANDOM
*

*

*

***************************************
* Entry Parameters:
*

*

Register
C:
Registers DE:

22H
FCB Address

*
*

Returned
Value:
Register
A:

Return Code

*

*

*
*
*
*
*

***************************************

The Write Random operation is initiated similar to the Read
Random call, except that data is written to the disk from the current
DMA address.
Further, if the disk extent or data block which is the
target of the write has not yet been allocated, the allocation is
performed before the write operation continues. As in the Read Random
operation, the random record number is not changed as a result of the
write.
The logical extent number and current record positions of the
file control block are set to correspond to the random record which is
being written.
Again, sequential read or write operations can
commence following a random write, with the notation that the
currently addressed record is either read or rewritten again as the
sequential operation begins. You can also simply advance the random
record position following each write to get the effect of a sequential
write operation. Note that in particular, reading or writing the last
record of an extent in random mode does not cause an automatic extent
switch as it does in sequential mode.
The error codes returned by a random write are identical to the
random read operation with the addition of error code 05, which
indicates that a new extent cannot be created due to directory
overflow.

(All Information Contained Herein is Proprietary to Digital Research.)
27

***************************************

** FUNCTION 35: COMPUTE FILE SIZE
**
*****************************************
* Entry Parameters:
*
*
Register
C: 23H
*
*
Registers DE: FCB Address
*
*
*
* Returned Value:
*
*
Random Record Field Set
*
***************************************

When computing the size of a file,
the DE register pair
addresses an FCB in random mode format (bytes r0, rl, and r2 are
present). The FCB contains an unambiguous file name which is used in
the directory scan. Upon return, the random record bytes contain the
"virtual" file size which is, in effect, the recbrd· address of the
record following the end of the file.
if, following a call to
function 35, the high record byte r2 is 01, then the file contains the
maximum record count 65536. Otherwise, bytes r0 and rl constitute a
l6-bit value
(r0 is the least significant byte, as before) which is
the 'file size.
Data can be appended to the end of an existing file by simply
calling function 35 to set the random record position to the end of
file, then performing a sequence of random writes starting at the
preset record address.
The virtual size of a file corresponds to the physical size when
the file is written sequentially. If, instead, the file was created
in random mode and "holes" exist in the allocat'ion, then the file may
in fact contain fewer records than the size indic,ates.
If, for
example, only the last record of an eigh t megabyte file is wr i tten in
random mode (i.e., record number 65535), then the virtual size is
65536 records, although only one block of data is actually allocated.

(All Information Contained Herein is Proprietary to Digital Research.)

28

***************************************
*
*

*

*

FUNCTION 36: SET RANDOM RECORD

*

*

***************************************
* Entry Parameters:
*
Register
C: 24H
*
*
Registers
DE:
FCB
Address
*
*
*
** Returned
Value:
*
Random
Record
Field
Set
*
*
***************************************
The Set Random Record function causes the BDOS to automatically
produce the random record position from a file which has been read or
written sequentially to a particular point.
The function can be
useful in two ways.
First, it is often necessary to initially read and scan a
sequential file to extract the positions of various "key" fields.
As
each key is encountered, function 36 is called to compute the random
record position for the data corresponding to this key.
If the data
unit size is 128 bytes, the resulting record position is placed into a
table with the key for later retrieval.
After scanning the entire
file and tabularizing the keys and their record numbers, you can move
instantly to a particular keyed record by performing a random read
using the corresponding random record number which was saved earlier.
The scheme is easily generalized when variable record lengths are
involved since the program need only store the buffer-relative byte
position along with the key and record number in order to find the
exact starting position of the keyed data at a later time.
A second use of function 36 occurs when switching from a
sequential read or write over to random read or write. A file is
sequentially accessed to a particular point in the file,
function 36
is called which sets the record nu~ber, and subsequent random read and
write operations continue from the selected point in the file.

(All Information Contained Herein is Proprietary to Digital Research.)
29

•

3.

A SAMPLE FILE-TO-FILE COpy PROGRAM.

The program shown below provides a relatively simple example of
file operations. The program source file is created as COPY.ASM using
the CP/M ED program and then assembled using ASM or MAC, resulting in
a "HEX" file. The LOAD program is the used to produce a COPY.COM file
which executes directly under the CCP. The program begins by setting
the stack pointer to a local area, and then proceeds to move the
second name from the default area at 006CH to a 33-byte file control,
block called DFCB. The DFCB is then prepared for file operations by
clearing the current record field. At this point, the source and
destination FCB's are ready for processing since the SFCB at 005CH is
properly set-up by the CCP upon entry to the COpy progr~u.
That is,
the first name is placed into the default fcb, with the proper fields
zeroed, including the current record field at 007CH.
The program
continues by opening the source file, deleting any exising destination
file, and then creating' the destination file.
If all this is
successful, the program loops at the label COpy until each record has
been read from the source file and placed into the destination file.
Upon completion of the data transfer, the destination file is closed
and the program returns to the CCP command level by jumping to BOOT.

·,
~

sample file-to-file copy program
at the ccp level, the command

;
,

·

0000
0005
005c
005c
006c
0080
0100

=
=
=

=

=
=

=

·,

boot
bdos
fcbl
sfcb
fcb2
dbuff
tpa

copy a:x.y b:u.v
copies the file named x.y from drive
a to a file named u.v on drive b.
; system reboot
bdos entry point
first file name
source fcb
second file name
; defaul t buffer
beg inning of tpa

equ
equ
equ
equ
equ
equ
equ

0000h
0005h
005ch
fcbl
006ch
0080h
0100h

equ
equ
equ
equ
equ
equ
equ

15
16
19
20
21
22

org
lxi

tpa
beginning of tpa
sp,stack; local stack

;

0009
000f
0010
0013
0014
0015
0016

=
=

=
=
=

=
=

0100
0100 3llb02

printf
openf
closef
deletef
readf
writef
makef

;

·
,

0103 0e10

print buffer func#
open file func#
close file func#
delete file func#
sequential read
sequential write
make file func#

9

move second file name to dfcb
mvi
c,16
; half an fcb

(All Information Contained Herein is Propr ietary to big i tal Research.)
30

131135
131138
r31Qlb
QlIQlc
QlIQld
01Qle
01Qlf
131113

116cr3r3
21dar31
la
mfcb:
13
77
23
r3d
c2r3br31

13113 af
0114 32far31

,·

lxi
lxi
Idax
inx
mov
inx
dcr
jnz

d,fcb2
h,dfcb
d
d

m,a
h
c

mfcb

source of move
destination fcb
; source fcb
ready next
dest fcb
ready next
count 16 ••• 0
loop 16 times

name has been moved, zero cr
xra
a
; a = 00h
sta
dfcbcr; current rec

=

13

source and destination fcb's ready

Qll17115cr3r3
011a cd6901
r311d 1187131
131213 3c
13121 cc6101

lxi
call
lxi
inr
cz

13124 Ilda01
13127 cd73r31

source file open, prep destination
lxi
d,dfcb
destination
call
delete
remove if present

012a
012d
01313
0133
0134

Ilda01
cd8201
119601
3c
cc6101

,·

lxi
call
lxi
inr
cz

d, sfcb
source file
open
; error if 255
d,nofile; ready message
255 becomes 13
a
finis
done if no file

d,dfcb
make
d,nodir
a

finis

destination
create the file
ready mes sage
255 becomes 0
done if no dir space

source file open, dest file open
copy until end of file on source
;

0137
r313a
013d
013e

115c00 copy:
cd7801
b7
c251r31

·
,

;

0141
13144
13147
014a
r314b
,014e

IldaQll
cd7d0l
lla9 £11
b7
c46101
c33701

lxi
call
ora
jnz

d,sfcb
read

not end
lxi
call
lxi
ora
cnz
j mp

of file, write the record
d,dfcb
destination
write
write record
d,space
ready message
00 if write ok
a
finis
end if so
loop un til eo f
copy

a

eofile

source
read next record
end of file?
skip write if so

;

0151
13154
0157
Ql15a
Ql15b

Ilda01
cd6e01
21bb01
3c
cc6101

eofile: ; end of file, close destination
d,dfcb
destination
lxi
close
; 255 if error
call
lxi
h,wrprot; ready message
inr
255 becomes 130
a
shouldn't happen
finis
cz
copy operation complete, end

(All Information Contained Herein is Proprietary to Digital Research.)
31

015e 11cc01

·,

finis:
0161 0e09
0163 cd0500
0166 c30000

lxi

d,normal~

~ write
mvi
call
jmp

message given by de, reboot
c,printf
bdos
~ write message
boot
~ reboot system

ready message

system interface subroutines
(all return directly from bdos)
0169 0e0f
open:
016b c30500

mvi
jmp

c,openf
bdos

016e 0e10
close:
0170 c30500

mvi
jmp

c,closef
bdos

·,

·,

01730e13
delete: mvi
0175 c30500
jmp

c,deletef
bdos

0178 0e14
read:
017a c30500

mvi
jmp

c, readf
bdos

mvi
jmp

c,writef
bdos

0182 0e16
make:
0184 c30500

mvi
jmp

c,makef
bdos

0187
0196
01a9
01bb
!{llcc

console
db
db
db
db
db

mes sages
'no source file$'
'no directory spaceS'
'out of data space$'
'write protected?$'
'copy complete$'

·,
~

017d 0e15
write:
017f c30500
~

01da
01fa

6e6f20fnofile:
6e6f209nodir:
6f7574fspace:
7772695wrprdt:
636f700normal:

=

dfcb:
dfcbcr

01fb
stack:
021b

data areas
ds
33
; destination fcb
equ
dfcb+32 ; current record

as

32

16 level stack

end

Note that there are several simplifications in this particular
program.
First, there are no checks for invalid file names which
could, for example, contain ambiguous references.
This situation
could be detected by scanning the 32 byte default area starting at
location 005CH for ASCII question marks. A check should also be made
to ensure that the file names have, in fact, been included (check
locations 005DH and 006DH for non-blank ASCII characters). Finally, a
check should be made to ensure that the source and destination file
names are different. A speed improvement could be made by buffering
more data on each read operation. One could, for example, determine
(All Information Contained Herein is Proprietary to Digital Research.)
32

the size of memory by fetching FBASE from location 0006H and use the
entire remaining portion of memory for a data buffer. In this case,
the programmer simply resets the DMA address to the next successive
128 byte area before each read. Upon writing to the destination file,
the DMA address is reset to the beginning of the buffer and
incremented by 128 bytes to the end as each record is transferred to
the destination file.

•

(All Information Contained Herein is Proprietary to Digital Research.)
33

4.

A SAMPLE FILE DUMP UTILITY.

The file dump program shown below is slightly more complex than
the :simple copy program given in the previous section. The dump
program reads an inputf ile, specified in the CCP command line, and
displays the content of each record in hexadecimal format at the
console. Note that the dump program saves the CCp's stack upon entry,
resets the stack to a local area, and restores the CCp's stack before
returning directly to the CCP.
Thus, the dump program does not
perform and warm start at the end of processing.
; DUMP program reads input file and displays hex data

=

pr~ntf

=
=

brkf
openf
readf

org
equ
equ
equ
equ
equ
equ
equ

fcb
buff

equ
equ

cr
If

non graphic characters
egu
0dh
;carriage return
equ
0ah
;line feed

fcbdn
fcbfn
fcbft
fcbrl
fcbrc
fcbcr
fcbln

file control block definitions
equ
fcb+0
;disk name
equ
fcb+l
;file name
equ
fcb+9
;disk file type (3 characters)
equ
fcb+12 ;file's current reel number
equ
fcb+15 ;file's record count (13 to 128)
equ
fcb+32 ;current (next) record number (0
equ
fcb+33 ; fcb length

0HH}

13005
0001
0002
0009
000b
000f
0014

=
=
=

=

005c =
0080 =
000d

=

13 00a =

o05c =

013 5d =
01365 =
0068 =
006b =
007c =
0137d =

bdos
cons
typef

.,

.,

1130h
13 0 05h

11
15
213

;dos entry point
; read console
;type function
;buffer print entry
;break key function (true if char
;file open
;read function

5ch
813h

;file control block address
;input disk buffer address

1
2
9

cd cl 0 1
f e ff
010f c21b01

set up stack
lxi
h,0
dad
sp
entry stack pointer in hI from the ccp
shld
oldsp
set sp to local stack area (restored at finis)
lxi
sp,stktop
read and print successive buffers
call
setup
;set up input file
cpi
255
;255 if file not present
jnz
openok ;skip if open is ok

0112 Ilf301
0115 cd9c01
0118 c35101

file not there, give error message and return
d,opnmsg
lxi
call
err
jmp
finis
ito return

0100 210000
01133 39
0104 221502
0107 3157132

o1 0a
o10d

(All Information Contained Herein is Proprietary to Digital Research.)
34

openok:
011b 3e80
011d 321302
0120 210000

;open operation ok, set buffer index to end
mvi
a,80h
;set buffer pointer to 80h
sta
ibp
hI contains next address to print
lxi
h,0
;start with 0000

;

gloop:
0123
0124
0127
0128
012b

e5
cda201
el
da5101
47

push
h
;save line position
call
gnb
pop
;recall line position
h
;carry set by gnb if end file
finis
jc
mov
b,a
print hex values
check for line fold
mov
a,l
ani
0fh
;check low 4 bits
jnz
nonum
print line number
call
crlf

012c 7d
012d e60f
012f c24401
0132 cd7201

0138 0f
0139 da5101

check for break key
call
break
accum lsb = 1 if character ready
rrc
;into carry
jc
finis
;don't print any more

013c
013d
0140
0141

mov
call
mov
call

a,h
phex
a,l
phex

inx
mvi
call
mov
call
j mp

h

0135 cd5901

7c
cd8f01
7d
cd8f01
nonum:

0144
0145
0147
014a
014b
014e

23
3e20
cd6501
78
cd8f01
c32301

.

a,'

ito next line number

,

pchar
a,b
phex
gloop

•

I

finis:
end of dump, return to ccp
(note that a jmp to 0000h reboots)
cr If
call
lhld
oldsp
sphl
stack pointer contains ccp's stack location
ret
ito the ccp

0151 cd7201
0154 2a1502
0157 f9
0158 c9

.

sub r ou tin e s

break:

;check break key (actually any key will do)
push h! push d! push b; environment saved
mvi
c,brkf
call
bdos
pop b! pop d! pop h; environment restored

I

0159
015c
015e
0161

e5d5c5
0e0b
cd0500
cldlel

(All Information Contained Herein is Proprietary to Digital Research.)
35

ret

0164 c9
i

pchar:
0165
0168
0l6a
0l6b
0l6e
0171

e5d5c5
0e02
Sf
cd0500
cldlel
c9

iprint a character
push h! push d! push bi saved
c, typef
mvi
mov
e,a
bdos
call
pop b! pop d! pop hi restored
ret

i

cr If:
0172
0174
0177
0179
017c

mvi
call
mvi
call
ret

3e0d
cd6501
3e0a
cd650l
c9

a,cr
pchar
a,lf
pchar

i

pnib:

0184 c630
0186 c38b01

iprint nibble in reg a
0fh
ani
i low 4 bits
cpi
10
jnc
p10
less than or equal to 9
10'
adi
prn
jmp

0189 c637
p10:
0l8b cd6501 prn:
0l8e c9

greater or equal to 10
adi
10
I a •
pchar
call
ret

0l7d e60f
017f fe0a
0181 d28901

i

0l8f
0190
0191
0192
0193
0194
0197
0198
019b

-

phex:

iprint hex char in reg a
push
psw
rrc
rrc
rrc
rrc
pnib
call
iprint nibble
pop
psw
call
pnib
ret

err:

iprint error message
d,e addresses message ending with "$10
c,printf
iprint buffer function
mvi
bdos
call
ret

f5
0f
0f
0f
0f
cd7d0l
fl
cd7d0l
c9

019c 0e09
01ge cd0500
01al c9

.,
gnb:
01a2 3a1302
01a5 fe80
01a7 c2b301

i get next byte
Ida
ibp
cpi
80h
jnz
g0
read another buf'fer

(All Information Contained Herein is Proprietary to Digital Research.)
36

;

9laa cdce9l
9lad b7
9lae cab39l

call
ora

;

9lbl 37
9lb2 c9

diskr
a
;zero value if read ok
jz
gf{J
;for another byte
end of data, return with carry set for eof
stc
ret

;

g9:
9lb3
9lb4
9lb6
9lb7

5f
1699
3c
321392

·
I

9lba 218999
9lbd 19
;

9lbe 7e
;

9lbf b7
9lc9 c9

·

;read the byte at buff+reg a
mov
e,a
;ls byte of buffer index
mvi
d,f{J
;double precision index to de
inr
a
;index=index+l
sta
ibp
;back to memory
pointer is incremented
save the current file address
lxi
h,buff
dad
d
absolute character address is in hI
mov
a,m
byte is in the accumulator
ora
a
;reset carry bit
ret

I

setup:
;
f{Jlcl af
f{Jlc2 327cf{J9

; set up file
open the file for input
xra
a
i zero to accum
sta
fcbcr
iclear current record

;

f{Jlc5 11Sc00
0lc8 ge0f
0lca cd0500
;

0lcd c9

d,fcb
lxi
c,openf
mvi
bdos
call
255 in accum if open error
ret

;

diskr:
9lce
0ldl
0ld4
9ld6
0ld9
0ldc

e5d5c5
l15c90
ge14
cd0509
cldlel
c9

·;

;read disk file record
push h! push d! push b
lxi
d,fcb
mvi
c" r.eadf
call
bdos
pop b! pop d! pop h
ret

I

fixed message area
0ldd 46494c0signon: db
'file dump version 2.0$'
0lf3 ~d9a4e90pnmsg: db
cr,lf,'no input file present on disk$'
0213
0215

·,

ibp:
oldsp:

var iable area
ds
2
ds
2

;input buffer pointer
:entry sp value from ccp

stack area
ds
64

ireserve 32 level stack

;

9217
f{J257

stktop:

end

(All Information Contained Herein is Proprietary to Digital Research.)
37

•

5.

A SAMPLE RAND
4AlEiHo
4A21H+o
4A24H+b
4A27f1+b
4A2A1Hb
4A2ofI+b
4A30H+b

JMP BOO'l'
J i'1P WBOOrl'
Jll1p CONST
J-t-lP COlUN

J I'll' CONOlJT
Jtv1i? LIST
J~P PUNCH
Jt'1P READER
JMP HOME
Jr·1P SELDSK
J~1P SET'rRK
J!\1..i? SE'rSEC
J Hi? S E'rDfJIA
J r.1i? READ
JMP ~I)'RI'rE
J £vIP L I S'rS'I'
JMP S ECrRAN

where

the

ARRIVE HERE FROM COLD START LOAD
ARRIVE HERE FOR WAR!"1 S'rART
CHECK FOR CONSOLE CHAR READY
READ CONSOLE CHARACTER IN
~VRI'rE CONSOLE CHARAC'rER ou'r
WRITE LISTING CHARACTER OUT
WRI'l'E CHARACTER 'ro PUNCH DEVICE
READ READER DEVICE
MOVE TO TRACK 00 ON SELECTED DISK
SELECT DISK DRIVE
SE'I' 'fRACK NUMBER
SET SECTOR NUMBER
S E'r Drv1A ADDRESS
READ SELECTED SECTOR
WRITE SELECTED SECTOR
RETURN LIST STATUS
SECTOR TRANSLATE SUBROUTINE

8ach jumo address corresponds to a particular subroutine which
performs tne specific function, as outlined below. There are three
major divisions in the jump table:
the system (re) initialization
whicn results from calls on BOOT and WBOOT, simple character I/O
performed by calls on CONST, CONIN, CONOU'I', LIST, PUNCH, READER, and
LISTS'r, and diskette I/O performed by calls on HOME, SELDSK, SET'rRK,
SETSEC, SETOMA, READ, WRITE, and SECTRAN.
All simple character I/O operations are assumed to be performed in
ASCII, upper and lower case, with high order ("parity bit) set to zero.
An end-of-file condition for an input device is given by an ASCII
control-z (lAH). Peripheral devices are seen by CP/M as "logical"
devices, and are assigned to physical devices within the BIOS.
In order to operate, the BOOS needs only the CONST, CONIN, and
CONOU'r subroutines (LIST, PUl~CH, and READER may be used by PIP, but
not the BOOS). Further, the LISTST entry is used currently only by
DESPOOL, and thus, the initial version of CBIOS may have empty
subroutines for the remaining ASCII devices •
......

(All Information Contained Herein is Proprietary to Digital Research.)
14

The characteristics of each device are
CONSOLE

The ?rincipal interactive console which communicates
with the operator, accessed through CaNST, CONIN, and
CONOUT. Typically, the CONSOLE is a device such as a
CRT or Teletype.

LIST

The principal listing device,
if it exists on your
system, which is usually a hard-copy device, such as a
printer or Teletype.

PUNCH.

The principal tape punching device, if it exists, which
is normally a high-speed paper tape punch or Teletype.

READER

The principal tape reading device,
optical readei or Teletype.

such

as

a

simple

Note that a single ?eripheral can be assigned as
the LIS'r, PUNCH, and READER dev ice s imul taneousl y.
If
no peri?heral device is assigned as the LIST, PUNCH, or
READER device, the CBIOS created by the user may give
an appropriate error message so that the system does
not "hang" if the device is accessed by PIP. or some
other user program.
Alternately, the PUNCH and LIST
routines can just simply return, and the READER routine
can return with a lAH (ctl-Z)
in reg A to indicate
immediate end-of-file.
For added flexibility,
the user can, optionally
implemen t
the "IOBY'rE"
function
wh ich
allows
reassignment of physical and logical devices.
The
IOBYTE
function creates a mapping of logical to
physical devices which can be altered during CP/M
processing
(see the STAT commanc). 'rhe definition of
the IOBYTE function corresponds to the Intel standard
as follows:
a single location in memory (currently
location 0003H) is maintained, called IOBYTE,
which
defines the logical to ?hysical device mapping Which is
in effect at a particular time.
The mapping is
performed by splitting the IOBYTE into four distinct
fields of two bits each, called the CONSOLE, READER,
PUNCH, and LIST fields, as shown below:
most significant
IOBYTE AT

0003H

I LIST
bits 6,7

I PUl'-JCH
bits 4,5

least significant

I READER
bits 2,3

I CONSOLE I
bits 0,1

The value in each field can be in the range 0-3,
defining the assigned source or destination of each
logical device.
The values which can be assigned to
each field are given below

(All Information Contained Herein is

15

Pro~rietary

to Digital Research.)

CONSOLE field (bits 0,1)
o - console is assigned to the console printer device (TTY:)
I
console is assigned to the CRT device (CRT:)
2 - batch mode: use the READER as the CONSOLE input,
and the LIST device as the CONSOLE output (BAT:)
3 - user defined console device (UCl:)
READER field (bits 2,3)
- READER is the 'reletype device (TTY:)
1
READER is the high-speed reader device (RDR:)
2
user defined reader # 1 (URI:)
3
user defined reader # 2 (UR2:)

'"

PUNCH field (bits 4,5)
o - PUNCH is the
1 - PUNCH is the
2 - user defined
3
user defined

Teletype device (TTY:)
high speed punch device (PUN:)
punch # 1 (UPl:)
punch # 2 (UP2:)

LIST field (bits 6,7)
o - LIST is the Teletype device (TTY:)
1 - LIST is the CRT device (CRT:)
2 - LIST is the line printer device (LPT:)
3 - u~er defined list device (ULl:)
Note again that the implementation of the IOBYTE is
optional, and affects only the organization of your
CBIOS.
No CP/M systems use the IOBYTE (although they
tolerate the existence of the IOBYTE at location
0~03H),
except for PIP which allows access to the
physical
devices,
and
S'rA'l'
which
allows
logical-physical assignments to be
made
and/or
displayed (for more information, see the "CP/M Features
and Fac il i ties Gu ide") •
In any case,
the 10BY'rE
implementation should be omitted until your basic CBIOS
is fully imolemented and tested: then add the 10BYTE to
increase your facilities.
Disk I/O is always performed through a sequence of
calls on the various disk access subroutines which set
u~ the disk number to access, the track and sector on a
particular disk, and the direct memory access
(DMA)
address involved in the I/O operation. After all these
parmneters have been set up, a call is made to the READ
or WRITE function to oeriorm the actual I/O operation.
Note that there is often a single call to SELDSK' to
select a disk drive, followed by a number of read or
write operations to the selected disk before selecting
another drive for subsequent operations.
Similarly,
there may be a single call to set the DMA address,
followed by several calls which read or write from the
selected DMA address before the DMA address is changed.
The track and sector sUbroutines are always called
before tne READ or WRI'rE operations are performed.

(All Information Contained Herein is Proprietary to Digital Research.)

16

Note that the READ and WRITE routines should
perform several retries
(10 is standard)
before
reporting the error condition to the BOOS.
If the
error condition is returned to the BOOS, it will report
the error to the user.
The HOME subroutine mayor may
not actually perform the track 00 seek, depending upon
your controller characteristics; the important point is
that track 00 has been selected for the next operation,
and is often treated in exactly the same manner as
SET'rRK with a parameter of 00.
The exact responsibilites
subroutine are given below:

of

eacn

entry

point

Boo'r

The BOOT entry point gets control from the cold start
loader' and is responsible
for
basic
system
initialization,
including sending a signon message
(which can be omitted in the first version). ' If the
IOBYTE function is implemented, it must be set at this
point.
'rhe var ious system parameters which are set by
the wBOOT entry point must be initialized, and control
is transferred to the CCP at 3400H+b for further
processing. Note that reg C must be set to zero to
select dr ive A.

WBoo'r

The WBOOT entry point gets control when a warm start
occurs.
A warm start is performed whenever a user
r;>rogram branches to location 0000H, or when the CPU is
reset from the front panel. 'rhe CP/i"1 system must be
loaded from the first two tracks of drive A up to, but
not including,
the BIOS (or CBIOS,
if you have
completed your patch). System parameters must be initialized as shown below:
location 0,1,2

set to JHP WBOO'f for warm starts
(0000H: JHP 4A03H+b)
if
location 3
set initial value of IOBYTE,
implemented in your CBIOS
location 5,6,7
set to Jr.lP BOOS, which is the
primary entry point to CP/M for
(0005H: JMP
transient programs.
3C06H+b)
(see Section 9 for complete details of page zero use)
Upon completion of the initialization,
the WBOOT
program must branch to the CCP at 3400H+b to (re)start
the system. Upon entry to the CCP, register C is set
to the drive to select after system initialization.
CONST

Sample the
device and
ready to
characters

status of the currently assigned console
return 0FFH in register A if a character is
read, and 00H in register A if no console
are ready.

CONIN

Read the next console character into register

A,

and

(All Information Contained Herein is Proprietary to Digital Research.)

17

•

set the parity oit (high order bit) to zero. If no
console character is ready, wait until a character is
typed oetore returning.
CONOUT

Send the character from register C to the console
output device.
The character is in ASCII, with high
order parity bit set to zero. You may want to include
a time-out on a line feed or carriage return, if your
console device requires some time interval at the end
of the line (sucn as a TI Silent 700 terminal).
You
can, if you wish, filter out control characters which
cause your console device to react in a strange way (a
control-z causes the Lear Seigler terminal to clear
the screen, for examole).

LISlr

Send the character from register C to the currently
assigned listing device.
The character is in ASCII
with zero parity.

PUNCH

Send the cnaracter from register C to the currently
assigned punch device. The character is in ASCII with
zero parity.

READER

Read the next character from the currently assigned
reader device into register A with zero parity (high
order bit must be zero), an end of file condition is
reported by returning an ASCII control-z (lAH).

HOME

Return the disk head of the currently selected disk
(initially disk A) to the track 00 position. If your
controller allows access to the track 0 flag from the
drive, step the head until the track 0 flag is
detected. If your controller does not support this
feature, you can translate the HOME call into a call
on SE'II'rRK witn a parameter of 0.

SELDSK

Select the disk drive given by register C for further
operations, wnere register C contains 0 for drive A, 1
for drive' 8, and so-forth up to 15 for drive P (the
standard
CP/M distribution version supports four
drives). On each disk select, SELDSK must return in
HL the base address of a 16-byte area, called the Disk
Parameter Header, described in the Section 10. For
standard floppy disk drlves, the contents of the
header and associated tables does not change, and thus
the program segment included in the sample C8IOS
performs this operation automatically. If there is an
attempt to select a non-existent drive, SELDSK returns
HL=0000H as an error indicator. Although SELDSK must
return the header address on each call, it
is
advisable to postpone the actual physical disk select
operation until an I/O function (seek, read or write)
is actually performed, since disk selects often occur
without utimately performing any disk I/O, and ~many
controllers will unload the head of the current disk

(All Information Contained Herein is Proprietary to Digital Research.)
18

before selecting the new drive. This would
excessive amount of noise and disk wear.

cause

an

SE'l'TRK

Register BC contains the track number for subseauent
disk accesses on the currently selected drive.
You
can choose to seek the selected track at this time, or
delay the seek until the next read or write actually
occurs.
Register BC can take on values in the range
0-76 corresponding to valid track numoers for standard
floppy disk drives, and 0-65535 for non-standard disk
subsystems.

SE'l'SEC

Register BC contains the sector number (1 through 26)
for subsequent disk accesses on the currently selected
drive.
You can choose to send this information to the
controller at this point, or instead delay sector
selection until a read or write operation occurs.

SE'rOMA

Register BC contains the OMA (disk memory access)
address for subsequent read or write operations.
For
example, if B = 00H and C = 80H when SETOMA is called,
then all subsequent read operations read their data
into 80H through 0FFH, and all subsequent write
operations get their data from 80d through 0FFH, until
the next call to SETDMA occurs.
The initial DMA
address
is assumed to be 80H.
Note that the
controller need not actually support direct memory
access.
If,
for example, all data is received and
sent through I/O ports, the CBIOS which you construct
will use the 128 byte area starting at the selected
DMA address for the memory buffer during the following
read or write operations.

READ

Assuming the drive has been selected, the track has
been set, the sector has been set, and the DMA address
has been specified, the READ subroutine attempts to
read one sector based upon these parameters, and
returns the following error codes in register A:

o
1

no errors occurred
non-recoverable error condition occurred

Currently, CP/M responds only to a zero or non-zero
value as tne return code. That is, if the value in
register A is 0 then CP/M assumes that the disk
operation completed properly.
If an error occurs,
however, the CBIOS should attempt at least 10 retries
to see if the error is recoverable. When an error is
reported the BOOS will print the message "BOOS ERR ON
x:
BAD SECTOR". The operator then has the option of
typing  to ignore the error, or ctl-C to abort.
~vRITE

write the data from the currently selected OMA address
to the currently selected drive,
track, and sector.
'r he d a t a s h 0 u 1 d be mar ked as" non del e ted d a t a " to

(All Information Contained Herein is Proprietary to Digital Research.)
19

..

maintain compatibility with other CP/l'-l systems.
The
error codes given in the READ command are returned in
register A, with error recovery attempts as described
above.
Return the ready status of the list device.
Used by
the DESPOOL program to improve console response during
its operation.
The value 00 is returned in A if the
list device is not ready to accept a character, and
0FFH if a character can be sent to the printer. Note
that a 00 value always suffices.
SEC'l'RAN

Performs sector logical to physical sector translation
in order to impro~e the over~ll response of CP/M.
Standard CP/M systems are shipped with a "skew factor"
of 6, where six physical sectors are skipped between
each logical reaa operation. This skew factor allows
enough time between sectors for most programs to load
their buffers without missing the next sector.
In
particular computer systems which use fast processors,
memory, and disk subsystems, the skew factor may be
changed to improve overall response.
Note,
however,
that you should maintain a single density
IBM
compatible version of CP/M for information transfer
into and out of your computer system, using a skew
factor of 6.
In general, SECTRAN receives a logical
sector number in BC, and a translate table address in
DE.
The sector number is used as an index into the
translate table, with the resulting physical sector
number in HL.
For stanaard systems, the tables and
indexing code is orovided in the CBIO~ and need not be
changed.

(All Information Contained Herein is Proprietary to Digital Research.)
20

7.

A SAMPLE BIOS

'rhe program sho\vn in A.ppendix C can serve as a basis for your
first BIOS. The simolest functions are assumed in this BIOS, so that
you can enter it through the front panel, if absolutely necessary.
Note that the user must alter and insert code into the subroutines for
CONS;r, CONIN, CONOUT, READ, WRITE, and WAITIO subroutines. Storage is
reserved for user-supplied code in these regions. The scratch area
reserved in ?age zero (see Section 9) for the BIOS is used in this
program, so that it could be implemented in ROM, if desired.
Once operational, this skeletal version can be enhanced to print
the initial sign-on message and perform better error recovery. The
subroutines for LIST, PUNCH, and READER can be filled-out,
and the
IOBYTE function can be implemented.

•

(All Information Contained Herein is proprietary to Digital Research.)

21

8.

A SAM.PLE COLO S'rAR'r LOADER

'rhe program shown in Appendix D can serve as a basis for your cold
start loader~ The disk read function must be supplied by the user,
ana the program must be loaded somehow starting at location 0000.
Note tnat space is reserved for your patch so that the total amount of
storage required for the cold start loader is 128 bytes.
Eventually,
you will probably want to get this loader onto the first disk sector
(track 0, sector 1), and cause your controller to load it into memory
automatically upon system start-up.
Alternatively, you may wish to
place tne cold start loader into ROM, and place it above the CP/M
system.
In this case, it will be necessary to originate the program
at a higher address, and key-in a jump instruction at system start-up
which branChes to the loader. Subsequent warm starts will not require
this key-in operation, since the entry point 'WBOOT ' gets control,
thus bringing the system in from disk automatically. Note also that
the skeletal cold start loader has minimal error recovery, which may
be enhanced on later versions.

(All Information Contained Herein is Proprietary to Digital Research.)
22

9.

RESERVED LOCATIONS IN PAGE ZERO

Main memory page zero, between locations 00H ana 0FFH, contains
several segments of code and data which are used during CP/M
processing. The code and data areas are given below for reference
puq)oses.
Locations
from
to
00008 - 0002H

Contents
Contains a jump instruction to the warm start
entry point at location 4A03H+b. This allows a
simple programmed restart (JHP 01tJ0LiiH) or manual
restart from the front Danel.

0003H - 000 3H

Contains the Intel standard I08YTE,
optionally included in tne user's
described in Section 6.

1010 10 48 - 000 4H

Current default drive number (0=A, ••• ,15=.!?).

0005H - 0007H

Contains a jump instruction to the ODOS,and
serves two purposes:
JMP 0005H provides the
primary entry point to the BOOS, as described in
the manual "CP/M Interface Guide," and LHLO
01tJ06H brings the address
field
of
the
instruction to the tiL register pair. This value
is the lowest aadress in memory used by CP/M
(assuming the CCP is being overlayed).
Note
that the DD'r ?rogram will change the address
field to reflect the reduced memory size in
debug mode.

0008H - 0027H

(interrupt locations 1 through 5 not used)

01030H - 1tJ037H

(interrupt location
reserved)

1tJ1038H - 1tJ03AH

Restart 7 - Contains a jum? instruction into the
DDT or SID ?rogram when running in debug mode
for programmed breakpoints, but is not otherwise
used by cp/rvJ..

003BH - 003FH

(not currently used - reserved)

0i040H - 1i.104FH

16 byte area reserved for scratch by CBIOS, but
is not used for any purpose in the distribution
version of CP/M

1tJ050H - 005BH

(not currently used - reserved)

005CH - 1007CH

default file control block produced for a
Command
transient program by the
Console
.!?rocessor.

0070H - 007FH

Optional default random record position

6,

not

which is
CBIOS, as

currently

used

(All Information Contained Herein is Proprietary to Digital Research.)
23

•

0080H - 00FFH

default 12d byte disk buffer (also filled with
the command line when a transient is loaded
under the CCP).

Note that this information is set-up for normal operation under
the CP/M system, but can be overwritten by a transient program if the
BDOS tacilities are not required by the transient.
If, for example, a particular program performs only simple I/O and
must begin execution at location 0, it can be first loaded into the
~PA,
using normal CP/M facilities, with a small memory move progr~
which gets control when loaded
(the memory move program must get
control from location 0100H, which is the assumed beginning of all
transient programs). The move program can then proceed to mo~e the
entire memory image down to location 0, and pass control to the
starting address of the memory load.
Note that if the BIOS is
overwritten, or if location 0 (containing the warm start entry point)
is overwritten, then the progr~mer must bring the CP/M system back
into memory with a cold start sequence.

(All Information Contained Herein is Proprietary to Digital Research.)
24

H'J.

DISK PARAMETER TABLES.

Tables are included in the BIOS which describe the particular
characteristics of the disk subsystem used with CP/M. These tables
can be either hand-coded, as shown in the sample CBIOS in Appendix C,
or automatically generated using the DISKDEF macro library, as shown
in Appendix B. The purpose here is to describe the elements of these
tables.
In general, each disk drive has an associated
(16-byte)
disk
parameter header which both contains information about the disk dr ive
and provides a scratchpad area for certain BDOS operations.
The
format of the disk parameter header for each drive is shown below
Disk
XLT
16b

Parameter

I 0000 I 0000 I 0000 IDIRBUFI
16b

16b

16b

16b

Header
DPB

CSV

ALV

16b

16b

16b

where each element is a word (16-bit) value.
Parameter Header (DPH) element is
XLT

The meaning'of each Disk

Address of the logical to physical translation vector,
if used for this particular drive, or the value 0000H
if no sector translation takes place (i.e, the physical
and logical sector numbers are the same). Disk drives
with identical sector skew factors share the same
translate tables.
Scratchpad values for use
value is unimportant).

within

the

BDOS

(initial

DIRBUF

Address of a 128 byte scratchpad area for directory
operations within BDOS.
All DPH's address the same
scratchpad area.

DPB

Address of a disk parameter block for this drive.
Drives with identical disk characteristics address the
same disk parameter block.

CSV

Address of a scratchpad area used for software check
for changed disks. This address is different for each
DPH.

ALV

Address of a scratchpad area used by the BDOS to keep
disk storage allocation information. This address is
different for each DPH.

-

Given n disk drives, the DPH's are arranged in a table whose first row
of 16 bytes corresponds to drive 0, with the last row corresponding to
drive n-l. The table thus appears as

(All Information Contained Herein is Proprietary to Digital Research.)
25

•

DPBASE:
00 IXLT 001 0000 1 0000 1 0000 IDIRBUFIDBP 001csv 001ALV 001
01 IXLT 011 0000 1 0000 1 0000 IDIRBUFloBP 0llcsv 0llALV 011
(and so-forth through)
n-IIXLTn-ll 0000 1 0000 1 0000 1DIRBUFIDBPn-1ICSVn-IIALVn-l1
where the label DPBASE defines the base address of the DPH table.
A responsibility of the SELDSK subroutine is to return the base
address of the DPH for the selected drive. The following sequence of
operations returns the table address, with a 0000H returned if the
selected drive does not exist.
NDISKS

EQU

4

iNUMBER OF DISK DRIVES

SELDSK:
iSELECT DISK GIVEN BY BC
LXI
H,0000H iERROR CODE
MOV
A,C
iDRIVE OK?
CPI
NDISKS
iCY IF SO
RNC
iRET IF ERROR
iNO ERROR, CONTINUE
MOV
L,C
iLOW(DISK)
MOV
H,B
iHIGH(DISK)
DAD
H
i*2
DAD
H
i*4
DAD
H
i*8
DAD
H
i*16
LXI
D,DPBASE iFIRST DPH
DAD
D
i DPH (DISK)
RET
The translation vectors (XLT 00 through XLTn-l)
are located
elsewhere in the BIOS, and simply correspond one-for-one with the
logical sector numbers zero through the sector count-I.
The Disk
Parameter Block
(DPB)
for each drive is more complex. A particular
OPB, which is addressed by one or more DPHls, takes the general form
SPT
l6b

IBSHIBLMIEXMI
8b

8b

8b

DSM

DRM

l6b

l6b

IAL01ALII
8b

8b

where each is a byte or word value, as shown
indicator below the field.

by

CKS

OFF

l6b

l6b

the

SPT

is the total number of sectors per track

BSH

is the data allocation block shift
by the data block allocation size.

.18b"

factor,

or

"16b"

determined

(All Information Contained Herein is proprietary to Digital Research.)
26

EXM

is the extent mask, determined by the data
allocation size and the number of disk blocks.

DSM

determines the total storage capacity of the disk drive

DRM

determines the total number of directory entries which
can be stored on this drive AL0,ALI determine reserved
directory blocks.

CKS

is the size of the directory check vector

OFF

is the number of reserved tracks at
the (logical) disk.

the

block

beginning

of

The values of BSH and BLM determine (implicitly) the data allocation
size BLS, which is not an entry in the disk parameter block.
Given
that the designer has selected a value for BLS, the values of BSH. and
BLM are shown in the table below
BLS
1,024
2,048
4,096
8,192
16,384

BSH
3
4
5
6

BLM
7
15
31
63
127

7

where all values are in decimal. The value of EXM depends upon both
the BLS and whether the DSM value is less than 256 or greater than
255, as shown in the following table
BLS
1,024
2,048
4,096
8,192
16,384

DSM

< 256

DSM

>

255

N/A
0
1
3

0
1
3
7

15

7

The value of DSM is the maximum data block number supported by
this particular drive, measured in BLS units.
The product BLS times
(DSM+l) is the total number of bytes held by the drive and, of course,
must be within the capacity of the Dhysical disk, not counting the
reserved operating system tracks.
..
The DRM entry is the one less than the total number of directory
entries, which can take on a 16-bit value.
The values of AL0 and ALl,
however, are determined by DRM.
The two values AL0 and ALI can
together be considered a string of l6-bits, as shown below.

(All Information Contained Herein is Proprietary to Digital Research.)
27

•

AL0

ALI

--------------------------------------~----------

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
where position 00 corresponds to the high order bit of the byte
labelled AL0, and 15 corresponds to the low order bit of the byte
labelled ALI.
Each bit position reserves a data block for number of
directory entries,
thus allowing a total of 16 data blocks to be
assigned for directory entries (bits are assigned starting at 00 and
filled to the right until position 15). Each directory entry occupies
32 bytes, resulting in the following table
BLS
1,024
2,048
4,096
8,192
16,384

Directory
32 times
64 times
128 times
256 times
512 times

Entries
# bits
# bits
# bits
# bits
# bits

Thus, if DRM = 127 (128 directory entries), and BLS = 1024, then there
are 32 directory entries per block, requiring 4 reserved blocks.
In
this case, the 4 high order bits of AL0 are set, resulting in the
value~ AL0 = 0F0H and ALI = 00H.
The CKS value is determined as follows:
if the disk drive" media
is removable, then CKS = (DRM+l)/4, where DRM is the last directory
entry number.
If the media is fixed, then set CKS = 0 (no directory
'records are checked in this case).
Finally,
skipped at the
automatically
mechanism for
partitiQning a

the OFF field determines the number of tracks which are
beginning of the physical disk~
This value is
added whenever SETTRK is called, and can be used as a
skipping reserved operating system tracks,
or for
large disk into smaller segmented sections.

To complete the discussion of the DPB, recall that several DPH's
can address the same DPB if their drive characteristics are identical.
Further,
the DPB can be dynamically changed when a new drive is
addressed by sim?ly changing the pointer in the DPH since the BDOS
copies the DPB values to a local area whenever the SELDSK function is
invoked.
Returning back to the DPH for a particular drive, note that the
two address values csv and ALV remain.
Both addresses reference an
area of un initialized memory following the BIOS.
The areas must be
unique for each drive, and the size of each area is determined by the
values in the DPB.
The size of the area addressed by CSV is CKS bytes, which is
sufficient to hold the directory check information for this particular
drive.
If CKS = (DRM+l)/4, then you must reserve (DRM+l)/4 bytes for
directory check use.
If CKS = 0, then no storage is reserved.
(All Information Contained Herein is Proprietary to Digital Research.)
28

The size of the area addressed by ALV is determined by the
maximum number of data blocks all~ed for this particular disk, and is
computed as (DSM/8)+I.
The CBIOS shown in Appendix C demonstrates an instance of these
tables for standard 8" single density drives.
It may be useful to
examine, this program,
and compare the tabular values with the
definitions given above.

•

(All Information Contained Herein is Proprietary to Digital Research.)
29

11.

THE DISKDEF MACRO LIBRARY.

A macro library is shown in Appendix F, called DISKDEF, which
greatly simplifies the table construction process. You must have
access to the MAC macro assembler, of course,
to use the DISKDEF
facility, while the macro library is included with all CP/M 2.0
distribution disks.
A BIOS disk definition consists of
macro statements:
MACLIB

DISKDEF

DISKDEF
DISKDEF

o , •••

· . . . ..
DISKS
· . . . ..
DISKDEF
· .....
ENDEF

the

following

sequence

of

n

1 , ...

n-l

where the MACLIB statement loads the DISKDEF.LIB 'file
(on the same
disk as your BIOS) into MAC's internal tables. The DISKS macro call
follows, which specifies the number of drives to be configured with
your system, where n is an integer in the range 1 to 16. A series of
DISKDEF macro calls then follow which define the characteristics of
each logical disk, 0 through n-l (corresponding to logical drives A
through P). NJte that the DISKS and DISKDEF macros generate the
in-line fixed data tables described in the previous section, and thus
must be placed in a non-executable portion of your BIOS,
typically
directly following the BIOS jump vector.
The remaining portion of your BIOS is defined following the
DISKDEF macros, with the ENDEF macro call immediately preceding the
END statement.
The ENDEF
(End of Diskdef) macro generates the
necessary uninitialized RAM areas which are located in memory above
your BIOS.
The form of the DISKDEF macro call is
DISKDEF

dn,fsc,lsc, [skf] ,bls,dks,dir,cks,ofs, [0]

where
dn
fsc
Isc
skf
bls
dir
cks
ofs
[0 ]

is
is
is
is
is
is
is
is
is

the logical disk number, 0 to n-l
the first physical sector number (0 or I)
the last sector number
the optional sector skew factor
the data allocation block size
the number of directory entries
the number of "checked ll directory entries
the track offset to logical track 00
an optional 1.4 compatibility flag

The value "dnll is the drive number being

defined

with

this

DISKDEF

(All Information Contained Herein is Proprietary to Digital Research.)
30

macro invocation.
The "fsc" parameter accounts for differing sector
number ing systems, and is usually 0 or 1.
The "lsc"
is the last
numbered sector on a track. When present, the "skf" parameter defines
the sector skew factor which is used to create a sector translation
table according to the skew.
If the number of sectors is less than
256, a single-byte table is created, otherwise each translation table
element occupies two bytes. No translation table is created if the
skf parameter is omitted (or equal to 0).
The "bls" parameter
specifies the number of bytes allocated to each data block, and takes
on the values 1024, 2048, 4096, 8192, or 16384.
Generally,
performance increases with larger data block sizes since there are
fewer directory references and logically connected data records. are
physically close on the disk.
Further, each directory entry.addresses
more data and the BIOS-resident ram space is reduced. The "dks"
specifies the total disk size in "bls" units. That is, if the bls =
2048 and dks = 1000, then the total disk capacity is 2,048,000 bytes.
If dks is greater than 255, then the block size parameter bls must be
greater than 1024.
The value of "dir" is the total number of
directory entries which may exceed .255,
if desired.
The licks"
parameter determines the number of directory items to check on each
directory scan, and is used internally to detect changed disks during
system operation, where an intervening cold or warm start has not
occurred (when this situation is detected, CP/M automatically marks
the disk read/only so that data is not subsequently destroyed). As
stated in the previous section, the value of cks = dir when the media
is easily changed, as is the case with a floppy disk subsystem.
If
the disk is permanently mounted, then the value of cks is typically 0,
since the probability of changing disks without a restart is quite
low.
The "ofs" value determines the number of tracks to skip when
this particular drive is addressed, which can be used to reserve
additional operating system space or to simulate several logical
drives on a single large capacity physical drive.
Finally, the
[0]
parameter is included when file compatibility is required with
versions of 1.4 which have been modified for higher density disks.
This parameter ensures that only 16K is allocated for each directory
record, as was the case for previous versions.
Normally, this
parameter is not included.
For convenience and economy of table space, the special form
DISKDEF

i, j

gives disk i the same characteristics as a previously defined drive j.
A standard four~drive single density system, which is compatible with
version 1~4, is defined using the following macro invocations:

(All Information Contained Herein is Proprietary to Digital Research.)
31

•

DISKS
DISKDEF
DISKDEF
DISKDEF
DISKDEF

4

0,1,26,6,1024,243,64,64,2
1,0
2,0
3,0

ENDEF
with all disks having the same parameter values of 26 sectors per
track
(numbered 1 through 26), with 6 sectors skipped between each
access, 1024 bytes per data block, 243 data blocks for a total of 243k
byte disk capacity, 64 checked directory entries,
and two operating
system tracks.
The DISKS macro generates n Disk Parameter Headers
(DPH's),
starting at the DPH table address DPBASE generated by the macro.
Each
disk header block contains sixteen bytes, as described above, and
correspond one-for-one to each of the defined drives.
In the four
drive standard system, for example, the DISKS macro generates a table
of the form:
DPBASE
DPE0 :
DPEl:
DPE2 :
DPE3 :

EQU
DW
DW
DW
DW

$
XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0
XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSVl,ALVl
XL'N} ,00 00H, 00 00H, 00 00H ,DIRBUF ,DPB0 , CSV2, ALV2
XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3

where the DPH labels are included for reference purposes to show the
beginning table addresses for each drive 0 through 3. The values
contained within the disk parameter header are described in detail in
the previous section.
The check and allocation vector addresses are
generated by the ENDEF macro in the ram area following the BIOS code
and tables.
Note that if the "skf" (skew factor) parameter is omitted
(or
equal to 0),
the translation table is omitted, and a 0000H value is
inserted in the XLT position of the disk parameter header for
the
disk.
In a subsequent call to perform the logical to physical
translation, SECTRAN receives a translation table address of DE =
0000H,
and simply returns the original logical sector from BC in the
HL r eg i s t e r p air. A t ran s 1 ate tab 1 e i s con s t r u c ted when the s-k f
parameter is present, and the (non-zero) table address is placed into
the corresponding DPH's.
The table shown below,
for example,
is·
constructed when the standard skew factor skf = 6 is specified in the
DISKDEF macro call:
XLT0:

DB
DB

1,7,13,19,25,5,11,17,23,3,9,15,21
2,8,14,20,26,6,12,18,24,4,10,16,22

Following the ENDEF macro call, a number of uninitialized data
areas are defined.
These data areas need not be a part of the BIOS
which is loaded upon cold start, but must be available between the
BIOS and the end of memory.
The size of the un initialized RAM area is
determined by EQU statements generated by the ENDEF macro.
For a
standard four-drive system, the ENDEF macro might produce
(All Information Contained Herein is Proprietary to Digital Research.)
32

BEGDAT EQU $
(da ta areas)
ENDDA'I' EQU $
DATSIZ EQU $-BEGDAT

4C72 =
4DB0 =
013C =

which indicates that uninitialized RAM begins at location 4C72H,
ends
at 4DB0H-l, and occupies 013CH bytes. You must ensure that these
addresses are free for use after the system is loaded.
After modification, you can use the STAT program to check your
drive characteristics, since STAT uses the disk parameter block to
decode the drive information. The STAT command form
STAT d:DSK:
decodes the disk parameter block for drive d (d=A, ••• ,P) and
the values shown below:
r:
k:
d:
c:
e:
b:
s:
t:

128 Byte
Kilobyte
32 Byte
Checked
Records/
Records/
Sectors/
Reserved

displays

Record Capacity
Drive Capacity
Directory Entries
Directory Entries
Extent
Block
Track
Tracks

Three examples of DISKDEF macro invocations are
corresponding STAT parameter values
(the last
8-megabyte system).

shown below
produces a

with
full

DISKDEF 0,1,58,,2048,256,128,128,2
r=4096, k=512, d=128, c=128~ e=256, b=16, s=58, t=2
DISKDEF 0,1,58,,2048,1024,300,0,2
r=16384, k=2048, d=300, c=0, e=128, b=16, s=58, t=2
DISKDEF 0,1,58,r16384,512,128,128,2
r=65536, k=8192, d=128, c=128, e=1024, b=128, s=58, t=2

(All Information Contained Herein is Proprietary to Digital Research.)
33

•

12.

SECTOR BLOCKING AND DEBLOCKING.

Upon each call to the BIOS WRITE entry point,
the CP/M BDOS
includes information which allows effective sector blocking and
deblocking where the host disk subsystem has a sector size which is a
multiple of the basic 128-byte unit.
The purpose here is to present a
general-purpose algorithm which can be included within your BIOS which
uses the BDOS information to perform the operations automatically.
Upon each call to WRITE,
information in register C:

o
1

2

=

=
=

the

BDOS

provides

the

following

normal sector write
write to directory sector
write to the first sector
of a new data block

Condition 0 occurs whenever the next write operation is into a
previously written area, such as a random mode record update, when the
write is to other than the first sector of an unallocated block, or
when the write is not into the directory area.
Condition 1 occurs
when a write into the directory area is performed. Condition 2 occurs
when the first record
(only)
of a newly allocated data block is
written.
In most cases, application programs read or write multiple
128 byte sectors in sequence, and thus there is little overhead
involved in either operation when blocking and deblocking records
since pre-read operations can be avoided when writing records.
Appendix G lists the blocking and deblocking algorithms in skeletal
form
(this file is included on your CP/M disk). Generally, the
algorithms map all CP/M sector read operations onto the host disk
through an intermediate buffer which is the size of the host disk
sector. Throughout the program, values and variables which relate to
the CP/M sector involved in a seek operation are prefixed by "sek,"
while those related to the host disk system are prefixed by "hst."
The equate statements beginning on line 29 of Appendix G define the
mapping between CP/M and the hos t system, and mu s t be changed if other
than the sample host system is involved.
The entry points BOOT and WBOOT must contain the initialization
code starting on line 57, while the SELDSK entry point must be
augmented by the code starting on line 65.
Note that although the
SELDSK entry point computes and returns the Disk Parameter Header
address, it does not physically selected the host disk·at this point
(it is selected later at READHST or WRITEHST).
Further, SETTRK,
SETTRK, and SETDMA simply store the values, but do not take any other
action at this point.
SECTRAN performs a trivial trivial function of
returning the physical sector number.
The principal entry points are READ and WRITE, starting on lines
110 and 125, respectively. These subroutines take the place of your
previous READ and WRITE operations.
The actual physical read or write takes place at either WRITEHST
or READHST, where all values have been prepared:
hstdsk is the host
(All Information Contained Herein is Proprietary to Digital Research.)
34

disk number, hsttrk is the host track number, and hstsec is the host
sector number (which may require translation to a physical sector
number) •
You must insert code at this point which performs the full
host sector read or write into, or out of, the buffer at hstbuf of
length hstsiz.
All other mapping functions are performed by the
algorithms.
This particular algorithm was tested using an 80 megabyte hard
disk unit which was originally configured for 128 byte sectors,
producing approximately 35 megabytes of formatted storage.
\r\lhen
configured for 512 byte host sectors, usable storage increased to 57
megabytes, with a corresponding 400% improvement in overall response.
In this situation,
there is no apparent overhead involved
in
deblocking sectors, with the advantage that user programs still
maintain the (less memory consuming)
128-byte sectors.
This is
primarily due, of course,
to the information provided by the BDOS
which eliminates the necessity for pre-read operations to take place •

•

(All Information Contained Herein is Proprietary to Digital
35

Re~earch.)

APPENDIX A: THE MDS COLD START LOADER
MDS-800 Cold Start Loader for CP/M 2.0
Version 2.0 August, 1979
0000
ffff
0000

=
=
=

false
egu
true
egu
testing egu
bias

0000

=

bias

0000
0806
1880
1600
1603

=
=
=
=
=

cpmb
bdos
bdose
boot
rboot

3000
1880
13002
0031
0019
0018
f800
ff0f
0078
0079
007b
007f
0078
0079
007a
00ff
0003
0004
0100

=

=
=
=

=

=

=

=

=
=
=
=
=

=
=
=
=
=

if
egu
endif
if
egu
endif
egu
egu
egu
egu
egu

o
not false
false
testing
03400h
not testing
0000h
bias
806h+bias
1880h+bias
1600h+bias
boot+3

;base of dos load
;entry to dos for calls
;end of dos load
;cold start entry point
;warm start entry point

;loaded here by hardware

.,

org

3000h

bdosl
ntrks
bdoss
bdos0
bdosl
Gil

egu
egu
egu
egu
eou

bdose-cpmb

mon8e!
rmon80
base
rtype
rbyte
reset

egu
egu
egu
egu
egu
egu

0f800h
0ff0fh
078h
base+l
base+3
base+7

;intel monitor base
irestart location for mon80
i 'base' used by controller
iresult type
;result byte
ireset controller

dstat
ilow
ihigh
bsw
recal
readf
stack

egu
egu
egu
egu
egu
egu
egu

base
base+l
base+2
0ffh
3h
4h
100h

idisk status port
ilow iopb address
;high iopb address
iboot switch
;recalibrate selected drive
idisk read function
;use end of boot for stack

.,

2

bdosl/128
25
bdoss-bdos0

; tracks to read
;# sectors in bdos
;# on track 0
i# on track 1

rstart:
3000 310001
3003 db79
3005 db7b
30137 dbff

1~~6 e~~130

lxi
sp,stackiin case of call to mon80
clear disk status
in
rtype
in
rbyte
check if boot switch is off
coldstart:
in
bsw
ani
02b d t
t·switch on?
coT s ar
Jnz
36

clear the controller
out
reset
ilogic cleared

300e d37f
3010 0602
3012 214230

mvi
'lxi

b,ntrks inumber of tracks to read
h, iopb0

start:

j~t¥ ~~~g30

read first/next track into cpmb
mov
a,l
out
ilow
mov
a,h
ou t
ihigh
in
dstat
ani
4
Jz
wai to

3022 db79
3024 e603
3026 fe02

check disk status
in
rtype
ani
lIb
cpi
2

3015
3016
3018
3019
30lb

7d
d379
7c
d37a
db78

wai to:

i

3028 d20030
302b db7b
302d
302e
3031
3032

17
dc0fff
If
e6le

3034 c20030

if
cnc
endif
if
jnc
endif

testing
rmon80
igo to monitor if 11 or 10
not testing
rstart iretry the load

in
rbyte
ii/o complete, check status
if not ready, then go to mon80
ral
cc
rmon80 inot ready bit set
rar
irestore
ani
lll10b ioverrun/addr err/seek/crc
if
cnz
endif
if
jnz
endif

testing
rmon80
igo to monitor
,not testing
rstart iretry the load

3037'110700
303a 19
303b 05
303c c2l530

lxi
dad
dcr
jnz

303f c300l6

jmp boot, print message, set-up jmps
jmp
boot

d,iopbl ilength of iopb
d
iaddressing next iopb
b
icount down tracks
start

parameter blocks
37

•

3042
3043
3044
3045
3046
3047
0007

80
04
19
00
02
0000

iopb0:

=

iopbl

3049
304a
304b
304c
304d
304e
3050

80
04
18
01
01
800c

iopbl:

db
db
db
db
db
dw
egu

80h
readf
bdos0
11
2
cpmb
$-iopb0

i iocw, no update
i read function
i# sectors to read trk

db
db
db
db
db
c1w
end

80h
readf
bdosl
isectors to read on track 1
1
itrack 1
1
isector 1
cpmb+bdos0*128
ibase of second rd

"

itrack 0
istart with sector 2, trk 0
istart at base of bdos

i

38

APPENDIX B:

THE MDS BASIC I/O SYSTEM (BIOS)

mds-800 i/o drivers for cp/m 2.0
(four drive single density version)
version 2.0 august, 1979
0014

=

vers

equ

20

;version 2.0

copyright (c) 1979
digital research
box 579, pacific grove
california, 93950
4a00
3400 =
3c06 =
1600 =
002c =
0002 =
0004 =
0080 =
000a =

cpmb
bdos
cpml
nsects
offset
cdisk
buff
retry

org
equ
egu
equ
equ
equ
equ
equ
equ

4a00h
;base of bios in 20k system
3400h
;base of cpm ccp
3c06h
;base of bdos in 20k system
$-cpmb ;length (in bytes) of cpm system
cpml/128;number of sectors to load
2
;number of disk tracks used by cp
0004h
;address of last logged disk
0080h
;default buffer address
10
;max retries on disk i/o before e

perform following functions
boot
cold start
wboot
warm start (save i/o byte)
(boot and wboot are the same for mds)
const
console status
reg-a = 00 if no character ready
reg-a = ff if character ready
conin
console character in (result in reg-a)
conout console character out (char in reg-c)
list
list out (char in reg-c)
punch
punch out (char in reg-c)
reader paper tape reader in (result to reg-a)
move to track 00
horne
(the following calls set-up the io parameter bloc
mds, which is used to perform subsequent reads an
seldsk select disk given by reg-c (0,1,2 ••• )
settrk set track address (0, ••• 76) for sub r/w
setsec set sector address (1, ••• ,26)
setdma set subsequent dma address (initially 80h
read/write assume previous calls to set i/o parms
read
read track/sector to preset dma address
write
write track/sector from preset dma addres
4a00
4a03
4a06
4arii9
4a0c

jump vector for indiviual routines
jmp
boot
c3b34a
c3c34a wboote: jmp
wboot
c36l4b
jmp
const
jmp
conin
c3644b
jmp
conout
c36a4b
39

•

4a0f
4a12
4a15
4a18
4alb
4ale
4a2l
4a24
4a27
4a2a
4a2d
4a30

c36d4b
c3724b
c3754b
c3784b
c37d4b
c3a74b
c3ac4b
c3bb4b
c3c14b
c3ca4b
c3704b
c3b14b

4a33+=
4a33+824a00
4a37+000000
4a3b+6e4c73
4a3f+0d4dee
4a43+824a00
4a47+000000
4a4b+6e4c73
4a4f+3c4dld
4a53+824a00
4a57+000000
4a5b+6e4c73
4a5f+6b4d4c
4a63+824a00
4a67+000000
4a6b+6e4c73
4a6f+9a4d7b
4a73+=
4a73+la00
4a75+03
4a76+07
4a77+00
4a78+f200
4a7a+3f00
4a7c+c0
4a7d+00
4a7e+1000
4a80+0200
4a82+=
4a82+0l
4a83+07
4a84+0d
4a85+l3
4a86+l9
4a87+05
4a88+0b
4a89+ll
4a8a+17
4a8b+03

dpbase
dpe0:

dpel:

dpe2:

dpe3 :

dpb0

xlt0

jmp
jmp
jmp
jmp
jmp
jmp
jml?
jmp
jmp
jmp
jmp
jmp

list
punch
reader
home
seldsk
settrk
setsec
setdma
read
write
listst ;list status
sectran

maclib
disks
egu
dw
dw
dw
dw
dw
dw
dw
dw
dw
dw
dw
dw
dw
dw
dw
dw
diskdef
equ
dw
db
db
db
dw
dw
db
db
dw
dw
egu
db
db
db
db
,
db
db
db
db
db
db

diskdef ;load the disk definition library
4
;four disks
$
;base of disk parameter blocks
xlt0,0000h
;translate table
0000h,0000h
;scratch area
dirbuf,dpb0
;dir buff,parm block
csv0,alv0
;check, alloc vectors
xltl,0000h
;translate table
0000h,0000h
;scratch area
dirbuf,dl?bl
;dir buff,parm block
csvl,alvl
;check, alloc vectors
xlt2,0000h
;translate table
0000h,0000h
;scratch area
dirbuf,dpb2
idir buff,parm block
csv2,alv2
;check, alloc vectors
xlt3,0000h
;translat€ table
0000h,0000h
;scratch area
dirbuf,dpb3
;dir buff,parm block
csv3,alv3
;cheek, alloe vectors
0,1,26,6,1024,243,64,64,offset
$
; di s k parm block
26
;sec per track
3
iblock shift
7
;block mask
o
iextnt mask
242
;disk size-l
63
;directory max
192
;alloe0
o
;allocl
16
icheck size
2
;offset
$
itranslate table
1
7
13
19
25
5
11
17
23
3

40

4a8c+09
4aSd+0f
4aSe+15
4aSf+02
4a90+08
4a91+0e
4a92+14
4a93+1a
4a94+06
4a95+0c
4a96+12
4a97+1S
4a9S+04
4a99+0a
4a9a+110
4a9b+16
4a73+=
001f+=
0010+=
4aS 2+=

dpbl
alsl
cssl
xltl

4a73+=
001f+=
00HJ+=
4aS2+=

dpb2
als2
css2
xlt2

4a73+=
001f+=
001121+=
4aS2+=

dpb3
als3
css3
xlt3

db
9
db
15
db
21
db
2
db
8
db
14
db
20
db
26
db
6
db
12
db
IS
db
24
db
4
db
10
db
16
db
22
diskdef 1,10
equ
dpb0
equ
als0
equ
css0
xlt0
equ
diskdef 2,0
equ
dpb0
equ
als0
equ
css0
equ
xlt0
diskdef 3,0
dpb0
equ
equ
als0
equ ,
css0
equ
xlt0
endef occur s at

iequivalent parameters

isame allocation vector size
isame checksum vector size
i same translate table
iequivalent parameters

isame allocation vector size
isame checksum vector size
i same translate table
ieguivalent parameters

isame allocation vector size
isame checksum vector size
isame translate table
end of assembly

end of controller - independent code, the remaini
are tailored to the particular oper.ating environm
be altered for any system which differs from the
the following code assumes the mds monitor exists
and uses the i/o subroutines within the monitor

.,
00fd
00fc
00f3
007e

=
=
=
=

revrt
intc
icon
inte

fS00
ff0f
fS03
fS06
fS09
fS0c
fS0f
fS12

=
=
=
=
=
=
=
=

monS0
rmonS0
ci
ri
co
po

.,

10
csts

we also
equ
equ
equ
equ

assume the mds system has four disk drive
0fdh
iinterrupt revert port
0fch
iinterrupt mask port
0f3h
iinterrupt control port
0111$1110bienable rst o (warm boot) ,rst 7

mds monitor equates
equ
0f800h ;mds monitor
equ
0ff0fh irestart monS0 (boot error)
equ
0fS03h ;console character to reg-a
equ
0fS06h ireader in to reg-a
0fS09h
;console char from c to console 0
equ
equ
0fS0ch ;punch char from c to punch devic
0fS0fh ilist from c to list device
equ
0fS12h ;console status 00/ff to register
equ
41

•

disk ports and commands
. ;base of disk command io ports
equ
78h
;disk status (input)
equ
base
equ
base+l ;result type (input)
equ
base+3 ;result byte (input)

101078 =
101078 =
101079 =
IOf07b =

base
dstat
rtype
rbyte

=
=

ilow
ihigh

equ
equ

base+l
base+2

;iopb low address (output)
;iopb high address (output)

1010104 =
1010106 =
00103 =
1010104 =
f00fOd =
fOfOfOa =

readf
writf
recal
iordy
cr
If

equ
equ
equ
egu
equ
equ

4h
6h
3h
4h
0dh
0ah

;read function
;write function
;recalibrate drive
;i/o finished mask
;carriage return
;line feed

4a9c
4a9f
4aal
4aad
4ab0

s ignon: ; s ignon
db
db
db
db
db

101079
fOI07a

0dfOa0a
32310
6b20.43f
32 2e3 0
fOd0af00

;

.,

boot:
4ab3
4ab6
4ab9
4abc
4abd
4acfO

31010101
219c4a
cdd34b
af
3204100
c30f4b

message: xxk cp/m vers y.y
cr,lf,lf
120 1
;sample memory size
Ik cp/m vers I
vers/lfO+lfO l , 1 . 1 ,vers mod 10+ 110 1
cr,lf,0

;print signon message and go to ccp
(note: mds boot initialized iobyte at 0003h)
lxi
sp,buff+80h
lxi
h,signon
call
prmsg
;print message
xra
a
fclear accumulator
cdisk
;set initially to disk a
sta
jmp
gocpm
;go to cp/m

wboot:; loader on track 0, sector 1, which will be skippe
read cp/m from disk - assuming there is a 128 byt
star t.
4ac3 31810100

lxi

sp,buff ;using dma - thus 810 thru ff ok f

4ac6 0e0a
4ac8 c5

mvi
c,retry ;max retries
push
b
wboot0: ;enter here on error retries
4ac9 01101034
lxi
b,cpmb ;set dma address to start of disk
4acc cdbb4b
call
setdma
4acf 0efOIO
q1vi
c,0
;boot from drive 10
4adl cd7d4b
call
seldsk
4ad4 0e00
mvi
c,1O
4ad6 cda74b
call
settrk ;start with track 10
4ad9 0elO2
mvi
c,2
;start reading sector 2
4adb cdac4b
call
setsec
4ade cl
4adf 062c

read sectors, count nsects to zero
pop
b
;10-error count
mvi
b,nsects
42

rdsec:
4ael
4ae2
4ae5
4ae8
4aeb
4aee
4aef
4af0
4afl
4af4
4af7
4af9

c5
cdc14b
c2494b
2a6c4c
118000
19
44
4d
cdbb4b
3a6b4c
fela
da054b

4afc
4aff
4b00
4b01
4b04
4b05
4b06
4b07
'4b0a
4 b0 b
4b0c

3a6a4c
3c
4f
cda74b
af
3c
rdl:
4f
cdac4b
cl
05
c2e14a
gocpm:

4b0f
4b10
4b12
4b14
4b15
4b17
4b19
4blb
4blc

f3
3e12
d3fd
af
d3fc
3e7e
d3fc
af
03f3

4ble 018000
4b21 cdbb4b
4b24
4b26
4b29
4b2c
4b2f
4b32
4b35
4b38
4b3b
4b3e

3ec3
320000
21034a
220100
320500
21063c
220600
323800
2100f8
223900

iread next sector
push
b
isave sector count
call
read
jnz
booterr iretry if errors occur
Ihld
iod
;increment dma address
lxi
d,128
isector size
dad
d
iincremented dma address in hI
mov
b,h
c,l
mov
iready for call to set dma
setdma
call
Ida
ios
isector number just read
cpi
26
iread last sector?
jc
rdl
must be sector 26, zero and go to next track
Ida
iot
iget track to register a
inr
a
mov
c,a
iready for" call
call
settrk
xra
a
iclear sector number
inr
a
ito next sector
mov
c,a
iready for call
call
setsec
pop
b
irecall sector count
dcr
b
i done?
jnz
rdsec
done with the load, reset default buffer address
i (enter here from cold start boot)
enable rst0 and rst7
di
mvi
a ,12h
iinitialize command
out
revrt
xra
a
out
intc
icleared
mvi
a,inte irst0 and rst7 bits on
out
intc
xra
a
icon
;interrupt control
out
set default buffer address to 80h
lxi
b,buff
call
setdma
reset monitor entry points
mvi
a, j mp
sta
0
lxi
h,wboote
shld
1
ijmp wboot at location 00
sta
5
lxi
h,bdos
shld
6
ijmp bdos at location 5
sta
7*8
ijmp to mon80 (may have been chan
lxi
h,mon80
shld
7*8+1
leave iobyte set
43

•

4b4l
4b44
4b45
4b46

3a04flfl
4f
fb
c30034

·,

previously selected disk was b, send parameter to
Ida
cdisk
:last logged disk number
mov
c,a
:send to ccp to log it in
ei
jmp
cpmb

:

error condition occurred, print message and retry

booterr:
4b49 cl
4b4a 0d
4b4b ca524b

pop
b
:recall counts
dcr
c
jz
booterfl
try again
push
b
jmp
wboot0

4b4e c5
4b4f c3c94a
booter0:
4b52 2l5b4b
4b55 cdd34b
4b58 c30fff

·,

otherwise too many retries
lxi
h,bootmsg
call
prmsg
jmp
rmon80
:mds hardware monitor

bootrnsg:
4bSb 3f626f4

db

:

'?boot',0

const:

:console status to reg-a
(exactly the same as mds call)
jmp
csts

conin:

:console character to reg-a
call
ci
ani
7fh
:remove parity bit.
ret

4b6l c3l2f8
4b64 cd03f8
4b67 e67f
4b69 c9
;

conout: ;console character from c to console out
4b6a c309f8
jmp
co

·,

list:
4b6d c30ff8

;list device out
(exactly the same as mds call)
jmp
10

;

listst:
;return list status
xra
a
ret
:always not ready

4b70 af
4b7l c9
;

punch:
4b72 c30cf8

·,

;punch device out
(exactly the same as mds call)
jmp
po

reader: ;reader character in to reg-a
(exactly the same as mds call)
4b75 c306f8
jmp
ri
;

horne:

;move to horne position
44

;
4b78 0e00
4b7a c3a74b

treat as track 00 seek
mvi
c,0
jmp
settrk

;

se1dsk: ;se1ect
4b7d 210000
1xi
4b80 79
mov
4b81 fe04
cpi
4b83 d0
rnc

disk given by register c
h,0000h ireturn 0000 if error
a,c
ndisks itoo large?
;leave hI = 0000

4b84
4b86
4b89
4b8a
4b8c
4b8d
4b90

10b
i00 00 for drive 0,1 and 10 10 fo
dbank
ito select drive bank
arC
i00, 01, 10, 11
1b
imds has 0,1 at 78, 2,3 at 88
a
iresu1t 00?
setd rive
a,00110000b
;se1ects drive 1 iri bank

e602
32664c
79
e601
b7
ca924b
3e30

ani
sta
mov
ani
ora

jz

mvi
setdrive:
4b92 47
mov
4b93 21684c
1xi
4b96 7e
mov
4b97 e6cf
ani
4b99 b0
ora
4b9a 77
mov
mov
~B~8 ~~00
mvl.
4bge 29
dad
4b9f 29
dad
4ba0 29
dad
dad
4ba1 29
1xi
4ba2 11334a
4ba5 19
dad
ret
4ba6 c9

b,a
isave the function
h,iof
iio function
a,m
11001111b
;mask out disk number
b
;mask in new disk number
m,a
;save it in iopb

~~~

;h1=disk number
i*2
;*4
;*8
;*16

h

h
h

h
d,dpbase
d
;h1=disk header table address

.,
4ba7 216a4c
4baa 71
4bab c9

settrk: ;set track address given by c
1xi
h,iot
mov
m,c
ret

setsec: ;set sector number given by c
1xi
h,ios
mov
m,c
ret
sectran:
;trans1ate sector bc using table at de
4bb1 0600
mvi
b,0
idoub1e precision sector number i
4bb3 eb
xchg
itrans1ate table address to hI
4bb4 09
b
dad
;trans1ate(sector) address
4bb5 7e
mov
a,m
itrans1ated sector number to a
4bb6 326b4c
sta
ios
1,a
i return sector number in 1
mo~
~gg~
re
4bac 216b4c
4baf 71
4bb0 c9

gg

.,

setdma: ;set dma address given by regs b,c
45

4bbb
4bbc
4bbd
4bc0

mov
mov
shld
ret

69
6r.1
226c4c
c9

l,c
h,b
iod

;

read:
4bcl
4bc3
4bc6
4bc9

r.1er.14
cde04b
cdfr.14b
c9

; read next disk
mvi
c,readf
setfunc
call
waitio
call
ret

record (assuming disk/trk/sec/dma
;set to read function
;perform read function
;may have error set in reg-a

;

write:
4bca
4bcc
4bcf
4bd2

r.1er.16
cder.14b
cdfr.14b
c9

prmsg:
4bd3 7e
4bd4 b7
4bd5 c8
4bd6
4bd7
4bd8
4bdb
4bdc
4bdd

e5
4f
cd6a4b
el
23
c3d34b

;disk write function
mvi
c,writf
call
setfunc :set to write function
waitio
call
ret
;may have error set
utility subroutines
:print message at h,l to 0
mov
a,m
ora
a
: zero?
rz
more to print
push
h
mov
c,a
call
conout
pop
h
inx
h
jmp
prmsg

:

setfunc:
4ber.1
4be3
4be4
4be6
4be7

21684c
7e
e6f8
bl
77

4be8
4bea
4bed
4bee
4bef

e620
216b4c
b6
77
c9

set function for next i/o (command in reg-c)
lxi
h,iof
:io function address
mov
a,m
:get it to accumulator for maskin
11111000b
:remove previous command
ani
ora
:set to new command
c
mov
m,a
;replaced in iopb
the mds-800 controller req's disk bank bit in sec
mask the bit from the current i/o function
ani
00100000b
:mask the disk select bit
lxi
h,ios
;address the sector selec
ora
m
:select proper disk bank
mov
m,a
;set disk select bit on/o
ret
;

waitio:
4bf0 0e0a

mvi

c,retry :max retries before perm error

rewai t:
4bf2 cd3f4c
4bf5 cd4c4c

start the i/o function and wait for completion
call
intype :in rtype
call
inbyte :clears the controller

4bf8 3a664c

Ida

dbank

;set bank flags
46

4bfb
4bfc
4bfe
4c00
4c03
4c05
4c06
4c08

b7
3e67
064c
c20b4c
d379
78
d37a
c3H'4c

·,

iodrl:
4c0b d389
4c0d 78
4c0e d38a

ora
mvi
mvi
jnz
'out
mov
out
jmp

;zero if drive 0,1 and nz
a
a,iopb and 0ffh ; low address for iopb
b, iopb shr 8
; high address for iopb
iodrl
;drive bank I?
ilow
;low address to controlle
a,b
ihigh
; high address
wait0
ito wait for complete

; dr ive bank 1
out
ilow+10h
mov
a,b
ihigh+10h
out

;88 for drive bank 10

;

4c10 cd594c wai to:
4c13 e604
4c15 ca104c

call
ani
jz

instat
iordy
wait0

;wait for completion
;ready?

4clb fe02
4cld ca324c

check io completion ok
call
intype
;must be io complete (00)
00 unlinked i/o complete,
01 linked i/o comple
10 disk status changed
11 (not used)
cpi
10b
;ready status change?
jz
wready

4c20 b7
4c21 c2384c

must be 00 in the accumulator
ora
a
;some other condition, re
jnz
werror

4c24
4c27
4c28
4c2b
4c2c
4c2e

check i/o error bits
. inbyte
call
ral
jc
wready
rar
11111110b
ani
jnz
werror

4c18 cd3f4c

cd4c4c
17
da324c
If
e6fe
c2384c

4c31 c9

·,

;unit not ready
;any other errors?

read or write is ok, accumulator contains zero
ret

wready: ;not ready, treat as error for now
4c32 cd4c4c
call
inbyte
;clear result byte
4c35 c3384c
jmp
trycount
werror: ;return hardware malfunction (crc, track, seek, e
the mds controller has returned a bit in each pos
of the accumulator, corresponding to the conditio
o
- deleted data (accepted as ok above)
;
,
1
- crc error
2
- seek error
3
- address error (hardware malfunction)
4
- data over/under flow (hardware malfunct
5
- write protect (treated as not ready)
6
- write error (hardware malfunction)
I
7
- not ready
;

·

·

47

(accumulator bits are numbered 7 6 5 4 3 2 1 0)
it may be useful to filter out the various condit
but we will get a permanent error message if it i
recoverable.
in any case, the not ready conditio
treated as a separate condition for later improve
trycount:
register c contains retry count, decrement 'til z
4c38 0d
dcr
c
jnz
rewait ;for another try
4c39 c2f24b
cannot recover from error
mvi
a,l
;error code
ret

4c3c 3e01
4c3e c9
4c3f
4c42
4c43
4c46
4c48
4c49
4c4b

intype,
3a664c intype: Ida
b7
ora
c2494c
jnz
db79
in
c9
ret
db89
intypl: in
c9
ret

inbyte, instat read drive bank 00 or 10
dbank
a
intypl ;skip to bank 10
r type

4c4c
4c4f
4c50
4c53
4c55
4c56
4c58

3a664c inbyte: Ida
ora
b7
jnz
c2564c
in
db7b
c9
ret
db8b
inbytl: in
c9
ret

dbank
a
inbytl
rbyte

4c59
4c5c
4c5d
4c60
4c62
4c63
4c65

3a664c instat: Ida
b7
ora
c2634c
jnz
db78
in
c9
ret
db88
instal: in
c9
ret

rtype+10h

;78 for 0,1

88 for 2,3

rbyte+10h

;

,.
4c66 00

dbank:
iopb:

4c67
4c68
4c69
4c6a
4c6b
4c6c

80
04
01
02
01
8000

iof:
ion:
iot:
ios:
iod:

dbank
a
instal
dstat
dstat+10h

data areas (must be in ram)
db
;disk bank 00 if drive 0,1
0
10 if drive 2,3
;io parameter block
db
80h
;normal i/o operation
db
readf
;io function, initial read
db
1
;number of sectors to read
db
offset ;track number
db
1
;sector number
dw
buff
do address
define ram areas for bdos operation
48

4c6e+=
4c6e+
4cee+
4d0d+
4dld+
4d3c+
4d4c+
4d6b+
4d7b+
4d9a+
4daa+=
013c+=
4daa

endef
begdat equ
di rbuf: ds
ds
al v0:
ds
csv0:
ds
alvl:
ds
csvl:
ds
alv2 :
csv2:
ds
alv3:
ds
csv3:
ds
enddat equ
da tsiz equ
end

$
128
31
16
31

~directory

IE?

31
16
31
16
$
$-begdat

49

access buffer

APPENDIX C:

A SKELETAL CBIOS

skeletal cbios for first level of cp/m 2.0 alter a
0014 =

msize

egu

icp/m version memory size in kilo

20

"bias" is address offset from 3400h for memory sy
than 16k (referred to as lib" throughout the text)
0000
3400
3c06
4a00
0004
0003

=
=
=
=
=
=

bias
ccp
bdos
bios
cdisk
iobyte

egu
equ
equ
egu
equ
equ

(msize-20) *1024
3400h+bias
ibase of ccp
ccp+806h
ibase of bdos
ccp+1600h
ibase of bios
0004h
;current disk number 0=a, ••• ,15=p
0003h
iintel i/o byte

4a00
002c =

nsects

org
equ

bios
iorigin of this program
($-ccp)/128
iwarm start sector count

4a00
4a03
4a06
4a09
4a0c
4a0f
4a12
4alS
4a18
4alb
4ale
4a21
4a24
4a27
4a2a
4a2d
4a30

jump vector for individual subroutines
c39c4a
jmp
boot
icold start
c3a64a wboote: jmp
wboot
iwarm start
c3114b
jmp
const
iconsole status
c3244b
jmp
conin
;console character in
c3374b
jmp
conout
;console character out
c3494b
jmp
list
;list character out
jmp
c34d4b
;punch character out
punch
;reader
character out
jmp
reader
c34f4b
;move head to home positi
c3S44b
jmp
home
jmp
c3Sa4b
seldsk
;select disk
settrk
;set
track number
jmp
c37d4b
;set sector number
jmp
c3924b
setsec
c3ad4b
jmp
setdma
iset dma address
c3c34b
jmp
read
;read disk
c3d64b
write
;write disk
jmp
c34b4b
jmp
listst
;return list status
jmp
c3a74b
sectran
;sector translate

fixed data tables for four-drive standard
ibm-compatible 8" disks
disk parameter header for disk 00
4a33 734a00 dpbase: dw
trans,0000h
4a37 000000
dw
0000h,0000h
4a3b f04c8d
dw
dirbf,dpblk
4a3f ec4d70
dw
chk00,al100
disk parameter header for disk 01
4a43 734a00
dw
trans,0000h
4a47 000000
dw
0000h,0000h
4a4b f04c8d
dw
dirbf,dpblk
4a4f fc4d8f
dw
chk01,al101
disk parameter header for disk 02
4aS3 734a00
dw
trans,0000h
4aS7 000000
dw
0000h,0000h
4aSb f04c8d
dw
dirbf,dpblk
4aSf 0c4eae
dw
chk02,al102
50

4a63
4a67
4a6b
4a6f

disk parameter header for disk 03
dw
trans,0000h
0000h,0000h
dw
dirbf,dpblk
dw
dw
chk03,al103

734a00
000000
f04c8d
lc4ecd
i

~~11
4a7b
4a7f
4a83
4a87
4a8b

~9~~~g trans:
170309
150208
141a06
121804
1016
dpblk:

4a8d la00
4a8f 03
4a91O 07
4a91 00
4a92 f200
4a94 3f00
4a96 c0
4a97 1010
4a98 1000
4a9a 0200

sector translate vector

gg

db
db
db
db
db

~5:5~rl~17

23,3,9,15
21,2,8,14
20,26,6,12
18,24,4,10
16,22

isectors
isectors
isectors
isectors
isectors
isectors
isectors

5~g~1~~

9,10,11,12
13,14,15,16
17,18,19,20
21,22,23,24
25,26

idisk parameter block, common to all disks
dw
26
isectors per track
db
3
iblock shift factor
db
7
iblock mask
(0
db
inull mask
dw
242
idisk size-l
dw
idirectory max
63
192
ialloc 0
db
Ii)
db
ialloc 1
icheck size
dw
16
itrack offset
ow
2
end of fixed tables

i

boot:
4a9c
4a9d
4aa0
4aa3

af
320300
320400
c3ef4a

i

wboot:
4aa6
4aa9
4aab
4aae

318000
0e00
cd5a4b
cd544b

4abl 062c
4ab3 0e00
4ab5 1602
4ab7 210034
10adl:
4aba
4abb
4abc
4abd
4abe
4acl

c5
d5
e5
4a
cd924b
cl

individual subroutines to perform each function
isimplest case is to just perform parameter initi
xra
a
izero in the accum
sta
iobvte
iclear the iobyte
sta
cdisk
iselect disk zero
jmp
gocpm
iinitialize and go to cp/
isimplest case is to read the disk until all sect
lxi
sp,80h
iuse space below buffer f
mvi
c,0
iselect disk Ii)
call
seldsk
call
home
;go to track 00
mvi
b,nsects
ib counts # of sectors to
mvi
c,0
iC has the current track
mvi
d,2
;d has the next sector to
note that we begin by reading track 0, sector 2 s
~ontains the cold start loader, which is skipped
lxi
h,ccp
ibase of cp/m (initial 10
i load one more sector
isave sector count, current track
push
b
d
isave next sector to read
push
h
isave dma address
push
iget sector address to register c
mov
c,d
call
setsec iset sector address from register
pop
b
irecall dma address to b,c
51

•

4ac2 c5
4ac3 cdad4b

push
call

b
setdma

;replace on stack for later recal
;set dma address from b,c

4ac6 cdc34b
4ac9 fe00
4acb c2a64a

drive set to 10, track set, sector set, dma addres
call
read
;any errors?
cpi
100h
jnz
wboot
;retry the entire boot if an erro

4ace
4acf
4ad2
4ad3
4ad4
4ad5
4ad6

el
1180100
19
dl
cl
05
caef4a

no error, move to next sector
pop
h
;recall dma address
lxi
d,128
;dma=dma+128
dad
d
;new dma address is in h,l
pop
d
;recall sector address
pop
b
;recall number of sectors remaini
dcr
b
;sectors=sectors-l
gocpm
;transfer to cp/m if all have bee
jz

4ad9
4ada
4adb
4add

14
7a
felb
daba4a

more sectors remain to load, check for track chan
inr
d
mov
;sector=27?, if so, change tracks
a,d
cpi
27
jc
loadl
;carry generated if sector<27

4ae0 1601
4ae2 0c

end of current track, go to next track
mvi
d,l
;begin with first sector of next
inr
c
;track=track+l

4ae3
4ae4
4ae5
4ae6
4ae9
4a,ea
4aeb
4aec

save register state, and change tracks
push
b
push
d
push
h
settrk ;track address set from register
call
pop
h
pop
d
pop
b
jmp
loadl
;for another sector

c5
d5
e5
cd7d4b
el
dl
cl
c3ba4a

end of load operation, set parameters and go to c
gocpm:
4aef
4afl
4af4
4af7

3ec3
32101000
21034a
220100

rnvi
sta
lxi
shld

a,0c3h ;c3 is a jmp instruction
10
;for jmp to wboot
h,wboote
;wboot entry point
1
;set address field for jmp at 10

4afa 320500
4afd 21063c
4b00 220600

sta
lxi
shld

5
h,bdos

4b03 1018101010
4blO6 cdad4b

lxi
call

b,8lOh
setdma

;default dma address is 810h

4blO9
4b0a
4b0d
4b0e

ei
Ida
mov
jmp

cdisk
c,a
ccp

;enable the interrupt system
;get current disk number
;send to the ccp
;go to cp/m for further processin

fb
3alO401O
4f
c3101034

6

52

;for jmp to bdos
;bdos entry point
;address field of jump at 5 to bd

i

i
;

·,

simple i/o handlers (must be filled in by user)
in each case, the entry point is provided, with s
to insert your own code

const:

iconsole status, return 0ffh if character ready,
ds
10h
ispace for status subroutine
mvi
a, 00h
ret

conin:

iconsole character into register a
ds
10h
ispace for input routine
ani
7fh
istrip parity bit
ret

4bll
4b21 3eliH'
4b23 c9
4b24
4b34 e67f
4b36 c9
i

4b37 79
4b38
4b48 c9

conout: iconsole character output from register c
mov
a,c
iget to accumulator
ds
10h
ispace for output routine
ret
i

list:
4b49 79
4b4a c9
4b4b af
4b4c c9

·,

;list character from register c
a,c
;character to register a
mov
ret
inul1 subroutine

listst: ;return list status (0 if not ready, I if ready)
xra
a
;0 is always ok to return
ret

·,

punch:
4b4d 79
4b4e c9

;punch character from register Co
mov
a,c
;character to register a
ret
;null subroutine

;

4b4f 3ela
4b51 e67f
4b53 c9

reader: ;read character into register a from reader devic
mvi
a,lah
;enter end of file for now (repla
ani
7fh
;remember to strip parity bit
ret
;

,
·home:
4b54 0e00
4b56 cd7d4b
4b59 c9
4b5a
4b5d
4b5e
4b61

210000
79
32ef4c
fe04

,
·seldsk:

i/o drivers for the disk follow
for now, we will simply store the parameters away
in the read and write subroutines
;move to the track 00 position of current drive
translate this call into a settrk call with param
mvi
c,0
;select track 0
call
settrk
ret
;we will move to 00 on first read
;select
lxi
mov
sta
cpi

disk given by register c
h,0000h ;error return code
a,c
diskno
4
;must be between 0 and 3
53

4b63 d0

rnc
ino carry if 4,5, ...
disk number is in the proper range
ds
10
ispace for disk select
compute proper disk parameter header address
Ida
diskno
mov
l,a
il=disk number 0,1,2,3
mvi
h,0
ihigh order zero
dad
h
i*2
dad
h
i*4
dad
h
i *8
dad
h
i*16 (size of each header)
lxi
d,dpbase
dad
d
ihl=.dpbase(diskno*16)
ret

4b64
4b6e
4b71
4b72
4b74
4b75
4b76
4b77
4b78
4b7b
4b7c

3aef4c
6f
2600
29
29
29
29
11334a
19
c9

4b7d 79
4b7e 32e94c
4b81
4b91 c9

settrk: iset track given by register c
mov
a,c
sta
track
ds
10h
ispace for track select
ret
i

setsec: iset sector given by register c
mov
4b92 79
a,c
4b93 32eb4c
sta
sector
4b96
ds
10h
ispace for sector select
4ba6 c9
ret
sectran:
4ba7
4ba8
4ba9
4baa
4bac

eb
09
6e
2600
c9

.

itranslate the sector given by bc using the
; transla te table given by de
xchg
;hl=.trans
dad
b
;hl=.trans(sector)
mov
I,m
;1 = trans(sector)
mvi
h,0
;hl= trans(sector)
ret
iwith value in hI

I

setdma: ;set dma address given by registers band c
4bad 69
mov
l,c
;low order address
4bae 60
h,b
;high order address
mov
4baf 22ed4c
shld
dmaad
isave the address
4bb2
ds
10h
;space for setting the dma add res
4bc2 c9
ret
read:
4bc3
4bd3 c3e64b

;perform read operation {usually this is similar
so we will allow space to set up read command, th
common code in write)
ds
10h
;set up read command
jmp
waitio ito perform the actual i/o

i

write:
4bd6

;perform a write operation
ds
10h
iset up write commanu

i

waitio: ;enter here from read and write to perform the ac
operation.
return a 00h in register a if the ope
properly, and 01h if an error occurs during the r
54

in this case, we have saved the disk number in 'd
the track number in I track I (0-76
the sector number in I sector I (1the dma address in I dmaad I (II' -655
ds
256
;space reserved for i/o drivers
mvi
a,l
;error condition
;replaced when filled-in
ret

4be6
4ce6 3efill
4ce8 c9

the remainder of the cbios is reserved uninitiali
data area, and does not need to be a part of the
system memory image (the space must be available,
however, between "begdat" and "enddat").
4ce9
4ceb
4ced
4cef

2

track:
sector:
dmaad:
diskno:

ds
ds
ds
ds

1

scratch
equ
ds
ds
ds
ds
ds
ds
ds
ds
ds

ram area for bdos use
$
; beginning of data
128
;scratch directory
31
;allocation vector
31
;allocation vector
31
;allocation vector
31
;a11ocation vector
16
; check vector 0
16
;check vector 1
; check vector 2
16
; check vector 3
16

equ
equ
end

;end of data area
$
$-begdat; size of data area

4cf0
4cf0
4d70
4d8f
4dae
4dcd
4dec
4dfc
4e0c
4elc

=

begdat
dirbf:
al100 :
al101:
al102 :
alHl3:
chk00 :
chk01:
chk02:
chk03:

4e2c
013c
4e2c

=
=

enddat
datsiz

;two bytes for expansion
;two bytes for expansion
;direct memory address
;disk number 0-15

2
2

area
area
0
1
2
3

;

•

55

APPENDIX D:

A SKELETAL GETSYS/PUTSYS PROGRAM

combined getsys and putsys programs from Sec 4.
Start the programs at the base of the TPA
0100
0014 =

msize

org

0100h

equ

20

size of cp/m in Kbytes

"bias" is the amount to add to addresses for > 20k
(referred to as lib" throughout the text)
0000
3400
3c00
4a00

=
=
=
=

bias
ccp
bdos
bios

equ
,equ
equ
equ

(msize-20)*1024
34013h+bias
ccp+0800h
ccp+1600h

getsys programs tracks 0 and 1 to memory at
3880h + bias
register
a

usage
(scratch register)
track count (0 ••• 76)
sector count (1. •• 26)
(scratch register pair)
load address
set to stack address

b

c
d,e
h,l
sp
gstart:
0100 318033
0103 218033
0106 13600

lxi
lxi
mvi

sp,ccp-013813h
h,ccp-01380h
b,0

mvi

c,l

call
1xi
dad
inr
mov
cpi
jc

read$sec
0,128

rd$trk:
0108 13e01

start of getsys
; convenient p1ac
set initial loa
start with trac
read next track
each track star

rd$sec:
0113a
010d
13110
0111
0112
13113
0115

cd131303
1181300
19
13c
79
fe1b
da0a01

d

c
a,c
27
rdsec

get the next se
offset by one s
(h1=h1+128)
next sector
fetch sector nu
and see if la
<, do one more

arrive here at end of track, move to next track
13118
0119
011a
011c

04
78
fe02
da0801

inr
mov
cpi
jc

b

a,b
2

rd$trk

track
check
track
<, do

= track+l
for last
= 2 ?
another

arrive here at end of load, halt for lack of anything b
011f fb
0120 76

ei
hIt

56

putsys program, places memory image starting at
3880h + bias back to tracks 0 and 1
start this program at the next page boundary
0200

org

($+0100h) and 0ff00h

1xi
1xi
mvi

sp,ccp-0080h
h,ccp-0080h
b,0

convenient p1ac
start of dump
start with trac

mvi

c,l

start with sect

call
1xi
dad
inr
mov
cpi
jc

write$sec
d,128

write one secto
length of each

=

+ 128 = + 1 see if past end of t no, do another put$sys: 0200 318033 0203 218033 0206 0600 wr$trk: 0208 0e01 wr$sec: 020a 020d 0210 0211 0212 cd0004 118000 19 0c 79 ~213 fe1b 0215 da0a02 d c a,c 27 wr$sec arrive here at end of track, move to next track 0218 0219 021a 021c 04 78 fe02 da0802 inr mov cpi jc b a,b 2 wr$trk track = track+1 see if last track no, do another done with putsys, halt for lack of anything bette 021f fb 0220 76 ei hIt user supplied subroutines for sector read and write move to next page boundary 0300 org ($+0100h) and 0ff00h read$sec: read the next sector track in , sector in dmaaddr in 0300 c5 0301 e5 0302 0342 el 0343 c1 push push b h user defined read operation goes here ds 64 pop pop h b 57 0344 c9 ret 0400 org ($+0100h) and 0ff00h write$sec: . I 0400 c5 0401 e5 0402 0442 e1 0443 c1 0444 c9 same parameters as read$sec push push b h user defined write operation goes here ds 64 pop pop ret h b end of getsys!putsys program 0445 end 58 another page bo APPENDIX E: A SKELE'rAL COLD START LOADER this is a sample cold start loader which, when modified resides on track 00, sector 01 (the first sector on the diskette). we assume that the controller has loaded this sector into memory upon system start-up (this program can be keyed-in, or can exist in read/only memory beyond the address space of the cp/m version you are running). the cold start loader brings the cp/m system into memory at "10adp" (3400h + "bias"). in a 20k memory system, the value of "bias" is 0000h, with large values for increased memory sizes (see section 2). afte loading the cp/m system, the clod start loader branches to the "boot" entry point of the bios, which begins at "bios" + "bias." the cold start loader is not used until the system is powered u? again, as long as the bios is not overwritten. the origin is assumed at 0000h, an must be changed if the controller brings the cold start loader into another area, or if a read/only memory area is used. 0000 org 0 base of ram in cp/m liH1l4 = msize equ 20 min mem size in kbytes 0000 3400 4a00 0300 4a00 1900 0032 bias ccp bios biosl boot size sects egu equ egu egu egu egu equ (msize-20)*1024 3400h+bias ccp+1600h 0300h bios bios+biosl-ccp size/128 offset from 20k system base of the ccp base of the bios length of the bios = = = = = = = size of cp/m system # of sectors to load begin the load operation cold: lxi mvi lxi 0000 010200 0003 1632 0005 210034 Isect: ., b,2 d,sects h,ccp b=0, c=sector 2 d=# sectors to load base transfer address load the next sector insert inline code at this point to read one 128 byte sector from the track given in register b, sector given in register c, into the address given by branch to location "cold" if a read error occurs 59 • ************************************************* * * user supplied read operation goes here ••• * ************************************************* 0008 c36b00 000b jmp ds past$patch 60h ., remove this when patche past$patch: ; go to next sector if load is incomplete 006b 15 dcr d ; sects=sects-l , head for the bios 006c ca004a jz boot . more sectors to load we aren't using a stack, so use as scratch registe to hold the load address increment 006f 318000 0072 39 lxi dad sp,128 sp 128 bytes per sector = + 128 0073 0074 0075 0077 inr mov cpi jc c a,c 27 Isect sector = sector + 1 0c 79 felb da0800 last sector of track? no, go read another end of track, increment to next track 007a 0e01 007c 04 007d c30800 0080 mvi inr jmp end sector = 1 track = track + 1 for another group of boot loader c,l b Isect 60 APPENDIX F: CP/M DISK DEFINITION LIBRARY 1: 2: CP/M 2.0 disk re-definition library 3: ; 4: ; 5: 6: 7: Copyright (c) 1979 Digital R=bearch Box 579 Pacific Grove, CA 93950 8: 9: ; 110: 11: 12: 13: 14: 15 : 16: 17: 18: 19: 20: 21: ; ; ; ; ; ; 22: ; 23: ; 24: 25: 26: 27: 28: 29: ; 30: ; 31: 32: ; 33: 34: 35: 36: 37: 38: 39: 410: 41: ; ; ; ; ; ; CP/M logical disk drives are defined using the macros given below, where the sequence of calls is: disks n diskdef ?arameter-list-0 diskdef 9arameter-list-l diskdef parameter-list-n endef where n is the number of logical disk drives attached to the CP/M- system, and parameter-list-i defines the ,characteristics of the ith drive (i=0,1, ••. ,n-l) each parameter-list-i takes the form dn,£Qc,lsc, [skf] ,bls,dks,dir,cks,ofs, [0] where dn is the disk number Ii) ,1, ••• ,n-l fsc is tile first sector number (usually 0 or 1) lsc is ti1e last sector number on a track skf is ofjtional iiskew factor" for sector translate bls is tne data block size (1024,2048, ••• ,16384) dks is tnt:: disk size in bls increments (word) dir is tn€: number of directory elements (word) cks is th~ number of dir elements to checksum ofs is the number of tracks to skip (word) [0] is an opt.ional 0 which forces 16K/directory en for convenience, the form dn,dm defines disk dn as having the same characteristics as a previously defined disk dm. 42: ; 43: ; 44: ; 45: 46: 47: 48: 49: 50: 51: 52: 53: ; ; ; ; ; ; a standard four disks diskdef dsk set rept dsk set diskdef endm endei drive CP/M system is defined by 4 10,1,26,6,1024,243,64,64,2 o 3 dsk+1 %dsk,0 the value of "begdat" at the end of assembly defiries t 61 • 54: 55: 56: 57: 58: 59: 610: 61: 62: 63: 64: 65: 66: 67: 68: 69: ; ,. dskhdr macro dn define a single disk header list dpe&dn: dw xlt&dn,00100h. ;translate table dw 0000h,0000h ;scratch area dw dirbuf,dpb&dn ;dir buff,parm block dw csv&dn,alv&dn ;check, ailoc vectors endm ;; ; 70: disks 71: 72: 73: 74: ;; ndisks dpbase ; ; "15: dsknxt 76: 77: 78: 79: 80: 81: 82: a 3: 84: 85: 136: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101 : 102: dsknxt ., dpbhdr dpb&dn ,. ddb ; ; ; ; gcd ;; ;; ., ., gcdm gcdn gcdr 1103: 108: macro nd define nd disks ;;for later reference set nd ;base of disk parameter blocks equ $ generate the r~d elements set 0 rept nd dskhdr %dsknxt dsknxc+l set endm endm macro equ endm dn ;disk parm block $ macro da ta, cornmen t define a db statement db data endm comment ; ddw 104: gcdx 105: gcdr 1106: 1107: beginning of the uninitialize ram area above the bios, while the valve of "enddat" defines the next location followinq the end of the data area. the size of this area is ~iven by the value of "datsiz" at the end of t assembly. note that the allocation vector will be qui large if a large disk size is defined with a small blo size. macro da ta, commen t define a dw statement dw data endm comment macro m,n greatest common divisor of m,n produces value gcdn as result (used in sector translate table generation) set m ;;variable for m set n ;;variable for n set 0 ;;variable for r rept 65535 set gcdm/gcdn set gcdm - gcdx*gcdn if gcdr = 0 exitm endif 62 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128 : 129 : 1310: 131 : 132 : 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 1510: 151 : 152: 153 : 154: 155: 156: 157: 158: 159 : 160: 161: 162 : 163: gcdm gcdn set set endm endm gcdn gcdr : diskdef macro dn,fsc,lsc,skf,bls,dks,dir,cks,ofs,k16 ;; generate the set statements for later tables if nul lsc ;; current disk dn s~me as orevious fsc dpb&dn equ dpb&fsc ;8quivalent parameters als&dn equ als&fsc ;same allocation vector size css&dn equ css&fsc ;same checksum vector size xlt&dn equ xlt&fsc ;same translate table else secmax set lsc-{fsc) ;;sectors 0 •.• secmax sectors set secmax+l;;number of sectors als&dn set (dks)/8 ;;size of allocation vector if ({dks) mod 0) ne f2J als&dn set als&dn+l endif css&dn set (cks) /4 ; inumber of checksum elements generate the block shift value I I bls/128 ;;number of sectors/block blkval set blkshf set 0 ;;counts right 0's in blkval 0 ;;~ills with l's from right blkmsk set rept 16 ;i~nce for each bit position if blkval=l exitm endif ;; otherwise, high ord~r 1 not found yet blkshf set blkshf+l blkmsk set (blkmsk shl 1) or 1 blkval set blkval/2 endm ,, generate the extent mask byte blkval set bls/1024 iinumber of kilobytes/block extmsk set 0 iifill from right with l's rept 16 if blkval=l exitm endif otherwise more to shift ; ; extmsk set (extmsk shl 1) or 1 blkval set blkval/2 endm may be double byte ~llocation ;; if (dks) > 256 extmsk set (extmsk shr 1) endif ;; may be optional [0] in last position if not nul k16 extmsk set k16 endif now generate directory reservation bit vector ; ; set dir dirrem ii# remaining to process .. .. 63 • 164: dirbks 165: dirblk 166: 167: 168: 169: 170: ii 171 : 172 : 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: ; ; dirblk dirrem dirrem 190: ii 191: 192: xlt&dn 193: 194: 195: xlt&dn 196: 197: ii 198: 199: 200: 201 : 202: nxtsec nxtbas 203: 2104: ii ,. ,. neltst ;; 2105: nelts 206: xlt&dn 207: 208: 209: 210: 211 : 212 : 213: nxtsec 214: 215: nxtsec 216: 217: nelts 218: bls/32 ;;nuffiber of entries per block set set i;f111 with l's on each loop o rept 16 if dirrem=0 exitm endif not complete, iterate once again shift right and add 1 high order bit set (dirblk shr i) or 8000h if dirrem > dirbks set dirrem-di~bks else set endif endm dpbhdr dn ;;ge~erate equ $ ddw %sectors,<;sec per track> ddb %blkshf, ddb %blkmsk, ddb %extmsk, ddw %(dks)-l,<;oisk size-I> ddw %(dir)-l,<;airectory max> ddb %dirblk shr &,<;alloc0> ddb %dirblk ana 0ffh,<;allocl> ddw %(cks)/4~ ddw %ofs, generate the translate table, if requested if nul skf equ 0 ino xlate table else if skf = g ino xlate table equ o else generate the translate taole set (1 iiaext sector to fill set 0 iifficves by one on overflow gcd %sectors,skf gcdn = gcd(sectors,skew) set sectors/gcdn neltst is number of elements to generate before we overlap orevious elements set ne1tst iicounter equ $ itranslate table rept sectors i ionce for each sector if sectors < 256 ddb %nxtsec+(fsc) else ddw %nxtsec+(fsc) endif set nxtsec+(skf) if nxtsec >= sectors nxtsec-sectors set endif set nelts-l if nelts = 0 64 219 : 220: 221 : 222 : 223: 224: 225: 226: 227: 228: 229 : 230: 231 : 232 : 233: 234: 235: 236: 237: 238: 239: 240: 241: 242 : 243 : 244: 245: 246: 247: 248: 249: nxtbas nxtsec nelts set set set endif endm endif endif endm nxtbas+l nxtbas neltst macro as endm lab,space space macro aefds endm Ib,dn,val Ib&dn,%val&dn ;;end of nul fac test ;;end of nul bls test ; aefas lab: ·, Ids ·, ·, ., begdat endef macro generate the nec~ssary ram data areas egu $ ;directory access buffer dirbuf: ds 128 dsknxt set 0 rept ndisks ;;once for eacn disk Ids alv,%dsknxt,als Ids csv,%dsknxt,css dsknxt set dsknxt+l endm enddat egu $ $-begdat datsiz egu ;; db 0 at this point forces hex record endm • 65 APPENDIX G: 1: 2: 3: 4: 5: ;***************************************************** 1* ;* ;* Sector Deblocking Algorithms for CP/M 2.0 * * * ;***************************************************** 6: 7: ; 8: smask 9: ;; 10 : BLOCKING AND DEBLOCKING ALGORITHMS. ; ; 11 : @y 12 : @x 13: ;; 14: 15 : 16: 17: ·. 18: , , 19: @y 20: @x 21: 22 : utility macro to compute sector mask macro hblk compute log2(hblk), return @x as result (2 ** @x = hblk on return) set hblk set 0 count right shifts of @y until = 1 rept 8 if @y = 1 exi tm endif. @y is not 1, shift right one position . set @y shr 1 set @x + 1 endm endm 23: ; . 24: ,.***************************************************** , 25: · * '* 26 : ,· * CP/M to host disk constants * 27: ,· * * . 28: ,.***************************************************** 29: blksiz equ 2048 ;CP/M allocation size 30: hstsiz equ 512 ;host disk sector size 31 : hstspt equ 20 ;host disk sectors/trk 32: hstblk equ hstsiz/128 ;CP/M sects/host buff 33: cpmspt equ hstblk * hstspt ;CP/Msectors/track 34: secmsk equ hstblk-l ;sector mask hstblk ;compute sector mask 35: smask ;log2(hstblk) 36: secshf equ @x 37: 38: 39: 40: 41: 42: 43: 44: ; ,.***************************************************** * ,.* ,.* BOOS constants on entry to write * ,.* * ,.***************************************************** o wrall wrdir 45 : wrual equ equ equ 46: 47: 48: 49: 50: 51: 52: 53: The BOOS entry points given below show the code which is re-levant to deblocking only. ;write to allocated ;write to directory ;write to unallocated 1 2 , ·;***************************************************** ,.* ;* ;* ,.* * * * * ,.***************************************************** 66 54: 55: 56: 57: 58: 59: 60: 61 : 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: HHJ: 101: 102: 103: ·, ·, boot: dpbase DISKDEF macro, or hand coded tables go here egu ;disk param block base $ wboot: :enter here on system boot to initialize xra a ; 0 to accumulator sta hstact ;host buffer inactive sta unacnt ;clear unalloc count ret ; seldsk: ·, set trk: :select mov sta mov mvi rept dad endm lxi dad ret disk a,c sekdsk l,a h,0 :selected disk number ;seek disk number :disk number to HL 4 :multiply by 16 h d,dpbase d ;base of parm block ;hl=.dpb(curdsk) ;set track given by registers Be mov h,b mov l,c shld sektrk itrack to seek ret setsec: ·, ;set sector given by register c mov a,c :sector to seek sta seksec ret setdma: ·, iset dma address given by mov h,b mov l,c shld dmaadr ret sectran: ;translate sector number mov h,b mov l,c ret 67 Be Be • lrl14: .***************************************************** I 1 rlI 5: .* I lrl1 6: ·I * lrl17: . * I The READ entry point takes the place of the previous BIOS defintion for READ • * 1 rlI8: .* I * 1 rlI9: .***************************************************** I llrl1 : read: Ill: 112: 113: 114: 115: 116: 1read the selected CP/M sector mvi a,l readop sta 1read operation rsflag sta 1must read data mvi ·a ,wrual sta wrtype 1treat as unalloc jmp rwoper 1to perform the read 117: 118: I 119 : I.***************************************************** · 12rl1 : 121: 122: 123: 124: 125: 126: 127: .* I .* I ·.** I I * * * * .***************************************************** I write: 128: 129 : 13rl1: 131: 132: 133: 1 134: 135: 136: 137 : 138: 139: 140 : 141: 142: The WRITE entry point takes the place of the previous BIOS defintion for WRITE. · 1write the selected CP/M sector xra 1rl1 to accumulator a readop 1not a read operation sta rnov a,c 1write type in c sta wrtype cpi wrual 1write unallocated? jnz chkuna 1check for unalloc write to unallocated, set parameters mvi a,blksiz/128 1next unalloc recs st.a unacnt Ida sekdsk 1disk to seek sta unadsk 1unadsk = sekdsk Ihld sektrk shld unatrk 1unatrk = sectrk Ida seksec sta unasec 1unasec = seksec 143: I 144: chkuna: 145: 1check for write to unallocated sector 146: Ida unacnt 1any unalloc remain? 147: ora a 148: jz alloc 1skip if not 149: 15rl1: 1 151: 152: 153: 154: 155: 156: 157: 1 158: 1 more unallocated records remain dcr a ;unacnt = unacnt-l sta unacnt Ida sekdsk ;same disk? lxi h,unadsk cmp m 1sekdsk = unadsk? jnz alloc ;skip if not disks are the same 68 159: 1610: 161: 162 : 163: 164 : 155: 166: 167: 168: 169: 1710: 171: 172: 173: 174: 175: 176: 177: 178: 179: 1810: 181: 182: 183: 184: 185: 186: 187: 188: 189: 1910: 191: 192: 193: 194: 195: 196: 197: 198: 199: 21010: 2101: 202: 20~: 2104: 2105: 2106: 2107: 2108: 2109: 2110: 211: 212: 213: 1xi call jnz h,unatrk sektrkcmp a110c ;sektrk = unatrk? ;skip if not tracks are the same Ida seksec 1xi h,unasec CPO m jnz a110c ;same sector? ;seksec = una sec? ,skip if not match, move to next sector for future ref inr m ;unasec = unasec+1 mov a,m ;end of track? cpi cpmspt ;count CP/M sectors jc noovf ;skip if no overflow overflow to next track mvi m,e 1h1d unatrk inx h sh1d unatrk ;unasec = 10 ;unatrk = unatrk+1 noovf: ;match found, mark as unnecessary read xra a ;10 to accumulator rsf1ag ; rsf1ag = 10 sta jmp rwoper ito perform the write ; a11oc: ., ;not an unallocated record, requires pre-read xra a ; 10 to accum unacnt sta ;unacnt = 10 inr a ;1 to accum rsf1ag. sta ; rsf1ag = 1 . ,• ***************************************************** * ,.* ;* Common code for READ and WRITE follows * .* * I .***************************************************** I rwoper: ;enter here to perform the read/write xra a ;zero to accum sta erf1ag ;no errors (yet) Ida seksec ;compute host sector rept secshf ora ;carry = 10 a rar ;shift right endm sta sekhst ;host sector to seek active host sector? 1xi h,hstact mov a,m mvi m,l 69 ;host active flag ;a1ways becomes 1 • 214: 215: 216: 217: 218: 219 : 2210: 221: 222 : 223: 224: 225: 226: 227: 228: 229: 2310: 231 : 232: 233: 234: 235: 236: 237: 238 : 239: 2410: 241: 242: 243: 244: 245: 246: 247: 248: 249: 2510: 251: 252: 253: 254: 255: 256: 257 : 258: 259: 260: 261: 262 : 263: 264: 265: 266: 267: 268: ora jz ; ;was it already? ;fill host if not a filhst host buffer active, same as seek buffer? sekdsk Ida ;same disk? lxi h ,hstdsk ;sekdsk = hstdsk? cmp m nomatch jnz same disk, same track? lxi h,hsttrk call sektrkcmp nomatch jnz ;sektrk = hsttrk? same disk, same track, same buffer? Ida sekhst lxi h,hstsec ;sekhst = hstsec? cmp m ;skip if match jz match ; nomatch: ;proper Ida ora cnz disk, but not correct sector hstwrt ;host written? a ;clear host buff writehst ; filhst: ;may have to fill the host buffer Ida sekdsk sta hstdsk Ihld sektrk shld hsttrk Ida sekhst hstsec sta ;need to read? Ida rsflag ora a cnz readhst ; ye s, if 1 xra ;/0 to accum a sta hstwr t ;no pending write ; match: ;copy data to or from buffer Ida seksec ;mask buffer number ani secmsk ;least signif bits mov l,a ;ready to shift mvi h,/O ;double count rept 7 ;shift left 7 dad h endm hI has relative host buffer address lxi d,hstbuf dad d ;hl = host address xchg ;now in DE Ihld dmaadr ;get/put CP/M data mvi c,128 ;length of move 710 269 :, 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: , 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301 : 302: 303 : 304 : 305: 306: 307: 308 : 309: 310: 311: 312: 313 : 314: 315 : 316 : 317: 318: 319 : 320: Ida ora jnz readop a rwmove iwhich way? iskip if read write operation, mark and switch direction mvi a,l sta hstwrt i hstwr t = 1 xchg isource/dest swap rwmove: ;C initially 128, DE is source, HL is dest Idax d ;source character inx d mov m,a ito dest inx h dcr c ; loop 128 times jnz rwmove .. data' has been moved to/from host buffer Ida wrtype iwrite type cpi wrdir ito directory? Ida erf1ag ;in case of errors rnz inO further processing clear host buffer for directory write ;errors? ora a iskip if so rnz xra i0 to accum a hstwr t ibuffer written sta call writehst Ida erflag ret ·,,.***************************************************** ,.* * ,· * utility subroutine for 16-bit compare * ,· * * ,.***************************************************** sektrkcmp: ;HL = .unatrk or .hsttrk, compare with sektrk xchg lxi h,sektrk Idax d ;low byte compare cmp m i same? rnz ireturn if not low bytes equal, test high Is inx d inx h d 1dax cmp m i sets flags ret 71 • 321: 322: 323: 324 : 325: 326: 327: 328 : 329 : 3310: 331 : 332: 333: 334: 335: 336: 337: 338: 339: 3410: 341 : 342: 343: 344: 345: 346: 347 : 348: 349: 3510: 351 : 352: 353 : 354: 355: 356: 357: 358: 359: 3610: 361: 362: 363: 364: 365: 366: 367: 368: 369: 3710: ,.***************************************************** ,.* ,· * ,· * ,· * ·, * . WRITEHST perf~rms the physical write to the host disk, READHST reads the physical disk. * "It * * * ,. ***************************************************** writehst: ihstdsk = host disk #, hsttrk = host track #, ihstsec = host sect i. write "hstsiz h bytes ifrom hstbuf and return error flag in erflag. ;return erflag non-zero if error ret ·, readhst: ihstdsk = host disk #, hsttrk = host track i, ihstsec = host sect i. read "hstsiz" bytes iinto hstbuf and return error flag in erflag. ret ·,,.***************************************************** i * * ,· * unitialized RAM data areas * ,· * * ,.*************************************n******~******** ·, sekdsk: ds sektrk: ds seksec: ds 1 iseek disk number iseek track number iseek sector number 1 2 1 ihost disk number ihost track number ihost sector number 1 1 1 iseek shr secshf ihost active flag ihost written flag 1 2 i hstdsk: ds hsttrk: ds hstsec: as i sekhst: ds hstact: ds hstwr t: ds i unacnt: unaask: unatrk: unasec: ds as ds ds 1 1 2 1 iunalloc rec cnt ilast unalloc disk ilast unalloc track ilast unalloc sector erflag: rsflag: readop: w:type: dmaadr: hstbuf: ds ds ds as ds ds 1 1 1 1 2 ;error reporting iread sector flag ;1 if read operation ;write operation type ;last dma address ;host buffer hstsiz 72 371: ,.***************************************************** 372: ,. * * 373: ., * The ENDEF macro invocation goes here * * 374: ,.* 375: ,.***************************************************** end 376: • 73 MICROSOFT BASIC 80 REFERENCE MANUAL I [1YA][]©OO©®©[P1J rn3£®[]© c ®@ release 5.0 • Revision 1 ~ Microsoft, 1979 Introduction BASIC-80 is the most extensive implementation of BASIC available for the 8080 and Z80 microprocessors. In its fifth major release (Release 5.0), BASIC-80 meets the ANSI qualifications for BASIC, as set forth in document BSRX3.60-1978. Each release of BASIC-80 consists of three upward compatible versions: 8K, Extended and Disk. This manual is a reference for all three versions of BASIC-80, release 5.0 and later. This manual is also a reference for Microsoft BASIC-86 and the Microsoft BASIC Compiler. BASIC-86 is currently available in Extended and Disk Standalone. versions, which are comparable to the BASIC-80 Extended and Disk Standalone versions. There are significant differences between the 5.0 release of BASIC-80 and the previous releases (release 4.51 and earlier). If you have programs written under a previous release of BASIC-80, check Appendix A for new features in 5.0 that may affect execution. The manual is divided into three large qhapters plus a number of appendices. Chapter 1 covers a variety of topics, largely pertaining to information representation when using BASIC-BO·. Chapter 2 contains the syntax and semantics of every command and statement in BASIC-BO, ordered alphabetically. Chapter 3 describes all of BASIC-BO's intrinsic functions, also ordered alphabetically. The appendices contain information pertaining to individual operating systems; plus lists of error messages, ASCII codes, and math functions; and helpful information on assembly language subroutines and disk I/O. • BASIC-80 Reference Manual CQNTENTS INTRODUCTION CHAPTER 1 General Information About BASIC-80 CHAPTER 2 BASIC-80 Commands and Statements CHAPTER 3 BASIC-80 Functions APPENDIX A New Features in BASIC-80, Release 5.0 APPENDIX B BASIC-80 Disk I/O APPENDIX C Assembly Language Subroutines APPENDIX 0 BASIC-80 with the CP/M Operating System APPENDIX E BASIC-80 with the ISIS-II Operating System APPENDIX F BASIC-80 with the TEKDOS Operating System APPENDIX G BASIC-80 with the Intel SBC and APPENDIX H Standalone Disk BASIC APPENDIX I Converting Programs to BASIC-80 APPENDIX J Summary of Error Codes and Error Messages APPENDIX K Mathematical Functions APPENDIX L ASCII Character Codes ~DS Systems • CHAPTER 1 GENERAL INFORMATION ABOUT BASIC-SO 1.1 INITIALIZATION The procedure for initialization will vary with different implementations of BASIC-SO. Check the appropriate appendix at the back of this manual to determine how BASIC-SO is initialized with your operating system. 1.2 MODES OF OPERATION When BASIC-SO is initialized, it types· the prompt "Ok". "Ok" means BASIC-SO is at command level, that is,' it is ready to accept commands. At this point, BASIC-SO may be used in either of two modes: the direct mode or the indirect mode. In the direct mode, BASIC commands and statements are not preceded by line numbers. They are executed as they are entered. Results of arithmetic and logical operations may be displayed immediately and stored for later use, but the instructions themselves are lost after execution. This mode is useful for debugging and for . using BASIC as a "calculator" for quick computations that do not require a complete program. The indirect mode is the mode used for entering programs. Program lines are preceded by line numbers and are stored in memory. The program stored in memory is executed by entering the RUN command. 1.3 LINE FORMAT Program lines in a BASIC program have the .(square brackets indicate optional) : following format nnnnn BASIC statement[:BASIC statement ••• ] • GENERAL INFORMATION ABOUT BASIC-80 Page 1-2 At the programmer's option, more than one BASIC statement may be placed on a line, but each statement on a line must be separated from. the last by a colon. A BASIC program line always begins with a line number, with a carriage return, and may contain a maximum of: ends 72 characters in 8K BASIC-80 255 characters in Extended and Disk BASIC-80. In Extended and Disk versions, it is possible to extend a logical line over more than one physical line by use of the terminal's key. lets you continue typing a logical line on the next physical line without entering a . (In the 8K version, has no effect. Every BASIC program line begins with a line number. Line numbers indicate the order in which the program lines are stored in memory and are also used as references when branching and editing. Line numbers must be in the range 0 to 65529. In the Extended and Disk versions, a period C.) may be used in EDIT, LIST, AUTO and DELETE commands to refer to the current line. . GENERAL INFORMATION ABOUT BASIC-SO 1.4 Page 1-3 CHARACTER SET The BASIC-SO character set is comprised of alphabetic characters, numeric characters and special characters. The alphabetic characters in BASIC-SO are the upper case and lower case letters of the alphabet. The numeric characters in BASIC-SO are the digits a through 9. The following special characters recognized by BASIC-SO: Character and terminal keys are Name Brank = + * / f\ ( ) % # $ [ ] & ? < > \ @ Semicolon Equal sign or assignment symbol Plus sign Minus sign Asterisk or multiplication symbol Slash or division symbol Up arrow or exponentiation symbol Left parenthesis Right parenthesis Percent Number (or pound) sign Dollar sign Exclamation point Left bracket Right bracket Comma Period or decimal point Single quotation mark (apostrophe) Colon Ampersand Question mark Less than Greater than Backslash or integer division symbol At-sign Underscore Deletes last character typed. Escapes Edit Mode subcommands. See Section 2.16. Moves print position to next tab stop. Tab stops are every eight columns. Moves to next physical line. Terminates input of a line. • GENERAL INFORMATION ABOUT BASIC-SO 1.4.1 Page 1-4 Control.9haracters The following control characters are in BASIC-80: Control-A Enters Edit Mode on the line being typed. Control-C Interrupts program execution BASIC-80 command level. Control-G Rings the bell at the terminal. Control-H Backspace. Control-I Tab. Control-O Halts program continues. A output. Control-R Retypes typed. Control-S Suspends program execution. Control-Q Resumes program execution after a Control-S. Control-U Deletes typed. 1.5 and returns to Deletes the last character typed. Tab stops are every eight columns. the the line line output second that that while execution Control-O restarts is is currently currently being being CONSTANTS Constants are the actual values BASIC uses during execution. There are two types of constants: string and numeric. A string constant is a sequence of up to 255 alphanumeric characters enclosed in double quotation marks. Examples of string constants: "HELLO" "$25,000.00" "Number of Employees" Numeric constants are positive or negative numbers. ,Numeric constants in BASIC cannot contain commas. There are five types of numeric constants: 1. Integer constants Whole numbers between -32768 and +32767._ Integer constants do not have decimal points. 2. Fixed Point constants Positive or negative real numbers, i.e., numbers that contain decimal points. GENERAL INFORMATION ABOUT BASIC-80 3. Floating Point constants Page 1-5 Positive or negative numbers repre-· sented in exponential form (similar to scientific notation). A floating point constant consists of an optionally signed integer or fixed point number (the mantissa) followed by the letter E and an optionally signed integer (the exponent). The exponent must be in the range -38 to +38. Examples: 235.988E-7 = .0000235988 2359E6 = 2359000000 (Double precision floating point constants use the letter D instead of E. See Section 1.5.1.) 4. Hex constants Hexadecimal numbers with the prefix &H. Examples: &H76 &H32F 5. Octal constants Octal numbers with the prefix &0 or &. Examples: &0347 &1234 1.5.1 Single And Double Precision ~ For Numeric Constants In the 8K version of BASIC-80, all numeric constants are single precision numbers. They are stored with 7 digits of precision, and printed with up to 6 digits. In the Extended and Disk versions, however, numeric constants may be either single precision or double prec1s10n numbers. With double precision, the numbers are stored with 16 digits of precision, and printed with up to 16 digits. • GENERAL INFORMATION ABOUT BASIC-80 A single precision constant is has: Page 1-6 any numeric 1. seven or fewer digits, or 2. exponential form using E, or 3. a trailing exclamation point ( 1 ) A double precision constant is has: any numeric 1. ~ight 2. exponential form using D, or 3. a trailing number sign (# ) constant that con$tant that or more digits, or Examples: Single Precision Constants 46.8 -7.09E-06 3489.0 22.51 1.6 Double Precision Constants 345692811 -1.09432D-06 3489.0# 7654321.1234 VARIABLES Variables are names used to represent values that are used in a BASIC program. The value of a variable may be assigned explicitly by the programmer, or it may be assigned as the result of calculations in the program. Before a variable is assigned a value, its value is assumed to be zero. 1.6.1 Variable Names And Declaration Characters BASIC-80 variable names may be any length, however, in the 8K version, only the first two characters are significant. In the Extended and Disk versions, up to 40 characters are significant. The characters allowed in a variable name are letters and numbers, and the decimal point is allowed in Extended and Disk variable names. The first character must be a letter. Special type declaration characters are also allowed -- see below. A variable name may not be a reserved word. The Extended and Disk versions allow embedded reserved words; the 8K version does not. If a variable begins with FN, it is assumed to be a call to a user-defined function. Reserved words include all BASIC-80 commands, statements, function GENERAL INFORMATION ABOUT BASIC-80 Page 1-7 names and operator names. Variables may represent either a numeric value or a string. String variable names are written with a dollar sign ($) as the last character. For example: A$ = IISALES REPORT II • The dollar sign is a variable type declaration character, that is, it IIdeclares ll that the variable will represent a string. In the Extended and Disk versions, numeric variable names may declare integer, single or double precision values. (All numeric values in 8K are single precision.) The type declaration characters for these variable names are as follows: % Integer variable Single precision variable # Double precision variable The default type for precision. a numeric variable name is single Examples of BASIC-80 variable names follow. In Extended and Disk versions: PI# MINIMUM! LIMIT% declares a double precision value declares a single precision value declares an integer value In 8K, Extended and Disk versions: N$ ABC declares a string value represents a single precision value In the Extended and Disk versions of BASIC-BO, there is a second method by which variable types may be declared. The BASIC-80 statements DEFINT, DEFSTR, DEFSNG and DEFDBL may be inclcded in a program to declare the types for certain variable names. These statements are described in detail in Section 2.12. 1.6.2 Array Variables An array is a group or table of values referenced by the same variable name. Each element in an array is referenced by an array variable that is subscripted with integers or integer expressions. An array variable name has as many subscripts as there are dimensions in the array. For example V(10) would reference a value in a one-dimensional array, T(1,4) would reference a value in a two-dimensional array, and so on. • GENERAL INFORMATION ABOUT BASIC-80 1.7 Page 1-8 TYPE CONVERSION When necessary, BASIC will convert a numeric constant from one type to another. The following rules and examples should be kept in mind. 1. If a numeric constant of one type is set equal to a numeric variable of a different type, the number will be stored as the type declared in the variable name. (If a string variable is set equal to a numeric value or. vice versa, a "~ype mismatch" error occurs.) Example: 10 A% = 23.42 20 PRINT A% RUN 23 2. During expression evaluation, all of the operands in an arithmetic or relational operation are converted to the same degree of precision, i.e., that of the most precise operand. Also, the result of an arithmetic operation is returned to this degree of precision. Examples: 10 D# = 6#/7 The arithmetic was performed 20 PRINT D# in double precision and the RUN result was returned in D# .8571428571428571 as a double precision value. 10 0 = 6#/7 20 PRINT D RUN .857143 The arithmetic was performed in double precision and the result was returned to D (single precision variable), rounded and printed as a single precision value. 3. Logical operators (see Section 1.8.3) convert their operands to integers and return an integer result. Operands must be in the range -32768 to 32767 or an "Overflow" error occurs. 4. When a floating point value is converted integer, the fractional portion is rounded. Example: 10 C% = 55.88 20 PRINT C% RUN 56 to an GENERAL INFORMATION ABOUT BASIC-BO 5. Page 1-9 If a double precision variable is assigned a single value, only the first seven digits, rounded, of the converted number will be valid. This is because only seven digits of accuracy were supplied with the single precision value. The absolute value of the difference between the printed double precision number and the original single precision value will be less than 6.3E-B times the original single precision value. Example: prec~s~on 10 A = 2.04 20 B# = A 30 PRINT A~B# RUN 2.04 2.039999961B53027 1.B EXPRESSIONS AND OPERATORS An expression may be simply a string or numeric constant, or a variable, or it may combine constants and variables with operators to produce a single value. Operators perform mathematical or logical operations on values. The operators provided by BASIC-BO may be divided into four categories: 1.B.1 1. Arithmetic 2. Relational 3. Logical 4. Functional • Arithmetic Operators The arithmetic operators, in order of precedence, are: Operator Operation Sample Expression Exponentiation XAY Negation -X *,/ Multiplication, Floating Point Division X*y X/Y +,- Addition, Subtraction X+Y GENERAL INFORMATION ABOUT BASIC-80 Page 1-10 To change the order in which the operations are performed, use parentheses. Operations within parentheses are performed first. Inside parentheses, the usual order of operations is maintained. Here are some sample algebraic expressions and counterparts. Algebraic Expression X+Y*2 x-..L Z X-Y/Z Z X+Y -Z- (X2) Y yZ X X(-Y) BASIC BASIC Expression X+2Y XY their X*Y/Z (X+Y)/Z (XJ\2) J\Y XJ\(YJ\Z) X*(-Y) Two consecutive operators must be separated by parentheses. 1.8.1.1 Integer Division And Modulus Arithmetic Two additional operators are available in Extended and Disk versions of BASIC-BO: Integer division and modulus arithmetic. Integer division is denoted by the basks lash ('). The (must be in the range operands are rounded to integers -32768 to 32767) before the division is performed, and the quotient is truncated to an integer. For example: 10\4 = 2 . 25. 68\6.99 = 3 The precedence of integer divisionis multiplication and floating point division. just after Modulus arithmetic is denoted by the operator MOD. It gives the integer value that is the remainder of an integer division. For example: 10.4 MOD 4 = 2 (10/4=2 with a remainder 2) 25.68 MOD 6.99 = 5 (26/7=3 with a remainder 5) The precedence of modulus arithmetic is just division. after integer GENERAL INFORMATION ABOUT BASIC-BO Page 1-11 1.8.1.2 Overflow And Division ~ Zero If, during the evaluation of an expression, a division by zero is encountered, the "Division by zero" error message is displayed, machine infinity with the sign of the numerator is supplied as the result of the division, and execution continues. If the evaluation of an exponentiation results in zero being raised to a negative power, the "Division by zero" error message is displayed, positive machine infinity is supplied as the result of the exponentiation, and execution continues. If overflow occurs, the "Overflow" error message is displayed, machine infinity with the algebraically correct sign is supplied as the result, and execution continues. 1.B.2 Relational Operators Relational operators are used to compare two values. The result of the comparison is either "true" (-1) or "false" (0). This result may then used to make a decision regarding program flow. (See IF, Section 2.26.) Relation Tested EXEression = Equality- x=y <> Inequality x<>y < Less than x Greater than x>y <= Less than or equal to X<=Y >= Greater than or equal to X>=y °Eerator (The equal sign is also used to variable. See LET, Section 2.30.) assign a value to a When arithmetic and relational operators are combined in one expression, the arithmetic is always performed first. For example, the expression X+y < (T-1)/Z is true if the value of X plus Y is less than the T-1 divided by Z. More examples: IF SIN(X) 0 THEN K=K+1· value of • GENERAL INFORMATION ABOUT BASIC-SO 1.S.3 Page 1-12 Logical Operators Logical operators perform tests on multiple relations, bit manipulation, or Boolean operations. The logical operator returns a bitwise result which is either "true" (not zero) or "false" (zero). In an expression, logical operations are performed after arithmetic and relational operations The outcome of a logical operation is determined as shown in the following table. The operators are listed in order of precedence. 0 NOT X NOT X a 1 a AND 1 y 1 a o a 1 a X AND Y 1 X Y X OR Y 1 1 1 O· X 1 1 a a a OR 1 1 1 a a o o X Y X XOR Y 1 1 1 XOR 1 a a o 1 o o 1 1 o IMP Y 1 X IMP Y o o o 1 1 1 X Y x EQV Y 1 1 1 X 1 1 a a 1 EQV a a o 1 o 1 o o 1 Just as the relational op~rators can be used to make decisions regarding program flow, logical operators can connect two or more relations and return a true or false value to be used in a decision (see IF, Section 2.26). For GENERAL INFORMATION ABOUT BASIC-80 Page 1-13 example: IF 0<200 AND F<4 THEN 80 IF I>10 OR K < > <= operators >= String comparisons are made by taking one character ,at a time from each string 'and comparing the ASCII codes.' If all the ASCII codes are the same, the strings are equal. If the ASCII codes differ, the lower code number preced~s the higher. If, during string comparison, the end of one string is reached, the shorte~ string ~s said to be smaller. Leading and, trailing blanks are significant. Examples: "M" < "AB" "FILENAME" = "FILENAME" "X&" > "X#" "CL " > "CL" "kg" > "KG" "SMYTH" < "SMYTHE" B$ < "9/12/7~" wher~ B$ = "S/12/7S~ Thus, string comparisons can be used to test string, values or to alphabetize strings., All string constants used in comparison expressions must be enclosed in quotation marks. GENERAL INFORMATION ABOUT BASIC-SO 1.9 Page 1-15 INPUT EDITING If an incorrect character is entered as a line is being typed, it can be deleted with the RUBOUT key or with Control-H. Rubout surrounds the deleted characterCs) with backslashes, and Control-H has the effect of backspacing over a character and erasing it. O~ce a characterCs) has been deleted, simply continue typing the line as desired. To delete a line that is in the process of being typed, type Control-U. A carriage return is executed automatically after the line is deleted. To correct program lines for a program that is currently in memory, simply retype the line using the same line number. BASIC-SO will automatically replace the old line with the new line. More sophisticated editing capabilities are provided in the Extended and Disk versions of BASIC-SO. See EDIT, Section 2. 16. To delete the entire program that is currently residing in memory, enter the NEW command. CSee Section 2.41.) NEW is usually used to clear memory prior to entering a new program. 1.10 ERROR MESSAGES If BASIC-SO d~tects an error that causes program execution to "terminate, an error message is printed. In the SK version, only the error code is printed. In the Extended and Disk versions, the entire error message is printed. For a complete list of BASIC-SO error codes and error messages, see Appendix J. .. CHAPTER 2 BASIC-80 COMMANDS AND STATEMENTS All of the BASIC-80 commands and statements are described in this chapter. Each description is formatted as follows: Format: Shows the correct format for the instruction. See below for format notation. Versions: Lists the versions of BASIC-80 in which the instruction is available. Purpose: Tells what the instruction is used for. Remarks: Describes in detail how the instruction is used. Example: Shows sample programs or program segments that demonstrate the use of the instruction. Format Notation Wherever the format for a statement or command is given, the following rules apply: 1. Items in capital letters must be input as shown. 2. Items in brackets lower « » case letters enclosed in angle are to be supplied by the user. 3. Items in square brackets ([ ]) are optional. 4. All punctuation except angle brackets and square brackets (i.e., commas, parentheses, semicolons, hyphens, equal signs) must be included where shown. 5. Items followed by an ellipsis ( ••• ) may be repeated any number of times (up to the length of the line)'. I BASIC-80 COMMANDS 2.1 A~D STATEMENTS Page 2-2 AUTO Format: AUTO [[,]] Versions: Extended, Disk Purpose: To generate a line number every carriage return. Remarks: AUTO begins numbering at and increments each subsequent line number by . The default for both values is 10. If is followed by a comma but is not specified, the last increment specified in an AUTO command is assumed. automatically after If AUTO generates a line number that is already being used, an asterisk is printed after the number to warn the user that any input will replace the existing line. However, typing a carriage return immediately after the asterisk will save the line and generate the next line number. AUTO is terminated by typing Control-C. The line in which Control-C is typed is not saved. After Control-C is typed, BASIC returns to command level. Example: AUTO 100,50 Generates line numbers 100, 150, 200 ••. AUTO Generates line numbers 10, 20, 30, 40 •.• BABIC-80 COMMANDS AND STATEMENTS 2.2 Page 2-3 CALL Format: CALL [«argument list»] Version: Extended, Disk Purpose: To call an assembly language subroutine. Remarks: The CALL statement is one way to transfer program flow to an assembly language subroutine. (See also the USR function, Section 3.40) contains an address that is the starting point in memory of the subroutine. may not be an array variable name. contains the arguments that are passed to the assembly language subroutine. The CALL statement generates the same calling sequence used by Microsoft's FORTRAN, COBOL and BASIC compilers. Example: 110 MYROUT=&HDOOO 120 CALL MYROUT(I,J,K) • BASIC-BO COMMANDS AND STATEMENTS 2.3 Page 2-4 CHAIN Format: CHAIN [MERGE] [, [] [,ALL] [,DELETE]] Version: Disk Purpose: To call a program and pass variables to it the current program. Remarks: is the name of the called. Example: program from that is CHAIN"PROG1" is a line number or an expression that evaluates to a line number in the called program. It is the starting point for execution of the called program. If it is omitted, execution begins at the first line. Example: CHAIN"PROG1",1000 is not command. affected by a RENUM With the ALL option, every variable in the current program is passed to the called program. If the ALL option is omitted, the current program must contain a COMMON statement to list the' variables that are passed. See Section 2.7. Example: CHAIN"PROG1",1000,ALL If the MERGE option is included, it allows a subroutine to be brought into the BASIC program as an overlay. That is, a MERGE operation is performed with the current program and the called program. The called program must be an ASCII file if it is to be MERGEd. Example: CHAIN MERGE"QVRLAY",1000 After an overlay is brought in, it is usually desirable to delete it so that a new overlay may be brought in. To do this, use the DELETE option. Example: CHAIN MERGE"OVRLAY2",1000,DELETE 1000-5000 The line numbers in are affected by RENUM command. the BASIC-SO COMMANDS AND STATEMENTS NOTE: Page 2-5 The Microsoft BASIC compiler does not support the ALL, MERGE, and DELETE options to CHAIN. If you wish to maintain compatibility with the BASIC compiler, it is recommended that COMMON be used to pass variables and that overlays not be used. • BASIC-SO COMMANDS AND STATEMENTS 2.4 Page 2-6 CLEAR . Format: CLEAR [ , [] [, ] ] Versions: SK, Extended, Disk Purpose: To set all numeric variables to zero and all string variables to null; and, optionally, to set the end of memory and the amount of stack space. Remarks: is a memory location which, if specified, sets the highest location available . for use by BASIC-SO. sets aside stack space for BASIC. The default is 1000 bytes or one-eighth of the available memory, whichever is smaller. NOTE: In previous versions of BASIC-SO, set the amount of string space and set the end of memory. BASIC-80, release 5.0 and later, allocates string space dynamically. An "Out of string space" error occurs only if there is no free memory left for BASIC to use. Examples: CLEAR CLEAR ,32768 CLEAR,,2000 CLEAR,32768,2000 BASIC-80 COMMANDS AND STATEMENTS 2.5 Page 2-7 CLOAD Formats: CLOAD CLOAD? CLOAD* Versions: 8K (cassette), Extended (cassette) Purpose: To load a program or an array from cassette tape into memory. Remarks: CLOAD executes a NEW command before it loads program from cassette tape. is string expression or the first character of string expression that was specified when program was CSAVEd. the the the the CLOAD? verifies tapes by comparing the program currently in memory with the file on tape that has the same filename. If they are the same, BASIC-80 prints Ok. If not, BASIC-80 prints NO GOOD. CLOAD* loads a numeric array that has been saved on tape. The data on tape is loaded into the array called specified when the array was CSAVE*ed. CLOAD and CLOAD? are always entered at command level as direct mode commands. CLOAD* may be entered at command level or used as a program statement. Make sure the array has been DIMensioned before it is loaded. BASIC-80 always returns to command level after a CLOAD, CLOAD? or CLOAD* is executed. Before a CLOAD is executed, make sure the cassette recorder is properly connected and in the Play mode, and the tape is possitioned correctly. See also CSAVE, Section 2.9. NOTE: CLOAD and CSAVE are not included implementations of BASIC-80. Example: CLOAD "MAX2" Loads file "M" into memory. in all • BASIC-80 COMMANDS AND STATEMENTS 2.6 Page 2-8 CLOSE Format: CLOSE[[#][,[#]]] Version: . Disk Purpose: To conclude I/O to a disk file. Remarks: is the number under which the file was OPENed. A CLOSE with no arguments closes all open files. The association between a particular file and file number terminates upon execution of a CLOSE. The file may then be reOPENed using the same or a different file number; likewise, that file number may now be reused to OPEN any file. A CLOSE for a sequential output file writes final buffer of output. the The END statement and the NEW command always CLOSE all disk files automatically. (STOP does not close disk files.) Example: See· Appendix B. BASIc-ao COMMANDS AND STATEMENTS 2.7 Page 2-9 COMMON Format: COMMON Version: Disk Purpose: To pass variables to a CHAINed program. Remarks: The COMMON statement is used in conjunction with the CHAIN statement. COMMON statements may appear anywhere in a program, though it is recommended that they appear at the beginning. The same variable cannot appear in more than one COMMON statement. Array variables are specified by appending "()" to the variable name. If all variables are to be passed, use CHAIN with the ALL option and omit the COMMON statement. Example: 100 COMMON A,B,C,D() ,G$ 110 CHAIN "PROG3", 1 a • • • BASIC-BO COMMANDS AND STATEMENTS 2.B Page 2~10 CONT Format: CONT Versions: BK, Extended, Disk Purpose: To continue program execution after a Control-C has been typed, or a STOP or END statement has been executed. Remarks: Execution resumes at the point where the break occurred. If the break occurred after a prompt from an INPUT statement, execution continues with the reprinting of the prompt (? or prompt string) • CONT is usually used in conjunction with STOP for debugging. When execution is stopped, intermediate values may be examined and changed using direct mode statements. Execution may be resumed with CONT or a direct mode GOTO, which resumes execution at a specified line number. With the Extended and Disk versions, CONT may be used to continue execution after an error. CONT is invalid if the program has been edited during the break. In 8K BASIC-80, execution cannot be CONTinued if a direct mode error has occurred during the break. Example: See example Section 2.61, STOP. Page 2-11 BASIC-80 COMMANDS AND STATEMENTS 2.9 CSAVE Formats: CSAVE CSAVE* Versions: 8K (cassette), Extended (cassette) Purpose: To save the program or an memory on cassette tape. Remarks: Each program or array saved on tape is identified by a filename. When the command CSAVE is executed, BASIC-80 saves the program currently in memory on tape and uses the first character in as the filename. may be more than one character, but only the first character is used for the filename. array currently in When the command CSAVE* is executed, BASIC-80 saves the specified array on tape. The array must be a numeric array. The elements of a multidimensional array are saved with the leftmost subscript changing fastest. CSAVE may be used as a program statement or as a direct mode command. Before a CSAVE or CSAVE* is executed, make sure the cassette-recorder is properly c6nnected and in the Record mode. See also CLOAD, Section 2.5. NOTE: CSAVE and CLOAD are not included implementations of BASIC-80. Example: CSAVE "TIMER" Saves the program currently in memory on cassette under filename liT". in all • BASIC-80 COMMANDS AND STATEMENTS 2.10 Page 2-12 DATA Format: DATA Versions: SK, Extended, Disk Purpose: To store the numeric and string constants that are accessed by the program's READ statement(s). (See READ, Section 2.54) Remarks: DATA statements are nonexecutable and may be placed anywhere in the program. A DATA statement may contain as many constants as will fit on a line (separated by commas), and any number of DATA statements may be used in a program. The READ statements access the DATA statements in order (by line number) and the data contained therein may be thought of as one continuous list of items, regardless of how many items are on a line or where the lines are placed in the program. may contain numeric constants in any format, i.e., fixed point, floating point or integer. (No numeric expressions are allowed in the list.) String constants in DATA statements must be surrounded by double quotation marks only if they contain commas, colons or significant leading or trailing spaces. Otherwise, quotation marks are not needed. The variable type (numeric or string) given in the READ statement must agree with the corresponding constant in the DATA statement. DATA statements may be reread from the beginning by use of the RESTORE statement (Section 2.57). Example: See examples in Section 2.54, READ. BASIC-80 COMMANDS AND STATEMENTS 2.11 Page 2.,.13 DEF FN Format: DEF FN[«parameter list»]= Versions: 8K, Ext-ended, Disk Purpose: To define and name a function that is written by theuser. Remarks: must be a legal variable name. This name, preceded by FN, becomes the name of the function is comprised of those variable names in the function definition that are to be replaced when the function is called. The items in the list are separated by commas. is an expression that performs the operation of the function. It is limited to one line. Variable names that appear in this expression serve only to define the function; they do not affect program variables that have the same name. A variable name used in a function definition mayor may not appear in the parameter list. If it does, the value of the parameter is supplied when the function is called. Otherwise, the current value of the variable is used. 0 The variables in the parameter list represent, on a one-to-one basis, the argument variables or values that will be given in the function call. (Remember, in the 8K version only one argument is allowed in a function call, therefore the DEF FN statement will contain only one variable.) In Extended and Disk BASIC-80, user-defined functions may be numeric or string; in 8K, user-defined string functions are not allowed. If a type is specified in the function name, the value of the expression is forced to that type before it is returned to the calling statement. If a type is specified in the function name and the argument type does not match, a "Type mismatch" error occurs. A DEF FN statement must be executed before the function it defines may be called. If a function is called before it has been defined, an "Undefined user function" error occurs. DEF FN is illegal in the direct mode. • BASIC-80 COMMANDS AND STATEMENTS Page 2-14 Example: • 410 DEF FNAB(X,Y)=XA3/YA2 420 T=FNAB(I,J) • • Line 410 defines the function function is called in line 420. FNAB. The BASIC-80 COMMANDS AND STATEMENTS 2.12 Page 2-15 DEFINT/SNG/DBL/STR Format: DEF where is INT, SNG, DBL, or STR Versions: Extended, Disk Purpose: To declare variable types as integer, precision, double precision, or string. Remarks: A DEFtype statement declares that the variable names beginning with the letter(s) specified will be that ·type variable. However, a type declaration character always takes precedence over a DEFtype statement in the typing of a variable. single If no type declaration statements are encountered, BASIC-80 assumes all variables without declaration characters are single· precision variables. Examples: 10 DEFDBL L-P All variables beginning. with the letters L, M, N, 0, and P will be double precision variables. 10 DEFSTR A All variables beginning with the letter A will be string variables. • BASIC-80 COMMANDS AND STATEMENTS 2.13 Page 2-16 DEF USR Format: DEF USR[]= Versions: Extended, Disk Purpose: To specify the starting address of language subroutine. Remarks: may be any digit from 0 to 9. The digit corresponds to the number of the USR routine whose address is being specified. If is omitted, DEF USRO is assumed. The value of is the starting address of the USR routine. See Appendix C, Assembly Languag~ Subroutines. an assembly Any number of DEF USR statements may appear in a program to redefine subroutine starting addresses, thus allowing access to as many subroutines as necessary. Example: 200 DEF USRO=24000 210 X=USRO(YA2/2.89) BASIC-80 COMMANDS AND STATEMENTS 2.14 Page 2-17 DELETE Format: DELETE[] [-] Versions: Extended, Disk Purpose: To delete program lines. Remarks: BASIC-80 always returns to command level after a DELETE is executed. If does not exist, an "Illegal function call" error occurs. Examples: DELETE 40 Deletes line 40 DELETE 40-100 Deletes lines 40 through 100, inclusive DELETE-40 Deletes all lines up to and including line 40 • BASIC-80 COMMANDS AND STATEMENTS 2.15 Page 2-18 DIM Format: DIM Versions: 8K, Extended, Disk Purpose: To specify the maximum values for array variable subscripts and allocate storage accordingly. Remarks: If an array variable name is used without a DIM statement, the maximum value of its subscript(s) is assumed to be 10. If a subscript is used that is greater than the maximum specified, a "Subscript out of range" error occurs. The minimum value for a subscript is always 0, unless otherwise specified with the OPTION BASE statement (see Section 2.46). The DIM statement sets all the elements of the specified arrays to an initial value of zero. Example: 10 20 30 40 DIM A(20) FOR I=O TO 20 READ A (I) NEXT I BASIC-80 COMMANDS AND STATEMENTS 2.16 Page 2-19 EDIT Format: EDIT Versions: Extended, Disk Purpose: To enter Edit Mode at the specified line. Remarks: In Edit Mode, it is possible to edit portions of a line without retyping the entire line. Upon entering Edit Mode, BASIC-80 types the line number of the line to be edited, then it types a space and waits for an Edit Mode subcommand. Edit Mode Subcommands Edit Mode sub commands are used to move the cursor or to insert, delete, replace, or search for text within a line. The subcommands are not echoed. Most of the Edit Mode subcommands may be preceded by an integer which causes the command to be executed that number of times. When a preceding integer is not specified, it is assumed to be 1. Edit Mode subcommands may be categorized according to the following functions: 1. Moving the cursor 2. Inserting text 3. Deleting text 4. Finding text 5. Replacing text 6. Ending and restarting Edit Mode NOTE In the descriptions that follow, represents any character, represents a string of characters of arbitrary length, [i] represents an optional integer (the default is 1), and $ represents the Escape (or Altmode) key. • BASIC-80 COMMANDS AND STATEMENTS 1. 2. 3. 4. Page 2-20 Moving the Cursor Space Use the space bar to move the cursor to the right. [i]Space moves the cursor i spaces to the right. Characters are printed as you space over them. Rubout In Edit Mode, [i]Rubout moves the cursor i spaces to the left (backspaces). Characters are printed as you backspace over theme Inserting Text I I$ inserts at the current cursor position. The inserted characters are printed on the terminal. To terminate insertion, type Escape. If Carriage Return is typed during an Insert command, the effect is the same as typing Escape and then Carriage Return. During an Insert command, the Rubout or Delete key on the terminal may be used to delete characters to the left of the cursor. If an attempt is made to insert a character that will make the line longer than 255 characters, a bell (Control-G) is typed and the character is not printed. x The X subcommand is used to extend the line. X moves the cursor to the end of the line, goes into insert mode, and allows insertion of text as if an Insert command had been given. When you are finished extending the line, type Escape or Carriage Return. Deleting Text D [i]D deletes i characters to the right of the cursor. The deleted characters are echoed between backslashes, and the cursor is positioned to the right of the last character deleted. If there are fewer than i characters to the right of the cursor, iD deletes the remainder of the line. H H deletes all characters to the cursor and then automatically mode. H is useful for replacing the end of a line. right of the enters insert statements at Finding Text S The subcommand [i]S searches for the ith occurrence of and positions the cursor before it. The character at the current cursor position is not included in the search. If is not found, the cursor will stop at the end of Page 2-21 BASIC-80 COMMANDS AND STATEMENTS the line. All characters passed over during the search are printed. K 5. Replacing Text C 6. The subcommand [i]K is similar to [i]S, except all the characters passed over in the search are deleted. The cursor is positioned before , and the deleted characters are enclosed in backslashes. The subcommand C changes the next character to . If you wish to change the next i characters, use the subcommand iC, followed by i characters. After the ith new character is typed, change mode is exited and you will return to Edit Mode. Ending and Restarting Edit Mode Typing Carriage Return prints the remainder of the line, saves the changes you made and exits Edit Mode. E The E subcommand has the same effect as Carriage Return, except the remainder of the line is not printed. Q The Q subcommand returns to BASIC-80 command level, without saving any of the changes that were made to the line during Edit Mode. L The L subcommand lists the remainder of the line (saving any changes made so far) and repositions the cursor at the beginning of the line, still in Edit Mode. L is usually used to list the line when you first enter Edit Mode. A The A subcommand lets you begin editing a line over again. It restores the original line and repositions the cursor at the beginning. NOTE If BASIC-80 receives an unrecognizable command or illegal character while in Edit Mode, it prints a bell (Control-G) and the command or character is ignored. • BASIC-SO COMMANDS .AND STATEMENTS Page 2-22 Syntax Errors When a Syntax Error is encountered during execution of a program, BASIC-SO automatically enters Edit Mode at the line that caused the error. For example: 10 K = 2 (4) RUN ?Syntax error in 10 10 When you finish editing the line and type Carriage Return (or the E subcommand), BASIC-aO reinserts the line, which causes all variable values to be lost. To preserve the variable values for examination, first exit Edit Mode with the Q subcommand. BASIC-aO will return to command level, and all variable values will be preserved. Control-A To enter Edit Mode on the line you are currently typing, type Control-A. BASIC-SO responds with a carriage return, an exclamation point (1) and a space. The cursor will be positioned at the first character in the line. Proceed by typing an Edit Mode subcommand. NOTE Remember, if you have just entered a line and wish to go back and edit it, the command "EDIT." will enter Edit Mode at the current line. (The line number symbol "." always refers to the current line. ) BASIC-80 COMMANDS AND STATEMENTS 2.17 Page 2-23 END Format: END Versions: 8K, Extended, Disk Purpose: To terminate program execution, close all and return to command level. Remarks: END statements may be placed anywhere in the program to terminate execution. Unlike the STOP statement, END does not cause a BREAK message to be printed. An END statement at the end of a program is optional. BASIC-80 always returns to command level after an END is executed. Example: 520 IF K>1000 THEN END ELSE GOTO 20 files • BASIC-SO COMMANDS AND STATEMENTS 2.1S Page 2-24 ERASE Format: ERASE Versions: SK, Extended, Disk Purpose: To eliminate arrays from a program. Remarks: Arrays may be redimensioned after they are ERASEd, or the previously allocated array space in memory may be used for other purposes. If an attempt is made to redimension an array without first ERASEing it, a "Redimensioned array" error occurs. NOTE: The Microsoft BASIC compiler ERASE. Example: 450 ERASE A,B 460 DIM B(99) does not support BASIC-80 COMMANDS AND STATEMENTS 2.19 Page 2-25 ERR AND ERL VARIABLES When an error handling subroutine is entered, the variable ERR contains the error code for the error, and the variable ERL contains the line number of the line in which the error was detected. The ERR and ERL variables are usually used in IF.aaTHEN statements to direct program flow in the error trap routine. If the statement that caused the error was a direct mode statement, ERL will contain 65535. To test if an error occurred in a direct statement, use IF 65535 = ERL THEN ••• Otherwise, use IF ERR IF ERL = error code THEN ••• = line number THEN a •• If the line number is not on the right side of the relational operator, it cannot be renumbered by RENUM. Because ERL and ERR are reserved variables, neither may appear to the left of the equal sign in a LET (assignment) statement. BASIC-80's error codes are listed in Appendix J. (For Standalone D'isk BASIC error codes, see Appendix H.) • BASIC-80 COMMANDS.AND STATEMENTS 2.20 Page 2-26 ERROR Format: ERROR Versions: Extended, Disk Purpose: 1) To simulate the occurrence of a BASIC-80 error; or 2) to allow error codes to be defined by the user. Remarks: The value of must be greater than 0 and less than 255. If the value of equals an error code already in use by BASIC-80 (see Appendix J), the ERROR statement will simulate the occurrence of that error, and the corresponding error message will be printed. (See Example 1.) To define your own error code, use a value that is greater than any used by BASIC-80's error codes. (It is preferable to use the highest available values, so compatibility may be maintained when more error codes are added to BASIC-80.) This user-defined error code may then be conveniently handled in an error trap routine. (See Example 2.) If an ERROR statement specifies a code for which no error message has been defined, BASIC-80 responds with the message UNPRINTABLE ERROR. Execution of an ERROR statement for which there is no error trap routine causes an error message to be printed and'execution to halt. Example 1: LIST 10 S = 10 20 T = 5 30 ERROR S + T 40 END Ok RUN String too long in line 30 Or, in direct mode: Ok ERROR 15 String too long Ok (you type this line) (BASIC-80 types this line) BASIC-80 COMMANDS AND STATEMENTS Example 2: Page 2-27 • • • 110 ON ERROR GOTO 400 120 INPUT "WHAT IS YOUR BET";B 130 IF B > 5000 THEN ERROR 210 • • • 400 IF ERR = 210 THEN PRINT "HOUSE LIMIT IS $5000" 410 IF ERL = 130 THEN RESUME 120 • • • • BASIC-80 COMMANDSAND STATEMENTS 2.21 Page 2-28 FIELD Format: FIELD[#], AS ••• Version: Disk Purpose: To allocate space for variables in a random file buffer. Remarks: To get data out of a random buffer after a GET or to enter data before a PUT, a FIELD statement must have been executed. is the number under which the file was OPENed. is the number of characters to be allocated to . For example, FIELD 1, 20 AS N$, 10 AS ID$, 40 AS ADD$ allocates the first 20 positions (bytes) in the random file buffer to the string variable N$, the next 10 positions to ID$, and the next 40 positions to ADD$. FIELD does NOT place any data in the random file buffer. (See LSET/RSET and GET.) The total number of bytes allocated in a FIELD statement must not exceed the record length that was specified when the file was OPENed. Otherwise, a "Field overflow" error occurs. (The default record length is 128.) Any number of FIELD statements may be executed for the same file, and all FIELD statements that have been executed are in effect at the same time. Example: See Appendix B. NOTE: or Do not use a FIELDed variable name in an INPUT LET--statement. Once a --variable-name is FIELDed, it points to the correct place in the random file buffer. If a subsequent INPUT or LET statement with that variable name is executed, the variable's pointer is moved to string space. BASIC-SO COMMANDS AND STATEMENTS 2.22 Page 2-29 FOR ••• NEXT Format: FOR =xTO y [STEP z] • • NEXT [] [, ••• ] where x, y and z are numeric expressions. Versions: SK, Extended, Disk Purpose: To allow a series of instructions to performed in a loop a given number of times. Remarks: is used as a counter. The first numeric expression (x) is the initial value of the counter. The second numeric expression (y) is the final value of the counter. The program lines following the FOR statement are executed until the NEXT statement is encountered. Then the counter is incremented by the amount specified by STEP. A check is performed to see if thevalue of the counter is now greater than the final value (y). If it is not greater, BASIC-SO branches back to the statement after the FOR statement and the process is repeated. If it is greater, execution continues with the statement following the NEXT statement. This is a FOR ••• NEXT loop. If STEP is not specified, the increment is assumed to be one. If STEP is negative, the final value of the counter is set to be less than the initial value. The counter is decremented each time through the loop, and the loop is executed until the counter is less than the final value. be The body of the loop is skipped if the initial value of the loop times the sign of the step exceeds the final value times the sign of the step •. Nested Loops FOR ••• NEXT loops may be nested, that is, a FOR ••• NEXT loop may be placed wi.thin the context of another FOR ••• NEXT loop. When loops are nested, each loop must have a unique variable name as its counter. The NEXT statement for the inside loop must appear before that for the outside loop. If nested loops have the same end point, a single NEXT statement may be used for all of them. The variable{s) in the NEXT statement may be • BASIc-ao COMMANDS AND STATEMENTS Page 2-30 omitted, in which case the NEXT statement will match the most recent FOR statement. If a NEXT statement is encountered before its corresponding FOR statement, a "NEXT without FOR" error message is issued and execution is terminated. Example 1: 10 K=10 20 FOR I=1 TO K STEP 2 30 PRINT I: 40 K=K+10 50 PRINT K 60 NEXT RUN 1 20 3 30 5 40 7 50 9 60 OR Example 2: 10 20 30 40 J=O FOR I=1 TO J PRINT I NEXT I In this example, the loop does not execute because the initial value of the loop exceeds the final value. Example 3: 10 I=5 20 FOR I=1 TO I+5 30 PRINT I: 40 NEXT RUN 1 2 3 4 5 6 Ok 7 a 9 10 In this example, the loop executes, ten times. The final value for the loop variable is always set before the initial value is set. (Note: Previous versions of BASIC-80 set the initial value of the loop variable before setting the final value: i.e., the above loop would have executed six times.) BASIC-80 COMMANDS AND STATEMENTS 2.23 Page 2-31 GET Format: GET [#][,] Version: Disk Purpose: To read a record from a random disk file into random buffer. Remarks: is the number under whicn the file was OPENed. If is omitted, the next record (after the last GET) is read into the buffer. The largest possible record number is -32767. Example: See Appendix -B. a • BASIC~80 2.24 COMMANDS AND STATEMENTS Page 2-32 GOSUB ••• RETURN Format: GOSUB • RETURN Versions: 8K, Extended, Disk Purpose: To branch to and return from a subroutine. Remarks: subroutine. is the first line of the A subroutine may be called any number of times in a program, and a subroutine may be called from within another subroutine. Such nesting of subroutines is limited only by available memory. The RETURN statement(s) in a subroutine cause BASIC-80 to branch back to the statement following the most recent GOSUB statement. A subroutine may contain more than one RETURN statement, should logic dictate a return at different points in the subroutine. Subroutines may appear anywhere in the program, but it is recommended that the subroutine be readily distinguishable from the main program. To prevent inadvertant entry into the subroutine, it may be preceded by a STOP, END, or GOTO statement that directs program control around the subroutine. Example: 10 GOSUB 40 20 PRINT "BACK FROH SUBROUTINE" 30 END 40 PRINT "SUBROUTINE"; 50 PRINT " IN"; 60 PRINT " PROGRESS" 70 RETURN RUN SUBROUTINE IN PROGRESS BACK FROM SUBROUTINE Ok BASIC-80 COMMANDS AND STATEMENTS 2.25 Page 2-33 GOTO Format: GOTO Versions: 8K, Extended, Disk Purpose: To branch unconditionally out of the normal program sequence to a specified line number. Remarks: If is an executable statement, that statement and those following are executed. If it is a nonexecutable statement, execution proceeds at the first executable statement encountered after . Example: LIST 10 READ R 20 PRINT "R =";R, 30 A -= 3.14*RA2 40 PRINT "AREA =";A 50 GOTO 10 60 DATA 5,7,12 Ok RUN AREA = 78.5 R = 4 AREA = 153.86 R = 7 AREA = 452.16 R = 12 ?Out of data in 10 Ok • BASIC-80 COMMANDS AND STATEMENTS 2.26 IF ••• ~[ ••• ELSE] AND Format: .!!... GOTO IF THEN number>] IF GOTO [ELSE ] Versions: 8K, Extended, Disk NOTE: The ELSE clause is allowed only in Extended Disk versions. Purpose: To make a decision regarding program flow on the result returned by an expression. Remarks: If the result of is not zero, the THEN or GOTO clause is executed. THEN may be followed by either a line number for branching or one or more statements to be executed. GOTO is always followed by a line number. If the result of is zero, the THEN or GOTO clause is ignored and the ELSE, clause,' if present, is executed. Execution continues with the next executable statement. (ELSE is allowed only in Extended and Disk versions.) Extended and Disk versions allow a comma before THEN. and based Nesting of !! Statements In the Extended and Disk versions, IF ••• THEN ••• ELSE statements may be nested. Nesting is limited only by the length of the line. For example IF X>Y THEN PRINT "GREATER" ELSE IF Y>X THEN PRINT "LESS THAN" ELSE PRINT IIEQUAL II is a legal statement. If the statement does not contain the same number of ELSE and THEN clauses, each ELSE is matched with the closest unmatched THEN. For example IF A=B THEN IF B=C THEN PRINT "A=C II ELSE PRINT "A<>C II will not print IIA<>C II when A<>B. If an IF ••• THEN statement is followed by a line number in the dirapt mode, an "Undefined line" the error results unless a statement with specified line number had previously beeri entered in the indirect mode. BASIC-80 COMMANDS AND STATEMENTS NOTE: Page 2-35 When using IF to test equality for a value . that is the result of a floating point computation, remember that the internal representation of the value may not be exact. Therefore, the test should be against the range over which the accuracy of the value may vary. For example, to test a computed variable A against the value 1.0, use: IF ABS (A-1.0)<1.0E-6 THEN ••• This test returns true if the value of A is with a relative error of less than 1.0E-6. Example 1: 200 IF I THEN GET#1,I This statement GETs record number I if I is zero. Example 2: 1.0 not 100 IF(I<20)*(I>10) THEN DB=1979-1:GOTO 300 110 PRINT "OUT OF RANGE" • • In this example, a test determines if I is greater than 10 and less than 20. If I is in this range, DB is calculated and execution branches to line 300. If I is not in this range, execution continues with line 110. Example 3: 210 IF IOFLAG THEN PRINT A$ ELSE LPRINT A$ This statement causes printed output to go either to the terminal or the line printer, depending on the value of a variable (IOFLAG) • If IOFLAG is zero, output goes to the line printer, otherwise output goes to the terminal. • BASIC-80 COMMANDS AND STATEMENTS 2.27 Page 2-36 INPUT Format: INPUT[i] [<"prompt string">;] Versions: 8K, Extended, Disk Purpose: To allow input from the terminal during execution. Remarks: When an INPUT statement is encountered, program execution pauses and a question mark is printed to indicate the program is waiting for data. If <"prompt string"> is included,· the string is printed before the question mar~. The required data is then entered at the terminal. program If INPUT is immediately followed by a semicolon, then the carriage return typed by the user to input data does not echo a carriage return/line feed sequence. The data that is entered is assigned to the variable(s) given in . The number of data items supplied must be the same as the number of variables in the lis.t. Data items are separated by commas. The variable names in the list may be numeric or string variable names (including subscripted variables). The type of each data item that is input must agree with the type specified by the variable name. (Strings input to an INPUT statement need not be surrounded by quotation marks. ) Responding to INPUT with too many or too few items, or with the wrong type of value (numeric instead of string, etc.) causes the messsage "?Redo from start" to be printed. No assignment of input values is made until' an acceptable response is given. In the 8K version, direct mode. INPUT is illegal in the BAStC-80 COMMANDS AND STATEMENTS Examples: Page 2-37 10 INPUT X 20 PRINT X "SQUARED IS" XA2 30 END RUN ? 5 (The 5 was typed in by the user in response to the question mark.) 5 SQUARED IS 25 Ok LIST 10 PI=3.14 20 INPUT ttWHAT IS THE RADIUS";R 30 A=PI*RA2 40 PRINT "THE AREA OF THE CIRCLE IS";A 50 PRINT 60 GOTO 20 Ok RUN WHAT IS THE RADIUS? 7.4 (User types 7.4) THE AREA OF THE CIRCLE IS 171.946 WHAT IS THE RADIUS? etc. • BASIC-80 COMMANDS AND STATEMENTS 2.28 Page 2-38 INPUT# Format: INPUT# , Version: Disk Purpose: To read data items from a sequential disk and assign them to program variables. Remarks: is the number used when the file was OPENed for input. contains the variable names that will be assigned to the items in the file. (The variable type must match the type specified by·the variable name.) With INPUT#, no question mark is printed, as with INPUT. file The data items in the file shoul~ appear just as they would if data were being typed in response to an INPUT statement. With numeric values, leading spaces, carriage returns and line feeds are ignored. The first character encountered that is not a space, carriage return or line feed is assumed to be the start of a number. The number terminates on a space, carriage return, line feed or comma. If BASIC-80 is scanning the sequential data file· for a string item, leading spaces, carriage returns and line feeds are also ignored. The first character encountered that is not a space, carriage return, or line feed is assumed to be the start of a string item. If this first character is a quotation mark ("), the string item will consist of all characters read between the first quotation mark and the second. Thus, a quoted string may not contain a quotation mark as a character. If the first character of the string is not a quotation mark, the string is an unquoted string, and will terminate on a comma, carriage or line feed (or after 255 characters have been read). If end of file is reached when a numeric or string item is being INPUT, the item is terminated. Example: See Appendix B. BASIC-BO COMMANDS AND STATEMENTS 2.29 Page 2-39 KILL Format: KILL Version: Disk Purpose:', To delete a file from disk. Remarks: If a KILL statement is given for a file that is currently OPEN, a "File already open" error occurs. KILL is used for all types of disk files: program files, random data files and sequential data files. Example: 200 KILL "DATA1" See also Appendix B. • o BASIC-80 COMMANDS AND STATEMENTS 2.30 LET Format: [LET] = Versions: 8K, Extended, Disk Purpose: To assign variable. Remarks: Notice the word LET is optional, i.e., the equal sign is sufficient when assigning an expression to a variable name. Example: 110 120 130 140 LET LET LET LET the 110 120 130 140 value D=12 E=12A2 F=12A4 SUM=D+E+F or / Page 2-40 D=12 E=12A2 F=12A4 SUM=D+E+F of an expression to a BASIC-SO COMMANDS AND STATEMENTS 2.31 Page 2-41 LINE INPUT Format: LINE INPUT[i] [<"prompt string">i] Versions: Extended, Disk Purpose: To input an entire line (up to 254 characters) to a string variable, without the use of delimiters. Remarks: The prompt string is a string literal that is printed at the terminal before input is accepted. A question mark is not printed unless it is part of the prompt string. All input from the end of the prompt to the carriage return is assigned to . If LINE INPUT is immediately followed by a semicolon, then the carriage return typed by the user to end the input line does not echo a carriage return/line feed sequence at the terminal. A LINE INPUT may be escaped by typing Control-C. BASIC-SO will return to command level and type Ok. Typing CONT resumes execution at .the LINE INPUT. Example: See Example, Section 2.32, LINE INPUT#. • BASIC-80 COMMANDS AND STATEMENTS 2.32 Page 2-42 LINE INPUT# Format: LINE INPUT#, Version: Disk Purpose: To read an entire line (up to 254 characters), without delimiters, from a sequential disk data file to a string variable. Remarks: is the number under which the file was OPENed. is the variable name to which the line wil~ be assigned. LINE INPUT# reads all characters in the sequential file up to a carriage return. It then skips over the carriage return/line feed sequence, and the next LINE INPUT# reads all characters up to the next carriage return. (If a line feed/carriage return sequence is encountered, it is preserved.) LINE INPUT# is especially useful if each line of a data file has been broken into fields, or if a BASIC-80 program saved in ASCII mode is being read as data by another program. Example: 10 OPEN "O",1,"LIST" 20 LINE INPUT "CUSTOMER INFORMATION? " ; C$ 30 PRINT #1, C$ 40 CLOSE 1 50 OPEN "I",1,"LIST" 60 LINE INPUT #1, C$ 70 PRINT C$ 80 CLOSE 1 RUN 234,4 CUSTOMER INFORMATION? LINDA JONES LINDA JONES 234,4 MEMPHIS Ok MEMPHIS BASIC-80 COMMANDS AND STATEMENTS 2.33 Page 2-43 LIST Format 1: LIST [] Versions: 8K, Extended, Disk Format 2: LIST [[-[]]] Versions: Extended, Disk Purpose: To list all or part of the program currently memory at the terminal. . Remarks: BASIC-80 always returns to command level after a LIST is executedo in Format 1: If is omitted, the program is listed beginning "at the lowest line number. (Listing is terminated either by the end of the program or by typing Control-C.) If is included, the 8K version will list the program beginning at that line; and the Extended and Disk versions will list only the specified line. Format 2: options: This format allows the following 1. If only the first number is specified, that line and all higher-numbered lines are listed. 2. If only the second number is specified, all lines from the beginning of the program through that line are listed. 3. If both numbers are range is listed. specified, the entire • BASIc-ao COMMANDS AND STATEMENTS Examples: Page 2-44 Format 1: LIST Lists the program currently in memory. LIST 500 In the 8K version, lists all programs lines from 500 to the end. In Extended and Disk, lists line 500. Format 2: LIST 150- Lists all lines from 150 to the end. LIST -1000 Lists all lines from the lowest number through 1000. LIST 150-1000 Lists lines 150 through 1000, inclusive. Page 2-45 BASIC-80 COMMANDS AND STATEMENTS 2.34 LLIST Format: L~IST Versions: Extended, Disk Purpose: To list all or part of the program currently memory at the line printer. Remarks: LLIST assumes a 132-character wide printer. [[-[]]] in BASIC-80 always returns to command level after an LLIST is executed. The options for LLIST are the same as for LIST, Format 2. NOTE: LLIST and LPRINT are not implementations of BASIC-80. Example: See the examples for LIST, Format 2. included in all • BASIC-80 COMMANDS AND STATEMENTS 2.35 Page 2-46 LOAD Format: LOAD [,R] Version: Disk Purpose: To load a file from disk into memory. Remarks: is the name that was used when the file was SAVEd. (With CP/M, the default extension .BAS is supplied.) LOAD closes all open files and deletes all variables and program lines currently residing in memory before it loads the designated program. However, if the "R" option is used with LOAD, the program is RUN after it is LOADed, and all open data files are kept open. Thus, LOAD with the "R" option may be used to chain several programs (or segments of the same program). Information may be passed between the programs using their disk data files. Example: LOAD "STRTRK",R BASIC-80 COMMANDS AND STATEMENTS 2.36 Page 2-47 LPRINT AND LPRINT USING Format: LPRINT [] LPRINT USING <"format string">; Versions: Extended, Disk Purpose: To print data at the line printer. Remarks: Same as PRINT and PRINT USING, except output goes to the line printer. See Section 2.49 and Section 2.50. LPRINT assumes a 132-character-wide printer. NOTE: LPRINT and LLIST are not implementations of BASIC-80. included in all .. BASIC-80 COMMANDS AND STATEMENTS 2.37 Page 2-48 LSET AND RSET Format: LSET = RSET = Version: Disk Purpose: To move data from memory to a random file buffer (in preparation for a PUT statement). Remarks: If requires fewer bytes than were FIELDed to , LSET left-justifies the string in the field, and RSET right-justifies the string~ (Spaces are used to pad the extra positions.) If the string is too long for the field, characters are dropped from the right. Numeric values must be converted to strings before they are LSET or RSET. See the MKI$, MKS$, MKD$ functions, Section 3.25. Examples: 150 LSET A$=MKS$(AMT) 160 LSET D$=DESC($) See also Appendix B. NOTE: LSET or RSET may also be used with a non-fielded string variable to left-justify or right-justify a string in a given field. For example, the program lines 110 A$=SPACE$(20) 120 RSET A$=N$ right-justify the string N$ in a 20-character field. This can be very handy for formatting printed output. BASIC-80 COMMANDS AND STATEMENTS 2.38 Page 2-49 MERGE Format: MERGE Version: Disk Purpose: To merge a specified disk file into the currently in memory. Remarks: is the name used when the file was SAVEd. (With CP/M, the default extension .BAS is supplied.) The file must have been SAVEd in ASCII format. (If not, a "Bad file mode" error occurs.) program If any lines in the disk file have the same line numbers as lines in the program in memory, the lines from the file on disk will replace the corresponding lines in memory. (MERGEing may be thought of as "inserting" the program lines on disk into the program in memory.) BASIC-80 always returns to command executing a MERGE command. Example: level after MERGE "NUMBRS" • BASIC-SO COMMANDS AND STATEMENTS 2.39 Page 2-50 MID$ Format: MID$«string exp1>,n[,m])= where n and m are integer expressions and and are string expressions. Versions: Extended, Disk Purpose: To replace a portion of one string with string. Remarks: The characters in , beginning at position n, are replaced by the characters in . The optional m refers to the number of characters from that will be used in the replacement. If m is omitted, all of is used. However, regardless of whether m is omitted or included, the replacement of characters never goes beyond the original length of . Example: 10 A$="KANSAS CITY, MO" 20 MID$(A$,14)="KS" 30 PRINT A$ RUN KANSAS CITY, KS another MID$ may also be used as a function that returns a substring of a given string. See Section 3.24. BASIC-80 COMMANDS AND STATEMENTS 2.40 Page 2-51 NAME Format: NAME AS Version: Disk Purpose: To change the name of a disk file. Remarks: must exist and must not exist~ otherwise an error will result. After a NAME command, the file exists on the. same disk, in the same area of disk space, with the newname. Example: Ok NAME "ACCTS" AS "LEDGER" Ok In this example, the file that was formerly named ACCTS will now be named LEDGER • • BASIC-80 COMMANDS AND STATEMENTS 2.41 Page 2-52 NEW Format: NEW Versions: 8K, Extended, Disk Purpose: To delete the program currently clear all variables. Remarks: NEW is entered at command level to clear memory before entering a new program. BASIC-80 always returns to command level after a NEW is executed. in memory and BASIC-80 COMMANDS AND STATEMENTS 2.42 Page 2-53 NULL Format: NULL Versions: 8K, Extended, Disk Purpose: To set the number of nulls to be printed at end of each line. Remarks: For 10-character-per-second tape punches, should be >=3. When tapes are not being punched, should be 0 or 1 for Teletypes and Teletype-compatible CRTs. should be 2 or 3 for 30 cps hard copy printers. The default value is o. Example: Ok NULL 2 Ok 100 INPUT X 200 IF X<50 GO TO 800 the • Two null characters will be printed after each line. • BASIC-80 COMMANDS AND STATEMENTS 2.43 Page 2-54 ON ERROR GOTO Format: ON ERROR GOTO Versions: Extended, Disk Purpose: To enable error trapping and specify the line of the error handling subroutine. Remarks: Once error trapping has been enabled all errors detected, including direct mode errors (e.g., Syntax errors), will cause a jump to the specified error handling subroutine. If does not exist, an "Undefined line" error results. To disable error trapping, execute an ON ERROR GOTO O. Subsequent errors will print an error message and halt execution. An ON ERROR GOTO 0 statement that appears in an error trapping subroutine causes BASIC-80 to stop and print the error message for the error that caused the trap. It is recommended that all error trapping subroutines execute an ON ERROR GOTO 0 if an error is encountered for which there is no recovery action. NOTE: If an e~ror occurs during execution of an error handling subroutine, the BASIC error message is printed and execution terminates. Error trapping does not occur within the error handling subroutine. Example: 10 ON ERROR GOTO 1000 first BASIC-80 COMMANDS AND STATEMENTS 2.44 Page 2-55 ON ••• GOSUB AND ON ••• GOTO Format: ON GOTO ON GOSUB E~tended, Versions: 8K, Disk Purpose: To branch to one of several specified line numbers,- depending on the value returned when an expression is evaluated. Remarks: The value of determines which line number in the list will be used for branching. For example, if the value is three, the third line number in the list will be the destination of the branch. (If the value is a non-integer, the fractional portion is rounded.) In the ON ••• GOSUB statement, each line number in the list must be the first line number of a subroutine. If the value of is negative, zero or greater than the number of items in the list, an "III~gal function call" erro~ occurs. Example: 100 ON L-1 GOTO 150,300,320,390 • BASIC-80 COMMANDS AND STATEMENTS 2.45 Page 2-56 OPEN Format: OPEN , [#],,[] Version: Disk Purpose: To allow I/O to a disk file. Remarks: A disk file must be OPENed before any disk I/O operation can be performed on that file. OPEN allocates a buffer for I/O to the file and determines the mode of access that will be used with the buffer. is a string expression whose character is one of the following: first o specifies sequential output mode I specifies sequential input mode R specifies random input/output mode is an integer expression whose value is between one and fifteen. The number is then associated with the file for as long "as it is OPEN and is used to refer other disk I/O statements to the file. is a string expression containing a name that conforms to your operating system's rules for disk filenames. is an integer expression which, if included, sets the record length for random files. The default record length is 128 bytes. See also page A-3. NOTE: A file can be OPENed for sequential input or random access on more than one file number at a time. A file may be OPENed for output, however, on only one file number at a time. Example: 10 OPEN "I",2,"INVEN" See also Appendix B. BASIC-80 COMMANDS AND STATEMENTS 2.46 Page 2-57 OPTION BASE Format: OPTION BASE n where n is 1 or Versions: Extended, Disk Purpose: To declare subscripts. Remarks: The default base is O. a the minimum value for array If the statement OPTION BASE 1 is executed, the lowest value an array subscript may have is one. • BASIC-80 COMMANDS AND STATErmNTS 2.47 Page 2-58 OUT Format: OUT I,J where: I and J are integer range a to 255. expressions in the Versions: 8K, Extended, Disk Purpose: To send a byte to a machine output port. Remarks: The integer expression I is the port number, and the integer expression J is the data to be transmitted. Example: 100 OUT 32,100 BASIC-80 COMMANDS AND STATEMENTS 2.48 Page 2-59 POKE Format: POKE I,J where I and J are integer expressions Versions: 8K, Extended, Disk Purpose: To write a byte into a memory location. Remarks: The integer expression I is the address of the memory location to be POKEd. The integer expression J is the data to be POKEd. J must be in the range 0 to 255. In the 8K version, I must be less than 32768. In the Extended and Disk versions, I must be in the range 0 to 65536. With the 8K version, .data may be POKEd into memory locations above 32768 by supplying a negative number for I. The value of I is computed by subtracting 65536 from the desired address. For example, to POKE data into location 45000, I = 45000-65536, or -20536. The complementary function to POKE is PEEK. The argument to PEEK is an address from which a byte is to be read. See Section 3.27. POKE and PEEK are useful for efficient data storage, loading assembly language subroutines, and passing arguments and results to and from assembly language subroutines. Example: 10 POKE &H5AOO,&HFF • BASIC-BO COMMANDS AND STATEMENTS 2.49 Page 2-60 PRINT Format: PRINT [] Versions: 8K, Extended, Disk Purpose: To output data at the terminal. Remarks: If is omitted, a blank line is printed. If is included, the values of the expressions are printed at the terminal. The expressions in the list may be numeric and/or string expiressions. (Strings must be enclosed in quotation marks.) Print Positions The position of each printed item is determined by the punctuation used to separate the items in the list. BASIC-80 divides the line into print zones of 14 spaces each. In the list of expressions, a comma causes the next value to be printed at the beginning of the next zone. A semicolon causes the next value to be printed immediately after the last value. Typing one or more spaces between expressions has the same effect as typing a semicolon. ' If a comma or a semicolon terminates the list of expressions, the next PRINT statement begins printing on the same line, spacing accordingly. If the list of expressions terminates without a comma or a semicolon, a carriage return is printed at the end of the line. If the printed line is longer than the terminal width, BASIC-BO goes to the next physical line and continues printing. Printed numbers are always followed by a space. Positive numbers are preceded by a space. Negative numbers are preceded by a minus sign. Single precision numbers that can be represefited with 6 or fewer digits in the unscaled format no less accurately than they can be represented in the scaled format, are output using the unscaled format. For example, 10A(-6) is output as .000001 and 10A(-7) is output as 1E-7. Double prec1s1on numbers that can be represented with 16 or fewer digits in the unscaled format no less accurately than they can be represented in the scaled format, are output using the unscaled format. For example, 10A(-16) is output as .0000000000000001 and 10A(-17) is o~tput as 1D-17. BASIC-80 COMMANDS AND STATEMENTS Page 2-61 A question mark may be used in PRINT in a PRINT statement. Example 1: plac~ of the word 10 X=5 20 PRINT X+5, X-5, X*(-5), XA5 30 END RUN 10 0 -25 Ok 3125 In this example, the commas in the PRINT statement cause each value to be printed at the beginning of the next print zone. Example 2: LIST 10 INPUT X 20 PRINT X "SQUARED IS" XA2 "AND"; 30 PRINT X "CUBED IS" XA3 40 PRINT 50 GOTO 10 Ok RUN ? 9 9 SQUARED IS 81 AND 9 CUBED IS 729 ? 21/ 21 SQUAREDjS 441 AND 21 CUBED IS 9261 ? In this example, the semicolon at the end of line 20 causes both PRINT statements to be printed on the same line, and line 40 causes a blank line to be printed before the next prompt • Example 3: 10 FOR X = 1 TO 5 20 J=J+5 30 K=K+10 40 ?J;K; 50 NEXT X Ok RUN 5 10 10 20 15 Ok 30 20 40 25 50 In this example, the semicolons in the PRINT statement cause each value to be printed immediately after the preceding value. (Don't forget, a number is always followed by a space and positive numbers are preceded by a space.) In line 40, a question mark is used instead of the word PRINT. • BASIC-80 COMMANDS' AND STATEMENTS 2.50 Page 2-62 PRINT USING Format: PRINT USING ; Versions: Extended, Disk Purpose: To print strings or numbers format. Remarks and Examples: is comprised of the string expressions or numeric expressions that are to be printed, separated by semicolons. , enclosed in quotation marks, is comprised of special formatting characters. These formatting characters (see below) determine the field and the format of the printed strings or numbers. using a specified String Fields When PRINT USING is used to print strings, one of three formatting characters may be used to format the string field: /I!/I "\n spaces\" Specifies that only the first character given string is to be printed. in the Specifies that 2+n characters from the string are to be printed. If the backslashes are typed with no spaces, two characters will be printed; with one space, three characters will be printed, and so on. If the string is longer than the field, the extra characters are ignored. If the field is longer than the string, the string will be left-justified in the field and padded with spaces on the right. Example: 10 A$="LOOK":B$="OUT/I 30 PRINT USING /I!";A$;B$ 40 PRINT USING /1\ \";A$;B$ 50 PRINT USING /1\ \/I;A$;B$;"!!/I RUN LO LOOKOUT LOOK OUT ! ! BASIC-80 COMMANDS AND STATEMENTS "&11 Page 2-63 Specifies a variable length string field. When the field is specified with "&", the string is output exactly as input. Example: 10 A$="LOOK":B$="OUT" 20 PRINT USING "!"; A$; 30 PRINT USING "&II;B$ RUN LOUT Numeric Fields When PRINT USING is used to print numbers, the following special characters may be used to format the numeric field: A number sign is used to represent each digit position. Digit positions are aiways, filled. If the number to be printed has fewer digits than positions specified, the number will be right-justified (preceded by spaces) in the field. A decimal point may be inserted at any position in the field. If the format string specifies that a digit is to precede the decimal point, the digit will always be printed (as a if necessary). Numbers are rounded as necessary. PRINT USING "##.##;".78 0.78 PRINT USING "###.##";987.654 987.65 PRINT USING "##.## 11;10.2,5.3,66.789,.234 10.20 5.30 66.79 0.23 In the last example, three spaces were inserted at the end of the format string to separate the printed values on the line. + A plus sign at the beginning or end of the format string will cause the sign of the number (plus or minus) to be printed before or after the number. • BASIC-80 COMMANDS AND STATEMENTS Page 2-64 A minus sign at the end of the format field will cause negative numbers to be printed with a trailing minus sign. PRINT USING "+##.## ";-68.95,2.4,55.6,-.9 -68.95 +2.40 +55.60 -0.90 PRINT USING "##.##";-68.95,22.449,-7.01 68.9522.45 7.01** A double asterisk at the beginning of the format string causes leading spaces in the numeric field to be filled with asterisks. The ** also specifies positions for two more digits. PRINT USING "**#.# ";12.39,-0.9,765.1 *12.4 *-0.9 765.1 $$ A double dollar sign causes a dollar sign to be printed to the immediate left of the formatted number. The $$ specifies two more digit positions, one of which is the dollar sign. The exponential format cannot be used with $$. Negative numbers cannot be used unless the minus sign trails to the right. PRINT USING "$$###.##";456.78 $456.78 **$ The **$ at the beginning of a format string combines the effects of the above two symbols. Leading spaces will be asterisk-filled and a dollar sign will be printed before the number. **$ specifies three more digit positions, one of which is the dollar sign. PRINT USING "**$##.##";2.34 ***$2.34 A comma that is to the left of the decimal point in a formatting string causes a comma to be printed to the left of every third digit to the left of the decimal point. A comma that is at the end of the format string is printed as part of the string. A comma specifies another digit position. The comma has no effect if used with the exponential (AAAA) format. PRINT USING "####,.##";1234.5 1,234.50 PRINT USING "####.##,";1234.5 1234.50, BASIC-80 COMMANDS AND STATEMENTS AAAA Page 2-65 Four carats (or up-arrows) may be placed after the digit position characters to specify exponential format. The four carats allow space for E+xx to be printed. Any decimal point position may be specified. The significant digits are left-justified, and the exponent is adjusted. Unless a leading + or trailing + or is specified, one digit position will be used to the left of the decimal point to print a space or a minus sign. PRINT USING "##.##AAAA";234.56 2.35E+02 PRINT USING ".####AAAA-";888888 .8889E+06 PRINT USING "+.##AAAA";123 +.12E+03 An underscore in the format string causes the next character to be output as a literal character. PRINT USING" 1##.## 1";12.34 !12.341 The literal character itself may be an underscore by placing " __" in the format string. % If the number to be printed is larger than the specified numeric field, a percent sign is If rounding printed in front of the number. causes the number to exceed the field, a percent sign will be printed in front of the rounded number. PRINT USING "##.##";111.22 %111.22 PRINT USING ".##";.999 %1.00 If the number of digits specified exceeds 24, an "Illegal function call" error will result. • BASIC-80 COMMANDS AND STATEMENTS 2.51 Page 2-66 PRINT# AND PRINT# USING Format: PRINT#,[USING<"format string">;] Version: Disk Purpose: To write data to a sequential disk file. Remarks: is the number used when the file was OPENed for output. <"format string"> is comprised of formatting characters as described in Section 2.50, PRINT USING. The expressions in are the numeric and/or string expressions that will be written to the file. PRINT# does not compress data on the disk. An image of the data is written to the disk, just as it would be displayed on the terminal with a PRINT statement. For this reason, care should be taken to delimit the data on the disk, so that it will be input correctly from the disk • . " In the list of expressions, numeric expressions should be delimited by semicolons. For example, PRINT#1,A;B;C;X;Y;Z (If commas are used as delimiters, the extra blanks that are inserted between print fields will also be written to disk.) String expressions must be separated by semicolons in the list. To format the string expressions correctly on the disk, use explicit delimiters in the list of expressions. For example, let A$="CAMERA" The statement and B$="93604-1". PRINT#1,A$jB$ would write CAMERA93604-1 to the disk. Because there are no delimiters, this could not be input as two separate strings. To correct the problem, insert explicit delimiters into the PRINT# statement as follows: PRINT#1,A$;","jB$ The image written to disk is CAMERA, 93604-1 BASIC-SO COMMANDS AND STATEMENTS which can variables. be read Page 2-67 back into string two If the strings themselves contain commas, semicolons, significant leading blanks, carriage returns, or line feeds, write them to disk surrounded by explicit quotation marks, CHR$(34) • For example, let A$="CAMERA, AUTOMATIC" B$=" 93604-1". The statement and PRINT# 1 ,A$; B$ would write the following image to disk: CAMERA, AUTOMATIC 93604-1 and the statement INPUT# 1 ,A$, B$ A$ and would input "CAMERA" to "AUTOMATIC 93604-1" to B$. To separate these strings properly on the disk, write double quotes to the disk image using CHR$(34). The statement PRINT#1,CHR$(34) ~A$;CHR$(34);CHR$(34);B$;CHR$(34) writes the following image to disk: "CAMERA, AUTOMATIC"" 93604-1" and the statement INPUT# 1 ,A$ ,B$ would input "CAMERA, AUTOMATIC" " 93604-1" to B$. to A$ and The PRINT# statement may also be used with the USING option to control the format of the disk file. For example: PRINT#1,USING"$$###.##,";J;K;L For more examples using PRINT#, see Appendix B. See also- WRITE#, Section 2.6~. BASIC-80 COMMANDS AND STATEMENTS 2.52 Page 2-68 PUT Format: PUT [#][,] Version: Disk Purpose: To write a record from random disk file. Remarks: is the number under which the file was OPENed. If is omitted, the record will have the next available record number (after the last PUT). The largest possible record number is 32767. Example: See Appendix B. a random buffer to a BASIC-80 COMMANDS AND STATEMENTS 2.53 Page 2-69 RANDOMIZE Format: RANDOMIZE [] Versions: Extended, Disk Purpose: To reseed the random number generator. Remarks: If is program execution printing omitted, BASIC-80 suspends and asks fora value by Random Number Seed (0-65529)? before executing RANDOMIZE. If the random number generator is not reseeded, the RND function returns the same sequence of random numbers each time the program is RUN. To change the sequence of random numbers every time the program is RUN, place a RANDOMIZE statement at the beginning of the program and change the argument with each RUN. Example: 1 0 RANDOMI ZE 20 FOR I=1 TO 5 30 PRINT RND; 40 NEXT I RUN Random Number Seed (0-65529)? 3 (user types 3) .88598 .484668 .586328 .119426 .709225 Ok RUN Random Number Seed (0-65529)? 4 (user types 4 for new sequence) • 803506 .162462 .929364 .292443 .322921 Ok RUN Random Number Seed (0-65529)? 3 (same sequence as first RUN) .88598 .484668 .586328 .119426 .709225 Ok • BASIC-80 COMMANDS AND STATEMENTS 2.54 Page 2-70 READ Format: READ Versions: 8K, Extended, Disk Purpose: To read values from a DATA statement and assign them to variables. (See DATA, Section 2.10~) Remarks: A READ statement must always be used in conjunction with a DATA statement. READ statements assign variables to DATA statement values on a one-to-one basis. READ statement variables may be numeric or string, and the values read must agree with the variable types specified. If they do not agree, a "Syntax error" will result. A single READ statement may access one or more DATA statements (they will be accessed in order), or several READ statements may access the same DATA statrnent. If the number of variables in exceeds the number of elements in the DATA statement(s), an OUT OF DATA message is printed. If the number of variables specified is fe',ver than the number of elements in the DATA statement(s), subsequent READ statements will begin reading data at the first unread element. If there are no subsequent READ statements, the extra data is ignored. To reread DATA statements from the start, use the RESTORE statement (see RESTORE, Section 2.57) Example 1: • 80 FOR I=1 TO 10 90 READ A (I) 100 NEXT I 110 DATA 3.08,5.19,3.12,3.98,4.24 120 DATA 5.08,5.55,4.00,3.16,3.37 This program segment READs the values from the DATA statements into the array A. After execution, the value of A(1) will be 3.08 I and so on. BASIC-80 COMMANDS AND STATEMENTS Example 2: Page 2-71 LIST 10 PRINT "CITY", "STATE", " ZIP" 20 READ C$,S$,Z 30 DATA "DENVER,", COLORADO, 80211 40 PRINT C$,S$,Z Ok RUN CITY DENVER, STATE COLORADO ZIP 80211 Ok This program READs string and numeric data the DATA statement in line 30. from • BASIC-SO COMMANDS AND STATEMENTS 2.55 Page 2-72 REM Format: REM Versions: SK, Extended, Disk Purpose: To allow explanatory remarks ,to be inserted in a program. Remarks: REM statements are not executed but are output exactly as entered when the program is lis,ted., , REM statements may be branched into (from a GOTO or GOSUB statement), and execution will continue with the first executable statement after the REM statement. In the Extended and Disk versions, remarks may be added to the end of a line by preceding the remark with a single quotation mark instead of : REM. Example: • • • 120 REM CALCULATE AVERAGE VELOCITY 130 FOR I=1 TO 20 140 SUM=SUM + V(I) • • • or, with Extended and Disk versions: • • 120 FOR I=1 TO 20 130 SUM=SUM+V(I) 140 NEXT I • • • 'CALCULATE AVERAGE VELOCITY BASIC-BO COMMANDS AND STATEMENTS 2.56 Page 2-73 RENUM Format: RENUM [[ ] [, [] [ , <.increment>] ] ] Versions: Extended, Disk Purpose: To renumber program lines. Remarks: is the first line number to be used in the new sequence. The default is 10. is the line in the current program where renumbering is to begin. The default is the first line of the program. is the increment to be used in the new sequence. The default is 10. RENUM also changes all line number references following GOTO, GOSUB, THEN, ON ••• GOTO, ON ••• GOSUB and ERL statements to reflect the new line numbers. If a nonexistent line number appears after one of these statements, the error message IIUndefined line xxxxx in yyyyy" is printed. The incorrect line number reference (xxxxx) is not changed by RENUM, but line number yyyyy may be changed. NOTE: RENUM cannot be used to change the order of program lines (for example, RENUM 15,30 when the program has three lines numbered 10, 20 and 30) or to create line numbers greater than 65529. An IIIllegal function call ll error will result. Examples: RENUM Renumbers the entire program. The first new line number will be 10. Lines will increment by 10. RENUM 300,,50 Renumbers the entire program. The first new line number will be 300. Lines will increment by 50. RENUM 1000,900,20 Renumbers the lines from 900 up so they start with line number 1000 and increment by 20. • BASIC-BO COMMANDS AND STATEMENTS 2.57 Page 2-74 RESTORE Format: RESTORE [] Versions: 8K, Extended, Disk Purpose: To allow DATA statements to specified point. . Remarks: Example: be reread from a After a RESTORE statement is executed, the next READ statement accesses the first item in the first DATA statement in the program. If is specified, the next READ statement accesses the first item in the specified DATA statement. 10 20 30 40 READ A,B,C RESTORE READ D,E,F DATA 57, 68, 79 • • BASIC-80 2."58 COMr~DS AND STATEMENTS Page 2-75 RESUME Formats: RESUME RESUME a RESUME NEXT RESUME Versions: Extended, Disk Purpose: To continue program execution after an recovery procedure has been performed. Remarks: Anyone of the four formats shown above may used, depending upon where execution is resume: RESUME or RESUME a RESUME NEXT error be to Execution resumes at the statement which caused the error. Execution resumes at the statement immediately following the one which caused the error. RESUME Execution resumes at . A RESUME statement that is not in an error trap _routine causes a "RESUME without error" message to be printed. Example: ·10 ON ERROR GOTO 900 • • • 900 IF (ERR=230) AND (ERL=90) THEN PRINT "TRY AGAIN" : RESUME 80 • • • • BASIC-80 COMMANDS AND STATEMENTS 2.59 Page 2-76 RUN Format 1: RUN [] Versions: 8K Extended, Disk Purpose: To execute the program currently in memory. Remarks: If is specified, execution begins on that line. Otherwise, execution begins at the lowest line number. ·BASIC-80 always returns to command level after a RUN is executed. Example: RUN Format 2: RUN [ ,RJ Version: Disk Purpose: To load a file from disk into memory and run it. Remarks: is the name used when the file was SAVEd. (With CP/M and ISIS-II, the default extension .BAS is supplied.) RUN closes all open files and deletes the current contents of memory before loading the designated program. However, with the " R" option, all data files remain OPEN. J Example: RUN "NEWFIL",R See also Appendix B. BASIC-80 COMMANDS AND STATEMENTS 2.60 Page 2-77 SAVE I ,p] Format: SAVE [,A Version: Disk Purpose:- To save a program file on disk. Remarks: is a quoted string that conforms to your operating system's requirements for filenames. (With CP/M, the default extension .BAS is supplied.) If already exists, the file will be written over. Use the A option to save the file in ASCII format. Otherwise, BASIC saves the file in a compressed binary format. ASCII format takes more space on the disk, but some disk access requires that files be in ASCII format. For instance, the MERGE command requires an ASCI.I format file, and some operating system commands such as LIST may require an ASCII format file. Use the P option to protect the file by saving it in an encoded binary format. When a protected file is later RUN (or LOADed), any attempt to list or edit it will fail. Examples: SAVE"COM2",A SAVE "PROG" ,P See also Appendix B. • ·BASIC-80 COMMANDS AND STATEMENTS 2.61 Page 2-78 STOP Format: STOP Versions: 8K, Extended, Disk Purpose: To terminate program command level. . Remarks:· execution and return· to STOP statements may be used anywhere in a program to terminate execution. When a STOP is encountered, the following message is printed: Break in line nnnnn Unlike the END statement, does not close files. the STOP statement BASIC-80 always returns to command level after a STOP is executed. Execution is resumed by issuing a CONT command (see Section 2.8). Example: 10 INPUT A,B,C 20 K=AA2*5.3:L=BA3/.26 30 STOP 40M=C*K+100:PRINT M RUN ? 1,2,3 BREAK IN 30 Ok PRINT, L 30.7692 Ok CONT 115.9 Ok BASIC-SO COMMANDS AND STATEMENTS 2.62 Page 2-79 SWAP Format: SWAP , Versions: Extended, Disk Purpose: To exchange the values of two variables. Remarks: Any type variable may be SWAPped (integer, single precision, double precision, string), but the two variables must be of the same type or a "Type mismatch" error results. Example: LIST 10 A$=" ONE II : B$=" ALL 20 PRINT A$ C$ B$ 30 SWAP A$, B$ 40 PRINT A$ C$ B$ RUN Ok ONE FOR ALL ALL FOR ONE Ok II C$="FOR" • BASIC-80 COMMANDS AND STATEMENTS 2.63 Page 2-80 TRON/TROFF Format: TRON TROFF Versions: Extended, Disk Purpos.e: To trace the execution of program statements. Remarks: As an aid in debugging, the TRON statE!ment (executed in either the direct or indirect mode) enables a trace flag that prints each line number of the program as it is executed •. The numbers appear enclosed in square brackets. The trage flag is disabled with the TROFF statement (or when a NEW command is executed). Example: TRON Ok LIST 10 K=10 20 FOR J=1 TO 2 30 L=K + 10 40 PRINTJ;K;L 50 K=K+10 60 NEXT 70 END Ok RUN [10] [20] [30] [40] 1 [50] [60] [30] [40] 2 [50] [60] [70] Ok TROFF Ok 10 20 20 30 BASIC-80 COMMANDS AND STATEMENTS 2.64 Page 2-81 WAIT Format: WAIT , I[,J] where I and J are integer expressions Versions: 8K, Extended, Disk Purpose: To suspend program execution while the status of a machine input port. Remarks: The WAIT statement causes execution to be suspended until a specified machine input port develops a specified bit pattern. The data read at the port is exclusive OR'ed with the integer expression J, and then AND'ed with I. If the result is zero, BASIC-80 loops back and reads the data at the port again. If the result is nonzero, execution continues with the next statement. If J is omitted, it is assumed to be zero. CAUTION: It is possible to enter an infinite loop with the WAIT statement, in which case it will be necessary to manually restart the machine. Example: 100 WAIT 32,2 monitoring • BASIC-SO COMMANDS AND STATEMENTS 2.65 Page 2-S2 WHILE ••• WEND Format: WHILE [] WEND Versions: Extended,· Disk Purpose: To execute a series of statements in a long as a given condition is true. Remarks: If is not zero (i.e., true), are executed until the WEND statement is encountered. BASIC then returns to the WHILE statement and checks . If it is still true, the process is repeated. If it is not true, execution resumes with the statement following the WEND statement. loop as WHILE/WEND loops may be nested to any level. Each WEND will match the most recent WHILE. An unmatched WHILE statement causes a "WHILE without WEND" error, and an unmatched WEND statement causes a "WEND without WHILE" er_ror. Example: 90 'BUBBLE SORT ARRAY A$ 100 FLIPS=1 'FORCE ONE PASS THRU LOOP 110 WHILE FLIPS 115 FLIPS=O FOR I=1 TO J-1 120 IF A$(I»A$(I+1) THEN 130 SWAP A$(I),A$(I+1) :FLIPS=1 140 NEXT I 150 WEND BASIC-80 COMMANDS AND STATEMENTS 2.66 Page 2-83 WIDTH Format: WIDTH [LPRINT] Versions: Extended, Disk Purpose: To set the printed line width in number characters for the terminal or line printer. Remarks: of If the LPRINT option is omitted, the line width set at the terminal. If LPRINT is included, the line width is set at the line printer. is must have a value in the range 15 to 255. The default width is 72 characters. If is 255, the line width is "infinite," that is, BASIC never inserts a carriage return. However, the position of the cursor or the print head, as given by the POS or LPOS function, returns to zero after position 255. • BASIC-80 COMMANDS AND STATEMENTS 2.67 Page 2-84 WRITE Format: WRITE[] Version: Disk Purpose: To output data at the terminal. Remarks: If is omitted, a blank line is output. If is, included, the values of the expressions are output at the terminal. The expressions in the li~t m~y be numeric and/or string expressions, and they must be separated by commas. When the printed items are output, each item will be separated from the last by a comma. Printed strings will be delimited by quotation marks. After the last item in the list is printed, BASIC inserts a carriage return/line feed. WRITE outputs numeric values using the same format as the PRINT statement, Section 2.49. Example: 10 A=80:B=90:C$=THAT'S ALL 20 WRITE A,B,C$ RUN 80, 90,"THAT'S ALL" Ok BASIC-80 COMMANDS AND STATEMENTS 2.68 Page 2-85 WRITE# Format: WRITE#, Version: Disk Purpose: To write data to a sequential file. Remarks: is the number under which the file was OPENed in "0" mode. The expressions in the list are string or numeric expres,sions, and they must be separated by commas. " The difference between WRITE# and PRINT# is that WRITE# inserts commas between the items as they are written to disk and delimits strings with quotation marks. Therefore,. it is not necessary for the user to put explicit delimiters in the list. A carriage return/line feed sequence is inserted after the last item in the list is written to disk. Example: Let A$="CAMERA" statement: and B$="93604-1". The WRITE#1,A$,B$ writes the following image to disk: "CAMERA","93604-1" A subsequent INPUT# statement, such as: INPUT#1,A$,B$ would input "CAMERA" to A$ and "93604-1" to B$. • CHAPTER 3 BASIC-80 FUNCTIONS The intrinsic functions provided by BASIC-80 are presented in this chapter. The functions may be called from any program without further definition. Arguments to functions are always enclosed in parentheses. In the formats given for the functions in this chapter, the arguments have been abbreviated as follows: X and Y Represent any numeric expressions I and J Represent integer expressions X$ and Y$ Represent string expressions If a floating point value is supplied where an integer is required, BASIC-80 will round the fractional portion and use the resulting integer. • BASIC-80 FUNCTIONS 3.1 Page 3-2 ABS Format: ABS eX) Versions: 8K, Extended, Disk Action: Returns the absolute value of the expression X. Example: PRINT ABS (7* (-5) ) 35 Ok 3.2 ASC Format: ASC(X$) Versions: 8K, Extended, Disk Action: Returns a numerical value that is the ASCII code of the first character of the string X$. (See Appendix L for ASCII codes.) If X$ is null, an "Illegal function call" error is returned. Example: 10 X$ = "TEST" 20 PRINT ASC(X$) RUN 84 Ok See the CHR$ conversion. function for ASCII-to-string BASIC-80 FUNCTIONS 3.3 Page 3-3 ATN Format: ATN(X) Versions: 8K, Extended, Disk Action: Returns the arctangent of X in radians. Result is in the range -pi/2 to pi/2. The expression X may be any numeric type, but the evaluation of ATN is always performed in single precision. Example: 10 INPUT X 20 PRINT ATN(X) RUN ? 3 1.24905 Ok 3.4 CDBL Format: CDBL(X) Versions: Extended, Disk Action: Converts X to a double precision number. " Example: 10 A = 454.67 20 PRINT AiCDBL(A) RUN 454.67 454.6700134277344 Ok II BASIC-80 FUNCTIONS 3.5 Page 3-4 CHR$ Format: CHR$(I) Versions: 8K, Extended, Disk Action: Returns a string whose one element has ASCII code I. (ASCII codes are listed in Appendix L.) CHR$ is commonly used to send a special character to the terminal. For instance, the BEL character could be sent (CHR$(7» as a preface to an error message, or a form feed could be sent (CHR$(12» to clear a CRT screen and return the cursor to the horne position. Example: PRINT CHR$ (66) B Ok See the ASC conversion. 3.6 function for ASClI-to-nurneric CINT Format: CINT (X) Versions: Extended, Disk Action: Converts X to an integer by rounding the fractional portion. If X is not in the range -32768 to 32767, an "Overflow" error occurs. Example: PRINT CINT(45.67) 46 Ok See the CDBL and CSNG functions for converting numbers to the double precision and single precision data type. See also the FIX and INT functions, both of which return integers. BASIC-SO FUNCTIONS 3.7 COS Format: COS (X) Versions: SK, Extended, Disk Action: Returns the cosine of X calculation of COS (X) is precision. Example: 10 X = 2*COS(.4) 20 PRINT X RUN 1.S4212· Ok 3.S Page 3-5 in radians. The performed in single CSNG Format: CSNG(X} Versions: Extended, Disk Action: Converts X to a single precision number. Example: 10 A# = 975.3421# 20 PRINT A#; CSNG(A#) RUN 975.3421· 975.342 Ok See the CINT and CDBL functions for converting numbers to the integer and double precision data types. • BASIC..,80 FUNCTIONS 3•9 Page 3-6 CVI, CVS, CVD Format: CVI«2-byte string» CVS«4-bytestring» CVD«8-byte string» Version:> Disk Action: Convert string values to numeric values. Numeric values that are read in from a random disk file must be converted from strings back into numbers. CVI converts a 2-byte string to an integer. CVS converts a 4-byte string to a single precision number. CVD converts an a-byte string to a double precision number. Example: 70 FIELD #1,4 AS N$, 12 AS B$, ••• 80 GET #1 90 Y=CVS(N$) See also MKI$, Appendix B. 3.10 MKS$, MKD$, Section 3.25 and EOF Format: EOF«file number» Version: Disk Action: Returns -1 (true) if the end of a sequential file has been reached. Use EOF to test for end-of-file while INPUTting, to avoid "Input past end" errors. Example: 10 20 30 40 50 OPEN "I",1,"DATA" C=O IF EOF(1) THEN 100 INPUT # 1 1M (C) C=C+1:GOTO 30 BASIC-80 FUNCTIONS 3.11 Page 3-.7 EXP Format: EXP(X) Versions: 8K, Extended, Disk Action: Returns e to the power of X. X must be <=87.3365. If EXP overflows, the "Overflow" error message is displayed, machine infinity with the appropriate sign is supplied as the result, and execution continues. Example: 10 X = 5 20 PRINT EXP (X-1) RUN 54.5982 Ok 3.12 FIX Format: FIX (X) Versions: Extended, Disk Action: Returns the truncated integer part of X. FIX (X) is equivalent to SGN(X)*INT(ABS(X)). The major difference between FIX and INT is that FIX does not return the next lower number for negative X. Examples: PRINT FIX(58.75) 58 Ok PRINT FIX(-58.75) -58 Ok • BASIC-80 FUNCTIONS 3.13 FRE Format: FRE(O) FRE (X$) Versions: 8K, Extended, Disk Action: ~ Example: 3.14 Page 3-8 Arguments to FRE are dummy arguments. If the argument isO (numeric), FRE returns the number of bytes in memory not being used by BASIC-80. If the argument is· a string, FRE returns the number of free bytes in string space. PRINT FRE(O) 14542 Ok HEX$ Format: HEX$(X) Versions: Extended, Disk Action: Returns a string which represents the hexadecimal value of the decimal argument. X is rounded to an integer before HEX$(X) is evaluated. Example: 10 INPUT X 20 A$ = HEX$ (X) 30 PRINT X "DECIMAL IS " A$ " HEXADECIMAL" RUN ? 32 32 DECIMAL IS 20 HEXADECIMAL Ok See the OCT$ function for octal conversion. BASIC-80 FUNCTIONS Page 3-9 3.15 INP Format: INP (I) Versions: 8K, Extended, Disk Action: Returns the byte read from port I. I must be in the range a to 255. INP is the complementary function to the OUT statement, Section 2.47. Example: 100 A=INP(255) 3.16 INPUT$ Format: INPUT $ (X [ , [#] Y] ) Version: Disk Action: Returns a string of X characters, read from the terminal or from file number Y. If the terminal is used for input, no characters will be echoed and all control characters are passed through except Control-C, which is used to interrupt the execution of the INPUT$ function. Example 1: 5 'LIST THE CONTENTS OF A SEQUENTIAL FILE IN HEXADECIMAL 100PEN"I",1,"DATA" 20 IF EOF(1) THEN 50 30 PRINT HEX$(ASC(INPUT$(1,#1»); 40 GOTO 20 50 PRINT 60 END Example 2: 100 110 120 130 PRINT "TYPE P TO PROCEED OR S TO STOP" X$=INPUT$(1) IF X$="P" THEN 500 IF X$="S" THEN 700 ELSE 100 • BASIC-80 FUNCTIONS 3.17 Page 3-10 INSTR Format: INSTR ([ I, ] X$ , Y$) Versions: Extended, Disk Action: Searches for the first occurrence of string Y$ in X$ and returns the position at which the match is found. Optional offset I sets the position for starting the search. I must be in therange 0 to 255. If I>LEN(X$) or if X$ is null or if Y$ cannot be found, INSTR returns O. If Y$ is null, INSTR returns I or 1. X$ and Y$ may be string variables, string expressions or string literals. Example: 10 X$ = "ABCDEB" 20 Y$ = "B" 30 PRINT INSTR(X$,Y$);INSTR(4,X$,Y$) RUN 2 6 Ok 3.18 INT Format: INT(X) Versions: 8K, Extended, Disk Action: Returns the largest integer <=X. Examples: PRINT INT(99.89) 99 Ok PRINT INT(-12.11) -13 Ok See the FIX and CINT functions which also return integer values. BASIC-80 FUNCTIONS 3.19 Page 3-11 LEFT$ Format: LEFT$(X$,I) Versions: SK, Extended, Disk Action: Returns a string comprised of the leftmost I characters of X$. r must be in the range 0 to 255. If I is greater than LEN(X$), the entire string (X$) will be returned. If I=O, the null string (length zero) is returned. Example: 10 A$ = "BASIC-80" 20 B$ = LEFT$(A$,5) 30 PRINT B$ BASIC Ok ,'- Also see the MID$ and RIGHT$ functions. 3.20 LEN Format: LEN (X$) Versions: 8K, Extended, Disk Action: Returns the number of characters in X$. Non-printing characters and blanks are counted. Example: 10 X$ = "PORTLAND, OREGON" 20 PRINT LEN (X$) 16 Ok • BASIC-80 FUNCTIONS 3.21 Page 3-12 LOC Format: LOC«file number» Version: Disk Action: With random disk files, LOC returns the next record number to be used if a GET or PUT (without a record number) is executed. With sequential files, LOC returns the number of sectors (128 byte blocks) read from or written to the file since it was OPENed. Example: 200 IF 3.22 ~OC(1»50 THEN STOP LOG Format: LOG (X) Versions: 8K, Extended, Disk Action: ·Returns the natural logarithm of X. greater than zero. Example: PRINT LOG (45/7) 1.86075 Ok X must be BASIc-ao FUNCTIONS 3.23 Page 3-13 LPOS Format: LPOS (X) Versions: Extended, Disk Action: Returns the current position of the line printer print head within the line printer buffer. Does not necessarily give the physical position of the print head. X is a dummy argument. Example: 100 IF LPOS(X»60 THEN LPRINT CHR$(13) 3.24 MID$ Format: MID$ (X$ , I [ , J] ) Versions: 8K, Extended, Disk Action: Returns a string of length J characters from X$ beginning with the Ith character. I and J must be in the range a to 255 • . If J is omitted or if there are fewer than J characters to the right of the Ith character, all rightmost characters beginning with the Ith character are returned. If I>LEN(X$), MID$ returns a null string. Example: LIST 10 A$=ItGOOD " 20 B$="MORNING EVENING AFTERNOON" 30 PRINT A$;MID$(B$,9,7) Ok RUN GOOD EVENING Ok Also see the LEFT$ and RIGHT$ functions. • BASIC-80 FUNCTIONS 3.25 Page 3-14 MKI$, MKS$, MKD$ Format: MKI$«integer expression» MKS$«single precision expression>} MKD$«double precision expression» Version: Disk Action: Convert numeric values to string values. Any numeric value that is placed in a random file buffer with an LSET or RSET statement must be converted to a string. MKI$ converts an integer to a 2-byte string. MKS$ converts a single precision number to a 4-byte string. MKD$ converts a double precision number to an 8-byte string. Example: 90 AMT=(K+T) 100 FIELD #1, 8 AS D$, 20 AS N$ 110 LSET D$ = MKS$(AMT) 120 LSET N$ = A$ 130 PUT #1 See also CVI, CVS, CVD, Section 3.9 and Appendix B. 3.26 OCT$ Format: OCT$ (X) Versions: 8K, Extended, Disk Action: Returns a string which represents the octal value of the decimal argument. X is rounded to an integer before OCT$(X) is evaluated. Example: PRINT OCT$(24) 30 Ok See the HEX$ conversion. function for hexadecimal BASIC-SO FUNCTIONS 3.27 Page 3-15 PEEK Format: PEEK (I) Versions: SK, Extended, Disk Action: Returns the byte (decimal integer in the range a to 255) read from memory location I. With the SK version of BASIC-SO, I must be less than 3276S. To PEEK at a memory location above 3276S, subtract 65536 from the desired address. With Extended and Disk BASIC-SO, I must be in the range a to 65536. PEEK is the complementary function to the POKE statement, Section 2.4S. Example: A=PEEK ( &H5AO 0) 3.2S POS Format: POS (I) Versions: SK, Extended, Disk Action: Returns the current cursor position. The leftmost position is O. X is a dummy argument. Example: IF POS(X»60 THEN PRINT CHR$(13) Also see the LPOS function. • BASIC-80 FUNCTIONS 3.29 Page 3-16 RIGHT$ Format: RIGHT$(X$,I) Versions: 8K, Extended, Disk Action: Returns the rightmost I characters of string X$. If I=LEN(X$), returns X$. If 1=0, the null string (length zero) is returned. Example: 10 A$="DISK BASIC-80" 20 PRINT RIGHT$(A$,8) RUN BASIC-80 Ok Also see the MID$ and LEFT$ functions. 3.30 RND Format: RND [ (X) ] Versions: 8K, Extended, Disk Action: Returns a random number between 0 and 1. The same sequence of random numbers is generated each time the program is RUN unless the random number generator is reseeded (see RANDOMIZE, Section 2.53). However, XO or X omitted generates the next random number in the sequence. X=O repeats the last number generated. Example: 10 FOR 1=1 TO 5 20 PRINT INT(RND*100); 30 NEXT RUN 24 30 31 51 5 Ok BASIC-80 FUNCTIONS 3.31 Page 3-17 SGN Format: SGN(X) Versions: 8K, Extended, Disk Action: If X>O, SGN(X) returns 1. If X=O, SGN(X) returns O. If X=0. STR$ Format: STR$(X) Versions: 8K, Extended, Disk Action: Returns a string representation of the value X. Example: 5 REM ARITHMETIC FOR KIDS 10 INPUT "TYPE A NUMBER"~N 20 ON LEN(STR$(N)) GOSUB 30,100,200,300,400,500 Also see the VAL function. of • BASIC-80 FUNCTIONS 3.37 Page 3-20 STRING$ Formats: STRING$(I,J) STRING$(I,X$) Versions: Extended, Disk Action: Returns a string of length I whose characters all have ASCII code J or the first character of X$. Example: 10 X$ = STRING$(10,45) 20 PRINT X$ "MONTHLY REPORT" X$ RUN ----------MONTHLY REPORT---------Ok 3.38 TAB Format: TAB (I) Versions: 8K, Extended, Disk Action: Spaces to position I on the terminal. If the current print position is already beyond space I, TAB has no effect. Space 0 is the leftmost position, and the rightmost position is the width minus one. I must be in the range 0 to 255. TAB may only be used in PRINT and LPRINT statements. Example: 10 PRINT "NAME" TAB(25) "AMOUNT" : PRINT 20 READ A$,B$ 30 PRINT A$ TAB(25) B$ 40 DATA "G. T. JONES","$25.00" RUN NAME AMOUNT G. T. JONES Ok $25.00 BASIC-80 FUNCTIONS 3.39 Page 3-21 TAN Format: TAN (X) Versions: 8K, Extended, Disk Action: Returns the tangent of X in radians. TAN (X) is calculated in single prec~s~on. If TAN overflows, the "Overflow" error message is displayed, machine infinity with the appropriate sign is supplied as the result, and execution continues. Example: 10 Y = Q*TAN(X)/2 3.40 USR Format: USR[] (X) Versions: 8K, Extended, Disk Action: Calls the user's assembly language subroutine with the argument X. is allowed in the Extended and Disk versions only. is in the range 0 to 9 and corresponds to the digit supplied with the DEF USR statement for that routine. If is omitted, USRO is assumed. See Appendix C. Example: 40 B = T*SIN(Y) 50 C = USR(B/2) 60 D = USR(B/3) • BASIC-80 FUNCTIONS 3.41 Page 3-22 VAL Format: VAL (X$) Versions: 8K, Extended, Disk .Action: . Returns the numerical valu,e of string X$. If the first character of X$-isnot +, -, &, or a .digit, VAL(X$)=O. Example: 10 READ NAME$,CITY$,STATE$,ZIP$ 20 IF VAL(ZIP$)<90000 OR VAL(ZIP$»96699 THEN PRINT NAME$ TAB(25) "OUT OF STATE II 30 IF VAL(ZIP$»=90801 AND VAL(ZIP$)<=908J5 THEN PRINT NAME$ TAB(25) "LONG BEACH" • See the STR$ conversion. function for numeric to string BASIC-80 FUNCTIONS 3.42 Page 3-23 VARPTR Format 1: VARPTR«variable name» Versions: Extended, Disk Format 2: VARPT~(#. A value must be assigned to prior to execution of VARPTR. Otherwise an "Illegal function call" error results. Any type variable name may be used (numeric, string, array), and the address returned will be an integer in the range 32767 to ~32768. If a negative address is returned, add it to 65536 to obtain the actual address. number» VARPTR is usually used to obtain the address of a variable or array so it may be passed to an assembly language subroutine. A function call of the form VARPTR(A(O) is usually specified when passing an array, so that the lowest-addressed element of the array is returned. NOTE: All simple variables should be assigned before calling VARPTR for an array, because the addresses of the arrays change whenever a new simple variable is assigned. Format 2: Returns the starting address of disk I/O buffer assigned to . the In Standalone Disk BASIC, VARPTR(# may be added at the end of the command line to set the maximum record size for use with random files. The default record size is 12B bytes. A new feature has been added to the INPUT statement. A comma may be used instead of a semicolon after the prompt string to suppress the question mark. For example, the statement INPUT "ENTER BIRTHDATE",B$ will print the prompt with no question mark. • APPENDIX B BASIC-80 Disk I/O Disk I/O procedures for the beginning BASIC-80 user are examined in this appendix. If you are new to BASIC-80 or if you're getting disk related errors, read through these procedures and program examples to make sure you're using all the disk statements correctly. Wherever a filename is required in a disk command or statement, use a name that conforms to your operating system's requirements for filenames. The CP/M operating system will append a default extension .BAS to the filename given in a SAVE, RUN, MERGE or LOAD command. B.1 PROGRAM FILE COMMANDS Here is a review of the commands program file manipulation. and statements used in SAVE "filename" [,A] Writes to disk the program that is currently residing in memory. Optional A writes the program as a series of ASCII characters. (Otherwise, BASIC uses a compressed binary format.) LOAD "filename" [ , R] Loads the program from disk into memory. Optional R runs the program immediately. LOAD always deletes the current contents of memory and closes all files before LOADing. If R is included, however, open data files are kept open. Thus programs can be chained or loaded in sections and access the same data files. • Page B-2 RUN "filename" [ ,R] RUN "filename" loads the program from disk into memory and runs it. RUN deletes the current contents of memory and closes all files before loading the program. If the R option is included, however, all open data files are kept open. MERGE IIfilename ll Loads the program from disk into memory but does not delete the current contents of memory. The program line numbers on disk are merged with the line numbers in memory. If two lines have the same number, only the line from the disk program is saved. After a MERGE command, the "merged ll program resides in memory, and BASIC returns to command level. KILL" filename II Deletes the file from the disk. IIfilename ll may be a program file, or a sequential or random access data file. NAME To change the name of a disk file, execute the NAME statement, NAME "oldfile" AS "newfile ll • NAME may be used with program files, random files, or sequential files. B.2 PROTECTED FILES If you wish to save a program in an encoded binary format, For use the "Protect ll option with the SAVE command. example: SAVE IIMYPROG II ,P A program saved this way cannot be listed or edited. Page B-3 ~ ~ B.3 FILES - SEQUENTIAL AND RANDOM I/O There are two types of disk data files that may be created and accessed by a BASIC-80 program: sequential files and random access files. B.3.1 Sequential Files Sequential files are easier to create than random files but are limited in flexibility and speed when it comes to accessing the data. The data that is written to a sequential file is stored, one item after another (sequentially), in the order it is sent and is read back in the same way. The statements and functions that are used files are: OPEN CLOSE PRINT# PRINT# USING EOF INPUT# LINE INPUT# with sequential WRITE# LOC The following program steps are required to sequential file and access the data in the file: create 1. OPEN the file in "0" mode. OPEN "0", # 1 , "DATA" 2. Write data to the file using the PRINT# statement. (WRITE# maybe used instead.) PRINT#1,A$;B$;C$ 3. To access the data in the file, you must CLOSE the file and reOPEN it in "I" mode. CLOSE#1 OPEN "I",#1,"DATA" 4. Use the INPUT# statement to read data from the sequential file into the program. INPUT#1,X$,Y$,Z$ a Program B-1 is a short program that creates a sequential file, "DATA", from information you input at the terminal. • Page B-4 10 OPEN "O",#1,"DATA" 20 INPUT "NAME" ;N$ 25 IF N$="DONE" THEN END 30 INPUT "DEPARTMENT";D$ 40 INPUT "DATE HlRED";H$ 50 PRINT#1,N$;",";D$;",";H$ 60 PRINT:GOTO 20 RUN NAME? MICKEY MOUSE DEPARTMENT? AUDIO/VISUAL AIDS DATE HIRED? 01/12/72 NAME? SHERLOCK HOLMES DEPARTMENT? RESEARCH DATE HIRED? 12/03/65 NAME? EBENEEZER .SCROOGE DEPARTMENT? ACCOUNTING DATE HIRED? 04/27/78 NAME? SUPER MANN DEPARTMENT? MAINTENANCE DATE HIRED? 08/16/78 NAME? etc. PROGRAM B-1 - CREATE A SEQUENTIAL DATA FILE Page B-5 Now look at Program B-2. It accesses the file "DATA" that was created in Program B-1 and displays the name of everyone hired in 1978. 10 OPEN "I",#1,"DATA" 20 INPUT#1,N$,D$,H$ 30 IF RIGHT$ (H$,2)"="78" THEN PRINT N$ 40 GOTO 20 RUN EBENEEZER SCROOGE SUPER MANN Input past end in 20 Ok PROGRAM B-2 - ACCESSING A SEQUENTIAL FILE Program B-2 reads, sequentially, every item in the file. When all the data has been read, line 20 causes an "Input past end" error. To avoid getting this error, insert line 15 which uses the EOF function to test for end-of-file: 15 IF EOF(1) THEN END and change line 40 to GO TO 15. A program that creates a sequential file can also write formatted data to the disk with the PRINT# USING statement. For example, the statement PRINT#1,USING"####.##,"~A,B,C,D could be used to write numeric data to disk without explicit delimiters. The comma at the end of the format string serves to separate the items in the disk file. The LOC function, when used with a sequential file, returns the number of sectors that have been written to or read from the file since it was OPENed. A sector is a 128-byte block of data. B.3.1.1 Adding ~ To A Sequential File If you have a sequential file residing on disk and later want to add more data to the end of it, you cannot simply open the file in "0" mode and start writing data. As soon as you open a sequential file in "0" mode, you destroy its current contents. The following procedure can be used to add data to an existing file called "NAMES". • Page B-6 1. OPEN "NAMES" in "I" mode. 2. OPEN a second file called "COPY" in "0" mode. 3. Read in the data in "NAMES" and write it to "COPY". 4. CLOSE "NAMES" and KILL it. 5. Write the new information to "COPyll. 6. Rename "COPY" as "NAMES" and CLOSE. 7. Now there is a file on disk called "NAMES" that includes all the previous data plus the new data you just added. Program B-3 illustrates this technique. It can be used to create or add onto a file called NAMES. This program also illustrates the use of LINE INPUT# to read strings with embedded commas from the disk file. Remember, LINE INPUT# will read in characters from the disk until it sees a carriage return (it does not stop at quotes or commas) or until it has read 255 characters. Page B-7 10 ON ERROR GOTO 2000 20 OPEN "I",#1,"NAMES" 30 REM IF FILE EXISTS, ~'1RITE IT TO "COpy" 40 OPEN "O",#2,"COPY" 50 IF EOF(1) THEN 90 60 LINE INPUT#1,A$ 70 PRINT#2,A$ 80 GOTO 50 90 CLOSE #1 100 KILL "NAMES" 110 REM ADD NEW ENTRIES TO FILE 120 INPUT "NAME" i N$ 130 IF N$="" THEN 200 'CARRIAGE RETURN EXITS INPUT LOOP 140 LINE INPUT "ADDRESS? "iA$ 150 LINE INPUT "BIRTHDAY? "iB$ 160 PRINT#2,N$ 170 PRINT#2,A$ 180 PRINT#2,B$ 190 PRINT:GOTO 120 200 CLOSE 205 REM CHANGE FILENAHE BACK TO "NAMES" 210 NAME "COPY" AS "NAMES" 2000 IF ERR=53 AND ERL=20 THEN OPEN "O",#2,"COPY":RESUME 120 2010 ON ERROR GOTO 0 PROGRAM B-3 - ADDING DATA TO A SEQUENTIAL FILE The error trapping routine in line 2000 traps a "File does not exist" error in line 20. If this happens, the statements that copy the file are skipped, and "COPY" is created as if it were a new file. B.3.2 Random Files Creating and accessing random files requires more program steps than sequential files, but there are advantages to using random files. One advantage is that random files require less room on the disk, because BASIC stores them in a packed binary format. (A sequential file is stored as a series of ASCII characters.) The biggest advantage to random files is that data can be accessed randomly, i.e., anywhere on the disk - - i t is not necessary to read through all the information, as with sequential files. This is possible because the information is stored and accessed in distinct units called records and each record is numbered. The statements and functions that are used with random files are: • Page B-8 OPEN FIELD LSET/RSET PUT CLOSE LOC MKI$ MKS$ MKD$ CVI CVS CVD GET B.3.2.1 Creating A Random File The following program steps are required to create a file. random 1• OPEN the file for random OPEN "R",#1,"FILE",32 access ("R" mode). This example specifies a record length of 32 bytes.If the record length is omitted, the default is 128 bytes. 2. Use the FIELD statement to allocate space in the random buffer for the variables that will be written to the random file. 3. Use LSET to move the data LSET N$=X$ into the random buffer. LSET A$=MKS$(AMT) Numeric values'must be made LSET P$=TEL$ into strings when placed in the buffer. To do this, use the "make" ,functions: MKI$ to make an integer value into a string, MKS$ for a single precision value, and MKD$ for a double precision value. 4. Write the data from the buffer to the disk using the PUT statement. FIELD #1 20 AS N$, 4 AS A$, 8 AS P$ PUT #1,CODE% Look at Program B-4. It takes information that is input, at the terminal and writes it to a random file. Each time the PUT statement is executed, a record is written to the file. The two-digit code that is input in line 30 becomes the record number. PalJe B-9 NOTE Do not use a FIELDed string variable in an INPUT or LET statement. This causes the pointer for that variable to point into string space instead of the random file buffer. 10 OPEN "R"#1,"FILE" 20 FIELD #1,20 AS N$, 4 AS A$, 8 AS P$ 30 INPUT "2-DIGIT CODE"~CODE% 40 INPUT "NAME" ~X$ 50 INPUT "AMOUNT"~AMT 60 INPUT "PHONE"iTEL$:PRINT 70 LSET N$=X$ 80 LSET A$=MKS$(AMT) 90 LSET P$=TEL$ 100 PUT #1,CODE% 110 GOTO 30 PROGRAM B-4 - CREATE A RANDOM FILE B.3.2.2 Access A Random File The following program steps are required to access a file: random 1. OPEN the file in "R" mode. OPEN "R",#1,"FILE",32 2. Use the FIELD statement to allocate space in the random buffer for the variables that will be read from the file. FIELD #1 20 AS N$, 4 AS A$, 8 AS P$ NOTE: In a program that performs both input and output on the same random file, you can often use just one OPEN statement and one FIELD statement. • Page B-10 3. Use the GET statement to move the desired record into the random buffer. GET #1,CODE% 4. The data in the buffer may now be acessed by the program. Numeric values must be converted back to numbers using the "convert" functions: CVI for integers, CVS for single precision values, and CVD for double precision values. PRINT N$ PRINT CVS (A$) Program B-5 accesses the random file "FILE" that was created in Program B-4. By inputting the three-digit code at the terminal, the information associated with that code is read from the file and displayed. 10 20 30 40 50 60 70 80 OPEN "R",#1,"FILE" FIELD #1, 20 AS N$, 4 AS A$, 8 AS p$ INPUT "2-DIGIT CODE";CODE% GET #1, CODE% PRINT N$ PRINT USING "$$###.##";CVS(A$} PRINT P$:PRINT GOTO 30 PROGRAM B-5 - ACCESS A RANDOM FILE The LaC function, with random files, returns the "current record number." The current record number is one plus the last record number that was used in a GET or PUT statement. For example, the statement IF LOC(1}>50 THEN END ends program execution if file#1 is higher than 50. the current record number in Program B-6 is an inventory program that illustrates random file access. In this program, the record number is used as the part number, and it is assumed the inventory will contain no more than 100 different part numbers. Lines 900-960 initialize the data file by writing CHR$(255} as the first character of each record. This is used later (line 270 and line 500) to determine whether an entry already exists for that part number. Lines 130-220 display the different inventory functions that the program perfo~s. When you type in the desired function number, line 230 branches to the appropriate subroutine. Page B-11 PROGRAM B-6 - INVENTORY 120 125 130 135 140 150 160 170 180 220 225 230 240 250 260 270 280 290 300 310 320 330 340 3,50 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 OPEN "R",#1,"INVEN.DAT",39 FIELD#1,1 AS F$,30 AS D$, 2 AS Q$,2 AS R$,4 AS P$ PRINT:PRINT "FUNCTIONS:":PRINT PRINT 1,"INITIALIZE FILE" PRINT2,"CREATE A NEW ENTRY" PRINT 3,"DISPLAY INVENTORY FOR ONE PART" PRINT 4,"ADD TO STOCK" PRINT 5,"SUBTRACT FROM STOCK" PRINT 6,IIDISPLAY ALL ITEMS BELOW REORDER LEVEL II PRINT:PRINT:INPUT"FUNCTION"iFUNCTION IF (FUNCTION<1)OR(FUNCTION>6) THEN PRINT "BAD FUNCTION NUMBERII:GOTO ON FUNCTION GOSUB 900,250,390,480,560,680 GOTO 220 REM BUILD NEW ENTRY GOSUB 840 IF ASC(F$)<>255 THEN INPUT"OVERWRITE"iA$:IF A$<>"Y" THEN RETURN LSET F$=CHR$(O) INPUT "DESCRIPTION"iDESC$ LSET D$=DESC$ INPUT "QUANTITY IN STOCK";Q% LSET Q$=MKI$(Q%) INPUT "REORDER LEVEL";R% LSET R$=MKI$(R%) INPUT "UNIT PRICE" i P LSET P$=MKS$(P) PUT#1,PART% RETURN REM DISPLAY ENTRY GOSUB 840 IF ASC(F$)=255 THEN PRINT "NULL ENTRY":RETURN PRINT USING "PART NUMBER ###";PART% PRINT D$ PRINT USING "QUANTITY ON HAND #####"iCVI(Q$) PRINT USING "REORDER LEVEL #####";CVI(R$) PRINT USING "UNIT PRICE $$##.##";CVS(P$) RETURN • REM ADD TO STOCK GOSUB840 IF ASC(F$)=255 THEN PRINT "NULL ENTRY":RETURN PRINT D$:INPUT "QUANTITY TO ADD "iA% Q%=CVI(Q$)+A% LSET Q$=MKI$(Q%) PUT#1,PART% RETURN REM REMOVE FROM STOCK GOSUB 840 IF ASC(F$)=255 THEN PRINT "NULL ENTRylI:RETURN PRINT D$ INPUT IIQUANTITY TO SUBTRACT"iS% Q%=CVI (Q$) IF (Q%-S%)100) THEN PRINT "BAD PART NUMBER":GOTO 840 ELSE GET#1,PART%:RETURN END REM INITIALIZE INPUT "ARE YOU SURE";B$:IF B$<>"Y" THEN RETURN LSET F$=CHR$(255) FOR I=1 TO 100 PUT#1,I NEXT I RETURN APPENDIX C Assembly Language Subroutines All versions of BASIC-aD have prov~s~ons for interfacing with assembly language subroutines. The USR Function allows assembly language subroutines to be called in the same way BASIC's intrinsic functions are called. NOTE The addresses of the DEINT, GIVABF, MAKINT and FRCINT routines are stored in locations that must be supplied individually for different implementations of BASIC. C.1 MEMORY ALLOCATION Memory space must be set aside for an assembly language subroutine before it can be loaded. During initialization, enter the highest memory location minus the amount of memory needed for the assembly language subroutine(s). BASIC uses all memory available from its starting loc~tion up, so only the topmost locations in memory can be set aside for user subroutines. When an assembly language subroutine is called, the stack pointer is set up for a levels (16 bytes) of stack storage. If more stack space is needed, BASIC's stack can be saved and a new stack set up for use by the assembly language subroutine. BASIC's stack must be restored, however, before returning from the subroutine. • Page C-2 The assembly language subroutine may be loaded into memory by means of the system monitor, or the BASIC POKE statement, or (if the user has the MACRO-SO or FORTRAN-SO package) routines may be assembled with MACRO-SO and loaded using LINK-SO. C.2 USR FUNCTION CALLS - SK BASIC The starting address of the assembly language subroutine must be stored in USRLOC, a two-byte location in memory that is supplied individually with different implementations of BASIC-SO. With SK BASIC, the starting address may be POKEd into USRLOC. Store the low order byte first, followed by the high order byte. The function USR will call the routine whose address is in USRLOC. Initially USRLOC contains the address of ILLFUN, the routine that gives the "Illegal ·function call" error. Therefore, if USR is called without changing the address in USRLOC, an "Illegal function call" error results. The format of a USR function call is USR(argument) where the argument is a numeric expression. To obtain the argument, the assembly language subroutine must call the routine DEINT. DEINT places the argument into the D,E register pair as a 2-byte, 2's complement integer. (If the argument is not in the range -32768 to 32767, an "Illegal function call" error occurs.) To pass the result back from an assembly language subroutine, load the value in register pair [A,B], and call the routine GIVABF. If GIVABF is not called, USR(X) returns X. To return to BASIC, the assembly language subroutine must execute a RET instruction. For example, here is an assembly multiplies the argument by 2: USRSUB: CALL DEINT XCHG DAD H MOV A,H MOV B,L JMP GIVABF language subroutine that iPutarg in D,E iIDove arg to H,L iH,L=H,L+H,L imove result to A,B ipass result back and RETurn Note that valid results will be obtained from this routine for arguments in the range -16384<=x<=163S3. The single instruction JMP GIVABF has the same effect as: Page C-3 CALL GIVABF ~T To return additional values to the program, load memory and read them with the PEEK function. them into There are several methods by which a program may call more than one USR routine. For example, the starting address of each routine may be POKEd into USRLOC prior to each USR call, or the argument to USR could be an index into a table of USR routines. C.3 USR FUNCTION CALLS - EXTENDED AND DISK BASIC In the Extended and Disk versions, the function is format of the USR USR[] (argument) where is fro~ 0 to 9 and the argument is any numeric or string express~on. specifies which USR routine is being called, and corresponds with the digit supplied in the DEF USR statement for that routine. If is omitted, USRO is assumed. The address given in the DEF USR statement determines the starting address of the subroutine. When the USR function call is made, register A contains a value that specifies the type of argument that was given. The value in A may be one of the following: Value in A ~ of Argument 2 Two-byte integer (two's complement) 3 String 4 Single precision floating point number 8 Double precision floating point number If the argument is a number, the [H,L] register pair points to the Floating Point Accumulator (FAC) where the argument is stored. If the argument is an integer: FAC-3 contains the lower 8 bits of the argument and FAC-2 contains the upper 8 bits of the argument. If the argument is a single precision floating point number: FAC-3 contains the lowest 8 bits of mantissa and I Page C-4 FAC-2 contains the middle 8 bits of mantissa and FAC-1 contains the highest 7 bits of mantissa with leading 1 suppressed (implied). Bit 7 is the sign of the number (O=positive, 1=negative). FAC is the exponent minus 128, and the binary point is to the left of the most significant bit of the mantissa. If the argument is a double precision floating point number: FAC-7 through FAC-4 contain four more bytes of mantissa (FAC-7 contains the lowest 8 bits). If the argument is a string, the [D,E] register pair points to 3 bytes called the "string descriptor." Byte 0 of the string descriptor contains the length of the string (0 to 255) • Bytes 1 and 2, respectively, are the lower and upper 8 bits of the string starting address in string space. CAUTION: If the argument is a string literal in the program, the string descriptor will point to program text. Be careful not to alter or destroy your program this way. To avoid unpredictable results, add +"" to the string literal in the program. Example: A$ = "BASIC-80"+"" This will copy the string literal into string space and will prevent alteration of program text during a subroutine call. Usually, the value returned by a USR function is the same type (integer, string, single precision or double precision) as the argument that was passed to it. However, calling the MAKINT routine returns the integer in [H,L] as the value of the function, forcing the value returned by the function to be integer. To execute MAKINT, use the following sequence to return from the subroutine: PUSH LHLD XTHL H xxx RET isave value to be returned iget address of MAKINT routine isave return on stack and iget back [H,L] ireturn Also, the argument of the function, regardless of its type, may be forced to an integer by callinq the FRCINT routine to get the integer value of the argument in [H,L]. Execute the following routine: LXI H PUSH LHLD PCHL SUB1: H xxx ..... iget ,address of subroutine icontinuation iplace on stack iget address of FRCINT Page C-5 C.4 CALL STATEMENT Extended and Disk BASIC-80 user function calls may also be made with the CALL statement. The calling sequence used is the same as that in Microsoft's FORTRAN, COBOL and BASIC compilers. A CALL statement with no arguments generates a simple "CALL" instruction. The corresponding subroutine should return via a simple "RET." (CALL and RET are 8080 opcodes - see an 8080 reference manual for details.) A subroutine CALL with arguments results in a somewhat more complex calling sequence. For each argument in the CALL argument list, a parameter is passed to the subroutine. That parameter is the address of the low byte of the argument. Therefore, parameters always occupy two bytes each, regardless of type. The method of passing the parameters depends upon the number of parameters to pass: 1. If the number of parameters is less than or equal to 3, they are passed in the registers. Parameter 1 will be in HL, 2 in DE (if present), and 3 in BC (if pres·ent). 2. If the number of parameters is greater than 3, they are passed as follows: 1. Parameter 1 in HL. 2. Parameter 2 in DE. 3. Parameters 3 through n in a contiguous data block. BC will point to the low byte of this data block (i.e., to the low byte of parameter 3) • Note that, with this scheme, the subroutine must know how parameters to expect in order to find them. many Conversely, the calling program is responsible for passing the correct number of parameters. There are no checks for correct number or type of parameters. If the subroutine expects more than 3 parameters, and needs to transfer them to a local data area, there is a system subroutine which will perform this transfer. This argument transfer routine is named $AT (located in the FORTRAN library, FORLIB.REL), and is called with HL pointing to the local data area, BC pointing to the third parameter, and A containing the number of arguments to transfer (i.e., the total number of arguments minus 2). The subroutine is • Page C-6 responsible for saving the first two parameters before calling $AT. For example, if a subroutine expects 5 parameters, it should look like: SUBR: SHLD XCHG SHLD MVI LXI CALL P1 ~SAVE P2 A,3 H,P3 $AT ;SAVE PARAMETER 2 ~NOo OF PARAMETERS LEFT ;POINTER TO LOCAL AREA ~TRANSFER THE OTHER 3 PARAMETERS PARAMETER 1 • • [Body of subroutine] RET DS DS DS P1: P2: P3: ;RETURN TO ;SPACE FOR ~SPACE FOR iSPACE FOR 2 2 6 CALLER PARAMETER 1 PARAMETER 2 PARAMETERS 3-5 A listing of the argument transfer routine AT$ follows. 00100 00200 00300 00400 00500 00600 00700 00800 00900 01000 01100 01200 01300 01400 01500 01600 01700 01800 01900 02000 02100 02200 02300 ., ; [B,C] i [H,L] ~ [A] $AT: AT1 : ARGUMENT TRANSFER POINTS TO 3RD PARAM. POINTS TO LOCAL STORAGE FOR PARAM 3 CONTAINS THE # OF PARAMS TO XFER(TOTAL-2) ENTRY XCHG MOV MOV MOV INX MOV INX XCHG MOV INX MOV INX XCHG DCR JNZ RET $AT ;SAVE [H,L] IN [D,E] H,B L,C C,M H B,M H M,C H M,B H A AT1 ~ [H,L] = PTR TO PARAMS ; [B,C] = PARAM ADR ~ [H,L] POINTS TO LOCAL STORAGE iSTORE PARAM IN LOCAL AREA iSINCE GOING BACK TO AT1 iTRANSFERRED ALL PARAMS? iNO, COpy MORE ;YES, RETURN Page C-7 When accessing parameters in a subroutine, don't forget that they are pointers to the actual arguments passed. NOTE It is entirely up to the programmer to see to it that the arguments in the calling program match in number, ~, and length with the parameters expected by the subroutine. This applies to BASIC subroutines, as well as those written in assembly language. C.s INTERRUPTS Assembly language subroutines can be written to handle interrupts. All interrupt handling routines should save the stack, register A-L and the PSW. Interrupts should always be re-enabled before returning from the subroutine, since an interrupt automatically disables all further interrupts once it is received. The user should be aware of which interrupt vectors are free in the particular version of BASIC that'has been supplied o Note to CP/M users: in CP/M BASIC, all interrupt vectors are free.} • APPENDIX D BASIC-BO with the CP/M Operating System The CP/M version of BASIC-BO (MBASIC) is supplied on a standard size 3740 single density diskette. The name of the file is MBASIC.COM. (A 2BK or larger CP/M system is recommended. ) To run MBASIC, bring up CP/M and type the following: A>MBASIC The system will reply: xxxx Bytes Free BASIC-BO Version 5.0 (CP/M Version) Copyright 1978 (C) by Microsoft Created: dd-rnrnrn-yy Ok MBASIC is the same as Disk BASIC-80 as manual, with the following exceptions: D.1 described in this INITIALIZATION The initialization dialog has been replaced by a set of options which are placed after the MBASIC command to CP/M. The format of the command line is: • A>MBASIC [] [/F:] [/M: If is present, MBASIC proceeds as if a RUN command were typed after initialization is complete. A default extension of .BAS is used if none is supplied and the filename is less than 9 characters long. This allows BASIC programs to be executed in batch mode using the SUBMIT facility of CP/M. Such programs should include a SYSTEM statement (see below) to return to CP/M when they have finished, allowing the next program in the batch stream to execute. Page D-2 If /F: is present, it sets the number of disk data files that may be open at anyone time during the execution of a BASIC program. Each file data block allocated in this fashion requires 166 bytes of memory. If the /F option is omitted, the number of files defaults to 3. The /M: option sets the highest memory location that will be used by MBASIC. In some cases it is desirable to set the amount of memory well below the CP/M's FDOS to reserve space for assembly language subroutines. In all cases, should be below the start of FDOS (whose address is contained in locations 6 and 7). If the /M option is omitted, all memory up to the start of FDOS is used. NOTE Both and are numbers that may be either decimal, octal (preceded by &0) or hexadecimal (preceded by &H). Examples: A>MBASIC PAYROLL. BAS Use all memory and 3 files, load and execute PAYROLL. BAS. A>MBASIC INVENT/F:6 Use all memory and 6 files, load and execute INVENT.BAS. A>MBASIC /M:32768 Use first 32K of memory and 3 files. A>MBASIC DATACK/F:2/M:&H9000 Use first 36K of memory, 2 files, and execute DATACK.BAS. D.2 DISK FILES Disk filenames follow the normal CP/M nam~ng conventions. All filenames may include A: or B: as the first two characters to specify a disk drive, otherwise the currently selected drive is assumed. A default extension of .BAS is used on LOAD, SAVE, MERGE and RUN commands if no "." appears in the filename and the filename is less than 9 characters long. Page D-3 D.3 FILES COMMAND Format: FILES [l Purpose: To print the names current disk. Remarks: If is omitted, all the files on the currently selected drive will be listed. is a string formula which may contain question marks (?) to match any character in the filename or extension. An asterisk (*) as the first character of the filename or extension will match any file or any extension. Examples: FILES FILES II*.BASII FILES IIB:*.*II FILES IITEST?BAS II of files residing on the D.4 ·RESET COMMAND Format: RESET Purpose: To close all disk files and write the directory information to a diskette before it is removed from a disk drive. Remarks: Always execute a RESET command before removing a diskette from a disk drive. Otherwise, when the diskette is used again, it will not have the current directory information written on the directory track. RESET closes all open files on all drives and writes the directory track to every diskette with open files. • Page D-4 D.S LOF FUNCTION Format: LOF(-LOF(1) THEN PRINT "INVALID ENTRY" D.6 EOF With CP/M, the EOF function may be used with random files. If a GET is done past the end of file, EOF will return -1. This may be used to find the size of a file using a binary search or other algorithm. D.7 MISCELLANEOUS 1. CSAVE and CLOAD are not implemented. 2. To return to CP/M, use the SYSTEM command or statement. SYSTEM closes all files and then performs a CP/M warm start. Control-C always returns to MBASIC, not to CP/M. 3. FRCINT is at 103 hex and MAKINT is at 105 hex. (Add 1000 hex for ADDS versions, 4000 for SBC CP/M versions.) APPENDIX E BASIC-80 with the ISIS-II Operating System With ISIS-II, BASIC-80 is the same as manual, with the following exceptions: E.1 described in this INITIALIZATION The initialization dialog has been replaced by a set options which are placed after the MBASIC command ISIS-II. The format of the command line is: of to -MBASIC [] [/F:] [/M: is present, BASIC proceeds as if a RUN command were typed after initialization is complete. A default extension of .BAS is used if none is supplied. If /F: is present, it sets the number of disk data files that may be open at anyone time during the execution of a BASIC program. The maximum is six and the default is three. The /M: option sets the' highest memory location that will be used by BASIC. Use this option to reserve memory locations above BASIC for assembly language subroutines. At initializ~tion, the system will reply: xxxx Bytes Free BASIC-80 Version x.x (ISIS-II Version) Copyright 1978 (C) by Microsoft • Page E-2 E.2 LINE PRINTER I/O To send output to the printer during execution of a BASIC program, open the line printer as if it were a disk file: 50 N=4 100 OPEN "O",N,":LP:" 120 PRINT #N,A,B/C Since BASIC buffers disk I/O, you may want to force out by CLOSEing the printer channel. buffers To LIST a program on the line printer, use: SAVE" :LP:",A E.3 ATTRIB STATEMENT In ISIS-II BASIC-80, the ATTRIB statement attributes. The format of the statement is: sets file ATTRIB , The attribute string consists of F, W, S or I for the attribute, followed by a 1 to set the attribute or a 0 to reset. Examples: ATTRIB ATTRIB ATTRIB ATTRIB E.4 "INFO.DAT", "W1" "GHOST.BAS","I1" ":F1:SYSFIL","W1F1S111" A$,B$ MISCELLANEOUS Note these other differences for ISIS-II BASIC: 1. MAKINT is located at located at xxxxx hex. 2. There is no Filenames do and MERGEs. xxxxx hex, and GIVINT is FILES command in ISIS-II BASIC. not default to .BAS on SAVEs, LOADs, APPENDIX F BASIC-80 with the TEKDOS Operating System The operation of BASIC-80 with the TEKDOS operating system is the same as described in this manual with the following exceptions: 1. At initialization, BASIC asks MEMORY SIZE? If you respond with a carriage return, BASIC will use all available memory. If you respond with a memory location (in decimal), BASIC will use memory only up to that location. This lets you reserve space at the top of memory for assembly language subroutines. 2. The number of disk files that may be time defaults to 5. 3. LPRINT and LLIST are not implemented. open a file to the printer. 4. TEKDOS does not support random disk I/O. corresponding BASIC-80 statements (PUT, OPEN"R", etc.) are inoperable under TEKDOS. 5. Control-C works only once due to a bug in TEKDOS. If you interrupt a running program or a LIST command with Control-C, BASIC appears to be in "single statement" mode. To clear this condition, exit BASIC with a SYSTEM command and re-enter BASIC with an XEQ BASIC. Avoid using the AUTO command, since it requires a Control-C to return to BASIC command level. open at one Instead, The GET, • APPENDIX G BASIC-80 with the INTEL SBC and MDS Systems G.1 INITIALIZATION The paper tape of BASIC-80 supplied for SBC and MDS systems is in Intel-compatible hex format. Use the monitor's R command to load the tape, then execute the G command· to start BASIC-80. The command is: .G4000 BASIC will respond: Memory size? If you want BASIC to use all available RAM, just type a carriage return. If you want to reserve space at the top of memory for machine language subroutines, enter the highest memory address (in decimal) that BASIC may use. Terminal Width? (8K versions only) Respond with the number of characters for the output line width in PRINT statements. The default is 72 characters. (Extended versions use WIDTH command.) Want SIN-COS-TAN-ATN? Type Y to retain these functions, type N to delete them, type A to delete ATN only. G.2 or SUBROUTINE ADDRESSES In the 8K version of SBC and MDS BASIC-80, DEINT is located at 0043 hex and GIVABF is located at 0045 hex. USRLOC is at xxx x hex. In the Extended version, FRCINT is located at xxx x hex, and MAKINT is located at xxxx hex. • Page G-2 G.3 LLIST AND LLPRINT LLIST and LPRINT are not implemented. APPENDIX H Standalone Disk BASIC Standalone Disk BASIC is an easily implemented, self-contained version of BASIC-80 that runs on almost any 8080 or Z80 based disk hardware without an operating system. Standalone Disk BASIC incorporates several unique disk I/O methods that make faster and more efficient use of disk access and storage. Random access with Standalone BASIC is faster than other disk operating systems because the file allocation table is kept in memory and updated periodically on the diskette. Therefore, there is no need for index blocks for random files, and there is no need to distinguish between random and sequential files. Because there are no index blocks, there is no large per-file-overhead either in memory or on disk. Binary SAVEs and LOADs are also faster because they are optimized by cluster, i.e., an entire cluster is read or written at one time, instead of a single sector. To initialize Standalone Disk BASIC, insert the BASIC diskette and power up the system. In one- or two-drive systems, BASIC asks if there are two drives. In systems with more than two drives, BASIC asks for the number of drives. BASIC then asks how many files, i.e., how many disk files may be open at one time. Answer with a number from a to 15, or, for a default of 1 file per drive, just enter a carriage return. The operation of Standalone Disk BASIC is the same as Disk BASIC-80 as described in this manual, with the following exceptions: H.1 FILENAMES Disk filenames are six characters with an optional three-character extension that is preceded by a decimal point. If a decimal point appears in a filename after fewer than six characters, the name is blank-filled to six characters and the next three characters are the extension. I Page H-2 If the filename is six or fewer characters with no decimal point, there is no extension. If the filename is more than six characters, BASIC inserts a decimal point after the sixth character and uses the next three characters as an extension. (Any additional characters are ignored.) H.2 DISK FILES The FILES command prints the names of the files residing on a disk. The format is: [L]FILES[] LFILES outputs to the line printer. In addition to the filename, the size of each file, in clusters, is output. A cluster is the minimum unit of allocation for a file -- it is one-half of a track. Filenames of files created with OPEN or ASCII SAVE are listed with a space between the name and extension. Filenames of binary files created with binary SAVE are listed with a decimal point between the name and extension. The protected file option with SAVE is not supported in Standalone Disk BASIC. H.3 FPOS The FPOS function: FPOS«file number» is the same as BASIC-80's LOC function except it returns the number of the physical sector where is located. (BASIC-80's LOC function and CP/M BASIC-80's LOF function are also implemented.) H.4 DSKI$/DSKO$ The DSKO$ statement: DSKO$,,, writes the string on the specified sector. The maximum length for the string is 128 characters. A string of fewer than 128 characters is zero-filled at the end to 128 characters. DSKI$ is the complementary function to the DSKO$ statement. DSKI$ returns the contents of a sector to a string variable name. The format is: DSKI$«drive>,,[, ••• ]] MOUNT with no arguments mounts all drives. When a diskette is mounted, BASIC reads the File Allocation Table (see Section H.11.2) from the diskette into memory and checks it for errors. If there are no errors, the disk is mounted. If an error is found, BASIC reads one or both of the back-up allocation tables from the diskette in an attempt to mount the disk; and a warning message, "x copies of allocation bad on drive y", is issued. x is 1 or 2 and y is the drive number. When a warning occurs, it is a good idea to make a new copy of the diskette. If all copies of the allocation table are bad or if a free entry is encountered in the file chain, a fatal error--"Bad allocation table"--is given and the diskette will not be mounted. While a disk is mounted, allocation table to the check for errors unless the set for that drive (see SET H.G BASIC occasionally writes the directory track, but it does not read after write attribute is statement). REMOVE COMMAND REMOVE is the complement of MOUNT. Before a diskette can be taken out of the drive, a REMOVE command must be executed. The format of the command is: REMOVE[[, ••• ]] REMOVE writes three copies of the current allocation table to disk and follows the same error-check procedure as HOUNT. MOUNT and REMOVE replace the RESET command that is in BASIC-BO. NOTE ALWAYS do a REMOVE before taking a diskette out of a drive. If you do not, the diskette you took out will not have an updated and checked allocation table, and the data on the next diskette inserted will be destroyed when the wrong allocation table is written to the directory track. • Page H-4 H.7 SET STATEMENT The SET statement determines the attributes of the currently mounted disk drive, a currently open file, or a file that need not be open. The format of the SET statement is: SET I # I , is a string of characters that determines what attributes are set. Any characters other than the following are ignored: R P E Read after write Write protect EBCDIC conversion (if available) Attributes are assigned in the following order: 1. MOUNT command When a MOUNT is done for a particular drive, the first byte of the information sector on the diskette (track 35, sector 20 for floppy; track 18, sector 13 for minifloppy) contains the attributes for the disk. (octal values: R=100, P=20, E=40) 2. SET, Statement This statement sets the current attributes for the The disk, in memory, while it is mounted. attributes are not permanently recorded and apply only while the disk is mounted. 3. When a file is created, the permanent file attributes recorded on the disk will be the same as the current drive attributes. 4. SET, Statement This statement changes the permanent file attributes that are stored in the directory entry for that file. It does not affect the drive attributes. 5. When an existing file is OPENed, the attributes of the file number are those of the directory entry. 6. SET#, Statement This statement changes the attributes for that file number but does not change the directory entry. Examples: SET 1,"R" Force read after write output to drive 1 checking SET #1,"R" Force read after write for all on output all to Page H-5 .t:!!,_ .I....J....J..t::: 1 while it is SET #1,"P" Give write protect error if attempted to file 1 SET "TEST", "p" Protect TEST modification SET 1,"" Turn off all attributes for drive 1 H.8 from any output is deletion and ATTR$ FUNCTION ATTR$ returns a string of the current attributes for a drive, currently open file, or file that need not be open. The format of ATTR$ is: ATTR$«drive> # [FOR ] AS [#] where is one of the following: • INPUT OUTPUT APPEND IBM USR The mode determines only the initial positioning within the file and the actions to be taken if the file does not exist. The action taken in each mode is: INPUT The initial position is at the start of the file. An error is returned if the file is not found. OUTPUT The initial position is at the start of the A new file is always created. APPEND The initial position is at the end of the file. An error is returned if the file is not found. file. Page H-6 IBM The initial position is after the last DSKI$ or DSKO$. The file is then set up to write contiguous. No file search is done. (The same effect may be achieved in many cases by altering the FORMAT program. See Section H.11.2.1.) USR Same as IBM mode except, instead of write contiguous, USRO is called and returns the next track/sector number. The USRO routine should read the current track/sector from B,C and return the next location in B,C. When USRO is first called, B,C contains the track and sector number of the previous DSKI$ or DSKO$. If the FOR clause is omitted, the initial position is at the start of the file. If the file is not found, it is created. Note that variable length records are not supported in Standalone Disk BASIC. All records are 128 bytes in length. USR mode is especially useful for creating diskettes that require sector mapping. This is the case if the diskette is intended for use on another system, for example, a CP/M system. Instead of opening the file for write contiguous (IBM mode), the USRO routine may be used to map the sectors logically, as required by the other system. When a file is OPENed FOR APPEND, the file mode is set to APPEND and the record number is set to the last record of the file. The program may subsequently execute disk I/O statements that move the pointer elsewhere in the file. When the last record is read, the file mode is reset to FILE and the pointer is left at the end of the file. Then, if you wish to append another record, execute: GET#n,LOF(n) This positions the pointer preparation for appending. at the end of the file in At anyone time, it is possible to have a particular filename OPEN under more than one file number. This allows different attributes to be used for different purposes. Or, for program clarity, you may wish to use different file numbers for different methods of access. Each file number has a different buffer, so changes made under one £ile are not accessible to (or affected by) the other numbers until that record is written (e.g., GET#n,LOC(n)). Page H-7 H.10 DISK I/O A GET or PUT (i.e., random access) cannot be done on a file that is OPEN FOR IBM or OPEN FOR USR. Otherwise, GET/PUT may be executed along with PRINT#/INPUT# on the same file, which makes midfile updating possible. The statement fqrmats for GET, PUT, PRINT#, and INPUT# are the same as those in BASIC-BO. The action of each statement in Standalone BASIC is as follows: GET If the "buffer changed" flag is set, write the buffer to disk. Then execute the GET (read the record into the buffer), and reset the position for sequential I/O to the beginning of the buffer. PUT Execute the PUT (write the buffer to the specified record number), and set the "sequential I/O is illegal" flag until a GET is done. INPUT# If the buffer is empty, write it if the "Buffer changed" flag is sei, then read the next buffer. PRINT# Set the "buffer changed" flag. If the buffer is full, write it to disk. Then, if end of file has not been reached, read the next buffer. H.10.1 FileFormat For a single density floppy, each file requires 137 bytes: 9 bytes plus the 12B-byte buffer. Because the File Allocation Table keeps random access information for all files, random and sequential files are identical on the disk. The only distinction is that sequential files have a Control-Z (32 octal) as the last character of the last sector. When this sector is read, it is scanned from the end for a non-zero byte. If this byte is Control-Z, the size of the buffer is set so that a PRINT overwrites this byte. If the byte is not Control-Z, the size is set so the last null seen is overwritten. Any sequential file can be copied in random mode and remain identical. If a file is written to disk in random mode (i.e., with PUT instead of PRINT) and then read in sequential mode, it will still have proper end of file detection. • Page H-8 H.11 DISK ALLOCATION INFORMATION With Standalone Disk BASIC, storage space on the diskette is allocated beginning with ~he cluster closest to the current position of the head. (This method is optimized for writing. Custom versions can be optimized for reading.) Disk allocation information is placed in memory when the disk is mounted and is periodically written back to the disk. Because this allocation information is kept in memory, there is no need for index blocks for random files, and there is no need to distinguish between random and sequential files. H.11.1 Directory Format On the diskette, each sector of the directory track contains eight file entries. Each file entry is 16 bytes long and formatted as follows: Bytes 0-8 9 10 11-15 Usage Filename, 1 to 9 characters. The first character may not be 0 or 255. Attribute: Octal 200 Binary file 100 Force read after write check 40 EBCDIC file 20 Write protected file Excluding 200, these bits are the same for the disk attribute byte which is the first byte of the information sector. Pointer into File Allocation Table to the first cluster of the file's cluster chain. Reserved for future expansion. If the first byte of a filename is zero, that file entry slot is free. If the first byte is 255, that slot is the last occupied slot in the directory, i.e., this flags the end of the directory. H.11.2 Drive Information For each disk drive that is information is kept in memory: MOUNTed, the following Page H-9 1. Attributes Drive attributes are read from the information sector when the drive is mounted and may be changed with the SET statement. Current attributes may be examined with the ATTR$ function. 2. Track Number This is the current track while the disk is mounted. Otherwise, track number contains 255 as a flag that the disk is not mounted. 3. Modification Counter This counter is incremented whenever an entry in the File Allocation Table is changed. After a given number of changes has been made, the File Allocation Table is written to disk. 4. Number of Free Clusters This is calculated when the drive is mounted, and updated whenever a file is deleted or a cluster is allocated. 5. File Allocation Table The File Allocation Table has a one-byte entry for every cluster allocated on the disk. If the cluster is free, this entry is 255. If the cluster is reserved, this entry is 254. If the cluster is the last cluster of the file, this entry is 300 (octal) plus the number of sectors from this cluster that were used. Otherwise, the entry is a pointer to the next cluster of the file. The File Allocation Table is read into memory when the drive is mounted, and updated: 1. When a file is deleted 2. When a file is closed 3. When modifications to the table total twice the number of sectors in a cluster (this can be changed in custom versions) 4. When modifications to the table have been made the and the disk head is on (or passes) directory track. • Page H-10 H.11.2.1 FORMAT Program - Before mounting a drive with a new diskette, run BASIC's FORMAT program to initialize the directory (set all bytes to 255), set the information sector to 0, and set all the File Allocation Table entries (except the directory track entry (254» to "free" (255). The FORMAT program is: 10 20 30 40 50 60 70 CLEAR 1500 A$=STRING$(255,128) B$=STRING$(35*2,255)+STRING$(2,254)+STRING$(56,255) FOR S=1 TO 19:DSKO$ 1,35,5,A$:NEXT FOR S=21 TO 25 STEP 2:DSKO$ 1,35,S,B$ DKSO$ 1,35,S+1,A$:NEXT DSKO$ 1,39,20,CHR$(0) After running FORMAT and MOUNTing the drive, files will be allocated as usual, i.e., on either side of the directory track. The FORMAT program may be altered to pre-allocate selected files. For instance, you may wish to use the FORMAT program to pre-allocate files contiguously (as they would be allocated in IBM mode). Then IBM and BASIC files may both exist on the diskette. The altered FORMAT program must also write the name of the filets) to the directory track (i.e., files1-8 in sector 1, files 9-16 in sector 2, etc.), so BASIC knows where the files start. H.11.3 File Block Each file on the disk has a file following information: 1. block that contains the File Mode (byte 0) This is the first byte (byte 0) of the file block, and its location may be read with VARPTR(#filenurnber). The location of any other byte in the file block is relative to the file mode byte. The file mode byte is one of the following: (octal) 1 2 4 10 20 40 100 200 Input only Output only File mode Append mode Delete file IBM mode Special format (USR) Binary save Page H-11 NOTE It iz not rsco~~ended that the user attempt to modify the next four bytes of the File Allocation Table. Many unforeseen complications may result. 2. Pointer to the File Allocation Table entry for first cluster allocated to the file (+1) the 30 Pointer to the File Allocation Table entry for last 9luster accessed (+2) the 40 Last sector accessed (+3) 50 Disk number of file (+4) 6. The size of the last buffer read (+5). This is 128 unless the last sector of the file is not full (i.e., Control-Z)0 7. The current position in the buffer (+6). This is the offset within the buffer for the next print or input. 8. File flag (+7), is one.of the following: Octal 100 Read after write check 40 Read/Write EBCDIC, not ASCII (Not available in all versions.) 20 File write protected 10 Buffer changed by PRINT 4 PUT has been done. PRINT/INPUT are errors until a GET is done. (See Section H.10.) 2 Flags buffer is empty 9. Terminal position for TAB PRINT statements (+8) 100 H.12 Beginning of length sector function buffer (+9), and comma in 128 bytes in ADVANCED USES OF FILE BUFFERS 1• Information may be passed from one program to another by FIELDing it to an unopened file number (not *0). The FIELD buffer is not cleared as long as the file is not OPENed. • Page H-12 2. The FIELDed buffer for an unopened file can also be used to format strings. For example, an aO-character string could be placed into a FIELDed buffer with LSET. The strings could then be accessed as four 20-character strings using their FIELDed variable names. For example: 100 200 300 400 500 FIELD#1, ao AS A$ FIELD#1, 20 AS A1$, 20 AS A2$, 20 AS A3$, 20 AS A4$ LINE INPUT "CUSTOHER INFORMATION: ";B$ LSET A$=B$ PRINT "NAME ";A1$;"SSN: ";A2$ 3. FIELD#O may be used as a temporary buffer, but note that this buffer is cleared after each of the following commands: FILES, LOAD, SAVE, HERGE, RUN, DSKO$, MOUNT, OPEN. 4. The effect of PRINT [USING] # into a string may be achieved by printing to a FIELDed buffer and then accessing it without reopening the file. To assure that this temporary buffer is not written to the disk, return the pointer to the beginning of the buffer and reset the "buffer changed" flag as follows: 10 OPEN "D" FOR IBM AS 1:REM THIS DOESN'T USE SPACE 20 PRINT USING#1 ••• 30 P=PEEK(6+VARPTR(#1» : REM OPTIONAL, TO GET LENGTH OF PRINT USING 40 FIELD#1 ••• AS •.• 50 Y=7+VARPTR(#11 60 POKE~PEEK(Y AND &360) :REM RESET BUFFER CHANGED FLAG 70 POKE6+VARPTR,0:REM CLEAR POSITION IN BUFFER Page H-13 H.13 STANDALONE BASIC DISK ERRORS 50 51 52 53 54 55 56 57 59 61 62 63 64 65 66 67 68 69 70 71 72 73 FIELD overflow Internal error Bad file number File not found File already open Disk not mounted Disk I/O error File already exists Disk already mounted Input past end Bad file name Direct statement in file Bad allocation table Bad drive number Bad track/sector File write protected Disk offline Deleted record Rename across disks Sequential after PUT Sequential I/O only File not OPEN • APPENDIX I converting Programs to BASIc-aD If you have programs written in a BASIC other than BASIC-aD, some minor adjustments may be necessary before running them with BASIC-aD. Here are some specific things to look for when converting BASIC programs. I.1 STRING DIMENSIONS Delete all statements that are used to declare the length of strings. A statement such as DIM A$(I,J), which dimensions a string array for J elements of length I, should be converted to the BASIC-aD statement DIM A$ (J) • Some BASICs use a comma or ampersand for string concatenation. Each of these must be changed to a plus sign, which is the operator for BASIC-SO string concatenation. In BASIC-SO, the MID$, RIGHT$, and LEFT$ functions are used to take substrings of strings. Forms such as A$(I) to access the Ith character in A$, or A$(I,J) to take a substring of A$ from position I to position J, must be changed as follows: BASIC-SO X$=A$(I) X$=A$(I,J) X$=MID$(A$,I,1) X$=MID$(A$,I,J-I+1) If the substring reference is on the left side of an assignment and X$ is used to replace characters in A$, convert as follows: Other BASIC A$(I)=X$ A$(I,J)=X$ SK BASIC-SO A$=LEFT$ (A$,I-1)+X$+MID$(A$,I+1) A$=LEFT$(A$,I-1) iX$iMID$(A$,J+1) Ext. and Disk BASIC-80 A$(I)=X$ A$(I,J)=X$ MID$(A$,1,1)=X$ MID$(A$,I,J-I+1)=X$ II Page I-2 I.2 MULTIPLE ASSIGNMENTS Some BASICs allow statements of the form: 10 LET B=C=O to set Band C equal to zero. BASIC-80 would interpret the second equal sign as a logical operator and set B equal to -1 if C equaled O. Instead, convert this statement to two assignment statements: 10 C=O:B=O I.3 MULTIPLE STATEMENTS Some BASICs use a backs I ash ( 1 to separate multiple statements on a line. With BASIC-80, be sure all statements on a line are separated by a colon (:). I.4 MAT FUNCTIONS Programs using the MAT functions available in some BASICs rewritten using FOR ••• NEXT loops to execute properly •. must be APPENDIX J Summary of Error Codes and Error Messages Code Number Message BS 9 Subscript out of An array element subscript that the array, or subscripts. range is referenced either with a is outside the dimensions of with the wrong number of CN 17 Can't continue An attempt is made that: to continue 1. has halted due to an error, 2. has been modified execution, or 3. does not exist. during a a program break in DD 10 Redimensioned array Two DIM statements are given for the same array, or a DIM statement is given for an array· after the default dimension of 10 has been established for that array. FC 5 Illegal function call A parameter that is out of range is passed to a math or string function. An FC error may also occur as the result of: 1• a negative subscript 2. a negative or zero argument with LOG 3. a negative argument to SQR 4. a negative mantissa exponent or unreasonably with a large non-integer • Page J-2 ID 12 5. a call to a USR function for which the starting address has not yet been given 6. an improper argument to r.1ID$, LEFT$, RIGHT$, INP, OUT, WAIT, PEEK, POKE, TAB, SPC, STRING$, SPACE$, INSTR, or ON ••• GOTO. Illegal direct statement that is illegal in di~ect mode is entered as a direct mode command. A NF 1 NEXT'without FOR A variable in a NEXT statement correspond to any previously unmatched FOR statement variable. does not executed, aD 4 Out of data A READ statement is executed when there are no DATA statements with unread data remaining in the program. OM 7 Out of memory A program is too large, has too many FOR loops or GOSUBs, too many variables, or expressions tha~ are too complicated. as 14 Out of string space String variables exceed the allocated amount of string space. Use CLEAR to allocate more string space, or decrease the size and number of strings. OV 6 Overflow The result of a calculation is too large to be represented in BASIC-80's number format. If underflow occurs, the result is zero and execution continues without an error. SN 2 Syntax error A line is encountered that contains some incorrect sequence of characters (such as. unmatched parenthesis, misspelled command or statement, incorrect punctuation, etc.). ST 16 String formula too complex A string expression is too long or too complex. The expression should be broken into smaller expressions. TM 13 Type mismatch A string variable name is assigned a numeric value or vice versa; a function that expects a numeric argument is given a string argument or vice versa. Page J-3 RG 3 UF 18 UL 8 /0 11 Return without GOSUB A RETURN statement is encountered for there is no previous, unmatched statement. which GOSUB Undefined user function A USR function is called before the function definition (DEF statement) is given. Undefined line A line reference in a GOTO, IF ••• THEN ••• ELSE or DELETE is nonexistent line. GOSUB, to a Division by zero A division by zero is encountered in an expression, or the operation of involution results in zero being raised to a negative power. Machine infinity with the sign of the numerator is supplied as the result of the division, or positive machine infinity is supplied as the result of the involution, and execution continues. Extended and Disk Versions Only 19 20 No RESUME An error trapping routine is contains no RESUME statement. entered RESUME without error A RESUME statement is encountered before error trapping routine is entered. but an 21 Unprintable error An error message is not available for the This is error condition which exists. usually caused by an ERROR with an undefined error code. 22 Missing operand An expression contains an operand following it. 23 operator Line buffer overflow attempt is made to input a line too many characters. that An 26 29 FOR without NEXT A FOR was encountered NEXT. without WHILE without WEND A WHILE statement does not WEND. have with no has a matching a matching • Page J-4 30 WEND without WHILE A WEND was encountered WHILE. without a matching Disk Errors 50 Field overflow A FIELD statement is attempting to allocate more bytes than were specified for the record length of a random file. 51 Internal error An internal malfunction has occurred in Disk BASIC-80. Report to Microsoft the conditions under which the message appeared. 52 Bad file number A statement or command references a file with a file number that is not OPEN or is out of the range of file numbers specified at initialization. 53 File not found A LOAD, KILL or OPEN statement references a file that does not exist on the current disk. 54 Bad file mode An attempt is made to use PUT, GET, or LOF with a sequential file, to LOAD a random file or to execute an OPEN with a file mode other than I, 0, or R. 55 File already open A sequential output mode OPEN is issued for a or a KILL is file that is already open; given for a file that is open. 57 Disk I/O error An I/O error occurred on a disk I/O operation. It is a fatal error, i.e., the operating system cannot recover from the error. 58 File already exists The filename specified in a NAME statement is identical to a filename already in use on the disk. 61 Disk full All disk storage space is in use. Page J-5 62 Input past end An INPUT statement is exeucted after all the data in the file has been INPUT, or for a null (empty) file. To avoid this error, use the EOF function to detect the end of file. 63 Bad record number In a PUT or GET statement, the record number is either greater than the maximum allowed (32767) or equal to zero. 64 Bad file name illegal form is used for the filename with LOAD, SAVE, KILL, or OPEN (e.g., a filename with too many characters). An 66 67 Direct statement in file A direct statement is encountered while LOADing an ASCII-format file. The LOAD is terminated. Too many files attempt is made to create a new file (using SAVE or OPEN) when all 255 directory entries are full. An • APPENDIX K Mathematical Functions Derived Functions Functions that are not intrinsic to BASIC-SO may be calculated as follows: Function BASIC-80 Equivalent SECANT COSECANT COTANGENT INVERSE SINE INVERSE COSINE INVERSE SECANT SEC(X)=1/COS(X} CSC(X)=1/SIN(X) COT(X)=1/TAN(X) ARCSIN(X)=ATN(X/SQR(-X*X+1)) ARCCOS(X)=-ATN (X/SQR(-X*X+1))+1.5708 INVERSE COSECANT INVERSE COTANGENT HYPERBOLIC SINE HYPERBOLIC COSINE HYPERBOLIC TANGENT HYPERBOLIC SECANT HYPERBOLIC COSECANT HYPERBOLIC COTANGENT INVERSE HYPERBOLIC SINE INVERSE HYPERBOLIC COSINE INVERSE HYPERBOLIC TANGENT INVERSE HYPERBOLIC SECANT INVERSE HYPERBOLIC COSECANT INVERSE HYPERBOLIC COTANGENT ARCSEC(X)=ATN(X/SQR(X~X-1)) +SGN(SGN(X)-1)*1.5708 ARCCSC(X)=ATN(X/SQR(X*X-1)) +(SGN(X)-1)*1.570B ARCCOT(X)=ATN(X)+1.5708 SINH(X)=(EXP(X)-EXP(-X))/2 COSH(X)=(EXP(X)+EXP(-X))/2 TANH (X)=EXP (-X)/EXP(X)+EXP(-X))*2+1 SECH(X)=2/(EXP(X)+EXP(-X)) CSCH(X)=2/(EXP(X)-EXP(-X)) COTH(X)=EXP(-X)/(EXP(X)-EXP(-X))*2+1 ARCSINH(X)=LOG(X+SQR(X*X+1)) ARCCOSH(X)=LOG(X+SQR(X*X-1) ARCTANH (X) =LOG ( (1 +X) / (1-X) ) /2 ARCSECH(X)=LOG«SQR(-X*X+1)+1)/X) ARCCSCH(X)=LOG«SGN(X)*SQR(X*X+1)+1)/X ARCCOTH(X)=LOG«X+1)/(X-1))/2 • APPENDIX L ASCII Character Codes ASCII Code 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 Character NUL SOH STX ETX EaT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESCAPE FS .GS RS US SPACE 11 # $ % & ( ) * ASCII Code 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 Character + 0 / 0 1 2 3 4 5 6 7 8 9 < = > ? @ A B C D E F G H I J K L M N a P Q R S T U ASCII Code 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 Character V W X y Z [ \ ] fI < a b c d e f g h i j k 1 m n 0 P q r s t u v w x Y z { I } DEL APCII codes are in decimal LF=Line Feed, FF=Form Feed, CR=Carriage Return, DEL=Rubout • INDEX ABS • • • • • • • • Addition • • ALL • • • • • • Arctangent • • • • Array variables • • Arrays • • • • • ASC • • • • • ASCII codes • • • • • • • • ASCII format • • • Assembly language subroutines · ATN ATTR$ ATTRIB AUTO • • • • • • • Boolean operators · CALL Carriage return Cassette tape CDBL CHAIN Character set CHR$ • CINT • • CLEAR • • CLOAD • • CLOAD* CLOAD? • CLOSE Command level COMMON Concatenation Constants • • CONT • Control characters Control-A COS • • • • CP/M · · · CSAVE CSAVE* CSNG CVD CVI CVS · DATA · • • 3-2 1-10 2-4, 2-9 3-3 1-7, 2-9, 2-18 1-7,2-7, 2-11 , 2-24 3-2 3-2, 3-4, L-1 2-4, 2-49, 2-77 2-3, 2-16, 2-59, 3-21, 3-23, C-1 • 3-3 H-5 • E-2 1-2, 2-2 1-12 • • • • • • • • • • • • • • • 2-3, C-5 1-3, 2-36, 2-41 to 2-42, 2-83 to 2-85 2-7, 2-11 3-3 2-4, 2-9 • 1-3 3-4 3-4 2-6, A-1 • • • 2-7 2-7 2-7 2-8, B-3, B-8 1-1 2-4, 2-9 1-14 1-4 2-10, 2-41 • 1-4 • 2-22 3-5 2-46, 2-49, 2-76 to 2-77, B-1, D-1, H-2 2-11 2-11 3-5 3-6, B-8 3-6, B-8 3-6, B-8 0 2-12, 2-74 • DEF FN • • • • • • DEF USR • • • • DEFDBL • • • • • DEFINT. • • DEFSNG • • • • • DEFSTR • • • • • DEINT • • • • DELETE • • • • • • DIM • • • • • • • Direct mode • Division. ••• Double precision • DSKI$ • • • • • • DSKO$ • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • o • • • • • • • • • 2-13 2-16, 3-21 1-7, 2-15 1-7, 2-15 1-7, 2-15 1-7, 2-15 C-1, G-1 1-2, 2-4, 2-17 2-18 1-1, 2-34, 2-54 1-10 1-5, 2-15, 2-60, 3-3, A-1 H..;2 H-2 EDIT • • • Edit mode END • • • EOF • • • ERASE • • • • • • • • • • • 1-2, 2-19 • • • • • • • • • • 1-4, 2-19 • • • • • • • • • 2-8, 2-10, 2-23, 2-32 • • • • • • • • 3-6, B-3, B-5, 0-4 2-24 • • • • • • • ERL • • • • • • 2-25 • • • • ERR • • • • • • 2-25 • • ERROR • • • • • • • • 2-26 Error codes • • 1-15, 2-25 to 2-26, J-1 • • • Error messages • • • • 1-15, J-1 Error trapping • • • • • 2-25 to 2-26, 2-54, 2-75, B-7 Escape • • • • • • • • • • 1-3, 2-19 EXP • • • • • • • • • 3-7 Exponentiation • • • • • • • • 1-10 to 1-11, 3-7 Expressions • • • • • • • • • 1-9/ FIELD • • • • • FILES • FIX •••• FOR ••• NEXT • FORMAT program • ••• • FPOS FRCINT •••• FRE •• • Functions • • • • • • • • • • • • • • • • • • • • • • • • • • • • GET • • • • • • • • • • • • • 2-28, B-8, H-11 •. GIVABF • • • • • • • GIVINT • • • • • GOSUB • • • • • • • • GOTO • • • • • • • • HEX$ • Hexadecimal • • • • • • • • • • • • • • • • • • 0-3, H-2 3-7 2-29, A-1 H-10 H-2 C-1, C-4, 0-4, G-1 3-8 1-14, 2-13, 3-1, K-1 • • 2-28, 2-31, B-8, D-4,A-3 H-7 • • • C-1 to C-2, G-1 • • • E-2 • • 2-32 • • • 2-32 to 2-33 • • • • • • 3-8 • • • • • • • 1-5, 3-8 IF ••• GOTO • • • • • • • 2-34 IF ••• THEN •• 2-25, 2-34 • • • IF ••• THEN ••• ELSE • • • • • • 2-34 Indirect mode • • • • o • • • 1-1 INP • 3-9 • INPUT 2-10, 2-28, 2-36, A-2, A-3, B-9 • • • • • • • • • • INPUT$ INPUT# • • • • • • • • • • • 3-9 • • • • • • • 2-38, A-3, B-3, H-7 • INSTR • • • INT • • • • • • • Integer. • •• Integer division • INTEL • • • • • • Interrupts • • ISIS-II • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 3-10 • • 3-7, 3-10 3-4, 3-7, 3-10 • • 1-10 • • G-1 • • C-7 2-76, E-1 • • KILL • • • • • • • • • • • • 2-39, B-2 LEFT$ • • LEN • • • LET • • LFILES • Line feed • • • • • LINE INPUT LINE INPUT# • • 3-11 • • 3-11 • 2-28, 2-40, B-9 • • H-2 • • 1-2,2-36,2-41 to 2-42, 2-84 to 2-85 • • • • • • • • • 2-41 • • • • • • • • 2-42, A-3, B-3 • • • • • • • • • • • • • • • • • • • • • • • • • • • • • Line numbers • • • • • • • • • 1-1 to 1-2, 2-2, 2-73 Line printer • • • • • • • 2-45, 2-47, 2-83, 3-13, A-2, E-2 Lines • • • • • • • • • • • 1-1 LIST • • • •.• • • • • • • • • 1-2, 2-43 LLIST • • • • • • • • • • • • 2-45, F-1, G-2 LOAD • • • • • • • • • • • • • 2-46, 2-77, B-1 LOC • • • • • • • • • • 3-12, B-3, B-5, B-8, H-2 LOF ••••• • • • D-4, H-2 3-12 LOG ••••• • • • • • Logical operators 1-12 Loops • • • • • • • • • • 2-29, 2-82 LPOS • • • • • • • • • • • • 2-83, 3-13 LPRINT • 2-47, 2-83, F-1, G-2 • • • • • • LPRINT USING • • • • • • • • • 2-47 2-48, B-8 LSET. •••• • • • • MAKINT • • • • MBASIC • • • MDS • • • • • • MERGE • • • • • MID$ • • • • • • MKO$ • • • • MKI$ • • • • • • • MKS$ • • • • • • • MOD operator • • • Modulus arithmetic MOUNT • • • Multiplication • • • • • • • • • • • • • • • • • • • • C-1, C-4, D-4, E-2, G-1 • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • D-1 G-1 2-4, 2-49, B-2 2-50, 3-13, I-1 3-14, B-8 3-14, B-8 3-14, B-8 1-10 1-10 H-3 1-10 NAME • • • • • • • • 2-51 Negation • • • • • • • • • • 1-10 2-8, 2-52 NEW • • • • • • • • • NULL • • • • • • • • 2-53 I Numeric constants Numeric variables • • • • • • 1-4 • • • • • • 1-7 OCT$. •• • Octal • • • • ON ERROR GOTO ON ••• GOSUB • • ON ••• GOTO • OPEN • • • • • • • • • • • Operators • OPTION BASE OUT • • • Overflow • • Overlay • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • Paper tape • • PEEK • • • • • POKE • • • • • ••.•• POS PRINT. •• PRINT USING • PRINT#: • PRINT#: USING • • • • • • • • • • • • • 3-14 • • 1-5, 3-14 • • 2-54 • • 2-55 • • 2-55, A-1 • • 2-8, 2-28, 2~56, B-3, B-8, H-"5 • • 1-9, 1-11 to 1-14 • • 2-57 • • 2-58 • • 1-11, 3-7, 3-21, A-1 • • 2-4 • • • • • • • • • • .. • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • Protected files PUT • • • • • • • • • • • • • • • • • · .. . • • • • • • 2-77, A-2, B-2 • • • • • • Random numbers • • RANDOHIZE • READ • • • • • • Relational operators REM • • • • • • • REMOVE • • • • • • • RENUM • • • • RESET • • • • RESTORE • • • • • RESUME • • • • • • RETURN • • • • • • • RIGHT$ • • • • • • RND • • • . RSET • • • • • Rubout • • • • • • • RUN • • • • • • • • · .• •. • • • • • • • • • ·.• • • • • • • • • • • • • • • • • • • • • • • • • SAVE • • • • • • • • • SBC • • Sequential files • • • • • • • • • • • • 3-15 3-15 3-15 A-1 A-2 A-3, B-3, H-7 A-3, B-5, B-5 • 2-28, 2-68, B-8, H-7 • • Random files • • • SET 2-53 2-59, 2-59, 2-83, 2-60, 2-62, 2-66, 2-66, • • • • • • • • • • • • • • • • • • • • • • • • • • • '. . 2~28, 2-31, 2-39, 2-48, 2-56, 2-68, 3-12, 3-14, A-3 B-7, D-4 2-69, 3-16 2-69, 3-16, A-1 2-70, 2-74 1-11 2-72 H-3 2-4, 2-25, 2-73 D-3 2-74 2-75 2-32 3-16 2-69, 3-16, A-1 2-48, B-8 1-3, 1-15, 2-20 2-76 to 2-77, B-2 • • 2-46, 2-76 to 2-77, B-1 • G-1 • • 2-38 to 2-39, 2-42, 2-56, 2-66, 2-85, 3-6, 3-12, B-3 • H-4 • SGN • • •• ••• SIN. •• • • • Single precision • • • SPACE$ • • •• • SPC. •••••• • SQR •• • Standalone Disk BASIC STOP • • •• ••• STR$ • •. •• ••• • String constants • • • String functions • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • String operators • String space • • • String variables • STRING$ • • • • • Subroutines • • • Subscripts • • • • Subtraction • • • SWAP •• •• •• SYSTEM •• ••• • • • • • • • • • • • • • • • • • • • • • • • • • • • TAB Tab • • • • • • •• • • • • • • • • • TAN •• • • • • TEKDOS • • • TROFF • • • • • • TRON •• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 3-17 3-17 1-5, 2-15, 2-60, 3-5, A-1 '" ." .j-IO 3-18 3-19 H-1 2-10, 2-23, 2-32, 2-78 3-19 1-4 3-6, 3-10 to 3-11, 3-13, 3-16, 3-19, 3-22, 1-1 1-14 2-6, 3-8, A-1, B-9 1-7, 2-15, 2-41 to 2-42 3-20 2-3, 2-32, 2~55, C-1 1-7, 2-18, 2-57 1-10 2-79 0-4, F-1 • • 3-20 • • 1-3 to 1-4 • • 3-21 • F-1 • • 2-80 • • 2-80 USR • • • • • • • • • • • 2-16, 3-21, C-1 USRLOC • • • • • • • • • • • C-2, G-1 VAL • Variables VARPTR • • • • • • • • 3-22 • • • • • • • 1-6 • • • • 3-23, H-10 • • • • WAIT • • . • • WEND •• •• WHILE •• • WIDTH. •• WIDTH LPRINT • WRITE. •• WRITE# • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 2-81 2-82 2-82 2-83, A-2 2-83, A-2 2-84 2-85, A-3, B-3 • Microsoft ~"f+, •• ~ ...a .....,"' . . . YYUI '4iiiiP D .. ~hlam DOft~"+ I "'WI 'V • • • 1'4iiiiP"""" " I Use this form to report errors or problems in: D D o Date Microsoft BASIC-80 H.icrosoft BASIC-86 Microsoft BASIC Compiler Report only one problem per form. Describe your hardware and operating system: BASIC Release number: Please supply a concise description of the problem and the circumstances surrounding its occurrence. If possible, reduce the problem to a simple test case. Otherwise, include all programs and data in machine readable form (preferably on a diskette). If a patch or interim solution is being used, please describe it. This form may also be used to describe suggested enhancements to Microsoft BASIC. Problem Description: • -()vpr- Did you find errors in the BASIC-80 Referenc.e Manual? If so, please include page numbers and describe: Fill in the following information before returning this form: Name --------------------------------------- Phone Organization ------------------------------------------------------------Ci ty __________ State Zip _ __ Address -------------------------Return. form to: ----------~------------- Microsoft 10800 NE Eighth, Suite 819 Bellevue, WA 98004 MICROSOFT UTILITY SOFTWARE MANUAL MltoDoltW ~@{fltw@[f® [[fi)@[Ji) M@D • ©Microsoft, 1978 Microsoft Utility Software Manual CONTENTS SECTION 1 1.1 1. 2 1.3 1.4 1.5 MACRO-SO Assembler ..... .. • • 5 Format of MACRO-SO Commands • • • • • • • • • 1 • 1 .1 MACRO-SO Command Strings • • • • • • • 1.1.2 MACRO-SO Switches • • • • • • • • • • • Format of MACRO-SO Source Files • • • • • • • 1.,2.1 Statements • • • • • • • • •• 1 .2.2 Symbols. • • • • • • • • • • • • • • • 1.2.3 Numeric Constants • • • • • • • • • • • 1.2.4 Strings. • • • • • • • • • • • • • • • Expression Evaluation • • • • • • • • • • • • 1.3.1 Arithmetic and Logical Operators • • • 1 . 3. 2 Modes • • • • • • • • • • • • 1.3.3 Externals • • • • • • • • • • • • • • • Opcodes as Operands • • • • • • • • • • • • • Pseudo Operations •••••••••••• 1 • 5 • 1 ASEG • • • • • • • • • • • • • • • • • 1 • 5 • 2 COMMON • • • • • • • • 1.5.3 CSEG • • • • • • • • • •• 1.5.4 Define Byte • • • • • • • • • • • • • • 1.5.5 Define Character • • • • • 1.5.6 Define Space • • • •••• 1.5.7 DSEG • • • • • • • • • • • • • •• 1.5.S Define Word • • • • • . • • • • • • • • 5 5 6 6 7 8 S 1• 5 • 9 1.5.10 1•5 • 11 1.5.12 1 • 5 • 13 1.5.14 1 • 5 • 15 1• 5 • 16 1.5.17 1 • 5 • 1S 1 • 5. 1 9 1 • 5 • 20 1 • 5 • 21 1.5.22 1.5.23 1.5.24 1.5.25 1.5.26 1.5.27 1.5.28 END. • • • • • • • •. 9 10 10 10 11 12 12 12 13 13 13 14 14 14 14 .••••• 15 ENTRY/PUBLIC • • • • • •••••• EQU.... • • • • • • • • • • EXT/EXTRN. • • • ••••••• NAME •• • • • • • •••••• ~ • Define Origin • • • • . • • • • • • • PAGE • • • • • • • • • • • • • • • SET. • • • • • • • • • • • • • • SUBTTL • • • • • • • • • • • • TITLE • • • • • • • • • • • • • • • • • • COMMENT • • • • • • • • • • • • • • • • P RINTX • • • • • • •••• • • • RADIX • • • • • • • • • • • • • • • • • REQUEST • • • • • • • • • • • •• .ZSO ••••••••••• • • , • .S080....... • ••••••• Conditional Pseudo Operations ••• Listing Control Pseudo Operations • • • Relocation Pseudo Operations ••••• Relocation Before Loading • • • • • • • 15 15 15 16 16 16 16 16 17 17 17 18 1S 0 g g 0 , • • ••• 18 18 19 20 20 21 • 1.6 ~ 22 . 22 1.6.2 1 .6. 3 1. 6.4 1• 6 • 5 1•6•6 1• 6 • 7 REPT-ENDM. • • • • • • • • IRP-ENDM • • • • • • • • • • • IRPC-ENDM.. ••• r1ACRO .•••.•••••••••• ENDM • • • . • • • • • • • EXITr-1. • • • • •• • . • •• • 1 • 6 • S LOCAL. • • • • • • •• • • 1.6.9 Special r·1acro Operators and Forms • Using ZSO Pseudo-ops • • • Sample Assembly • • • • • • ••••• MACRO-SO Errors • • • • • • • • • • .' Compatability with Other Assemblers • • • • • Format of Listings. • • • 1. 11 • 1 Symbol Table Listing • • • • •• • Cross Reference Facility • 23 24 24 24 26 26 27 27 /.S 29 30 31 32 33 34 LINK-SO Linking Loader 36 Macros and Block Pseudo Operations. •• 1•6 • 1 1.7 1.S 1.9 1.10 1.11 1.12 SECTION 2 2.1 2.2 2.3 2.4 2.5 SECTION 3 3.1 3.2 3.3 3.4 3.5 SECTION 4 Terms. • . • • . . . • • • • • Format of LINK-SO Commands • 2.1.1 LINK-SO Command Strings • • • . 2.1.2 LINK-SO Switches • • • • • • . Sample Link • • • • • • • . • Format of LINK Compatible Object Files LINK-SO Error Messages • • • . • • • • Program Break Information . • . • • . LIB-SO Library Manager • LIB-SO Commands • 301.1 Modules. . LIB-SO Switches LIB-SO Listings • Sample LIB Session Summaryof Switches Operating Systems • • . • • 36 • • • • 36 • • • • 37 • • • • . • • • · • 39 39 41 43 · 44 • • . • • ••• • • . . . . .. .... •••••••.••. • • • • • . •••• •••..••••.•• and Syntax • • • • • • • • 44 44 46 46 47 47 • 4S 4. , CP 1M . . . . 4.2 4.3 4.4 DTC Microfile . • • • •• • • • • 50 Altair DOS ••••.•.••..•• . 52 ISIS-II • • . . . • . . . • ••.. • 54 . . . . . . . . • . . . . • • • . 48 SECTION 1 t·1ACRO-80 Assembler 1.1 Format of MACRO-SO Commands 1• 1• 1 MACRO-80 Command Strings To run MACRO-BO, type MBa. followed by a carriage return. MACRO-SO will return the prompt "*" (with the DTC operating system, the prompt is ">."), indicating it is ready to accept commands. The format of a MACRO-SO command string is: objprog-dev: filename. ext, list-dev: filename. ext= source-dev:filename.ext ' objprog-dev: The device on which the object written. program is to be list-dev: The device on which the program listing is written. source-dev: The device from which the source-program input to HACRO-80 is obtained. If a device name is omitted, it defaults to the currently selected drive. filename. ext The filename and filename extension of the object program file, the listing file, and the source file. Filename extensions may be omitted. See Section 4 for the default extension supplied by your operating system. Either the object file or the listing file or both may be omitted. If neither a listing file nor an object file is desired, place only a comma to the left of the equal sign. If the names of the object file and the listing file are omitted, the default is the name of the source file. Examples: *=SOURCE .l-1AC Assemble the program SOURCE.MAC and place the object in SOURCE.REL *,LST:=TEST Assemble the program TEST.MAC and list on device LST • --~- *SMALL,TTY:=TEST 1• 1• 2 - Assemble the program TEST.MAC, place the object in SMALL.RELand list on TTY MACRo-ao Switches A number of different switches may be given in the MACRO-aO command string that will affect the format of the listing file. Each switch must be preceded by a slash (/): Switch Action o Print all listing addresses, etc. in octal. (Default for Altair DOS) H Print all listing addresses, etc. in hexadecimal. (Default for non-Altair versions) R Force generation of an object file. L Force generation of a listing file. C Force generation of a cross reference file. Z Assemble zao (Zilog format) mnemonics. (Default for Z80 operating systems) I Assemble 8080 mnemonics. 8080 operating systems) (Default for Examples: 1.2 *=TEST/L Compile TEST.MAC with object file TEST.REL and listing file TEST.LST *LAST,LAST/C=MOD1 Compile MOD1.MAC with object file LAST.REL and cross reference file LAST.CRF for use with CREF-80 (See Section 1.12) Format of MACRO-SO Source Files In general, MACRO-SO accepts a source file that is almost identical to source files for INTEL compatible assemblers. Input source lines of up to 132 characters in length are acceptable. Microsoft Utility Software Page 7 MACRO-BO preserves lower case letters in quoted strings and comments. All symbols, opcodes and pseudo-opcodes typed in lower case will be converted to upper case. NOTE If the source file includes line numbers from an editor, each byte of the line number must have the high bit on. Line numbers from Microsoft's EDIT-80 Editor are acceptable. 1 .2. 1 Statements Source files input to statements of the form: [label: [ : ] ] [operator] MACRO-BO [ argumen ts ] consist of [; comment] With the exception of the ISIS assembler $ controls (see Section 1.10), it is not necessary that statements begin in column 1. Multiple blanks or tabs may be used to improve readability. If a label is present, it is the first item in the statement and is immediately followed by a colon. If it is followed by two colons, it is declared as PUBLIC (see ENTRY/PUBLIC, Section 1.5.10). For exmple: FOO: : RET is equivalent to PUBLIC FOO: FOO RET The next item after the label (or the first item on the line if no label is present) is an operator. An operator may be an opcode (8080 or Z80 mnemonic), pseudo-op,_ macro call or expression. The evaluation order is as follows: 1. Macro call 2. Opcode/Pseudo operation 3. Expression Instead of flagging an expression as an error, the assembler treats it as if it were a DB statement I Microsoft Utility Software Page a (see Section 1.5.4). The arguments following the operator will, course, vary in for.m according to the operator. of A comment always begins with a semicolon and ends with a carriage return. A comment may be a line by itself or it may be app~nded to a line that contains a statement. Extended comments can be entered using the .COMMENT pseudo operation (see Section 1.5.19). 1.2.2 Symbols MACRO-aO symbols may be of any length, however, only the first six characters are significant. The following characters are legal in a symbol: A-Z 0-9 $ • ? @ With the aoao/zao assembler, the underline character is also legal in a symbol. A symbol may not start with a digit. When a symbol is read, lower case is translated into upper case. If a symbol reference is followed by ## it is declared external (see also the EXT/EXTRN pseudo-op, Section 1.5.12). 1.2.3 Numeric Constants The default base for numeric constants is decimal. This may be changed by the .RADIX pseudo-op (see Section 1.5.21). Any base from,2 (binary) to 16 (hexadecimal) may be selected. When the base is greater than 10, A-F are the digits following 9. If the first digit of the number is not numeric (i.e., A-F), the number must be preceded by a zero. This eliminates the use of zero as a leading digit for octal constants; as in -previOus versions of MACRO-aO. Numbers are 16-bit unsigned quantities. A number is always evaluated in the current radix unless one of the following special notations is used: nnnnB nnnnD nnnnO nnnnQ nnnnH X'nnnn' Binary Decimal Octal Octal Hexadecimal Hexadecimal Overflow of a number beyond two bytes is ignored Microsoft Utility Software Page 9 and the result is the low order 16-bits. A character constant is a string comprised of zero, one or two ASCII characters, delimited by quotation marks, and used in a non-simple expression. For example, in the statement DB 'A' + 1 'A' is a character constant. But the statement uses 'A' as a string because it is in a simple expression. The rules for character constant delimiters are the same as for strings. A character constant comprised of one character has as its value the ASCII value of that character. That is, the high order byte of the value is zero, and the low order byte is the ASCII value of the character. For example, the value of the constant 'A' is 41H. A character constant comprised of two characters has as its value the ASCII value of the first character in the high order byte and the ASCII value of the second character in the low order byte. For example, the value of the character constant "AB" is 41H*256+42H. 1.2.4 Strings A string is comprised of zero or more characters delimited by quotation marks. Either single or double quotes may be used as string delimiters. The delimiter quotes may be used as characters if they appear twice for every character occurrence desired. For example, the statement DB "I am ""great"" today" stores the string I am "great" today If there are zero characters between delimiters, the string is a null string. the • Microsoft Utility Software 1.3 Expression Evaluation 1.3.1 Arithmetic and Logical Operators Page 10 The following operators are allowed in expressions. The operators are listed in order of precedence. NUL LOW, HIGH *, I, MOD, SHR, SHL Unary Minus +, - EQ, NE, LT, LE, GT, GE NOT AND OR, XOR Parentheses are used to change the, order of precedence. During evaluation of an expression, as soon as a new operator is encountered that has precedence less than or equal to the last operator encountered, all operations up to the new operator are perfor.med. That is, subexpressions involving operators of higher precedence are computed first. All operators except +, -, *, I must be separated from their operands by at least one space. The byte isolation operators (HIGH,LOW) isolate the high or low order 8 bits of an Absolute 16-bit value. If a relocatable value is supplied as an operand, HIGH and LOW will treat it as if it were relative to location zero. 1.3.2 Modes All symbols used as operands in expressions are in one of the following modes: Absolute, Data Relative, Program (Code) Relative or COMMON. (See Section 1.5 for the ASEG, CSEG, DSEG and COMMON pseudo-ops.) Symbols assembled under the ASEG, CSEG (default), or DSEG pseudo-ops are in Absolute, Code Relative or Data Relative mode respectively. The number of COMMON modes in a program is determined by the number of CO~~ON blocks that have been named Microsoft Utility Software Page 11 with the COMMON pseudo-oPe Two COMMON symbols are not in the same mode unless they are ~n the sw~e COMMON block. In any operation other than addition or subtraction, the mode of both operands must be Absolute. If the operation is addition, the following rules apply: 1. At least one of the operands must be Absolute. 2. Absolute + = If the operation is subtraction, the following rules apply: = 1. - Absolute 2. - = Absolute where the two s are the same. Each intermediate step in the evaluation of an expression must conform to the above rules for modes, or an error will be generated. For example, if FOO, BAZ and ZAZ are three Program Relative symbols, the expression FOO + BAZ - ZAZ will generate an R error because the first step (FOO + BAZ) adds two relocatable valueso (One of the values must be Absolute.) This problem can always be fixed by inserting parentheses. So that FOO + (BAZ - ZAZ) is legal because the first step (BAZ ZAZ) generates an Absolute value that is then added to the Program Relative value, FOO. 1 .3. 3 Externals Aside from its classification by mode, a symbol is either External or not External. (See EXT/EXTRN, Section 1.5.12.) An External value must be assembled into a two-byte field. (Single-byte Externals are not supported.) The following rules apply to the use of Externals in expressions: 1. Externals are subtraction. legal only in addition and • - 1.4 -----~ 2. If an External symbol is used in an expression, the result of the expression is always External. 3. When the operation is addition, either (but not both) may be External. 4. When the operation is subtraction, first operand may be External. Opcodes ~ operand only the Operands 8080 opcodes are valid one-byte -operands. Note that only the first byte is a valid operand. For example: MVI A, (JMP) ADI (CPI) MVI B, (RNZ) CPI ACI (INX H) (LXI B) C,MOV A,B MVI Errors will be generated if more than one byte is included in the operand -- such as (CPI 5), LXI B,LABEL1) or (JMP LABEL2). Opcodes used as one-byte enclosed in parentheses. operands need not be NOTE Opcodes are not valid operands in Z80 mode. 1.5 Pseudo Operations 1 .5. 1 ASEG ASEG ASEG sets the location counter to an absolute segment of memory. The location of the absolute counter will be that of the last ASEG (default is 0), unless an ORG is done after the ASEG to change the location. The effect of ASEG is also achieved by using the' code segment (CSEG) pseudo operation and the /P switch in LINK-80. See also Section 1.5.27. Page 13 Microsoft Utility Software COMMON // COMMON sets the location counter to the selected cornmon block in memorye The location is always the beginning of the area so that compatibility with the FORTRAN COMMON statement is maintained. If is omitted or consists of spaces, it is considered to be blank common. See also Section 1.5.27. 1.5.3 CSEG CSEG CSEG sets thelocation counter to the code relative segment of memory. The location will be that of the last CSEG (default is 0) I unless an ORG is done after the CSEG to change the location. CSEG is the default condition of the assembler (the INTEL assembler defaults to ASEG). See also Section 1.5.27. 1 .5.4 Define Byte DB [, ••• ] DB [ ••• ] The arguments to DB are either expressions or strings. DB stores the values of the expressions or the characters of the strings in successive memory locations beginning with the current location counter. Expressions must evaluate to one byte. (If the high byte of the result is a or 255, no error is given; otherwise, an A error results.) Strings of three or more characters may not be used in expressions (i.e., they must be immediately followed by a comma or the end of the line). The characters in a string are stored in the order of appearance, each as a one-byte value with the high order bit set to zero. Example: 0000' 0002' 0003' 4142 42 41 42 43 DB DB DB 'AB' 'AB' AND OFFH 'ABC' • Microsoft Utility Software 1.5.5 Page 14 Define Character DC DC stores the characters in in successive memory lo~ations beginning with the current location counter. As with DB, characters are stored in order of appearance, each as a one-byte value with the high order bit set to zero. However, DC stores the last character of the string with the high order bit set to one. An error will result if the argument to DC is a null string. 1.5.6 Define Space DS DS reserves an area of memory. The value of gives the number of bytes to be allocated. All names used in must be previously defined (i.e., all names known at that point on pass 1). Otherwise, a V error is generated during pass 1 and a U error may be generated during pass 2. If a U error is not generated during pass 2, a phase error will probably be generated because the DS generated no code on pass 1. 1.5.7 DSEG DSEG DSEG sets the location counter to the Data Relative segment of memory. The location of the data relative counter will be that of the last DSEG (default is 0), unless an ORG is done after the DSEG to change the location. See also Section 1.5.27. 1.5.8 Define Word DW [, ••• ] DW stores the values of the expressions successive memory locations beginning with current location counter. Expressions evaluated as 2-byte (word) values. in the are Microsoft Utility Software 1.5 .. 9 Page 15 END END [] The END statement specifies the end of the program. If is present, it is the start address of the program. If is not present, then no start address is passed to LINK-BO for that program. 1.5.10 ENTRY/PUBLIC ENTRY [, ••• ] or PUBLIC [, •.• ] ENTRY or PUBLIC declares each name in the list as internal and therefore available for use by this program and other programs to be loaded concurrently. All of the names in the list must be defined in the current program or a U error results. An M error is generated if the name is an external name or common-blockname. 1.5.11 ~ EQU EQU assigns the value of to . If is external, an error is generated. If already has a value other than , an M error is generated. 1.5.12 EXT/EXTRN EXT or EXTRN [, •.• ] [, ••• ] EXT or EXTRN declares that the name(s) in the list are external (i.e., defined in a different program). If any item in the list references a name that is defined in the current program, an M error results. A reference to a name where the name is followed immediately by two pound signs (e.g., NAME##) also declares the name as external. • Microsoft Utility Software 1.5.13 Page 16 NAME NAME ( , modname ' ) NAME defines a name for the module. Only the first six characters are significant in a module name. A module name may also be defined with the TITLE pseudo-oPe In the absence of both. the NAME and TITLE pseudo-ops, the module name is created from the source file nameQ . 1.5. 14 Define. Origin ORG The location counter is set to the value of and the assembler assigns generated code starting with that value. All names used in must be known on pass 1, and the value must either be absolute or in the same area as the location counter. 1.5.15 PAGE PAGE [] PAGE causes the assembler to start a new output page. The value of , if included, becomes the new page size (measured in lines per page) and must be in the range 10 to 255. The default page size is 50 lines per page. The assembler puts a form feed character in the listing file at the end of a page. 1.5.16 SET SET SET is the same as EQU, except no generated if is already defined. 1.5.17 error is SUBTTL SUBTTL SUBTTL specifies a subtitle to be listed on the line after the title (see TITLE, Section 1.5.18) on each page heading. is truncated after 60 characters. Any number of SUBTTLs may be given in a program •. Page 17 Microsoft Utility Software 1.5.18 TITLE TITLE TITLE specifies a title to be listed on the first line of each page. If more than one TITLE is given, a Q error results. The first six characters of the title are used as the module name unless a NAME pseudo operation is used. If neither a NAME or TITLE pseudo-op is used, the module name is created from the source filename. 1.5.19 • COMMENT .COMMENT The first non-blank character encountered after • COMMENT is the delimiter. The following comprises a comment block which continues until the next occurrence of is encountered. For example, using an asterisk as the delimiter, the format of the comment block would be: • COMMENT * any amount of text entered here as the comment block * ireturn to normal mode 1.5.20 .PRINTX .PRINTX The first non-blank character encountered after .PRINTX is the delimiter. The following text is listed on the terminal during assembly until another occurrence of the delimiter is encountered • • PRINTX is useful for displaying progress through a long assembly or for displaying the value of conditional assembly switches. For example: IT ~M .PRINTX /CPM version/ ENDIF NOTE .PRINTX will output on both passes. If only one printout is desired, use the IF1 or IF2 pseudo-oPe • Microsoft Utility Software 1.5.21 Page 18 • RADIX .RADIX The default base (or radix) for all constants is decimal. The .RADIX statement allows the default radix to be changed to any base in the range 2 to 16. For example: LXI H,OFFH .RADIX 16 LXI H,OFF The two LXls in the example are identical. The in a .RADIX statement is always in decimal radix, regardless of the current radix. 1.5.22 • REQUEST .REQUEST [, ••• ] .REQUEST sends a request to the LINK-BO loader to search the filenames in the list for undefined globals before searching the FORTRAN library. The filenames in the list should be in the form of legal MACRO-BO symbols. They should not include filename extensions or disk specifications. The LINK-BO loader will supply its default extension and will assume the currently selected disk drive. 1.5.23 .ZBO .Z80 enables the assembler to accept Z80 opcodes. This is the default condition when the assembler is running on a Z80 operating system. Z80 mode may also be set by appending the Z switch to the MACRO-BO command string -- see Section 1.1.2. 1.5.24 .80aO .8080 enables the assembler to accept 8080 opcodes. This is the default condition when the assembler is running on an B080 operating system. 8080 mode may also be set by appending the I switch to the MACRO-aO command string -- see Section 1.1.2. Microsoft Utility Software 1.5.25 Page 19 Conditional Pseudo Operations The conditional pseudo operations are: o. IF/IFT True if is not IFE/IFF True if is IF1 True if pass 1. IF2 True if pass 2. IFDEF True if is defined or has been declared External. IFNDEF True if is undefined or not declared External. IFB True if is blank. The angle brackets around are required. IFNB True if is not blank. Used for testing when dummy parameters are supplied. The angle brackets around are required. o. All conditionals use the following format: IFxx [argument] [ELSE END IF Conditionals may be nested to any level. Any argument to a conditional must be known on pass 1 to avoid V errors and incorrect evaluation. For IF, IFT, IFF, and IFE the expression must involve values which were previously defined and the expression must be absolute. If the name is defined after an IFDEF or IFNDEF, pass 1 considers the name to be undefined, but it will be defined on pass 2. ELSE Each conditional pseudo operation may optionally be used with the ELSE pseudo operation which allows alternate code to be generated when the opposite condition exists. Only one ELSE is permitted for a • Microsoft Utility Software Page 20 given IF, and an ELSE is always bound to the most recent, open IF. A conditional with more than one ELSE or an ELSE without a conditional will cause a C error. ENDIF Each IF must have a matching ENDIF to terminate the conditional. Otherwise, an 'Unterminated conditional' message is generated at the end of each pass. An ENDIF without a matching IF causes a C error. 1.5.26 Listing Control Pseudo Operations Output to the listing file can be controlled by two pseudo-ops: .LIST and .XLIST If a listing is not being made, these pseudo-ops have no effect. .LIST is the default condition. When a .XLIST is encountered, source and object code will not be .listed until a .LIST is encountered. The output of cross reference information is controlled by .CREF and .XCREF. If the cross reference facility (see Section 1.12) has not been invoked, .CREF and .XCREF have no effect. The default condition is .CREF. When a .XCREF is encountered, no cross reference information is output until .CREF is encountered. The output of MACRO/REPT/IRP/IRPC expansions is controlled by three pseudo-ops: .LALL, .SALL, and .XALL. .LALL lists the complete macro text for all expansions. .SALL lists only the object code produced by a macro and not its text. .XALL is the default condition; it is similar to .SALL, except a source line is listed only if it generates object code. 1.5.27 Relocation Pseudo Operations The ability to create relocatable modules is one of the major features of MACRO-BO. Relocatable modules offer the advantages of easier coding and faster testing, debugging and modifying. In addition, it is possible to specify segments of assembled code that will later be loaded into ~~ (the Data Relative segment) and ROM/PR011 (the Code Relative segment). The pseudo operations that Microsort Ut~~~ty ~o~tware .l:'age ':::1 select relocatable areas are CSEG and DSEG. The ASEG pseudo-op is used to generate non-relocatable (absolute) code. The COMMON pseudo-op creates a common data area for every COMMON block that is named in the program. The default mode for the assembler is Code Relative. That is, assembly begins with a CSEG automatically executed and the location counter in the Code Relative mode, pointing to location a in the Code Relative segment of memory. All subsequent instructions will be assembled into the Code Relative segment of memory until an ASEG or DSEG or COMMON pseudo-op is executed. For example, the first DSEG encountered sets the location counter to location zero in the Data Relative segment of memory. The following code is asembled in the Data Relative mode, that is, it is assigned to the Data Relative segment of memory. If a subsequent CSEG is encountered, the location counter will return to the next free location in the Code Relative segment and so on. The ASEG, DSEG, CSEG pseudo-ops never have operands. If you wish to alter the current value of the location counter, use the ORG pseudo-oPe ORG Pseudo-op At any time, the value of the location counter may be changed by use of the the ORG pseudo-oPe The form of the ORG statement is: ORG where the value of will be the new value of the location counter in the current mode. All names used in must be known on pass 1 and the value of must be either Absolute or in the current mode of the location counter. For example, the statements DSEG ORG 50 set the Data Relative location counter to 50, relative to the start of the Data Relative segment of memory. - LINK-ao The LINK-80 linking loader (see Section 2 of this manual) combines the segments and creates each relocatable module in memory when the program is loaded. The origins of the relocatable segments are not fixed until the program is loaded and the origins are assigned by LINK-80. The command to • M~croso~~ u~~~~ty sottware Page 22 LINK-80 may contain user-specified or~g~ns through the use of the IP (for Code Relative) and ID (for Data and COMMON segments) switches. For example, statements ASEG ORG a program that begins with the 800H and is assembled entirely in Absolute mode will always load beginning at 800 unless the ORG statement is changed in the source file. However, the same program, assembled in Code Relative mode with no ORG statement, may be loaded at any specified address by appending the IP:
switch to the LINK-80 command string. 1.5.28 Relocation Before Loading Two pseudo-ops, ePHASE and .DEPHASE, allow code to be located in one area, but executed only at a different,specified area. For example: 0000' 0100 0103 0106 CD 0106 C3 0007' C9 FOO: 0007' C3 0005 ZOO: . PHASE BAZ: CALL 100H BAZ ZOO JMP RET .DEPHASE JMP 5 All labels within a .PHASE block are defined as the absolute value from the origin of the phase area. The code, however, is loaded in the current area (i.e., from 0' in this example). The code within the block can later be moved to 100H and executed. 1.6 Macros and Block Pseudo Operations The. macro facilities provided by MACRO-SO include three repeat pseudo operations: repeat (REPT) , indefinite repeat (IRP), and indefinite repeat character (IRPC). A macro definition operation (MACRO) is also provided. Each of these four macro operations is terminated by the ENDM pseudo operation. 1. 6. 1 Terms For the purposes of discussion of macros and block Microsoft Utility Software Page 23 operations, the following terms will be used: 1. is used to represent a dummy parameter. All dummy parameters are legal symbols that appear in the body of a macro expansion. 2. is a list of s separated commas. 3. is a list of arguments separated by commas. must be delimited·by angle brackets. Two angle brackets with no intervening characters or two commas with no intervening character~ enter a null argument in the list. Otherwise an argument is a character or series of characters terminated by a comma or >. With angle brackets that are nested inside an , one level of brackets is removed each time the bracketed argument is used in an . (See example, Section 1.6.5.) A quoted string is an acceptable argument and is passed as such. Unless enclosed in brackets or a quoted string, leading and trailing spaces are deleted from arguments. by «» 4. 1 .6. 2 is used to represent a list of actual parameters separated by commas. No delimiters are required (the list is terminated by the end of line or a comment), but the rules for entering null parameters and nesting brackets are the same as described for . (See example, Section 1.6.5.) REPT-ENDM REPT • ENDM The block of statements between REPT and ENDM is repeated times. is evaluated as a 16-bit unsigned number. If contains any external or undefined terms, an error is generated. Example: SET REPT SET DB ENDM o 10 X+1 X ;generates DB1-DB10 • Page 24 Microsoft Utility Software 1.6.3 IRP-ENDM IRP , • ENDM The must be enclosed in angle brackets. The number of arguments in the determines the number of times the block of statements is repeated. Each repetition substitutes the next item in the for every occurrence of in the block. If the is null (i.e., <», the block is processed once with each occurrence of removed. For example: X,<1,2,3,4,5,6,7,8,9,10> IRP DB ENDM X generates the same bytes as the REPT example. 1.6.4 IRPC-ENDM ,string (or in the block. For example: X,0123456789 X+1 IRPC DB ENDM generates examples. 1.6.5 the same code as the two previous MACRO Often it is convenient to be able to generate a given sequence of statements from various places in a program, even though differant parameters may be required each time the sequence is used. This capability is provided by the ~~CRO statement. The form is Microsoft Utility Software Page 25 MACRO ENDM where conforms to the rules for forming symbols. is the name that will be used to invoke the macro. The s in are the parameters that will be changed (replaced) each time the MACRO is invoked. The statements before the ENDM comprise the body of the macro. During assembly, the macro is expanded every time it is invoked but, unlike REPT/IRP/IRPC, the macro is not expanded when it is encountered. The form of a macro call is where is the name supplied in the ~~CRO definition, and the parameters in will replace the s in the MACRO on a one-to-one basis. The number of items in and is limited only by the length of a line. The number of parameters used when the macro is called need not be the same as the number of s in . If there are more parameters than s, the extras are ignored. If there are fewer, the extra s will be made nUll. The assembled code will contain the macro expansion code after each macro call. NOTE A dummy parameter in a MACRO/REPT/IRP/IRPC is always recognized exclusively as a dummmy parameter. Register names such as A and B will be changed in the expansion if they were used as dummy parameters. • Microsoft Utility Software Page 26 Here is an example of a MACRO defines a macro called Faa: Faa Y Y MACRO SET REPT SET DB ENDM ENDM definition X a x Y+1 Y This macro generates the same code as the three examples when the call FOO that previous 10 is executed. Another example, which generates the same code, illustrates the removal of one level of brackets when an argument is used as an arglist: Faa MACRO IRP DB ENDM ENDM X Y, Y Faa <1,2,3,4,5,6,7,8,9,10> When the call is made, the macro expansion looks like this: IRP DB ENDM 1.6.6 Y,<1,2,3,4,5,6,7,8,9,10> Y ENDM Every REPT, IRP, IRPC and MACRO pseudo-op must be te~inated with the ENDM pseudo-oPe Otherwise, the 'Unterminated REPT/IRP/IRPC/MACRO' message is generated at the end of each pass. An unmatched ENDM causes an a error. 1.6.7 EXITM The EXITM pseudo-op is used to terminate a REPT/IRP/IRPC or MACRO call. When an EXITM is executed, the expansion is exited immediately and any remaining expansion or repetition is not generated. If the block containing the EXITM is nested within another block, the outer level Microsoft Utility Software Page 27 continues to be expanded. 1.6.8 LOCAL LOCAL The LOCAL pseudo-op is allowed only inside a MACRO definition. When LOCAL is executed, the assembler creates a unique symbol for each is and substitutes that symbol for each occurrence of the in the expansion. These unique symbols are usually used to define a label within a macro, thus eliminating multiply-defined labels on successive expansions of the macro. The symbols created by the assembler range from •• 0001 to •• FFFF. Users will therefore want to avoid the form •• nnnn for their own symbols. I~ LOCAL statements are used, they must be the first statements in the macro definition. 1.6.9 Special Macro Operators & ~ Forms The ampersand is used in a macro expansion to concatenate text or symbols. A dummy parameter that is in a quoted string will not be substituted in the expansion unless it is immediately preceded by &. To form a symbol from text and a dummy, put & between them. For example: ERRGEN MACRO ERROR&X: PUSH MVI JMP ENDM X B B, , &X' ERROR In this example, the call ERRGEN A will generate: ERRORA: PUSH ,.., MVI B B, 'A' JMP ERROR In a block operation, a comment preceded by two semicolons is not saved as part of the expansion (i.e., it will not appear on the listing even under .LALL). A comment preceded by one semicolon, however, will be preserved and appear in the expansion. When an exclamation point is used in an argument, the next character is entered literally (i.e., !; and <;> are equivalent). • Microsoft Utility Software NUL Page 28 NUL is an operator that returns true if its argument (a parameter) is null. The remainder of a line after NUL is considered to be the argument to NUL. The conditional IF NUL argument is false if, during the expansion, the first character of the argument is anything other than a semicolon or carriage return. It is recommended that testing for null parameters be done using the IFB and IFNB conditionals. 1.7 Using Z80 Pseudo-ops When using the B080/Z80 assembler, the following Z80 pseudo-ops are valid. The function of each pseudo-qp is equivalent to that of its 8080 counterpart. Z80 pseudo-op COND ENDC *EJECT DEFB DEFS DEFW DEFM DEFL GLOBAL EXTERNAL Equivalent 8080 pseudo-op IFT ENDIF PAGE DB OS OW DB SET PUBLIC EXTRN The formats, where different, conform to the 8080 format. That is, DEFB and DEFW are permitted a list of arguments (as are DB and OW), and DEFM is permitted a string or numeric argument (as is DB). Microsoft Utility Software Page 2·9 Sample Assembly 1.8 A>M80 *EXMPL1,TTY:=EXMPL1 MAC80 3.2 0000' 0001' 0002 1 0003' 7E 23 66 6F 0004' 0006' AP 0007' 29 0008' 0009' OOOA' 17 85 6F OOOB' 05 OOOC' OOOF' C2 0006' EB 0010' 0011' 0012' 0013' 73 23 72 C9 No OOOOI' LOOP Fatal error(s) 1 00100 00200 00300 00400 00450 00500 00600 00700 00800 00900 01000 01100 01200 01300 01400 01500 01600 01700 01800 01900 02000 02100 02200 02300 02400 02500 02600 02700 02800 02900 06 03 MACaO 3.2 CSL3 PAGE PAGE 0006' S ;CSL3(P1,P2) ~SHIFT P1 LEFT CIRCULARLY 3 BI~S ~RETURN RESULT IN P2 ENTRY CSL3 ~GET VALUE OF F'IRST PARAMETER CSL3: MOV A,M INX H MOV H,M MOV L,A ; SHIFT COUNT MVI B,3 LOOP: XRA A ; SHIFT LEFT H DAD ; ROTATE IN CY BIT RAL ADD L MOV L,A ; DECREMENT COUNT OCR B iONE MORE TIME JNZ LOOP XCHG ~SAVE RESULT IN SECOND PARAMETER MOV M,E INX H MOV M,D RET END • Microsoft Utility Software 1.9 Page 30 MACRO-80 Errors MACRO-80 errors are indicated by a one-charact.er flag in column one of the listing file. If a listing file is not being printed on the terminal, each erroneous line is also printed or displayed on the terminal. Below is a list of the MACRO-80 Error Codes: A Argument error Argument to pseudo-op is not in correct format or is out of range (.PAGE 1; .RADIX 1; PUBLIC 1: STAX H; MOV M,M; INX C). C Conditional nesting error ELSE without IF, ENDIF without IF, on one IF. D E M N Double Defined symbol Reference to a symbol defined. which two is multiply External error Use of an external illegal in context FOO SET NAME##; MVI A,2-NAME##). Multiply Defined symbol Definition of a symbol defined. which is ELSEs (e.g., multiply Number error Error in a number, usually a bad digit 8Q). (e.g., o Bad opcode or objectionable syntax ENDM, LOCAL outside a block; SET, EQU or MACRO without a name; bad syntax in an opcode (MOV A:): or bad syntax in an expression (mismatched parenthesis, quotes, consecutive operators, etc.). P Phase error Value of a label or EQU name is pass 2. different on Q Questionable Usually means a line is not terminated properly. This is a warning error (e.g. MOV A,B,). R Relocation Illegal use of relocation in expression, such Data, code and COMMON areas are as abs-rel. relocatable. Page 31 MicrosOft Utility Software U Undefined symbol A symbol referenced in an expression is not defined. (For certain pseudo-ops, a V error is printed on pass 1 and a U on pass 2.) V Value error On pass 1 a pseudo-op which must have its value known on pass 1 (e.g., • RADIX, .PAGE, DS, IF, IFE, etc.), has a value which is undefined. If the symbol is defined later in the program, a U error will not appear on the pass 2 listing. Error Messages: 'No end statement encountered on input file' No END statement: either it is missing or it is not parsed due to being in a false conditional, unterminated IRP/IRPC/REPT block or terminated macro. 'Unterminated conditional' At least one conditional the end of the file. is unterminated at 'Unterminated REPT/IRP/IRPC/MACRO' At least one block is unterminated. [xx] 1. 10 [No] Fatal error(s) [,xx warnings] The number of fatal errors and warnings. The message is listed on the CRT and in the list file. Compatibility ~ Other Assemblers The $EJECT and $TITLE controls are provided for compatability with INTEL's ISIS assembler. The dollar sign must appear in column 1 only if spaces or tabs separate the dollar sign from the control word. The control $EJECT is the same as the MACRO-80 PAGE pseudo-oPe The control $TITLE ( , text' ) is the same as the pseudo-oPe ~~CRO-80 SUBTTL The INTEL operands PAGE and INPAGE generate Q errors when used with the MACRO-80 CSEG or DSEG • Page 32 Microsoft Utility Software. warnings; pseudo-ops. These errors are assembler ignores. the operands. the When MACRO-aO is entered, the default for the or~g~n is Code Relative O. With the INTEL ISIS assembler, the default is Absolute O. With MACRO-aO, the dollar sign ($) is a defined constant that indicates the value of the location counter at the start of the statement. Other assemblers may use a decimal point or an asterisk. Other constants are defined by MACRo-ao to have the following values: A=7 H=4 1.11 C=1 M=6 B=O L=5 D=2 SP=6 E=3 PSW=6 Format of Listings On each page of a MACRO-BO listing, the lines have the form: [TITLE text] [SUB TTL text] MAcao 3.2 first two PAGE x [-v] where: 1. TITLE text is the text supplied with the TITLE pseudo-op, if one was given in the source program. 2. page number, which is is the major form incremented only when a feed is (When using encountered in the source file. Microsoft's EDIT-BO text editor, a form feed is inserted whenever a page mark is done. ) When the symbol table is being printed, x = , S ' . 3. page number, which is Y is the minor incremented whenever the • PAGE pseudo-op is encountered in the source file, or whenever the current page size has been filled. 4. SUBTTL text is the text supplied with the SUBTTL pseudo-op, if one was given in the source program. x Next, a blank line is first line of output. printed, followed . by the A line of output on following form: MACRO-BO listing has the [crf#] a [error] loc#m xx xxxx ••• source Page 33 Microsoft Utility Software If cross reference information is being output: the first item on the line is the cross reference number, followed by a tab. A one-letter error code followed by a space appears next on the line, if the line contains an error. If there is no error, a space is printed. If there is no cross reference number, the error code column is the first column on the listingo The value of the location counter appears next on the line. It is a 4-digit hexadecimal number or 6-digit octal number, depending on whether the /0 or /H switch was given in the MACRO-SO command string. The character at the end of the location counter value is the mode indicator. It will be one of the following symbols: " , * Code Relative Data Relative COMMON Relative Absolute External Next, three spaces are printed followed by the assembled code. One-byte values are followed by a space. Two-byte values are followed by a mode indicator. Two-byte values are printed in the opposite order they are stored in, i.e., the high order byte is printed first. Externals are either the offset or the value of the pointer to the next External in the chain. The remainder of the line contains source code, as it was input. 1.11.1 the line of Symbol Table Listing In the symbol table listing, all the macro names in the program are listed alphabetically, followed by all the symbols in the program, listed alphabetically. After each symbol, a tab is printed, followed by the value of the symbol. If the symbol is Public, an I is printed immediately after the value. The next character printed will be one of the following. • Microsoft Utility Software Page 34 U Undefined symbol. C COMMON block name. (The "value" of the COMMON block is its length (number of bytes) in hexadecimal or octal.) * External symbol. Absolute value. Program Relative value. " Data Relative value. COMMON Relative value. 1.12 Cross Reference Facility The Cross Reference Facility is invoked by typing CREF80. In order to generate a cross reference listing, the assembler must output a special listing file with embedded control characters. The MACRO-BO command string tells the assembler to output this special listing file. (See Section 105.26 for the .CREF and .XCREF pseudo-ops.) /C is the cross reference switch. When the /C switch is encountered in a MACRO-BO command· string, the assembler opens a .CRF file instead of a .LST file. Examples: . *=TEST/C *T,U=TEST/C Assemble file TEST.MAC and create object file TEST.REL and cross reference file TEST.CRF. Assemble file TEST.MAC and create object file T.REL and cross reference file U.CRF. the assembler is finished, it is necessary to call the cross reference facility by typing CREF80. The command string is: Wh~n *listing file=source file Possible command strings are: The default extension for the source file is .CRF. The /L switch is ignored, and any other switch will cause an error message to be sent to the terminal. Possible command strings are: Microsoft Utility Software Page 35 file TEST.CRF and generate a cross reference listing file TEST.LST. *=TEST Ex~uiile *T=TEST Examine file TEST.CRF and generate a cross reference listing file T.LST. Cross reference listing files differ from listing files in that: ordinary 10 Each source statement is numbered with a reference number. 20 At the end of the listing, variable names appear in alphabetic order along with the numbers of the lines on which they are referenced or defined. Line numbers on which the symbol is defined are flagged with '#'. cross Microsoft Utility Software Page 36 SECTION 2 LINK-aD Linking Loader 2.1 Format of LINK-aD Commands 2. 1 • 1 LINK-aD Command Strings To run LINK-aD, type LaO followed by a carriage return. LINK-aD will return the prompt "*" (with the DTC operating system, the prompt is ">"), indicating it is ready to accept commands. Each command to LINK-aD consists of a string of filenames and switches separated by commas: objdev1:filename.ext/switch1,objdev2:filename.ext, ••• If the input device for a file is omitted, the default is the currently logged disk. If the extension of a file is omitted, the default is .REL. After each line is typed, LINK will load or search (see /S below) the specified files. After LINK finishes this process, it will list all symbols that remained undefined followed by an asterisk. Example: *MAIN DATA SUBR1 * DATA *SUBR1 */G 0100 0200 (SUBR1 is undefined) 0100 0300 (Starts Execution - see below) Typically, to execute a FORTRAN and/or COBOL program and subroutines, the user types the list of filenames followed by /G (begin execution). Before execution begins, LINK-80 will always search the system library (FORLIB.REL or COBLIB.REL) to . satisfy any unresolved external references. If the user wishes to first search libraries of his own, he should append the filenames that are followed by /S to the end of the loader command string. Microsoft Utility Software 2.1.2 Page 37 LINK-ao Switches A number of switches may be given in the LINK-a 0 command string to specify actions affecting the loading processo Each switch must be preceded by a slash (/)0 These switches are: Switch Action R Reseto Put loader back in its initial stateo Use /R if you l~aded the wrong file by mistake and want to restarto /R takes effect as soon as it is encountered in a command stringo E or E:Name Exit LINK-80 and return to the Operating System. The system library will be searched on the current disk to satisfy any existing undefined globals. The optional form E:Name (where Name is a global symbol previously defined in one of the modules) uses Name for the start address of the program. Use /E to load a program and exit back to the monitor. G or G:Name Start execution of the program as soon as the current command line has been interpreted. The system library will be searched on the current disk to satisfy any existing undefined globals if they existo Before execution actually begins, LINK-ao prints three numbers and a BEGIN EXECUTION message. The three numbers are the start address, the address of the next available byte, and the number of 2S6-byte pages used. The optional form G:Name (where Name is a global symbol previously defined in one of the modules) uses Name for the start address of the program. N If a FILENAME>/N is specified, the program will be saved on disk under the selected name (with a default extension of .COM for CP/M) when a /E or /G is done. A jump to the start of the program is inserted if needed so the program can run properly (at 100H for CP/M) 0 • Microsoft Utility Software P and 0 Page 3a /P and /0 allow the origines) to be set for the ~ program loaded. /P and /0 take effect when seen (not deferred), and they have no effect on programs already loadea7 The form is /P : ADDRESS> or /D:ADDRESS>, where ADDRESS> is the desired origin in the current typeout radix. (Default radix for non-MITS versions is hex. /0 sets radix to octal; /H to hex.) LINK-aO does a default /P:LINK origin>+3 (i.e., 103H for CP/M and 4003H for ISIS) to leave room for the jump to the start address. NOTE: Do not use /P or /D to load programs or data into the locations of the loader's jump to the start address (100H to 102H for CPM and 2800H to 2802H for DTC) , unless it is to load the start of the program there. If programs or data are loaded into these locations, the jump will not be generated. If no /D is given, data areas are loaded before program areas for each module. If a /D is given, all Data and Cornmon areas are loaded starting at the data origin and the program area at the program origin. Example: */P:200,FOO Data 200 300 */R */P:200 /D:400,FOO Data 400 480 Program 200 280 U List the origin and end of the program and data area and all undefined globals as soon as the currentcornmand line has been interpreted. The program information is only printed if a /D has been done. Otherwise, the program is stored in the data area. M List the origin and end of the program and data area, all defined globals and their values, and all undefined globals followed by an asterisk. The program information Microsoft Utility Software • Page 39 is only printed if a /D has been done. Otherwise, the program is stored in the data area. Search the filename immediately preceding the /S in the command string to .satisfy any undefined globals. S Examples: List all globals */M *MYPROG,SUBROT,MYLIB/S Load MYPROG.REL and SUBROT.REL and then search MYLIB.REL to satisfy any remaining undefined globals. */G 2.2 Begin execution of main program Sample ~ A>L80 *EXAMPL,EXMPL1/G DATA 3000 30AC [304F 30AC 49] [BEGIN EXECUTION] 1792 14336 -16383 14 112 14336 -16383 14 112 896 A> 2.3 Format of ~ Compatible Object Files NOTE Section 203 is reference material for users who wish to know the load format of LINK-aO relocatable object files. Most users will want to skip this section, as it does not contain material necessary to the operation of the package. LINK-compatible object files consist of a bit stream. Individual fields within the bit stream are not aligned on byte boundaries, except as noted below. Use of a bit stream for relocatable object files keeps the size of object files to a minimum, thereby decreasing the number of disk reads/writes. • Page 40 Microsoft Utility Software There are two basic types of load items: Absolute and Relocatable. The first bit of an item indicates one of these two types. If the first bit is a 0, the following 8 bits are loaded as an absolute byte. If the first bit is a 1, the next 2 bits are used to indicate one of four types of relocatable items: 00 Special LINK item (see below). 01 Program Relative. Load the following 16 bits after adding the current Program base. 10 Data Relative. Load the following 16 bits after adding the current Data base. 11 Common Relative. Load the following 16 bits after adding the current Common base. Special LINK items consist of the followed by: bit stream 100 a four-bit control field an optional A field consisting of a two-bit address type that isthe same as the two-bit field above except 00 specifies absolute address an optional B field consisting of 3 bits that give a symbol length and up to 8 bits for each character of the symbol A general representation of a special LINK item is: 1 OOxxxx yy nn A xxxx yy nn zzz field zzz + characters of symbol name B field Four-bit control field (0-15 below) Two-bit address type field Sixteen-bit value Three-bit symbol length field The following special types have a B-field only: o 1 2 Entry symbol (name for search) Select COMMON block Program name Microsoft Utility Software 3 4 Page 41 Request library search Reserved for future expansion The following special LINK items have both an A field and a B field: 5 6 . Define COMMON size Chain external (A is head of address chain, B is name of external symbol) Define entry point (A is address, B is name) Reserved for future expansion 7 8 The following special LINK items have an A field only: 9 10 11 12 13 14 External + offset. The A value will be added to the two bytes starting at the current location counter immediately before execution. Define size of Data area (A is size) Set loading location counter to A Chain address. A is head of chain, replace all entries in chain with current location counter. The last entry in the chain has an address field of absolute zero. Define program size (A is size) End program (forces to byte boundary) The following special Link item has neither an A nor a B field: 15 2.4 End file LINK-BO Error Messages LINK-BO has the following error messages: ?No Start Address A /G switch was issued, but no main program had been loaded. ?Loading Error The last file given for input was not a properlyforillatted LINK-BO object file. ?Out of Memory Not enough memory to load program. ?Command Error Unrecognizable LINK-BO command. ? Not Found , as given in the command string, did not exist. • Microsoft Utility Software Page 42 %2nd COMMON Larger /XXXXXX/ The first definition of COMMON block /XXXXXX/ was not the largest definition. Reorder module loading sequence or change COMMON block definitions. %Mult. Def. Global YYYYYY More than one definition for the global (internal) symbol YYYYYY was encountered during the loading process. ,Start = xxxx ,Public = (xxxx) ,External = (xxxx) A /0 or /P will cause already loaded data to be destroyed. %Overlaying [program] Area Data ?Intersecting [ program] Area Data The program and data area intersect and an address or external chain entry is in this intersection. The final value cannot be converted to a current value since i t is in the area intersection. ?Start Symbol - - Undefined After a /E: or /G: is given, the symbol specified was not defined. Origin [Above] Loader Memory, Hove Anyway (Y or N)? . Below After a /E or /G was given, either the data or program area has an origin or top which lies outside loader memory (i.e., loader origin to top of memory). If a Y is given, LINK-80 will move the area and continue. If anything else is given, LINK-80 will exit. In either case, if a /N was given, the image will already have been saved. ?Can't Save Object File A disk error occurred when the file was being saved. Microsoft Utility Software 2.5 Page 43 Program Break Information LINK-80 stores the address of the first free location in a global symbol called $MEMRY if that symbol has been defined by a program loaded. $MEMRY is set to the top of the data area +1. NOTE If -D is given and the data origin is less than the program area, the user must be sure there is enough room to keep the program from being destroyedo This is particularly true with the disk driver for FORTRAN-80 which uses $MEMRY to allocate disk buffers and FCB'so • Page 44 SECTION 3 LIB-80 Library Manager (CP/M Versions Only) LIB-80 is the object time library manager for CP/M versions of FORTRAN-80 and COBOL-80. LIB-80 will be interfaced to other operating systems in future releases of FORTRAN-SO and COBOL-SO. 3.1 LIB-80 Commands To run LIB-SO, type LIB followed by a carriage return. LIB-80 will return the prompt "*" (with the DTC operating system·, the prompt is ">"), indicating it is ready ·to accept commands. Each command in LIB-80 either lists information about a library or adds new modules to the library under construction. Commands to LIB-80consists of an optional destination filename which sets the name of the library being created, followed by an equal sign, followed by module names separated by commas. The default destination filename is FORLIB.LIB. Examples: *NEWLIB=FILE1 , FILE3,TEST *SIN,COS,TAN,ATAN Any command specifying a set of modules concatenates the modules selected onto the end of the last destination filename given. Therefore, *FILE1,FILE2 , TEST isequivalent to *FILE1 *FILE2 *TEST 3. 1 • 1 Modules A module is typically a FORTRAN or COBOL subprogram, main program or a MACRO-80 assembly that contains ENTRY statements a The primary function of LIB-80 is to concatenate modules in .REL files to form a new library. In Page 45 Microsoft Utility Software order to extract modules from previous libraries or .REL files, a powerful syntax has been devised to specify ranges of modules within a .REL file. The simplest way to specify a module within a file is simply to use the name of the module. For example: SIN But a relative quantity plus or minus 255 may be used. For example: also SIN+1 specifies the module after SIN and SIN-1 specifies the one before it. Ranges of'modules may also be two dots: specified by using •• SIN means all modules up to and including SIN. SIN •• means all modules from SIN to the end of the file. SIN •• COS means SIN and COS and all the modules in between. Ranges of modules and relative offsets may also used in combination: be SIN+1 •• COS-1 To select a given module from a file, use the name of the file followed by the module(s) specified enclosed in angle brackets and separated by commas: FORLIB or MYLIB.REL or BIGLIB. REL etc. If no modules are selected from a file, then all • Microsoft Utility Software Page 46 the modules in the file are selected: TESTLIB.REL 3.2 LIB-80 Switches A number of switches-are used to control LIB-80 operation. These switches are always preceded by a slash: 3.3 /0 Octal - set Octal typeout mode for /L command. /H Hex - set Hex typeout mode for /L command (default). /u List the symbols which would remain undefined o~ a search through the file specified. /L List the modules in the files specified and symbol definitions they contain. /e (Create) Throwaway the library under construction and start over. /E Exit to CP/M. The library under construction (.LIB) is revised to .REL and any previous copy is deleted. /R Rename - same as /E but does not exit to CP/M on completion. LIB-80 Listings To list the contents of a file in format, use /L: cross reference *FORLIB/L When building libraries, it is important to order the modules such that any intermodule references are "forward." That is, the module containing the global reference should physically appear ahead of the module containing the entry point. Otherwise, LINK-80 may not satisfy all global references on a single pass through the library. Use /U to list the symbols which could be undefined in a single pass through a library. If a module in the library makes a backward reference to a symbol in another module, /U will list that symbol. Example: Page 47 Microsoft Utility Software *SYSLIB!U NOTE: Since certain modules in the standard FORTRAN and COBOL systems are always force-loaded, they will be listed as undefined by /U but will not cause a problem when loading FORTRAN or COBOL programs. Listings are currently always sent to the terminal; use control-P to send the listing to the printer. 3.4 Sample LIB Session A>LIB *TRANLIB=SIN,COS,TAN,ATAN,ALOG *EXP *TRANLIBoLIB/U *TRANLIB.LIB/L (List of symbols in TRANLIB.LIB) */E A> 3.5 Summary of Switches and Syntax /0 /H /u /L /e /E /R Octal - set listing radix Hex - set listing radix List undefineds List cross reference Create - start LIB over Exit - Rename .LIB to .REL and exit Rename - Rename .LIB to .REL module::=module name 1+ or - number} module sequence ::= module I .. module I module •• I module1 •• module2 file specification: :=filename 1 1, FSO , =M&'{1 This command compiles the source file MAX1.FOR without producing an object or listing file. If necessary, return to the editor and correct any syntax errors. To compile the source file and and listing file, type produce an object A>F80 MAX1,r-iAX1=MAX1 or A>F80 =MAX1/L The compiler will create a REL (relocatable) file called MAX1.REL and a listing file called M&'{1.PRNG Loading, Executing and Saving the Program (Using LINK-80) To load the program into memory and execute it, type Microsoft Utility Software Page 49 .. A>L80 r·1AX1/G To exit LINK-SO and save the memory code), type image (object A>L80 MAX1/E,MAX1/N When LINK-80 exits, three numbers will be printed: the starting address for execution of the program, the end address of the program and the number of 256-byte pages used. For example [210C 401A 48] If you wish to use the CPM SAVE command to save a memory image, the number of pages used is the argument for SAVE. For example A>SAVE 48 MAX1.COM NOTE CP/M always saves memory starting at 100H and jumps to 100H to begin execution. Do not use /P or /D to set the origin of the program or data area to 100H, unless program execution will actually begin at 100H~ object code file has now been saved on the disk under the name specified with /N or SAVE ~in this case MAX1). To execute the program simply type the program name An A> MAX 1 CPM - Available Devices A:, B:, C:, D: HSR: LST: TTY: disk drives high speed reader line printer Teletype or CRT CPM Disk Filename Standard Extensions FOR COB MAC REL PRN COM FORTRAN-SO source file COBOL-SO source file MACRO-SO object file relocatable object file listing file absolute file • Microsoft Utility Software Page 50 CPM Command Lines CPM command lines and files are supported; i.e., a COBOL-BO, FORTRAN-BO, MACRO-BO or LINK-aO command line may be placed in the same line with the CPM run command. For example, the command A>F80 =TEST causes CPM to load and run the FORTRAN-BO compiler, which then compiles the program TEST.FOR and creates the file TEST.REL. This is equivalent to the following series of commands: A>FSO *=TEST *AC A> 4.2 DTC Microfile Create a Source File Create -a source--lile using the DTC editor. Filenames are up to five characters long, with 1-character extensions. COBOL-SO, FORTRAN-BO and MACRO-BO source filenames should have the extension T. Compile the Source File Before attempting -ro- compile the program and produce object code for the first time, it is advisable to do a simple syntax check. Removing syntax errors will eliminate the necessity of recompiling later. To perform the syntax check on the source file called MAX1,type *FBO ,=MAX1 This command compiles the source file MAX1 without producing an object or listing file. If necessary, return to the editor and correct any syntax errors. To compile the source file MAX 1 object and listing file, type and produce an *F80 MAX1,MAX1=MAX1 or *F80 =MAX1/L/R The compiler will create a relocatable file MAX1.0 and a listing file called MAX1.L. called Loading, Executing and Saving the Program (Using LINK-SO) To load the program into memory and execute it, Microsoft Utility Software Page 51 type *L80 MAX1/G To save the memory image (object code), type *L80 MAX1/E which will exit from LINK-80, return to monitor and print three numbers: the address for execution of the program, address of the program, and the number of pages usedo For exampl~ the DOS starting the end 256-byte [210C 401A 48'] Use the DTC SAVE command to save For example a memory image. *SA MAX1 2800 401A 2800 2800H (24000Q) is the load address used by the Operating Systemo DTC NOTE If a /P:ADDRESS> or /D:ADDRESS> has been included in the loader command to specify an origin other than the default (2800H), make sure the low address in the SAVE command is the same as the start address of the program o An object code file has now been saved on the disk under the name specified in the SAVE command (in this case MAX1)o To execute the program, simply type *RUN MAX1 DTC Microfile - Available Devices DO:, D 1 :, D 2 :, D 3 : TTY: LIN: disk drives Teletype or CRT communications port DTC Disk Filename Standard Extensions T o L COBOL-aO, FORTRAN-aO or ~~CRO-aO source file relocatable object file listing file • Microsoft Utility Software DTC Command Lines DTC command lines are supported Section 4.1, CPM Command Lines. 4.3 Page 52 as described in Altair DOS Create a Source File Create a source file using the Altair DOS editor. The name of the file should have four characters, and the first character must be a letter. For example, to create a file called MAX1, initialize DOS and type .EDIT MAX1 The editor will respond CREATING FILE 00100 Enter the program. When .you are finished and editing the program, exit the editor. entering Compile the Source ~ Load the compiler by typing .Fao The compiler will return the prompt character "*" Before attempting to compile the program and produce object code for the first time, it is advisable to do a simple syntax check. Removing syntax errors will eliminate the necessity of recompiling later. To perform the syntax check on the source file called MAX 1 , type * ,=&MAX1 • (The editor stored the program as &MAX1) Typing ,=&MAX1. compiles the source file MAX1 without producing an object or listing file. If necessary, return to the editor and correct any syntax errors. To compile the source file MAX 1 object and listing file, type and produce an *MAX 1R , &MAX 1= &MAX 1 • The compiler will create a REL (relocatable) file called MAX1RREL and a listing file called &~mX1LST. The REL filename must be entered as five characters instead of four, so it is convenient to use the source filename plus R. Microsoft Utility Software Page 53 After the source file has been compiled and a prompt has been printed, exit the compiler. If the computer uses interrupts with the terminal, type Control C. If not, actuate the RESET switch on the computer front panel. Either action will return control to the monitor. Using LINK-SO Load LINK-aO by typing .LSO LINK-ao will respond with a "*" prompt. Load the program into memory by entering the name of the program REL file *MAX1R Executing and Saving ~ Program Now you are ready to e~ther execute the program that is in memory or save a memory image (object code) of the program on disk. To execute the program, type */G To save the memory image (object code), type */E which will exit from LINK-aO, return to monitor and print three numbers: the address for execution of the program, address of the program, and the number of pages used. For example the DOS starting the end 256-byte [26301 44054 35] Usethe DOS SAVE command to save Type • SAV MAX1 a memory image. a 17100 44054 26301 17100 is the load address used by Altair DOS for the floppy disk. (With the hard disk, use 44000.) An object code file has now been saved on the disk under the name specified in the SAVE command (in this case MAX1). To execute the program, simply type the program name .HAX1 • M~crosoft utility Software Page 54 Altair DOS - Available Devices FO:, F1:, F2:, ••. TTY: disk drives Teletype or CRT Altair DOS Disk Filename Standard Extensions FOR COB MAC P~L LST FORTRAN-aO source file COBOL-aO source file MACRO-80 source file relocatable object file listing file Command Lines Command lines are not supported by Altair DOS. 4.4 ISIS-II Create a Source File Create a source =rile using the ISIS-II editor. Filenames are up to six characters long, with 3-character extensions. FORTRAN-a a source filenames should have the extension FOR and COBOL-SO source filenames should have the extension COB. MACRO-SO source filenames should have the extension MAC. Compile the Source File Before attempting ~ compile the program and produce object code for the first time, it is advisable to do a simple syntax check. Removing syntax errors will eliminate the necessity of recompiling later. To perform the syntax check on the source file called MAX1.FOR, type -FSO ,=MAX1 This command compiles the source file MAX1.FOR without producing an object or listing file. If necessary, return to the editor and correct any syntax errors. To compile the source file MAX1.FOR and produce object and listing file, type an -FSO MAX1,MAX1=MAX1 or -FSO =MAX1/L/R The compiler will create a REL (relocatable) file called MAX1.REL and a listing file called MAX1.LST. Microsoft Utility Software Page 55 Loading, Saving ~ Executing the Program (Using LINK-80) To load the program into memory and execute it, type -L80 MAX1/G To save the memory image (object code), type -L80 ~UlX1/E,MAX1/N which will exit from LINK-80, return to the ISIS-II monitor and print three numbers: the starting address for execution of the program, the end address of the program, and the number of 256-byte pages usedo For example [210C 401A 48] file has now been saved on the disk name specified with /N (in this case An object code under the MAX1). ISIS-II - Available Devices :FO:, :F1:, :F2:, ••• TTY: LST: disk drives Teletype or CRT line printer ISIS-II Disk Filename Standard Extensions FOR COB MAC REL LST FORTRAN-80 source file COBOL-80 source file MACRO-80 source file relocatable object file listing file ISIS-II Command Lines ISIS-II command lines are supported as described in Section 4.1, CPM Command Lines. • Microsoft Utility Software Page 56 Index .8080 • • • • COMMENT • .CREF • • • .DEPHASE • .LALL • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • .LIST • • • • • • • • • .PAGE • • • • • • • • • .PHASE • • • • • • • .PRINTX • • • • • • • • .RADIX • • • • • • • • • REQUEST • • • • • • .SALL • • • • • • • • • .XALL • • • • • • • • • • XC REF • • • • • • • • .XLIST • • • • • • • • .Z80 • • • • • • • • Absolute memory • • • Altair •• ••• • Arithmetic operators ASEG •• •• • Block pseudo ops • • • • • • • • • • • • • • • • • • 10, 12, 33 • • 6, 52 • • 10 • • 11-12, 21 • • • • 22 Character constants • • Code Relative • • • • • Command format • • • Comments • • • • • • • • CO~.MON • • • • • • • • Conditionals • • • • • • Constants • • • • • • • • CP/M • • • • • • • • Cross reference facility CSEG • • • • • • • • • Data Relative • • Define Byte • • • Define Character Define Origin • • Define Space • • Define Word • • DSEG • • • • • • DTC. •••• • EDIT-80 • • • ELSE • • • END • • • • ENDIF •• • • ENDM ENTRY • EQU • • • Error codes • • Error messages 0 18 17 20 22 20 20 32 22 17 8, 18 18 20 20 20 20 18 9 13, 21-22, 33 5, 36, 44 8 11, 13, 21-22, 33-34 19 8 37, 48 20, 33-34 11, 13, 21, 32 • • • • 10, 14, 20-22, 33 • • • • 8, 13 • • • • 14 • • • • 16 • • • • 14 • • • • 14 • • • • 11, 14, 21, 32 • • • 5, 36, 44, 50 • • • • o 7, 32 • • • • • 19 15 • • 19-20 • • • • • 22, 26 • 15, 44 o o o • • • 15-16 30, 33 o • 31, 41 o • • · EXITM • • • • • 26 EXT • 15 • • • • • • • Externals 11, 15, 30, 33 • • • EXTRN • 15 • • • • • · IF IF1 , • IF2 ~ IFB • • IFDEF • IFE IFF • • IFNB • IFT • INTEL • IRP • • IRPC ISIS-II · · • • • • • • • • • • • • • • • • • • • • • • • • • • • .. • • • • • • • • • • • • • • • • • • • • • • • • • · • • • • 19 • • 19 • • • • • • • • • • • • • • • · · Library manager • Listings • • • LOCAL • • • • • • Logical operators • • · · MACRO · Macro operators • · Modes • • • Modules· · • • NAME • • • • Operating system Operators • • • ORG • • • • · • • • • • 44 20, 32-33, 35, 46 27 10 ·· 20, 27 • 10 · 44 22-26 16 • • • • • 19 19 19 19 19 19 19 6, 31-32 20, 22, 24 20, 22, 24 38, 54 · 48 10 12-14, 16, 21 PAGE • • • • • • 16, 31 Program Relative • • • • 10 PUBLIC • • • • • • • 7, 15, 33 REPT • • • • • SET • • • • • Strings • • SUBTTL • • • Switches • Symbol table • • • • • · • . TITLE • • • • • • 20, 22-23 • • • • • • • • • • • • • 16 • • • 9 • • • 16, 31-32 • • 6, 37, 46-47 • • • 32-33 • • • 16-17, 32 / • SERVICE INFORMATION I Plfit .1 s t- ~A-6+ S'rOP - SoVtevl-z ~ \4+ tIJ/'rJ :3 c> r L\ 131 001(5 - Actte ReP - S..jo(J S J<7 trv.;) \e}-}-vN -r .b \OC)C ~e-ft-o~ CO{'Ne.r 1Pc2t/OS Sf: (ovis J;;fb S'tS 3/ Lf-43c. -.Ji8 I (;Jesl-po{)..f Ce;Jle.r llrO -e ~ Vlceeo - 15 9DW S.Jf - 11'15 C~ v ~1:f;.2, r2.5 ~\veJ - ~tlSo 'Pf-. Page 1 SERVICING PROCEDURES Your SuperBrain Video Terminal is warranted to the original purchaser for 90 days from date of shipment. This warranty covers the adjustment or replacement F.O.B. Intertec's plant in Columbia, South Carolina of any part or parts which in Intertec's judgment shall disclose to have been originally defective. A complete statement of your warranty rights is contained on the inside back cover of this manual. In order to validate your SuperBrain warranty, the Warranty Registration Form (contained in this section) must be completed in full and returned to Intertec Data Systems within 10 days of receipt of this equipment. Be sure to include the serial number of the specific terminal you are registering. The serial number of your terminal can be found on the rear 1/0 panel next to the power cord. A Customer Comment Card is also enclosed for your convenience if you desire to make comments regarding the overall operation andlor adaptability of the SuperBrain to your particular application. Completion of the Customer Comment Card is optional. IF SERVICE IS EVER REQUIRED: If you should encounter difficulties with the use or operation of this terminal, contact the supplier from whom the unit was purchased for instructions regarding the proper servicing techniques. Service procedures differ from dealer to dealer but most Intertec authorized service dealers can provide local, on·site servicing of this equipment on a per-call or maintenance contract basis. Plus, a variety of service programs are available directly from the factory including extended warranty, a module exchange program and on-site contract maintenance from over 50 locations in the U.S. Contact our National Service Department at the factory for rates and availability if you desire to participate in one of these programs. If you are not covered under one of the three programs described above and service cannot be made available through your local supplier, contact Intertec's Customer Service Department at (803) 798-9100. Be prepared to give the following information when you call: 1} The serial number of the equipment which is defective. If you are returning individual modules to the factory for repair, it will be necessary to have the serial number of the individual modules also. The serial number of the entire terminal may be found on the rear 1/0 panel just to the right of the power cord. Module serial numbers are listed on white stickers placed in conspicuous locations on each major module or subassembly of the terminal. NOTE: Individual modules cannot be returned to the factory for repair unless you originally purchased your unit directly from the factory. If your unit was purchased through a Dealer or OEM vendor, and you desire factory repair, then the entire terminal must be returned. 2} The name and location of the Dealer andlor Agent from which the unit was purchased. 3) A complete description of the alleged failure (including the nature and cause of the failure if readily available). The Customer Service Department will issue you Return Material Authorization Number (RMA Number) which will be valid for a period of 30 days. This RMA ~umber will be your official authorization to return equipment to IDSC for repair only. The Customer Service Department will also give you an estimate, if requested, of the time it should take to process and repair your equipment. Turnaround time on repairs varies depending on workloads and availability of parts but normally your equipment will be repaired and returned to you within 10 working days of its receipt. If your repair is urgent, you may authorize a special $50 Emergency Repair fee and have your equipment repaired and returned within no more than 48 hours of its receipt at our Service Center. Ask the Customer Service Department for more information about this program. • Page 2 SERVICING PROCEDURES (continued) IMPORTANT: Any equipment returned to Intertec without an RMA Number will result in the equipment being refused and possible cancellation of your SuperBrain warranty. Also if ,Your RMA Number expires, you must request a new number. Equipment arriving at Intertec bearing expired RMA Number will also be refused. After securing an RMA Number from the Customer Service Department, return the specified modules and/or complete terminals to Intertec, freight prepaid, at the address below. NOTE: The RMA Number must be plainly marked and visible on your shipping label ,to prevent the equipment from being refused at I ntertec's Receiving Department. ATTN: SUPERBRAIN SERVICE CENTER I ntertec Data Systems Corporation 2300 Broad River Road Columbia, South Carolina 29210 To aid our technicians in troubleshooting and correcting your reported malfunction, please complete an Intertec Equipment Malfunction Report (contained in this section) and enclose it with the equipment you intend to return to the factory. Be sure a declared value equal to the price of the unit is shown on the Bill of Lading, Express Receipt of Air Freight Bill, whichever is applicable. Risk of loss or damage to equipment during the time it is in transit either to or from I ntertec's facilities is your sole responsibility. A declared value must be placed on your Bill of Lading to insure substantiation of your freight claim if shipping damage or loss is incurred. All equipment returned to an Intertec Service Center must be freight prepaid. Equipment not prepaid on arrival at I ntertec's Receiving Department cannot be accepted. Upon repair of the defective equipment, it will be returned to you, F.O.B. the factory in Columbia, via UPS or equivalent ground transportation unless you specify otherwise. INSTRUCTIONS FOR HANDLING LOST OR DAMAGED EQUIPMENT The goods described on your Packing Slip were delivered to the Transportation Company at Intertec's premises in complete and good condition. If any of the goods called for on this Packing Slip are short or damaged, you must file a claim WITH THE TRANSPORTATION COMPANY FOR THE AMOUNT OF THE DAMAGE AND/OR LOSS. IF LOSS OR DAMAGE IS EVIDENT AT TIME OF DELIVERY: If any of the goods called for on your Packing Slip are short or damaged at the time of delivery, ACCEPT TH EM, but insist that the Freight Agent make a damaged or short notation on your Freight Bill or Express Receipt and sign it. IF DAMAGE OR LOSS IS CONCEALED AND DISCOVERED AT A LATER DATE: If any concealed loss or damage is discovered, notify your local Freight Agent or Express Agent AT ONCE and request him to make an inspection. This is absolutely necessary. Unless you do this, the Transportation Company will not consider your claim for loss or damage valid. If the agent refuses to make an inspection, you should draw up an affidavit to the effect that you notified him on a certain date and that he failed to make the necessary inspection. After you have ascertained the extent of the loss or damage, ORDER THE REPLACEMENT PARTS OR COMPLETE NEW UNITS FROM THE FACTORY. We will ship to you and bill you for the cost. This new invoice will then be a part of your claim for reimbursement from the Transportation Company. This together with other papers, will properly support your claim. • Page 3 SERVICING PROCEDURES (continued) IMPORTANT: The claims adjustment procedure for UPS shipments varies somewhat from the procedure listed above for regular motor and air freight shipments. If your equipment was shipped via UPS and sustained either damage or loss, the UPS representative in your area must initiate the claim by inspecting the goods and assigning a freight claim number to the damaged equipment. The representative will attach a "Call Tag" to the outside of the equipment box which will be your authorization to return the merchandise to our factory for claim adjustment. Upon receipt of this damaged equipment, we will perform the necessary repairs, process the appropriate paperwork with UPS and return the equipment to you. Please allow time for processing of any type claim. Normal time for proper processing of a UPS claim is 15-30 working days. Remember, it is extremely important that you do not give the Transportation Company a clear receipt if damage or shortages are evident upon delivery. It is equally important that you call for an inspection if the loss or damage is discovered later. DO NOT, UNDER ANY CIRCUMSTANCES, ORDER THE TRANSPORTATION COMPANY TO RETURN SHIPMENT TO OUR FACTORY OR REFUSE SHIPMENT UNLESS WE HAVE AUTHORIZED SUCH RETURN. ADDITIONAL TECHNICAL DOCUMENTATION Detailed technical documentation (i.e. schematics) describing the operation of the SuperBrain Video Terminal and the electrical interconnection of its various modules is available at nominal cost directly from Intertec Data Systems Corporation. However, due to the confidentiality of this technical information, it will be necessary to sign and return the Documentation Non-Disclosure Agreement (appearing on the next page) denoting your concurrence with its terms and conditions. The handling and processing costs of SuperBrain technical documentation is $50. Due to the large amount of requests being processed and the relatively small handling costs involved, we must request that you enclose payment ($50) upon return of your Non-Disclosure Agreement. Normally the documents will be mailed to you within 15 to 30 days after receipt of your payment and a signed copy of the Agreement. (IMPORTANT: The technical documentation will be mailed to the address listed at the top of the Non-Disclosure Agreement.) For prompt processing of your documentation request, please forward your signed agreement and payment to: Customer Service Department I ntertec Data Systems Corporation 2300 Broad River Road Columbia, South Carolina 29210 NOTE: Formal technical documentation for the SuperBrain will be sent to you normally within 10-15 days of receipt of your payment and signed Non-Disclosure agreement. IMPORTANT: Payment must accompany your Non-Disclosure Agreement. Agreements sent to us without payment will be discarded without notice. • HARDWARE ADDENDUMS I d[ =i11~= INTEJLJ1Q.dul~:.=s,-,-._________________ PRODUCT .._...S.up.ex6cQ.i.R.....__ ......__.. __._DATE ___ JalJ.u~a.,,~_80 Eco#_J!l0004_ PAGE 1 OF 1 ASSEMBLY NAME/NUMBER_._._J~S!.Y.I?'parQLCPU Modul e BACKGROUND AND IMPLEMENTATION INFORMATION: Standard SuperBrain terminals are supplied with 32K dynamic RAM but can be expanded to 64K. The instructions below detail the proper installation of the optional 32K RAM expansion kit. INSTALLATION: 1) Remove cover and locate RAM bank at upper left corner of Keyboard/CPU Module. (See Figure 1) 2) Install all sixteen RAM chips in the two upper rows of eight sockets each being careful to notice that all the chips are inserted correctly. (NOTE: The notch on each chip should be pointing toward the top of the board.) 3) After all sixteen RAM chips have been installed, find the small bare wire jumper located between the two chips designated 174LS157 1 and 174LS155 1. (See Figure 1) 4) Cut the LEFT end of the jumper (end closest to the 174LS157 1) and reconnect it to the pad just to the RIGHT of the other end (the two pads are approximately 0.111 apart). Installation of the additional 32K is now complete. Figura 1 - Location of SuperBrain RAM Bank Install extra 32K of RAM into these 1 sockets (8 sockets each row) 16 RAM chips are required to enable the extra 32K memory. Remove and reconnect jumper located in' this area OPERATION: To operate the SuperBrain with 64K, insert a DOS diskette (configured for 64K) into drive A. The sign-on message must read as follows: 64K SUPERBRAIN DOS VER A IMPORTANT: Do not attempt to operate the unit with a DOS Diskette configured for 32K. It will not work properly in a 64K machine. The program which allows for configuration of the SuperBrain in 32 or 64K of RAM is entitled ICPM6420.COM 1 and is contained on your CP/M DOS Diskette. The CP/M program MOVCPM, which reconfigures the size of the Disk Operating System, is not supplied on the DOS diskette. Intertec offers only two RAM configurations - 32K and 64K - so there should be no need to reconfigure the operating system to any other size. See reverse side for additional information IDS-910A THIS ENGINEERING CHANGE ORDER AFFECTS: DMATERIAL(S) /COMPONENTS(S) USED DPACKAGING/SHIPPING DPRODUCTION PROCEDURES ~SERVICING/PROCEDURES THIS CHANGE DOTHE~---------------------------- PREVENTS:~~ CHANGE FROM: 32K SuperBrain Operation CHANGE TO: 64K SuperBrain Operation INITIATED BY: THIS ECO DISTRIBUTED TO: KIT AND ORDERING INFORMATION o ENGINEERING KIT AVAILABLE? o OPERATIONS KIT N UM B E R___9_r.9~r o QUALITY ASSURANCE o SHIPPING & RECEIVING ~ CUSTOMER SERVICE PRICING: ... 0 YES 0 NO ___by ._c1~~_GI:iptjQI1._.______ ._. 1~50.fQL3tclcljttQnQJ_JfIL8l:\~L __ .. ......._1.•.O.• B .•. .fa ctoJ'y,_CoJumbj 9,L.S, C. ~ MARKETING ~ FIELD SERVICE o CUSTOM E R LIST ~ CUSTOMER AS REQUESTED CONTACT THE CUSTOMER SERVICE DEPARTMENT AT THE NUMBER AND ADDRESS ON REVERSE SIDE TO OBTAIN FURTHER INFORMATION AND/OR TO ORDER THIS KIT. SOFTWARE ADDENDUMS I SUPERBRAIN DOS 3.0 DESCRIPTION DOS 3.0 has two major differences from the previous versions of SUPERBRAIN DOS. First, DOS 3.0 incorporates CP/M 2.2 and secondly, the physical sector length of the diskette has been changed from 128 bytes/sector to 512 bytes/sector. An increased diskette capacity (40 kilobytes per diskette) is the result of these alterations. . The updated DOS requires the use of a VERSION 3.0 or higher PROM Bootloader. The version number can be easily verified by performing a system reset with no diskettes in the drives. The version number will be displayed in the sign-on message. Also included on this diskette are four different operating systems to facilitate the copying of 128 byte/sector diskettes to 512 byte/sector diskettes. They are the following: 32CPM5/5.COM - 32K DOS; Disk A is 512 bytes/sector; Disk B is 512 bytes/sector 32CPM5/1.COM - 32K DOS; Disk Disk 64CPM5/5.COM - 64K DOS; Disk Disk A is 512 bytes/sector; B is 128 bytes/sector A is 512 bytes/sector; B is 512 bytes/sector 64CPM5/1.COM - 64K DOS; Disk A is 512 bytes/sector; Disk B is 128 bytes/sector The distribution copy is initialized as a 64K system with both disk drives programmed to accept a 512 byte/sector diskette. This was done so a copy of the distribution diskette can be easily made before attempting to change operating systems. NOTE: THE STANDARD SUPERBRAIN IS SHIPPED WITH A 32K MEMORY. . . THEREFORE, A 32K DOS MUST BE GENERATED BEFORE PERFORMING ANY FILE MANIPULATIONS. RECOMMENDED OPERATING PROCEDURES To insure that the proper operating system for your SUPERBRAIN version is utilized, the following procedure should be performed. This procedure describes the generation of an operating system on a newlyformatted diskette. 1) Insert a blank diskette into Disk B. 2) Format the diskette using the FORMAT30.COM program. Type 'FORMAT30' (Return) NOTE: DRIVE B CAN ONLY BE FORMATTED IF IT IS NOT DESIGNATED AS A 128 BYTE/SECTOR DRIVE. 3) Select one of the two 512/512 operating systems and put it on Disk B. EXAMPLE: If you have a 32K system and you want to copy the distribution diskette, do the following: Type '32CPM5/5' (RETURN) System responds with 'SOURCE DRIVE NAME (OR RETURN TO SKIP) Type RETURN .System responds with DESTINATION DRIVE NAME (OR RETURN TO REBOOT) Type 'B' System responds with DESTINATION ON B, THEN TYPE RETURN Type RETURN When function is complete, type RETURN. 4) Remove the diskettes and interchange them in the drives. 5) Do a system reset. The system should sign-on with the generated DOS message. 6) Copy the programs from Disk B to Disk A using the PIP program. Now that a back-up copy has been generated, anyone of the four operating systems can be put on disk A by following the above procedures and using Disk A as the destination. To copy 128 byte/sector diskettes to a 512 byte/sector diskette, use either 64CPM5/1.COM or 32CPM5/1.COM. Put the 512 byte/sector diskette in Disk A and the 128 byte/sector diskette in Disk B. 32K BIOS PROGRAM The BIOS portion of the DOS is supplied as a source program (32BS5/5.ASM) to facilitate the modification of the software drivers for peripheral devices. This program can be edited, assembled, and integrated into the DOS. Any extra routines should only be added in the designated area of the BIOS program. SOFTWARE/HARDWARE COMPATIBILITY DOS 3.0 can only be operated on SUPERBRAIN units that have a REV-01 processor PC Board, and then only certain REV-01 boards quality. If your system does not have a REV-01 board, then DOS 3.0 cannot be used on that system. However, REV-01 boards that do not qualify can be factory retrofitted to support DOS 3.0. To determine if your machine can support DOS 3.0 software, it is necessary to visually inspect the Processor board. This is done in the following manner: 1) 2) 3) 4) Remove power from unit. Close door on disk drives. Remove cover by removing four screws. (2-front, 2-rear) To determine if the board is at the correct revision "level, the number 1532000-01 should be on the top right hand corner of the board and there should be two blue ribbon-cable connectors mounted on the board. If the board does not meet both conditions, it will not support DOS 3.0 5) If the board is REV-01, one more condition must be met. There should not be a 35391 or 35392 IC installed in the location shown in the diagram on the attached page. If an IC is present in that location and you would like to use DOS 3.0, contact the factory for pricing and scheduling. WHITE CONNECTOR ****. * * 5·POSITION QIP SWITCH (BLUE) * * *..* * * * * * * * * *..* 74LS245 ******* * 35391 OR 35392 ..***** Direct all inquiries to: CUSTOMER SERVICE INTERTEC DATA SYSTEMS 2300 BROAD RIVER ROAD COLUMBIA, SC 29210 TELEPHONE: 803/798-9100 NTHTEC' J ,/I,C IOI\TI\ ® ~~~H~adqUarters: TECHNICAL 8ULLETIN IDS - 912A 2300 Broad River Road, Columbia, South Carolina 29210.803/798-9100. TWX: 810-666-2115 ----;-J--. , ASSEMBLY NAME/NUMBER.__ DOSJ;ttSK~IIJ;____.__________.____ PRODUCT _SLLPer6.ra in REFERENCE Eco#_._.__~LA DISTRIBUTED TO________ APPROVE!!J-------- USING THE IIINP: II AND 1I0UT:1I FEATURES OF PIP TO FACILITATE FILE TRANSFERS TO AND FROM THE SUPERBRAIN The SuperBrain is presently equipped with one RS-232-C serial interface port (labeled IMain l on the rear panel). This interface is programmed for the following mode: 1 Ae-llla l1 y 'l'his A\Jx. Poco( Pro::.drlrt 5!)p-Prbr-c: ;r1 <; -GJ,o!;..f Asynchronous 1200 Baud 8 bits 1 Stop Bit No Parity This port is also wired so that the SuperBrain appears as a processor rather than as a terminal. If it is to be used as a terminal, pins 2 and 3 in the RS-232-C cable must be interchanged. Files can be transferred using the PIP program as described in Section 6.4 of the Operator1s Manual entitled IIAn Introduction to CP/M Features and Facilities. II When the SuperBrain transmits serial data, the destination is designated as a list (LST:) device; when receiving, the source device is considered a reader (RDR:). The serial port may also be considered as an input (INP:) or output (OUT:) port. When used in this mode, the operator has the option of communicating to the sending/receiving device via the SuperBrain console before actual files are transferred. Files transferred via the serial port must be in Intel hex format or ASCII. Binary files must be converted to hex files by utilizing the HEXGEN.ASM program before being sent to the SuperBrain. BASIC files must be saved in the ASCII format it they are to be trangferred to the serial interface. (NOTE: 'When ASCII files are transferred using the INP: or OUT: format, all data entered by the Operator on the console will also appear in the ASCII file. Undesired data must then be edited by using ED. COM). Sequence of Operation: 1. Connect SuperBrain MAIN port to console input of host computer. Be sure host computer is set to 1200 baud. 2. The largest program that can be transferred by PIP is 25K. If programs are larger than 25K, then programs most be broken down into smaller segments 25K or smaller. 3. All commands must be entered on the SuperBrain in the following sequence: Contact the Customer Service Department at the address above for additional information on this bulletin. ~F INTE~TEC ~ ~. ~t;:'!;!'dq"'rt'rt, 8,~d R~d. 2300 Co'"mb". S,"," C,,,Ii,, 2921 0 • 803/798-9100 • TWX, 810-666-2115 November', 1979 DATE OF THIS RELEASE .. PAGE 'DS - 91,. .2 ... oF6.BULLETIN #_...~U.~.O~~._.___._ ...._..... DOS DISKETTE ASSEMBLY NAME/NUMBER REFERENCE ECO# R ;'" TECHNICAL BULLETIN N/A DISTRIBUTED TO . A. To transfer ASCII file - ABC. ASM - from SuperBrain to host: A> PIP OUT: = ABC. ECHO (YIN) 'i ASM~ I?- + (Keyboard (Computer (Keyboard (Computer entry) responds) entry) responds) Now the SuperBrain will act like a dumb terminal for host computer. Any keyboard entry will be sent to host computer and displayed on screen. + PIP ABC.HST = CON:) (CTRL) (B) (Keyboard entry) (Computer responds) (Keyboard entry - these two keys at the same time) NOTE: Underlined characters are typed by customer. I~ represents a carri age return. II Now the file is being transferred and should be displayed on the screen. When the file has been transferred the operating system will show the prompt symbol. A> PIP OUT: = EOF: ECHO (YIN) 'i ~ + (CTRL) (B) (Keyboard entry) (Computer responds) (Keyboard entry) (Computer responds) (Keyboard entry - these two keys at the same time) Now the file transfer has been completed; both computers should return to the operating system. B. To transfer binary file - ABC.COM - from SuperBrain to host: A> PIP ABC.TST = ECHO (YIN) 'i INP:~ + (Keyboard (Computer (Keyboard (Computer entry) responds) entry) responds) Now the SuperBrain will act like a dumb terminal for the host computer. Any keyboard entry will be sent to the host computer and displayed on the screen. + PIP ABC.HEX = CON:) (Keyboard entry) Contact the Customer Service Department at the address above for additional information on this bulletin. JIIC ~~ INTE~TEC TECHNICAL BULLETIN DATA @ ~r~!~t~adqUartars: 2300 Br~ad IOS-912A River Road, Columbia, South Carolina 29210.803/798-9100. TWX: 810-666-2115 . November,J979 ... _.PAGE DATE OF THIS RELEASE ASSEMBL Y NAME/NUMBER __._.D.O~.PJSKEJI~ .... __ REFERENCE ECO#... -" NIp.. .. ...3... 0F ... P .... ...... ......_ ._ .. DISTRIBUTED TO ........ '" ... BULLETIN #.JH19004 ______. _ PRODUCT _._S1JR~.r.er.i:llr:L'· ____ ~;I·_' --.--..--.--.--.. _---.. -...-.--APPROVEoJ{.-.... , NOTE: The binary file on the SuperBrain will be transferred in INTEL HEX format. After the transfer use LOAD or DDT and SAVE to change. HEX file to a binary, COM file. (CTRL) (Z) End of file, Control Z? (CTRL) (Z) (Keyboard entry - these two keys at the same time) (Computer responds) (Keyboard entry - these two keys) Now the host computer is set up to input a file. The SuperBrain will return to the operating system with its prompt. (Keyboard entry) A> HEXDUMP ABC. COM) At this point the file will be transferred in HEX format and displayed on the screen. When the transfer is complete the SuperBrain will return to the operating system. C. To transfer ASCII file - ABC.PRN - to SuperBrain from host: A> PIP AB C. PRN ECHO (YIN) Y = IN P:.) ,. + (Keyboard (Computer (Keyboard (Computer entry) responds) entry) responds) Now the SuperBrain is ready for input from host. The keyboard entry will be sent to the host and displayed on the screen. Now set up commands to output from the host. + PIP CON: = ABC.PRN; (Keyboard entry) The file ABC.PRN on the host is now being input to the SuperBrain and displayed on the screen. After the file has been transferred, the SuperBrain should return to the operating system; if it does not, then type (CTRL) (Z) simultaneously. D. To transfer binary file - ABC. COM - to SuperBrain from host: (NOTE: Before transferring to SuperBrain, either HEXGEN.ASM or HEXDUMP.COM must be transferred to the host.) .~~.~ IIsXDI),o;t{:! t7tdW Pp·..."'=R: ~q:: A L\6TII~"I::-' FILE- jrd flSe-E: (t-&jo..qC ~ etivtvcdlii7t+ of ~) Nffn::: Pt:61&A).4 T E' PIP ABC.HEX = INP: [H] ECHO (YIN) Y .~ ,F'" + (Keyboard (Computer (Keyboard (Computer entry) responds) entry) responds) Now the SuperBrain ready to accept input. NOTE: Since a binary file is transferred in INTEL HEX format, the .HEX file on the SuperBrain can be changed using LOAD or DDT and SAVE, to a binary fi 1e. (Keyboard entry) + HEXDUMP ABC. COM; The file is now being transferred and also displayed on the screen. When the transfer is complete, the SuperBrain will return to the operating system. 2) Using HEXGEN. ASM Look at source listing: ORG 6000H LXI LXI LXI SP 6400H 0, 6000H H, 100H *ending address *beginning address The origin and the SP will need to be modified for your particular system. (For example: 32K system use ORG 5000H~ and SP, 5400H.) You may also change H,D to suit program size; register H is loaded with the end address of the program to be transferred and register o has the beginning address (most programs begin at 100H). Now run assembler to generate HEXGEN.HEX. You are ready to begin. A> PIP ABC.HEX = INP: ECHO (Y IN) Y + [H] -;. (Keyboard (Computer (Keyboard (Computer entry) responds) entry) responds) At this point the SuperBrain is ready for input and the host must be set up to output the HEX file. +.llilI P- Verslon 1.4 .,. (Keyboard entry) (Computer responds) Contact the Customer Service Department at the address above for additional information on this bulletin. =;till? d . . INTE~ DATA ~ ® TECHNICAL BULLETIN IDS-912A ~~~H~adqUarters: 2300 Broad'RiverRo~d, Columbia, South Carolina 29210. B03/798-9100 • TWX: 810-666-2115 DATE OF THIS RELEASE ...-NoYE:In.ber,__ 1912 ______ PAGE_. §.__ OF __§'__ BULLETIN #~119004___.._. ____ ASSEMBLY NAME/NUMBER-..___.. RQ.?_ ..QlS_KUIl_____ .__.___._____ PRODuCT_ilu.perBr.§i n REFERENCE ECO#~..___ . _. ._tlLA.__._.. __ ..___ .. DISTRIBUTED ~~T-' TO..____ ......._____________ APPROVED.;jf-___ Now we have loaded DDT into the host system. - IABC. COM ;. -RJI.. NEXT PC DADO 0100 -IHEXGEN.HEX;. .:B..')' NEXT PC 60B8 0100 (Keyboard entry) (Computer responds) (These two numbers are the end and starting address) (Keyboard entry) (Computer responds) At this point the host computer has 2 programs loaded into memory, one above the other. One is the program to be transferred and the other to generate the INTEL HEX format. -G6000 ;. (Keyboard entry) (The number is the same as ORG in the source listing) Now the file is being transferred and will be displayed on the screen. After the program has been transferred, the SuperBrain will return to the operating system. 3) To change back to a bi nar,t fi 1e, follow this ~rocedure: A> LOAD ABC. HEX ~ (Keyboard entry) LAST ADDRESS XXXX FIRST ADDRESS XXXX BYTES READ XXXX RECORDS WRITTEN XX (Computer responds) A> Now there are two fil es: A> DDT ABC.HEX:tl Version 1.4 Next PC ABCD 0100 (CTRL) (C) one HEX and one binary. or (Keyboard entry) (Computer responds) (Keyboard entry - both keys at same time) Contact the Customer Service Department at the address above for additional information on this bulletin. •..~~i Jllc: ~~ INTE(TEC DATA (iO) Q~TE TECHNICAL BULLETIN ~~~H~adqUarters: IDS-912A 2300 Broad River Road, Columbia, South Carolina 29210.803/798-9100 • TWX: 810-666-2115 November. 1979 OF THIS REI EASE ASSEMBLY NAME/NUMBER DOS NOTE: xx XX 6 OF 6 BU LLET IN # ....B"-"1......1..... 90,.,,0......4'--_ __ DISKETTE~________ PRODUCT .... ..s.up.eArp~Bp.rR.aojv~ED / REFERENCE Eco#:_ _ N/A A> SAVE PAGE DISTRIBUTED TO VEr;jf-- (Keyboard entry) ABG.COM;. =A times 16 + B under NEXT Now there are two files: one .HEX and one binary. Contact the Customer Service Department at the addres:: above for additional infnrmMinn nn thi.~ hI/lip-tin. DATE OF THIS RELEASE __~nuar. LIQ...LJ980 ASSEMBLY NAME/NUMBER___ PAGE Main Power SUDD 1y REFERENCE ECo#_.___NL8 __. _____ DISTRIBUTED TO 1 OF __l_BULLETIN # PRODUCT B010008 _._ Su~erBrain & Inter~Q~ I'nterTube & . SuperBrain Resellers 10/ APPROVED-jJ~W,--_. I COMPATIBILITY INFORMATION FOR REVISION 3 AND 4 OF THE INTERTUBE AND SUPERBRAIN MAIN POWER SUPPLY MODULE/ASSEMBLY Revision 4 of the SuperBrain Main Power Supply Module is compatible £rrll with Revision 1 of the SuperBrain Keyboard/CPU Module and any revision level of the InterTube Processor Module. Revisions 1 - 3 of the SuperBrain Main Power Supply can be used .Q!!.!y with Revision the SuperBrain Keyboard/GPU Module and any revision level of the InterTube Processor Module. o of CAUTION: Attempts by the customer to connect incompatible Power Supply Modules with either Keyboard/CPU Modules or Processor Modules will cause severe, irreparable damage to all modules connected in this manner. Since compatibility must be observed when interchanging modules, it is necessary for all customers to specify the revision level of any module which is r~quested to be sent from our Service Department prior to return of a defective module. Revision levels of all modules/subassemblies are listed as a suffix number of the standard Intertec module part number. Example: Intertec number 1424002-04 would specify revision level "4" of the SuperBrain Main Power Supply. Cont;,ct the Customer Service DeD8rtment;" the Rrfrlre!l!t Rhnvp. fnr IIrl,,;,ionai information '''' th;.~ hlllle,in. • Jlllic•~'~rt.n' DATE OF THIS RELEASE 2300 . _ R'w, R.... Co'"mb". S~'" eo..,,"" 292,0. January 10, ).J80_PAGE 1 ASSEMBLY NAME/NUMBER OF Keyboard/CPU Module 1 B03~'OO. :'E~,::: BU~~~r,I~ BULLETIN #~B~0.:!:.:10~0,!.!,0~9___-I-- PRODUCT. SuoerBrain REFERENCE Eco#_-=N/c..:.A"--____ DISTRIBUTED TO Manual s and as / regueste~PPROvED-jj,WiI/~__ ~r SUPERBRAIN CPU MODULE REVISION 1 SERIAL COMMUNICATIONS DIPSWITCH SETTING PROTOCOL Starting with Revision 1 of the SuperBrain Keyboard/CPU Module (all factory produced units effective January 10, 1980) there exists a small 5 position dipswitch located in the upper right hand corner of this module. This switch is used to control various clock parameters to and from the MAIN USART. For normal use these switches should be set as follows: 1 - OFF, 2 - OFF, 3 - ON, 4 - ON, 5 - OFF Listed below is a brief description of the function of each of these switches: 1- External TX Clock to MAIN USART - Originates from Pin #15 on MAIN RS232 connector at rear of terminal. 2 - External RX Clock to MAIN USART - Originates from Pin #17 on MAIN RS232 connector at rear of terminal. 3 - Internal TX Clock to MAINUSART - When on this switch enables the built-in baud rate generator (Western Digital BR-1941). NOTE: When this switch is in the 10N position switch 1 MUST be in the 10FF I position. I 4- Internal RX Clock to MAIN USART - When this switch is in the 10N I position switch 2 MUST be in the 10FF I position. 5- Internal Baud Clock to MAIN Port - This switch enables the transmission of the internal baud rate clock (Western Digital BR-1941) to the main RS232 port - this signal will appear on Pin #24 of the main port when this switch is in the ION I position. If this switch is not used, it should be left in the 'OFF I position to avoid any possible conflict with external RS232 signals. Contact the Customer Service Department at the address aboVe for additional information on this bulletin. STATEMENT OF LIMITED WARRANTY For ninety (90) days from the date of shipment from our manufacturing plant at 2300 Broad River Road. Columbia. South Carolina. Intertec warrants. to the original purchaser only. that its products. excluding software products. will be free of defective parts or components and agrees to replace or repair any defective component which. in Intertec's judgment. shall disclose to have been originally defective. Intertec neither offers nor implies any warranty whatsoever on any software praducts. Furthermore. Intertec's obligations under this limited warranty are subject to the following conditions: LIMITED WARRANTY REPAIRS Unless authorized by written statement from Intertec. all repairs must be done by Intertec at our plant in Columbia. South Carolina. Return of any and all ports and/or equipment must be freight prepaid and accompanied by on Intertec Return Material Authorization number which must be clearly visible on the customer's shipping label. Return of ports or equipment contrary to this policy sholl result in the material being refused. and the customer being invoiced for any replacement ports. if any were previously issued. at Intertec's standard prices. When making repairs or replacing parts in accordance with this limited warranty. Intertec reserves the right to alter and/or modify specifications of this equipment. Upon completion of the repairs. Intertec will return the equipment. freight collect. directly to the customer from whom it was sent via UPS or equivalent ground transportation. Authorization to return equipment for repair can be obtained by writing Intertec at the address stated herein or by colling our Customer Service Deportment at 803/798-9100. In the event Intertec shall authorize repair of its equipment. in writing. by on authorized repair agent. then Customer sholl bear all shipping. pocking. inspection and insurance costs necessary to effectuate repairs under this warranty. EXCLUSIONS The Limited Warranty provided by Intertec Data Systems Corporation does not include: (0) Any damage or defect caused by injuries received in shipment or any damage caused by unauthorized repairs or adjustments. The risk of loss or damage to the equipment sholl pass to the Customer upon delivery by Intertec to the carrier at Intertec's premises. (b) Repair. damage or increase in service time caused by failure to continually provide a suitable installation environment including. but not limited to. the failure to provide. or the failure of. adequate electrical power. air-conditioning. or humidity control. (c) Repair; damage or increase in service time caused by occident or disaster. which shall include. but not be limited to. fire. flood. water. wind. lightning. transportation neglect. misuse and alterations. which shall include. but not be limited to. any deviation from the original physical. mechanical or electrical design of the product. (d) Any statements made about the equipment by salesman. dealers or agents unless such statements are in a written document signed by an officer of Intertilc Data Systems Corporation. Such statements do not constitute warranties. sholl not be relied on by the buyer. and are not port of the contract for sale. (e) Any damage ariSing out of any application for its products other than for normal commercial and industrial use. unless such application is. upon request. specifically approved in writing by Intertec. Intertec products are sophisticated data processing units and are not sold or distributed for personal. family or household purposes. (f) Software. including either source code. object code or any computer program used in connection with our equipment. whether purchased directly from Intertec or from an independent source. WAIVER OF ALL EXPRESS OR IMPLIED WARRANTIES Our limited warranty to repair or replace defective parts or components for ninety (90) days after shipment from our Columbia plant is being offered in lieu of all express or implied warranties. INTERTEC MAKES NO EXPRESS WARRANTY OTHER THAN THE LIMITED WARRANTY SET FORTH ABOVE. CONCERNING THIS PRODUCT OR ITS COMPONENTS. NOR DO WE IMPLIEDLY WARRANT ITS MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. All statements. technical information and recommendations contained in this and related documents are based on tests we believe to be reliable. but the accuracy or completeness thereof is not guaranteed. THE FOREGOING LIMITED WARRANTIES ARE IN LIEU OF ALL OTHER WARRANTIES. EXPRESS OR IMPLIED. EXCEPT AS TO CONSUMER GOODS IN WHICH CASE THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY ONLY FOR THE PERIOD OF THE LIMITED WARRANTY. PURCHASERS OF CONSUMER PRODUCTS SHOULD NOTE THAT SOME STATES DO NOT ALLOW FOR THE EXCLUSION OF CONSEQUENTIAL DAMAGES OR THE LIMITATION OR THE DURATION OF IMPLIED WARRANTIES SO THE ABOVE EXCLUSION AND LIMITATION MAY NOT BE APPLICABLE. THIS LIMITED WARRANTY GIVES THE PURCHASER SPECIFIC LEGAL RIGHTS. AND THE PURCHASER MAY ALSO HAVE OTHER RIGHTS WHICH MAY VARY FROM STATE TO STATE. LIMITATION OF REMEDIES INTERTEC SHALL NOT BE LIABLE FOR ANY INJURY. LOSS OR DAMAGE. DIRECT OR CONSEQUENTIAL. TO PERSONS OR PROPERTY CAUSED EITHER DIRECTLY OR INDIRECTLY BY THE USE OR INABILITY TO USE ITS PRODUCTS AND/OR DOCUMENTS. SUCH LIMITATION IN LIABILITY SHALL REMAIN IN FULL FORCE AND EFFECT EVEN WHEN INTERTEC MAY HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH INJURIES. LOSSES OR DAMAGES. Before purchaSing or using. the Customer shall determine the suitability of Intertec's products and documents for his intended use and assumes all risk and liability whatsoever in connection therewith. THE LIMITED WARRANTY TO REPLACE OR REPAIR PARTS OR COMPONENTS FOR NINETY(90) DAYS IS THE EXCLUSIVE REMEDY PROVIDED TO THE CUSTOMER AND THE LIABILITY OF INTERTEC WITH RESPECT TO ANY OTHER CONTRACT. SALE OR ANYTHING DONE IN CONNECTION THEREWITH. WHETHER IN CONTRACT. IN TORT. UNDER ANY WARRANTY. OR OTHERWISE. SHALL NOT EXCEED THE PRICE OF THE PART OR COMPONENT ON WHICH SUCH LIABILITY IS BASED. Rights under this warranty are not assignable without the express prior consent. in writing. of Intertec Data Systems Corporation. and. regarding the terms of such consent in writing. the assignee shall have no greater rights than his aSSignor. In the event the Customer has any problem or complaints arising out of any breach of our limited warranty. including a failure to make repairs in accordance with the warranty. or unsuccessful repair attempts by an authorized repair facility. the Customer is encouraged to inform Intertec. in writing. of his or her problem or complaint. Any such writing should be addressed to Intertec Data Systems Corporation. 2300 Broad River Road. Columbia. South Carolina. 29210 and should be marked with the phrase "Warranty Claim." ." .\ r. () CORPORATE HEADQUARTERS. 2300 BROAD RIVER ROAD. COLUMBIA, SOUTH CAROLINA 29210 • 803/798-9100 .... ~ CORPORATE HEADQUARTERS. 2300 BROAD RIVER ROAD. COLUMBIA, SOUTH CAROLINA 29210 • 803/798-9100


Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Producer                        : Adobe Acrobat 9.2 Paper Capture Plug-in
Modify Date                     : 2010:01:02 16:13:27-08:00
Create Date                     : 2010:01:02 16:13:27-08:00
Metadata Date                   : 2010:01:02 16:13:27-08:00
Format                          : application/pdf
Document ID                     : uuid:fc375cf4-015b-4816-b069-da57fab5fc09
Instance ID                     : uuid:663f65e6-c844-4d9e-9c98-3ab399d4ec13
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 660
EXIF Metadata provided by
EXIF.tools

Navigation menu