0% found this document useful (0 votes)
134 views79 pages

Nevada Fortran For The Commodore 64

Uploaded by

fakekaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views79 pages

Nevada Fortran For The Commodore 64

Uploaded by

fakekaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

NEVADA FORTRAN™

Programmer's Reference Manual

Includes NEVADA ASSEMBLER™

Copyright© 1979, 1980, 1981, 1982, 1983 by Ian D. Kettleborough


Copyright© 1983 Commodore Electronics Limited
We hope you enjoy using NEVADA FORTRANTMfor the Commodore 64.
COPYRIGHT This software runs under CP/M 2.2 Operating System. Here are several
Copyright©, 1979, 1980, 1981, 1982, 1983 by Ian D. Kettleborough other Commodore software packages which you should know about:
and Copyright© 1983 by Commodore Electronics, Ltd. All rights
reserved worldwide. No part of the publication may be reproduced, NEVADA COBOLTM
This updated subset of COBOL was designed for small businesses with a
transmitted, transcribed, stored in a retrievel system or translated
Commodore 64. The four divisions of a COBOL program are reviewed, as
into any human or computer language in any form or by any well as the applicable Reserved Words. Details on using COBOL are
means, electronic, mechanical, magnetic, optical, chemical, described, along with error codes and messages. A glossary of items is
manual or otherwise, without the express written permission of also included.
Ian D. Kettleborough and Commodore Electronics Limited.
EASY SCRIPT 64
This is a powerful word processor with table producing capabilities,
DISCLAIMER comprehensive printer controls, easy update facilities, easy document
handling, the ability to interact with EASY SPELL 64, and more.
COMMODORE ELECTRONICS LTD. ("COMMODORE") MAKES
NO WARRANTIES, EITHER EXPRESS OR IMPLIED, WITH THE WORD MACHINE and THE NAME MACHINE
RESPECT TO THE PROGRAM DESCRIBED HEREIN, ITS QUALITY, This is an easy-to-Iearn and easy-to-use word processing package. Perfect
PERFORMANCE, MERCHANTABILITY, OR FITNESS FOR ANY for letters, address lists, memos, and notes, these programs let you
PARTICULAR PURPOSE. THIS PROGRAM IS SOLD "AS IS". THE overtype, insert, and delete text; personalize form letters; and print in draft,
ENTIRE RISK AS TO ITS QUALITY AND PERFORMANCE IS WITH formal, or informal formats.
THE BUYER. SHOULD THE PROGRAM PROVE DEFECTIVE
FOLLOWING ITS PURCHASE, THE BUYER (AND NOT THE EASY SPELL 64
Easy Spell 64 features the following: the automatic correction of spelling
CREATOR OF THE PROGRAM, COMMODORE, THEIR errors, the ability to count the number of words in your manuscript and
DISTRIBUTORS OR THEIR RETAILERS) ASSUMES THE ENTIRE interact with Easy Script 64, and a built-in 20,000 word dictionary that lets
COST OF ALL NECESSARY SERVICING, REPAIR OR you add words not already stored there.
CORRECTION AND ANY INCIDENTAL OR CONSEQUENTIAL
DAMAGES. IN NO EVENT WILL COMMODORE BE LIABLE FOR EASY MAIL 64
DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL With Easy Mail 64, you can easily manage your address files. Label
DAMAGES RESULTING FROM ANY DEFECT IN THE PROGRAM printing is also simplified with Easy Mail's ability to search for specific
EVEN IF IT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH fields/categories. The program's features include entry, change, or deletion
DAMAGES. SOME LAWS DO NOT ALLOW THE EXCLUSION OR of a file by name or number; the capability to print one or two abreast
LIMITATION OF IMPLIED WARRANTIES OR LIABILITIES FOR labels; a HELP screen; and the ability to print a complete printout of all the
data in each of your records.
INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE
LIMITATION OR EXCLUSION MAY NOT APPLY.
EASY CALC 64
Easy Calc 64 is an easy-touse electronic spread sheet which features
TRADEMARKS editing functions and HELP screens. With Easy Calc 64, you can also print
NEVADA FORTRANTM, NEVADA COBOLTM, NEVADA PILOTTM, bar charts and individually formatted tables.
NEVADA EDITTMand Ellis Computing are trademarks of Ellis
THE MANAGER
Computing, Inc. CP/M is a registered trademark of Digital The Manager is a general data base for handling your files.
Research Corporation.
THE COMMODORE 64 MACRO ASSEMBLER DEVELOPMENT SYSTEM
This package is designed for experienced Assembly language
programmers. Everything you need to create, assemble, load, and execute
6500 series Assembly language code is included.

NEVADA FORTRAN is a trademark of Ellis Computing


CP/M is a registered trademark of Digital Research, Inc.
SCREEN EDITOR Thank you for owning a Commodore computer. Now that you are a
The Screen Editor helps you design software by letting you create and edit member of the Commodore family, maybe you'd like to expand
your own screens. This programming tool is for users with some computer your computer's family. Here is a list of additional hardware which
experience. is compatible with your Commodore computer:

SUPER EXPANDER 64 Printers


This cartridge is a powerful extension of the BASIC language which gives The 1525E printer is an 80-column, dot-matrix, impact printer for
you the commands needed to easily access and implement Commodore's
creating printouts and hard-copies from your VIC 20 or
graphics, music, and sound capabilities. You will be amazed at how
Commodore 64. The printer features 30 characters per second
quickly and easily you can plot pOints and lines; draw arcs, circles,
ellipses, rectangles, triangles, octagons; paint shapes with specified print speed and prints graphics and text characters. The 1526
colors; read game paddle and joystick locations; create music and sound; Printer has all of the same features but is bi-directional and has
display text; split screens to display both text and graphics; and program programmable line spacing and a print format interpreter.
the function keys.
1520 Plotter/Printer
THE EASY FINANCE SERIES This is a four color, high resolution plotter that connects directly
Commodore is proud to announce an entire series of EASY FINANCE to your VIC 20 or Commodore 64 computer. With the 1520
software packages which may solve many of your business and personal Plotter/Printer you can plot on a piece of paper, the unique color
needs. The EASY FINANCE series is called "easy" because all of the graphics that you have created on your screen using LOGO
programs are simple to operate and require no programming experience.
Here is a brief description of each: graphiCS!

EASY FINANCE I - LOANS Commodore Speech Module


Calculates 12 different loan concepts including principal, regular payment, The speech module cartridge comes with a built-in vocabulary of
last payment, and remaining balance, 234 words which are easily programmed into sentences. The
EASY FINANCE II - INVESTMENTS module "talks" in a pleasant female or male voice ... it can
Includes 16 investment concepts. Functions such as future investment generate other types of voices with special vocabularies geared to
value, initial investment, and internal rate of return can be calculated. each software package. The speech module works with disk, tape,
EASY FINANCE 111- ADVANCED INVESTMENTS and also has a slot for accepting plug-in cartridges.
This advanced version of EASY FINANCE II, includes 16 more investment
concepts. Financial terms are clarified and functions such as discount 1701/1702 Monitor
commercial paper, financial management rate of return, and financial This full color monitor is compatible with the VIC 20, Commodore
leverage and earnings per share are described. 64, and other computers. The 1701/1702 Monitor features high
EASY FINANCE IV - BUSINESS MANAGEMENT quality resolution video and a built-in speaker with audio amplifier.
This package helps managers make the right decisions about production,
inventory, control, compensation, and much more. Lease purchase 1530 DATASSETTE
analysis, depreciation switch, and optimal order quantity are some of the The 1530 DATASSETTE is a low cost, highly reliable way to store
21 functions that can be calculated. and retrieve programs and data. It features keys for Play, Record,
EASY FINANCE V - STATISTICS Fast-Forward, Rewind, and Stop. The 1530 DATASSETTE uses
This includes payoff matrix analysis, regression analysis forecasting, and standard audio cassette tapes and allows naming of programs and
apportionment by ratios, files, verification of programs, and programmable end of tape
Please contact your local Commodore dealer for additional information on marker sensing.
other software available for your Commodore computer.
Joystick and Paddles
Controls for games and entertainment.
1600 Modem
This telephone interface lets you communicate with other
PREFACE
computer systems over your telephone line! The modem package NEVADA FORTRAN for Commodore 64 is an 8080180851Z80
includes cassette-tape terminal software, a free password and version of FORTAN IV. It is a powerful subset implementation of
one-hour subscription to the CompuServe System* and software this widely used language. The compiler works from disk (also
controls for duplex, baud rate, and parity. There is also an optional using the assembler) to produce 8080180851Z80 machine code that
adapter available for non-modular phones. executes at maximum CPU speed.
1650 AutoModem A source program is entered as FORTRAN IV program statements.
These statements must follow the conventions outlined in this
This telephone interface features automatic answer and automatic
document. The compiler acts upon the source statements to
dial. The modem package lets you communication with other
produce assembly code. At this stage, any mistakes are flagged
computer systems over the phone lines! It includes cassette-tape
with error messages. If an error should occur, the source may be
terminal with software, a free password and one-hour subscription
corrected at this time and recompiled. After the program has been
to the CompuServe System TM*and software controls for duplex,
compiled without any errors, the final step (normally transparent to
baud rate, and parity. You need a modular phone or adaptor to use
this product. the user) is to assemble the intermediate code into 8080 object
code. The object module is then ready for execution under the
PET 64 CPIM Operating System for your Commodore 64.
This unique machine combines many of the Commodore 64 This reference manual assumes you already have the knowledge
features with the capabilities of the Commodore PET. However, to program in FORTRAN and have read the Commodore 64 CPIM
sprites, color, and sound are not featured on this machine. Operating System. An additional list of supplementary materials
can be found in the back of this book.
SX-64 Portable Color Computers
This manual is not a tutorial and will not teach you "how to"
These new computers are Commodore 64's in a convenient program in FORTRAN. However, for the experienced FORTRAN
portable style. The model SX-64 (Single disk drive) is an excellent programmer who is already familiar with the CPIM Operating
investment for executive business people, as well as affordable for System, this manual provides the necessary tools for using this
today's students.
3.0 version of NEVADA FORTRAN on your Commodore 64. The
manual includes:
General Concepts and details of FORTRAN programming
Summaries of system functions and subroutines
A list of runtime and compile time errors
We hope you enjoy using NEVADA FORTRAN on your
Commodore 64.

.
Files on the NEVADA FORTRAN Data Disk TABLE OF CONTENTS
(Used with the NEVADA FORTRAN program)
FORT.COM PREFACE i
is the FORTRAN compiler
FRUN.COM is the runtime execution package FILES ON THE NEVADA FORTRAN DATA DISK ii
CONFIG.COM is a program to generate the error file and setup
compiler and runtime defaults. 1 GETTING STARTED 1
ERRORS is the error text file used by CON FIG.
GENERATING THE ERROR FILE FORT.ERR...................... 3
CONFIGURING THE FORTRAN SYSTEM 3
Files on the NEVADA FORTRAN Data Disk
(Used with the NEVADA ASSEMBLER included in back 2 COMPILING AND EXECUTING A PROGRAM......................... 4
section of this book) CREATING A PROGRAM 4
ASSM.COM is the assembler program RUNNING THE COMPILER 4
RUNA.COM is the runtime loader COMPILE OPTIONS 6
LD.ASM is a sample Assembler program
EXECUTING A PROGRAM.................................................... 8
CREATING A COM FILE....................................................... 8

3 THE FORTRAN LANGUAGE..................................................... 9


THE FORTRAN CHARACTER SET 9
FORTRAN PROGRAM STRUCTURE 10
FORTRAN STATEM ENTS 11
MULTI-STATEMENTS 11
FORTRAN PROGRAM PREPARATION 12
THE COpy STATEMENT 12
THE OPTIONS STATEMENT.. 13

4 NUMBER SYSTEM 15
NUMBER RANGES 15
CONSTANTS 15
Numerical Constants 15
String Constants 16
Logical Constants 16
VARIABLE NAMES 17
TYPE SPECIFICATION 17
Integer 17
Logical 18
Real 18
Double Precision 18

ii
DATA STATEMENT 19 CALL STATEMENT 43
COMMON BLOCKS 20 RETURN STATEMENT 44
IMPLICIT STATEMENT 21 NORMAL RETURN 44
MULTIPLE RETURN 44
5 EXPRESSIONS 22
BLOCK DATA SUBPROGRAM 45
HIERARCHY OF OPERATORS 22
EXPRESSION EVALUATION 23
10 INPUT/OUTPUT 46
INTEGER OPERATIONS 23
GENERAL INFORMATION 46
REAL OPERATIONS 24
1/0 LIST SPECIFICATION 47
LOGICAL OPERATIONS 24
READ STATEMENT 48
MIXED EXPRESSIONS 25
WRITE STATEMENT 50
MEMORY TO MEMORY I/O STATEMENTS 50
6 CONTROL STATEMENTS 26
DECODE Statement 50
UNCONDITIONAL GO TO STATEMENT 26
ENCODE Statement 51
COMPUTED GO TO STATEMENT 27
FORMAT STATEMENT AND FORMAT
ASSIGNED GO TO 27 SPECIFICATIONS 51
ASSIGN 27 A-Type (Aw) 52
ARITHMETIC IF STATEMENT 28 D-Type (Dw.d) 52
LOGICAL IF STATEMENT 28 E-Type (Ew.d) 52
IF-THEN-ELSE 29 F-Type (Fw.d) 53
DO-LOOPS 31 G-Type (Gw.d) 53
CONTINUE STATEMENT 32 I-Type (Iw) 54
ERROR TRAPPING 32 K-Type (Kw) 55
CONTROL/C CONTROL 34 L-Type (Lw) 55
TRACING 35 T-Type (Tw) 55
DUMP STATEMENT 36 X-Type (wX) 56
Z-Type 56
7 PROGRAM TERMINATION STATEMENTS 37
I-Type (I) 56
PAUSE STATEMENT 37
Repeating Field Specifications 57
STOP STATEMENT 38
String Output 57
END STATEMENT 38
FREE FORMAT 58
Input. 58
8 ARRAY SPECIFICATIONS 39
Output. 58
DIMENSION STATEMENT 39
BINARY 110 59
SUBSCRIPTS 41
REWIND STATEMENT 59
BACKSPACE STATEMENT 60
9 SUBPROGRAMS 42
ENDFILE STATEMENT 60
SUBROUTINE STATEMENT 42
GENERAL COMMENTS ON FORTRAN 110
FUNCTION STATEMENT 43 UNDER CP/M 61
SPECIAL CHARACTERS DURING CONSOLE 110 61
EXECUTING THE ASSEMBLER 78
11 GENERAL PURPOSE SUBROUTINE/FUNCTION LIBRARY ... 62
STARTUP 79
EXECUTING THE .OBJ FILE 80
Subroutine Names:
MEMORY USAGE 80
BIT 63 TERMINATION 80
CHAIN 63
CIN 64 14 STATEMENTS 81
CLOSE 64 INTRODUCTION 81
CTEST 65 LINE NUMBERS .. 81
DELAY 65 LABEL FIELD 82
DELETE 65 OPERATION FIELD 82
EXIT 66 OPERAND FIELD .. .. .. 82
LOAD 66 Register Names 83
LOPEN 67 Labels 83
MOVE 68 Constants 84
OPEN 68 Expressions 85
OUT 69 High and Low Order Byte Extraction 85
POKE 70 COMMENT FIELD .. 86
PUT 70
RENAME 70
15 PSEUDO-OPERATIONS 87
RESET 71
SEEK 71
16 ERROR CODES AND MESSAGES 88
SETIO 72

APPENDIX A - STATEMENT SUMMARY 94


Function Names:
CALL 72 APPENDIX B - SUMMARY OF SYSTEM FUNCTION 97
CBTOF 73
CHAR 73 APPENDIX C - SUMMARY OF SYSTEM SUBROUTINES 99
COMP 73
INP 74 APPENDIX 0 - RUNTIME ERRORS 101
PEEK 74
APPENDIX E - COMPILE TIME ERRORS 104
12 INTRODUCTION TO NEVADA ASSEMBLER 76
APPENDIX F - ASSEMBLY LANGUAGE INTERFACE 108
13 OPERATING PROCEDURES 77
HARDWARE REQUIREMENTS 77 APPENDIX G - GENERAL COMMENTS 109
SOFTWARE REQUIREMENTS 77
FILE TYPE CONVENTIONS 77 APPENDIX H - COMPARISON OF NEVADA FORTRAN
GETTING STARTED 77 AND ANSI FORTRAN 111

'
APPENDIX I - 8080 OPERATION CODE 112
1 GETTING STARTED
APPENDIX J - TABLE OF ASCII CODES (Zero Parity) 116 Required Hardware:
Your Commodore 64 computer
APPENDIX K - SAMPLE ASSEMBLER LISTING 119 The Commodore Z80 microprocessor (This is your CPIM
cartridge.)
APPENDIX L - SAMPLE PROGRAM OF LOADER A Commodore 1541 single disk drive
SOURCE CODE 121
A video display monitor such as the Commodore Color Monitor
Model 1701/1702
APPENDIX M - SUGGESTED REFERENCES 132
Required Software:

INDEX 133 Commodore's CPIM Operating System disk


A text editor. ED. COM is found on your Commodore CPIM
Operating System disk.
Throughout our discussion, we will be referring to the following
disks:
NEVADA FORTRAN Data disk
Included in your NEVADA FORTRAN software package, this
disk should only be read. A listing of the files contained on this
disk can be found at the front of this manual. (Consider this to
be disk B.)
CPIM Operating System disk
This is your Commodore CPIM Operating System disk that you
use with your ZOOcartridge.
CP/M NEVADA FORTRAN Operations disk
This is a disk which you create (Consider this to be disk A.)
Note that you should NEVER write on your NEVADA FORTRAN
Data disk. To prevent mistakes from occurring, be sure that this
disk is write protected. (Place a standard protection label over the
"square cornered" notch on the disk.) Before continuing, consult
your Commodore 64 CPIM Operating System User's Guide if you
are not familiar with the DIR, ERA, PIP, and STAT commands.
Follow these steps to get started using NEVADA FORTRAN:
1. Use one of your CPIM Operating System disk backup copies
to create your CPIM-NEVADA FORTRAN Operations disk. If
you don't have a backup copy of the CPIM Operating System
disk, see Section 4.2 The Copy Utility in your Commodore
CPIM Operating System User's Guide.
2. Insert the newly created CPIM NEVADA FORTRAN Operations
disk into the disk drive and boot CPIM. After CPIM is booted,
the computer automatically displays an 'A>' prompt.

1
3. Use the CPIM ERA command to erase all of the files except GENERATING THE ERROR FILE FORT_ERR
the PIP.COM, STAT.COM and ED.COM files from your newly In case a problem occurs in your program, error messages are very
created NEVADA FORTRAN Operations disk. important to help you understand what the problem is. The
4. Now, we will add the FORTRAN files to our newly created program CONFIG reads the text file ERRORS which contains the
disk. Remember, we will refer to the NEVADA FORTRAN Data compiler error messages. These messages may be changed but
disk as disk 'B' and the CPIM-NEVADA FORTRAN Operations can only be one line long. Also, the first two characters are the
Disk as disk 'A'. error number followed by a blank and the text of the error
message. To generate the error file, just enter CONFIG at the
Use the PIP command to copy the files from your NEVADA CPIM prompt and reply Y to the question about generating the
FORTRAN Data disk to the CPIM-NEVADA FORTRAN error file. You will then be asked to specify which drive contains
Operations disk. PIP will prompt you throughout the entire the file ERRORSand which drive the file FORT.ERR is to be
copy process. To invoke the PIP program, input: written to. Reply with a valid drive letter (A for one disk systems).
PIP You must generate the error file as it is not supplied on the disk.
This only needs to be done once or whenever any of the error text
After RETURN is pressed, an asterisk (*) is displayed on the is changed.
following line. Now, copy and verify the entire FORTRAN disk:
* A: = B: *. * + V1 CONFIGURING THE FORTRAN SYSTEM
The following prompt will then be displayed: The CONFIG program also allows you to set certain default values
Insert disk B into drive 0, press return in both the compiler and the runtime package. Just enter carriage
return (or ENTER)to leave the default as it is, or enter the new
Insert the NEVADA FORTRAN Data disk and press RETURN. The default value. You will be asked to enter the drive that contains
PIP program will read the first file from the disk. After a short the compiler (FORT.COM). The default sizes of the parameters that
period of time, the following prompt will be displayed: can be changed with an OPTIONS statement can be modified
Insert disk A into drive 0, press return along with the character used to delimit hexadecimal constants in
strings. You will also be able to specify if your system console
Insert the CPIM-NEVADA FORTRAN Operations disk and press can handle lowercase letters. Enter Y if it can or N if it cannot.
RETURN. The PIP program will now write onto the disk. This
process will continue until the entire NEVADA FORTRAN Data Next, certain parameters in the runtime package can be set. You
disk is copied onto the CPIM-NEVADA FORTRAN Operations disk. must first specify which drive contains the runtime package
Upon completion, an asterisk will appear. (FRUN.COM).The method that the runtime package performs
CPIM console 110 can be specified as either CPIM function 1 & 2,
PIP can be terminated at any time by pressing RETURN after any CPIM function 6 (for CPIM rev 2.0 only) or direct BIOS calls.
asterisk (*) prompt. We suggest now placing your NEVADA Specifying CPIM functions 1 & 2 allows you to use control-P to
FORTRAN Data disk in a safe place. You will not need it unless send a copy of your FORTRAN output to the printer. You will also
something happens to your Operations disk. Depending on how be able to specify if your system console can handle lowercase
much program development you do, it may be wise to backup your letters during program execution. Enter Y if it can or N if it cannot.
CPIM-NEVADA FORTRAN Operations disk at least once a day.
After creating FORT.ERR you can erase the files CONFIG.COM
NOTE: The NEVADA ASSEMBLER, ASSM.COM, must be on the and ERRORS if you need the disk space.
NEVADA FORTRAN Operations disk.

2 3
Notes:
2 COMPILING AND EXECUTING A PROGRAM If Z is specified in either the assembly or object drive position, no
CREATING A PROGRAM object program will be generated.
A program is created using the text editor ED.COM. The name of If the three drive specifiers are not specified, then the default drive
the FORTRAN source program should have the filename will be used.
extension of .FOR, such as PROG.FOR. Refer to section 3 for a
The files FORT.ERR and ASSM.COM must be present on the
detailed description of the format of each source statement. After
the program is created with the text editor, it is later, in a separate default drive when the compiler is run.
step, compiled. If the 0 is not specified as Z, then the assembly file will be
automatically assembled and the intermediate .ASM file will be
deleted. If Z is specified, then the file will not be assembled and
RUNNING THE COMPILER the intermediate .ASM will remain on the disk.
The general format of the command to compile a FORTRAN
program is:
FORT U:PGM.LAO SOPTIONS
where:
FORT is FORT.COM, the FORTRAN compiler
PGM is the FORTRAN source program to compile and has the
extension .FOR. However, the .FOR extension should not be
included when specifying the program name in this command.
U: is the drive where PGM.FOR is located (if not present, the
default drive is used).
L is the drive for the listing as follows:
A-P uses that drive for the listing
X listing to CPIM console
Y listing to CPIM LST: device
Z do not generate a listing
The listing will have the same filename as the source file but with
the extension .LST.
A is the drive for the intermediate assembly file as follows:
A-P uses that drive
Z do not generate an assembly file.
The assembly file will have the same filename as the source file
but with the extension .ASM. This file is usually deleted by the
FORTRAN compiler.
o is the drive for the final object program as follows:
A-P uses that drive
Z do not generate an object file
The object program will have the same filename as the source file
but with the extension .OBJ.

'
4 5
COMPILE OPTIONS WRITE (1,10)
Options that effect the compilation of the FORTRAN program can 10 FORMAT ('THIS IS
be specified on the command line by preceding the option string *A TEST')
with a dollar sign ($). For example: Produces: THIS IS A TEST
FORT U:PGM.LAO $NP2 without blank padding and
Here is a summary of Compile Options: THIS IS A TEST
with blank padding.
Option Description
If the last form is desired, then this could be written as:
N No assembly or object file will be produced.
P The listing file (if specified) will be paginated (66 WRITE (1,10)
lines to a page). Each new FORTRAN routine will 10 FORMAT ('THIS IS
start on a new page. *'A TEST')
1 Source statements will be blank padded to 64 to produce the same results as with the blank padding specified.
characters *
2 Source statements will be blank padded to 72 Here are some examples using Compile Options:
characters * FORT MYPROG $C = 20
H Used in conjunction with the P option to suppress
the heading in the listing. Compiles MYPROG.FOR from the default drive, generating
C = XXXX Specifies the maximum number of COMMON MYPROG.ASM, MYPROG.LST and MYPROG.OBJ on the default
blocks that may be defined in the program to be drive and allowing for the definition of up to 20 COMMON blocks.
compiled; default is 15.
B = XXXX Specifies the size of the input statement buffer; FORT B:READ.XCD $P2
default is 530 characters and the buffer must be Compiles READ.FOR from drive B, generating READ.ASM on drive
large enough to contain a complete statement (first C and the listing to the console. The listing will be paginated and
record plus all continuations). source statements will be padded to 72 characters.
M = XXXX Specifies the memory address at which blank
FORT TEST.YZZ $P
COMMON will end, i.e., blank COMMON will be
allocated downward in memory from the specified Compiles TEST.FOR from the default drive, no .ASM or .OBJ file
address. The address specified must be in will be produced but a paginated listing will go to the CPIM list
hexadecimal. This option is useful for forcing blank (LST:) device.
COMMON to be allocated at the same address in FORT UPDATEXBZ $PH
memory for passing data between routines that
CHAIN to each other. Compiles UPDATEFOR from the default drive, generating
UPDATEASM on drive B, a paginated listing minus the heading
* NOTE: Normally source statements are not blank padded. This line to the console and no .OBJ file.
may cause a problem where blanks are wanted inside a literal
string and the string is started on one statement and continued
over one or more continuation statements. Without the pad option,
the trailing blanks may be lost (of course you could break the
continued literal into several, making sure that there is a quote
after any blanks at the end of the statement). For example:

'
6 7
EXECUTING A PROGRAM 3 THE FORTRAN LANGUAGE
Once the object file has been produced, the program can be THE FORTRAN CHARACTER SET
executed by simply typing: The FORTRAN character set is composed of the following
FRUN u:filename characters:

where u: is optional and if not present, the default drive is used. The letters:
The FORTRAN runtime package, FRUN occupies memory from A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
100H to 3FFFH. It will load the program to be executed starting at
4000H. The program is then executed and continues until either it The numbers:
terminates normally or a runtime error occurs. 0,1,2,3,4,5,6,7,8,9
Example The special characters:
To compile and run the program GRAPH.FOR, the commands blank
would be: = equal sign (for replacement operations)
FORT GRAPH (listing, object to default disk) + plus sign
FRUN GRAPH (will execute the program) - minus sign
* asterisk
I slash
( left parenthesis
CREATING A COM FILE
) right parenthesis
A CPIM .COM file can be created that contains a copy of the , comma
runtime package and the program to be executed. This has the decimal pOint
advantage that just the filename need be entered to execute the $ dollar sign
program. Each program generated in this way will be at least 16K # number sign
in length, that being the size of the FORTRAN runtime package. & ampersand
To create a COM file just add .C to the end of the FRUN \ backslash
command. The command to turn GRAPH.OBJ into GRAPH.COM
NOTE: Lowercase letters will be converted to uppercase except
would be:
when lowercase appears in string literals.
FRUN GRAPH.C
The following is a list of the meanings of the special characters
Then to execute it, all that is needed is the command: used in this version of FORTRAN:
GRAPH $ Preceding a constant with a dollar sign indicates that it
is a hexadecimal constant.
# Preceding a constant with a number sign indicates that
it is a hexadecimal constant that is to be stored
internally in binary format.
& The & has two functions:
If used in a FORMAT statement, the character
following the ampersand is interpreted as a control
character (unless it is also an &).
Used to indicate that a statement label is being
passed to a SUBROUTINE for use in a multiple
RETURN statement.
\ A constant enclosed in backslashes in a character
string is assumed to be the hexadecimal code for an
ASCII character.

8 9
FORTRAN PROGRAM STRUCTURE There are four types of statements in FORTRAN:
A FORTRAN program is comprised of statements. Every 1) Declaration
statement must be of the following format. 2) Assignment
1) The first 5 columns of the statement are reserved for a 3) Control
statement label. This is a 1 to 5 digit number and is optional; 4) Input/Output.
however, if the statement is branched to from another part of These statement types are described in the following sections of
the program, a label must be present. this manual.
2) The sixth column is used to indicate a continuation of the
previous statement. Continuation is indicated by placing any FORTRAN STATEMENTS
character except a BLANK or ZERO in this column.
A statement may contain a statement label. A statement label is
3) Columns 7 through 12 are used for the body of the statement. placed in columns 1 through 5 of the statement. All labels on
This is anyone of the following statements which will be statements must be integers ranging between 1 and 99999.
described later. All statements are terminated by a <CR> Leading zeros will be ignored.
(Carriage Return) or semicolon (not enclosed in a character
string) in the case of multiple statements per line. A statement Statement labels are not required to be in any sequence, and they
may be of any length, but only the first 72 characters are will not be put in order. In any program, a statement label can be
retained during compilation. Statements will be processed used only once as a label. A statement may contain no more than
until the carriage return is encountered. The character 530 characters excluding blanks (other than those between single
positions between the carriage return and character position quotes), unless the B =option is specified.
72 will NOT be padded with BLANKS as some FORTRAN During compilation, blanks are ignored, except between single
systems will do, unless the 1 or 2 option is specified. This quotes and in H FORMAT specifications. Comments are indicated
means that if a character string is started on a line, and must by placing a C in column 1; the remaining part of the statement
be continued, the continuation logically starts immediately may be in any format and is ignored by the compiler.
after the last character of the previous line.
4) Columns 73 through 80 are used for identification purposes
and are ignored. MULTI-STATEMENTS

5) A comment line is indicated by placing a C in column 1. A Statements may be compacted with more than one logical
comment line has no effect on the program and is ignored. It statement per line. Statements are separated from each other with
is only used for documentation purposes. a semicolon and a colon is used to separate the label, if any.
Example
Example:
Columns 0123456789 1= 1
3 CONTINUE
WRITE (1,2)
2 FORMAT ('THIS IS AN
I = 1+ 1
TYPE I
* EXAMPLE CHARACTER STRING') GOT03
This outputs: THIS IS AN EXAMPLE CHARACTER STRING STOP
END
Uppercase and lowercase letters can be intermixed in a FORTRAN
statement. Lowercase letters are retained ONLY when they appear could be written as:
between QUOTES or are in the H FORMAT specification in a 1= 1;3:CONTINUE;1 = 1+ 1;TYPE I;GOTO 3; STOP;END
FORMAT statement. Otherwise, they will be converted to
uppercase internally. Thus, the variable QUANTITY, quantity, and
QuAnTiTy present the same variable.

10 11
FORTRAN PROGRAM PREPARATION THE OPTIONS STATEMENT
A FORTRAN source program is prepared using one of the ThiS is an optional statement of each program and/or subprogram
available CPIM text editors. The FORTRAN file must be in the which is to be compiled. If present, the OPTIONS statement must
following format: appear as the first statement in the main program and prior to the
SUBROUTINE or FUNCTION statement in each subprogram. The
Position 1...5....0....5....0....5....0 ....5....0....5 options statement allows the specification of various parameters
OPTIONS to be used by the compiler during compilation of a particular
routine. The options that are specified on an options statement
are only in effect for that routine and revert back to the default
unless an OPTIONS statement appears on subsequent routines.
FORTRAN program
Here is a summary of available options:
Options Descriptions
END A=n n is a decimal number which indicates the maximum
OPTIONS number of arrays. Default is a maximum of 15; each
SUBROUTINE X entry requires 4 bytes. This default can be changed
using the CONFIG program.
FORTRAN routine
B The FORTRAN source statement is included in the
END assembly file as a comment.

All FORTRAN routines are required to be compiled at one time. D= n n is a decimal number which indicates the maximum
allowable nesting of DO loops. Default is 5, each entry
requires 4 bytes. This default can be changed using the
THE COPY STATEMENT CON FIG program.
A FORTRAN program can contain COPY statements. The COPY E Instructs the compiler to list, as comments, a reference
statement contains the word COpy followed by at least one blank, table equating user symbols, constants, and labels to
followed by the FILENAME to be inserted at that point. COPY files internally generated ones.
may contain complete programs or just sections of programs. G Instructs the compiler to list all compile errors as error
Copied files may not themselves contain COpy statements. numbers, instead of explicit error statements. See the
Example Appendix for a list of error numbers and their meanings.
DIMENSION A(1) 1= n n is a decimal number specifying the depth that IF-
COPY ALLDEFS THEN-ELSE's may be nested. The default nesting is 5.
READ (1,10) I This default can be changed using the CONFIG
A=1 program.
T=5 L =n n is a decimal number indicating the number of
CALL ADDIT allowable labels. The default is 50. Each entry requires 6
STOP bytes. (n may be greater than 255). This default can be
END changed using the CONFIG program.
COpy B:ADDIT
N Check for FORTRAN errors only. Do not output an
assembly code file.

12 13
0= n n is a decimal number which indicates the maximum
number of operators ever pushed on the internal stack
4 NUMBER SYSTEM
The following section details how numbers are handled in
while doing a prefix translation of input expression.
Note functions and array subscripting require a double NEVADA FORTRAN.
entry. Default is 40; each entry is 2 bytes long. This Numbers are stored internally as a 6 byte BCD number containing
default can be changed using the CON FIG program. 8 digits, a one byte exponent, and a sign byte. This allows for the
number to range from .10000000E-127 to 0.99999999E+ 127. The
P= n n is a decimal number which indicates the maximum
sign byte contains the sign of the number; 0 indicating a positive
number of variables and/or constants ever pushed on
number and 1 indicating a negative number. The exponent is
the internal stack in evaluation. Default is 40; each entry
stored in excess 128. A one for the sign of the BCD number
is 2 bytes long. This default can be changed using the
indicates a negative number. The number ZERO is stored as an
CONFIG program.
exponent of zero; the rest of the number is ignored.
Q This option must be used whenever the program
All numbers in FORTRAN are stored in the following format:
expects to trap runtime errors. It causes code to be
generated for handling user trapping of runtime errors.
S= n n is a decimal number indicating the number of
allowable symbols. The default is 50. Each entry
requires 8 bytes (n may be greater than 255). This
BCD NUMBER :Sgn :Exp
default can be changed using the CON FIG program.
T= n n is a decimal number indicating the maximum number NUMBER RANGES
of temporary variables that are available during
Integer variables and constants can have any value from
EXPRESSION evaluation. Default table size is 15; each
_ 99999999 to + 99999999. Real variables and constants can take
variable requires 1 byte. This default can be changed
any value between - 0.99999999E - 127 and 0.99999999E + 126.
using the CONFIG program.
Integer variables and constants are stored internally in the same
X Instructs the compiler to generate code which will give format.
explicit runtime errors. In this mode, each statement
has an extra 5 bytes of overhead to keep track of the
statement number of the statement currently being CONSTANTS
executed.
A constant is a quantity that has a fixed value. A numerical
constant is an integer or real number; a string constant is a
Example
sequence of characters enclosed in single quotes. A logical
$OPTIONS X,G,S= 200,L= 100 constant has a value of .TRUE. or .FALSE.
Options used will be: Here is a more detailed description of each type of constant:
EXPLICIT runtime errors will be generated
Numerical Constants
EXPLICIT compile errors are not generated
The SYMBOL table has room for 200 symbols, and Numerical constants can be either integer or real. For example:
The LABEL table has room for 100 statement labels.
Integer 1,3099, - 70
Note: n is less than or equal to 255 unless otherwise stated. Real 1.34, - 5.98, 1.4E10
A hexadecimal constant can be specified by preceding the
number with a dollar sign. A hexadecimal constant is converted
internally into an integer and stored that way. The maximum value
for a hexadecimal constant is $FFFF.

14 15
Example VARIABLE NAMES
A variable is a symbolic name given to a quantity which may
$8050 change depending upon the operation of a program. A variable
1=$1000 consists of from one to six alphanumeric characters the first of
z= - $CCOO which must be a letter. There are four types of variables available:
Another way to specify a hexadecimal constant is to precede the INTEGER, REAL, DOUBLE PRECISION and LOGICAL.
constant with a # sign. This way of representing a hexadecimal
An INTEGER variable is a variable that starts with I, J, K, L, M or N
number differs in that the number is NOT converted to integer
by default or explicitly typed INTEGER through the use of an
format and is stored in binary in the first two bytes of the
constant. The number is stored high byte followed by low byte. INTEGER or IMPLICIT statement.
A REAL variable is a variable that starts with a letter other than I,
Example' J, K, L, M or N by default or explicitly typed REAL through the use
#ODOO of a REAL or IMPLICIT statement.
i =#127F A DOUBLE PRECISION variable must be explicitly typed DOUBLE
$805F is stored internally as: 328630000085 PRECISION with a DOUBLE PRECISION or IMPLICIT statement.
#805F is stored internally as: 5F 80 00 00 00 00
A LOGICAL variable must be explicitly typed LOGICAL with a
String Constants LOGICAL or IMPLICIT statement.
A string constant is specified by enclosing a sequence of
characters in single quotes. A single quote within a character TYPE SPECIFICATION
string must be represented by TWO quotes in a row (with no There are three Type Specification statements that can be used to
space between these two quotes). By specifying a hexadecimal override the default types of variables. Remember that variables
number within backslashes, any character (even unprintable ones) that begin with the letters I, J, K, L, M, N (unless changed by an
can be generated. IMPLICIT statement) will be of type INTEGER. All others will be of
type REAL. The Type Specification statement overrides the default
Example
type of a variable.
'This is a string constant'
Note: An array can also be specified in a Type Statement.
'This string constant' 'contains a single quote'
'Good \21\' is equivalent to 'Good!' Example
'\7F\' is equivalent to a rubout
INTEGER A,ZOT,ZAP(10)
Warning: Never include \0\ as part of a string constant as that REAL INT
character is used internally to indicate the end of a string. LOGICAL LOG1,LOG2
NOTE: The character used to delimit a hexadecimal number A more detailed description of each Type Specification follows.
(default is \) can be changed using the CONFIG program.
Integer
Logical Constants
The general format of the INTEGER statement is:
The two logical constants are .TRUE. and .FALSE.. Numerically,
.FALSE. has the value 0 (zero) and .TRUE. has the value 1. INTEGER v1,v2
However, any non-zero value will be considered as .TRUE.. Logical The INTEGER statement is used to explicitly override the default
operations always return a value of 0 or 1. These logical constants type of the variable. Should a variable occur in the declaration
can be assigned to any variable, but are usually used as part of a string, the type is automatically set to integer. This works for both
logical expression. subscripted and nonsubscripted variables. A variable can appear
only ONCE in a type specification statement.
Example
1= .TRUE. Example
1= (J .and. .TRUE.) INTEGER MODE,K453,NUMBER(40),MAXNUM
INTEGER ZAPIT

17
16
Logical
DATA STATEMENT
The general format of the LOGICAL statement is:
The DATA statement is used to initialize variables or arrays to a
LOGICAL v1,v2 numeric value or character string. The general format is:
The LOGICAL statement is used to override the default DATA Iist/n1,n2 ....I,Iist1/n1,n21
specification and type a variable as Logical. A logical variable's
where list is a list of variables (or array elements) to be initialized
value is interpreted as:
and n1, n2 ... are numbers or strings (constants) that the
.TRUE. if the variable has a non-zero value. corresponding item of list will be initialized to. An exception to
.FALSE. if the variable has a zero value. this is the array name. If only the name of the array (no subscripts)
Example appears in list, the whole array will be initialized. It is expected
that enough constants will be listed to completely fill the array. If
LOGICAL FTIME,LTIME not enough constants are supplied to fill the entire array, then
LOGICAL FLAG portions of the array will be undefined.

Real Subprogram arguments may not appear in list. When a DATA


statement is encountered during compilation, it is stored in
The general format of the REAL statement is: memory and ALL DATA statements are processed when the END
REAL v1,v2 statement for the particular routine is encountered. If there are
more DATA statements than can be stored in the available
The REAL statement is used to explicitly override the default type memory, a fatal compile error will result and compilation will
of the variable. Should a variable occur in the declaration string, terminate. Since DATA statements are processed when the END
the type is automatically set to REAL. This works for both statement is encountered; errors in a DATA statement will be
subscripted and nonsubscripted variables. A variable can appear printed after the END statement. These errors will include the four
only ONCE in a type specification statement. digit FORTRAN assigned line number and the variable in the
DATA statement being processed when the error occurred.
Example Example
REAL ALPHA,BETA(56),INIT,FIRST,ZAPIT,HI DIMENSION B(3),C(3)
DATA AI11,BI1,2,31,CI3*01
Double Precision DATA LlST/'THIS IS A CHARACTER STRING'I
The general format for DOUBLE PRECISION statement is: The above statement will assign the value 1 to A and the values 1
DOUBLE PRECISION v1,v2 to B(1), 2 to B(2) and 3 to (B)3. The asterisk is used to indicate a
repeat count. Thus, the array C will be set to zeroes. An error will
The DOUBLE PRECISION statement is used to explicitly override result if a variable in a DATA statement is not used elsewhere in a
the default type of the variable. When a variable occurs in the program.
declaration string, the type is automatically set to REAL. This
works for both subscripted and nonsubscripted variables. A NOTE: The other form of the DATA statement:
variable can appear only ONCE in a type specification statement. DATA A,B,CI1,2,31
Example is not supported by NEVADA FORTRAN and must be rewritten as:
DOUBLE PRECISION ALPHA,BETA(56),INIT,FIRST,ZAPIT,HI DATA AI11,BI2I,CI31
DOUBLE PRECISION VALUE1,VALUE2
WARNING: Even though the DOUBLE PRECISION statement is
supported, double precision arithmetic is NOT. All DOUBLE
PRECISION variables will be treated as if they were REAL. A
warning will be issued each time a DOUBLE PRECISION
statement is encountered.

18
19
Blank COMMON differs from named COMMON in the following
COMMON BLOCKS ways:
The COMMON block declaration sets aside memory (variable 1) Variables in blank common are allocated their actual memory
space) to be shared between routines (SUBROUTINES, addresses at runtime and therefore cannot be initialized with a
FUNCTIONS and the main program). COMMON blocks are DATA statement.
associated with a name which is used by each declaring routine to 2) Blank common is allocated at runtime directly below the BDOS
point to a specific COMMON block. (at the top of the TPA) in CPIM or at a user specified address.
To override the default placing of the blank common block in
The general form of a COMMON statement is:
memory, use the M = compiler option when the program is
COMMON Iname111ist1 Iname2/list2 compiled. If the size of blank common blocks is the same, then
where namel and name2 are the COMMON block names blank common can be used to pass data between routines that
associated with the corresponding Iist1 and list2. CHAIN as the blank common variables will occupy the same
place in memory.
Example
NOTE: The name of a named COMMON block must be different
DIMENSION X(100) from any SUBROUTINE or FUNCTION name.
COMMON IZZZ/ FIRST,LAST,X
CALL ADDEM
IMPLICIT STATEMENT
The IMPLICIT statement is used to change the default INTEGER,
END REAL, DOUBLE PRECISION and LOGICAL typing.
The general format of the IMPLICIT statement is:
SUBROUTINE ADDEM
REAL NUMBER IMPLICIT type (range), type(range)
COMMON IZZZ/ F,L,NUMBER(100)
where type is INTEGER, REAL, LOGICAL, or DOUBLE PRECISION.
Range is either a single letter or a range of letters in alphabetical
order. A range is denoted by the first and last letter of the range
END
separated by commas.
An array declaration may be included in a COMMON statement as
shown in the subroutine above. The use of COMMON blocks allow Example
data to be passed to and from a subprogram, but without passing IMPLICIT INTEGER (Z),REAL (A,B,C,D,E,G),INTEGER (M-S)
it as arguments (in a heavily called routine, this method can save IMPLICIT REAL (I,J)
execution time). If an array is to be included in a common IMPLICIT REAL (A-Z)
declaration, it must either be declared previously or declared in
An IMPLICIT statement specifies the type of all variables, arrays
the COMMON statement. and functions that begin with any letter that appears in the
If the name is omitted or the name is null (i.e. /I) then it is called specification. Type specification by an IMPLICIT statement may
blank COMMON. be overriden for any particular variable, array or function name by
the appearance of that name in a type statement.
Example
The IMPLICIT statement must appear before all other statements
COMMON A,B,C,D
in a particular routine: that is, immediately after the SUBROUTINE
COMMON /I A,B,C,D are equivalent statements
or FUNCTION statement or before the first statement of the main
program.
WARNING: Even though the DOUBLE PRECISION specification is
supported, double precision arithmetic is NOT. All DOUBLE
PRECISION variables will be treated as if they were REAL. A
warning will be issued each time a DOUBLE PRECISION
statement is encountered.

21
20
5 EXPRESSIONS EXPRESSION EVALUATION
FORTRAN expressions are evaluated as follows:
An expression is a combination of variables, functions and
constants, joined together with one or more operators. 1. Parenthesized expressions are always evaluated first, with the
inner most set being evaluated first.
Arithmetic Operators 2. Within parentheses (or whenever there are none) the order of
* * or Exponentiation expression evaluation is:
* Multiplication a. FUNCTION references
I Division b. Exponentiation
+ Addition c. Multiplication and Division
- Subtraction d. Addition and subtraction
Comparison Operators 3. Operators of the same precedence are evaluated from left to
.EQ. Equal to right during expression evaluation .
.NE. Not equal to
Example
.GT. Greater than
.LT. Less than A+ 1 + Z*5 will be evaluated as:
.GE. Greater than or equal to ((A+ (1+ (Z*5))
.LE. Less than or equal to VAL *Z + (T + 4)16*X* *Y will be evaluated as:
Logical Operators ((VAL*Z)+ (((T + 4)I6)* (X**Y)))
.NOT. Logial negation NOTE: Operators of equal precedence are executed from left to
.AND. Logical and right.
.OR. Logical or
.x0R. Logical exclusive or
INTEGER OPERATIONS
The .NOT. and unary minus (- ) operators preceded an operand.
All other operators appear between two operands. A fundamental difference between INTEGER and REAL arithmetic
operation is the manner in which rounding occurs. If you were to
divide 3.0 by 2.0 using floating point arithmetic, the answer would
HIERARCHY OF OPERATORS be 1.5. However, if the same operation were to be performed using
integer arithmetic, 3/2 would equal 1.
The following is the table of operator hierarchy and the correct
FORTRAN symbolic representation to be used in coding: Note: In using integer arithmetic, the fractional part of the number
is truncated. Another example is in the multiplication of two real
Highest System and User Functions numbers. For example, 2.9 times 4.8 equals 13.92. However, in
* * OR (up arrow) integer mode the result is 13. Also, no more than 8 digits of
* and I accuracy are maintained. Should more than 8 digits be generated
+ and - (including unary -) by an integer operation, a runtime error of INT RANG will result.
.LT., .LE., .NE., .EQ., .GE., .GT.
Example
.NOT.
.AND. 6/3=2
.OR. and .x0R. but =
7/3 2 (NOTE: no fraction is retained) and 7/9 =0
Lowest Replacement (= ) 99999999+ 5 =? integer overflow

23
22
REAL OPERATIONS The following logical operators are also available, as listed in the
following truth charts,
Unlike integers, Real operations and their results have a precision
of eight significant digits plus an exponent (base 10) between R= A .OR. B R=A .XOR. B
R=A .AND. B
- 127 and + 127.
A B R A B R
Example A B R
12/6.0 = 2.0 0 0 0 0 0 o 0 0 0
15.0/2 = 7.5 0 1 0 0 1 1 0 1 1
1.12. = 0.5 1 0 0 1 0 1 1 0 1

1 1 1 1 1 0
1 1 1
LOGICAL OPERATIONS
Logical operations are unlike INTEGER and REAL operations in R= .NOT. A
that they always return a value of zero (0) or one (1). All the logical
operations will return a one for a TRUE condition. However, any
NON-ZERO value will be interpreted as TRUE. If the logical
operation is a logically true statement, the result is a one; if the
statement is false, a zero is returned.
Example
MIXED EXPRESSIONS
A = 1 .GT. 2 (FALSE) A would evaluate to 0
Here is a summary of the standard FORTRAN rules for mixed
A = 1 .EQ. 1 (TRUE) A would evaluate to 1
A = 1 .LT. 2 (TRUE) A would evaluate to 1 mode expressions.
Expression Description
The relational operator abbreviations in the previous table
represent the following operations: Integer <op> Integer Gives an integer result
.LT. Less Than Real <op> Integer Gives a real result (with the
.LE. Less Than or Equal To integer being converted to real
.NE. Not Equal To before the operation is
.EQ. Equal To performed)
.GE. Greater Than or Equal To
Real <op> Real Gives a real result
.GT. Greater Than
.AND. True only if both operands are true Integer <op> Real Gives a real result, with the
.OR. True if either operand is true integer being converted to REAL
.xOR. True if operands are different before the operation is
performed
Example
Integer = Real Causes truncation of any
IF (A .EQ. B) GO TO 500 fractional part of real and an
IF (A .EQ. B.OR.K .EQ. D) STOP error if the truncated result is
Logical variables can also be used in assignment statements: outside the range of integers

A=A .AND. B Real = Integer Causes integer to be converted


I = (A .OR. B).XOR.((T .EQ. 35.4).OR.(T .EQ. 39)) to real
In general, in a mixed expression, integers are converted to real
before the operation takes place, giving a real result (unless both
operands are integer).
Note: <op> represents one of the operators: + - /*

24 25
6 CONTROL STATEMENTS COMPUTED GO TO STATEMENT
Here are several different statements that control the execution The general format of the Computed GO TO is:
flow of a FORTRAN program.
GO TO (n1 ,n2, ...nm),i
GO TO statements
The Computed GO TO statement works in a manner similar to the
Unconditional GO TO
GO TO statement. However, one of the distinct advantages is that
Computed GO TO
under program control, you may direct which statement is the next
Assigned GO TO
to be executed, based on the value of i. The computed GO TO
works as follows:
IF statements
Arithmetic IF Computed GO TO Present Value Next Executed
Logical IF Statement of Variable Statement
IF-THEN-ELSE K2=5 4
GO TO (1,5,98,167,4),K2
DO GO TO (44,28),J =
J 1 44
GO TO (51,6,7,1,46),M M=4 1
CONTINUE
GO TO (1,1,1,1 ,2,2),LOOT LOOT = 3 1
PAUSE
If the value of i exceeds the number of statement labels in the
STOP Computed GOTO, a runtime error COM GOTO will be generated. If
CALL the value of i is less than 1, a runtime error will also be generated.

RETURN
Explicit RETURN ASSIGNED GO TO
Multiple RETURN
The general format of the assigned GO TO is:
UNCONDITIONAL GO TO STATEMENT GO TO v,(n1,n2, ...)
The general format of the unconditional GO TO is: where v is the variable used in an ASSIGN statement and n1,n2
are statement labels.
GO TO n
Example
where n is a label on an executable statement.
GO TO LABL,(100,400,500)
The unconditional GO TO statement performs a transfer of control
GO TO K,(1,2,3,4,5)
to the statement number specified as the object of the branch. If
the statement number does not exist, an undefined label error will
occur. This error is detected during compilation. ASSIGN
The general format of the ASSIGN statement is:
Note: Labels on FORMAT statements in most FORTRAN systems
may not receive transfer of control. This is not true in this ASSIGN n TO V
implementation of FORTRAN. FORMAT statements act the same
where n is the statement label to be ASSIGNed to v. The ASSIGN
as a CONTINUE statement which will be discussed later.
statement assigns a statement label to be used in conjunction
Example with the ASSIGNED GO TO statement.
GO TO 10 Example
GO TO 400
ASSIGN 20 TO LABEL
10 CONTINUE
400 FORMAT (1X)
IF (KNT .GT. 10)ASSIGN 10 TO LABEL

GO TO LABEL,(10,20)

26 27
Example
ARITHMETIC IF STATEMENT
IF (DEGREE .EQ. 100)WRITE (1,*) RADIAN
The Arithmetic IF allows the programmer to evaluate an
IF ((A .EQ. 12).0R.(LOOP .LE. 500))RETURN
expression which may be any combination of INTEGER, REAL, or
IF (SIN(30)/WHERE - .00005 .LT .. 00004)STOP
LOGICAL operators. Based upon the expression's relationship to
IF (A .NE. B)GO TO 500
zero, control is transferred to one of three specified statements.
IF (A .EQ. 1)GO TO (1,2,3),J
The general form of the Arithmetic IF is: IF (VALUE .EQ. 6)IF (J)99,33,67
IF (e) n1 ,n2,n3
IF =
(I .GE. 500)J 1+20/8
IF =
(FLAG) A 2* A + 5
where e is an arithmetic expression which when evaluated is used
to determine the next statement to be executed.
If e is: Next Statement IF-THEN-ELSE

n1 The general format of the IFTHEN-ELSE statement is:


<0
=0 n2 IF (e) THEN
>0 n3 statement 1
statement 2
Example
IF (A) 1,2,3 ELSE
IF (BETA *SIN(BETAIDEGREE))100,150,432 statement 3
IF (A-1)1,1,99 statement 4
IF (.NOT. FLAG)1,5,7
ENDIF
The IFTHEN-ELSE is an extension of the logical IF with two
LOGICAL IF STATEMENT
additions:
The general format of the Logical IF is:
There can be more than one statement to execute if the IF is
IF (e) s true.
The logical IF statement operates as follows: There is the provision of specifying one or more statements to
be executed if the IF is false.
1. The expression e is evaluated, and a logical result is derived:
.TRUE. or .FALSE. (numerically 1 or 0, respectively). The ENDIF is required to indicate the end of the complete IF
THEN-ELSE statement.
2. Depending on the value which is derived, one of the following
two conditions occurs: To indicate an IFTHEN-ELSE, the s part of the logical IF is
replaced with the THEN statement. All statements between the
If e is evaluated as .TRUE., then the statement s is executed, THEN and the matching ELSE or ENDIF will be executed if the
and once the IF has completed, transfer is then passed to specified condition is true. All statements between the ELSE and
the next consecutive statement. ENDIF will be executed if the specified condition is false. The
If e is evaluted as .FALSE., the statement s is NOT executed ELSE is optional and if the condition is false, all statements
and control is then passed to the next sequential executable between the THEN and ENDIF will be skipped.
statement.
The statement s can be any statement other than an END,
another Logical IF or a DO.

29
28
If no ELSE condition is to be specified, then the THEN can be DO-LOOPS
terminated with an ENDIF. For example: The general format for a DO loop is:
IF (e) THEN DO n i = m1,m2,m3
statement 1
statement 2 The DO loop is the basic loop structure in FORTRAN. It works in a
ENDIF manner similar to the FOR-NEXT loop in BASIC. The DO Loop
works as follows:
The statements to be executed can be any statement including
another IF-THEN-ELSE. The i is set to the value of m1.
After each pass through the loop (which ends with the
Note: THEN, ELSE and ENDIF are individual statements statement labelled n), the step value, m3 is added to i. If the m3
terminated by either a carriage return or semicolon. term (step value), is omitted, then the stop value is assumed to
Example be one. Unlike other versions of FORTRAN, the i and m terms
do not have to be INTEGER values and the step may be
IF (I .EQ. 0) THEN negative. This allows fractional increments of the DO loop
L= K+ 1 index, i. The ability of a negative increment, m3, allows the loop
K=I to step in a downward direction. If the step value is positive, the
ELSE loop continues until the value of i is greater than that of m2. If
K=O the step value is negative, the loop continues until the value of i
ENDIF is less than that of m1. The n in the DO loop specifies the range
IF (J .LT. 7) THEN of the DO loop. This is the statement number of the last
LL= L+ 1 statement of the DO loop.
ELSE Irrespective of the relation of the initial and ending values, the DO
IF (A .EQ. B)THEN
will always be executed once.
Q=O
D=N Note that 2 or more DO loops may end on the same statement.
ELSE DO loops may not terminate on GO TO, STOP, IFTHEN-ELSE,
TYPE 'ERROR' END or RETURN statements. A common way to terminate a DO is
STOP with a CONTINUE statement.
ENDIF
ENDIF Example
DO 800 I = 1,100
DO 1 J = I,END,.005
DO 99 A= START,END,AINCR
DO 10 1=1,5
DO 20 J=3,99

20 CONTINUE

10 CONTINUE

30 31
CONTINUE STATEMENT The value placed in the variable v corresponds to the runtime error
that occurred. Here is a summary:
The format of the CONTINUE statement is:
CONTINUE Valued v Runtime Error
The CONTINUE statement is an executable FORTRAN statement. 1 Integer overflow
It generates no code and is generally used as the terminal 2 Convert error
statement of a DO loop. 3 Argument count error
4 Computed GOTO index out of range
Example Overflow
5
DO 100 1=1,50 6 Division by zero
7 Square root of negative number
8 Log of negative number
9 Call stack push error
100 CONTINUE 10 Call stack pop error
The CONTINUE statement simply serves to mark the range of the 11 CHAINILOAD error
DO. IT is also used for transfer of control, i.e. you can GO TO it. 12 Illegal FORTRAN logical unit number
13 Unit already open
14 Disk full
15 Unit not open
ERROR TRAPPING
16 Binary 1/0 to system console
Normally, when an error occurs during the execution of a 17 Line too long on READ or WRITE
FORTRAN program, a runtime error message will be generated. 18 FORMAT error
However, using the ERRSET and ERRCLR statements, it is 19 Input/Output error in READ or WRITE
possible to control and trap runtime errors. 20 Invalid character on input
21 Invalid input/output list
The general format of these statements is:
22 Assigned GOTO error
ERRSET n,v 23 CONTROL/C abort
ERRCLR 24 Illegal character input
where n is the label of the statement to go to if a runtime error 25 File operation error
occurs. And v is the variable to contain the error code of the 26 Seek error
runtime error that occurred. If more than one ERRSET statement is executed in a routine, then
The ERRSET statement causes control to be transferred to the the last one executed is the one in effect. If a runtime error should
statement labelled n when a runtime error occurs. No runtime be trapped with an ERRSET statement, the ERRSET statement is
error message will be printed if the error is trapped with an automatically cleared.
ERRSET statement. The ERRSET statement can only be used if
the Q option was specified on the OPTIONS statement for the
routine in which the error occurred. If an ERRSET or ERRCLR
statement is encountered and the Q option was not specified, a
compilation error will be generated.

32 33
TRACING
The ERRCLR statement clears the effect of the last executed
There are two statements that are used to trace a program:
ERRSET statement. The ERRCLR and ERRSET statements must
be in the same routine. TRACE ON
TRACE OFF
Example
When program execution begins, tracing is initially off and must
OPTIONSQ
be explicitly turned on. Once tracing is on, it remains on until the
program terminates or a TRACE OFF statement is executed. The
ERRSET 10,CODE
effect of both trace statements is global over the whole program.
Therefore, tracing does not have to be turned on in each
subroutine.
ERRCLR
The trace function will output the line number of the FORTRAN
statement before execution, only if the X option was specified on
STOP the options statement for this routine. Otherwise, the program will
10 TYPE 'ERROR ,ERROR CODE = ',CODE be traced only up to the entrance to the subroutine. It should be
noted that the line number for any entrance to a subroutine (either
END SUBROUTINE or FUNCTION) will always be output as ????
regardless of the state of the X option.
CONTROL/C CONTROL Example
At the beginning of each READ or WRITE statement, the state of IF (FLAG .EQ. O)TRACE ON
the CONTROL/C abort flag is tested. If the CONTROL/C abort flag TRACE OFF
is set, then the console is tested to see if CONTROL/C has been
hit. If CONTROL/C has been hit, then one of two actions will
=
DO 1 I 1,100
IF (I .EQ. 50)TRACE ON
occur: 1 TYPE I
If there is an ERRSET in effect, the error branch will be taken
with a CONTROL/C error.
A runtime error of CONTROL/C will be generated.
The user has control of the CONTROL/C flag through the CTRL
ENABLE and CTRL DISABLE statements. CTRL ENABLE sets the
CONTROL/C flag and allows a CONTROL/C from the console to
abort the program. CTRL DISABLE resets the flag and causes the
CONTROL/C to be ignored.
Example
DO 1 1= 1,100
IF (I .EQ. 51)CTRL DISABLE
1 TYPE I
END
The previous program will only abort if CONTROL/C is entered
while the first 50 numbers are being typed.
When program execution starts, the CONTROL/C flag will be set
which allows CONTROL/C to abort the program.
Note: The CONTROL/C error, if enabled, can be trapped with an
ERRSET statement. However, the CIN function will return a
control-C to the caller, regardless of the setting of the
CONTROL/C flag.

35
DUMP STATEMENT 7 PROGRAM TERMINATION STATEMENTS
The general format of the DUMP statement is: The following section details the various program termination
statements.
DUMP /ident/ output list
where ident is up to a ten character identifier for this DUMP PAUSE STATEMENT
statement and output list is a standard WRITE output list that may
contain variables, constants, character strings, array elements, The general format of the PAUSE statement is:
array names and implied DO loops. PAUSE 'any char string'
The DUMP statement is used to display information when a This statement causes the program to wait for any input from the
runtime error occurs that is not trapped by an ERRSET statement. system console. To continue execution, press any key on the
More than one DUMP statement may be executed in a routine and system keyboard. If the character string option is specified, the
the last one executed is the one that will be output on a runtime string will be displayed on the system console. The string is
error. Each subprogram may contain its own DUMP statement, but enclosed in single quotes ('). To output a quote, two quotes in a
only the last DUMP statement executed in a particular routine will row must be entered; e.g. (") outputs as ('). The quotes surrounding
be saved and output if a runtime error occurs. the text are not displayed.
Example
Example
DUMP IAFTER-DIVI 'Index after divide is ',K PAUSE
PAUSE 'DATA OUT OF SEQUENCE, IGNORED'
PAUSE 'THIS IS A SINGLE QUOTE (")
ISUM=O
DO 10 1=1,10
A= K/I ISUM = ISUM + I
IF (ISUM .EQ. 5) PAUSE 'SUM = 5'
10 CONTINUE
END STOP
will cause the dump statement to output if I is zero. END

36 37
STOP STATEMENT 8 ARRAY SPECIFICATION
The general format of the STOP statement is: An array is a collection of values that are referenced by the same
name and the particular element is specified by a subscript.
STOP 'any char string' Subscripts can be real, integer expressions, or constants and will
STOP n be truncated to an integer value after the expression is evaluated.
When a STOP statement is executed, termination of the executing
Every array that is to be used must be dimensioned. Also, an array
program will occur. If the character string is specified, it will be
may have from one to seven dimensions.
printed on the system console when the statement is executed.
After the character string is output, the program terminates and Example
returns to CPIM. The string is enclosed in single quotes. To output If GRADE has 3 elements then:
a quote, two quotes in a row must be entered. The quotes GRADE (1) refers to the first element
surrounding the text will not be output. GRADE (2) refers to the second element
In the second form, n is a one to five digit integer number that will GRADE (3) refers to the third element
display. The n is optional. NOTE: Subscripted variables cannot be used as subscripts. Thus
To terminate a program without the STOP being typed on the GRADE (A(I)) is invalid, where both GRADE and A are arrays.
console, use the EXIT subroutine.
Example DIMENSION STATEMENT
STOP 'PROGRAM COMPLETE' The general format for a DIMENSION statement is:
STOP 1267
STOP DIMENSION v(n1 ,n2, ..,nm), ..
STOP 'ERROR OCCURRED, CHECK OUTPUT' Where v is the array name and N 1,N2, .. are the size of each of the
IF (ERROR .NE. O)STOP 'ERROR' dimensions of the array v.
IF (FLAG .AND. STOPIT)STOP 'ALL DONE' The DIMENSION statement is used to define an array. The rules
for using the DIMENSION statement are as follows:

END STATEMENT Every subscripted variable must appear in a DIMENSION


statement whether explicit (in a dimension statement) or
The format of the END statement is: implied (in a REAL, DOUBLE PRECISION, INTEGER, LOGICAL
END or COMMON statement) prior to the use of the first executable
statement.
This is a required statement for every FORTRAN routine. It is used
by the compiler to indicate the end of one logical routine. If an A DIMENSION specification must contain the maximum
END statement is executed, then the message STOP END IN - dimensions for the array being defined.
XXXXX will be output to the system console, with XXXXX being
The dimensions specified in the statement must be numeric in
replaced by the name of the FORTRAN routine in which the END the main routine. However, in subprograms, the subscripts may
statement was executed and the program will terminate. be integer variables. Hence, the following statement is valid
only in a SUBROUTINE or FUNCTION:
DIMENSION A(I,J)
In the case where the dimensions of an array are specified as
variables, the value of the variable at runtime will be used in
computing the position within the array to be accessed.

38 39
SUBSCRIPTS
All arrays passed to subprograms must be DIMENSIONED in
Subscripts are used to specify an entry into an array (i.e., the value
the subprogram, as well as in the main program. If the
specified in the subscript is the element of the array referenced).
arguments in the subprogram differ from those in the main
Subscripts may be INTEGERS, REAL (fractions are truncated),
program, then only those sections of the array specified by the
LOGICAL expressions, or any other valid expression. Expressions
DIMENSION statement in the subprogram will be accessible in
are evaluated as previously explained in the EXPRESSION section.
the subprogram.
Example
The number of dimensions specified for a particular array
cannot exceed seven. ZIT(8)
A(1 + 2)
No single array can exceed 32,767 bytes in size (5461 elements).
ORANGES(I + 5- (K*10)12)
Note: The following is a method that can be used to get around ABLE(5)
the size limit of arrays. Allocate the large array in a named
common block as 2 or more sequential arrays. Use just the first
array and subscript out of it as necessary. The way that common
blocks are allocated will assure you that the arrays are allocated
sequentially in memory. For example, if you want an array of 7000
elements, it can be defined as:
COMMON /DUMMYI TABLE(4000),TABLE1(3000)
Then, you would just use the array TABLE. To access the 4945th
element, just use TABLE (4945) (which is actually the 945th
element of TABLE1).
Example
(this statement is valid only
DIMENSION GUN (S,E)
in a subprogram as it uses
variable dimensions).
DIMENSION A(2,2),B(10)
DIMENSION ZIT(10)
REAL ABLE(10)
LOGICAL FUNCT(100)
DOUBLE PRECISION ARR(10),B(8),A(SIZE)
DI M ENSION A(3,2,3),C(1 0),ZOT(1 0,10)
INTEGER SWITCH(15)
"A" would require 3*2*3*(6) =
108 bytes
"C" would require 10*(6) =
60 bytes
"ZOT" would require 10*10*(6) =
600 bytes
"SWITCH" would require 15*(6) =
90 bytes
In calculating the memory used by an array, multiply each of the
dimensions times each other, then times 6. The result will be the
number of bytes used by the array for storage.
WARNING: No subscript range checking is performed at runtime.

41
FUNCTION STATEMENT
9 SUBPROGRAMS
The general format of the FUNCTION statement is:
Subprograms provide a means to define frequently used sections
of code that can be considered a unit. FORTRAN provides the FUNCTION name(list)
means to execute these subprograms whenever they are A FUNCTION statement is used to define a logical routine as a
referenced. FUNCTION. The type of result of a FUNCTION can be specified by
There are 3 types of subprograms supported in this version of preceding the FUNCTION with REAL, DOUBLE PRECISION,
INTEGER, or LOGICAL; or the name of the FUNCTION may appear
FORTRAN:
in a type statement within the FUNCTION.
SUBROUTINE subprograms
FUNCTION subprograms Example
Built in library functions FUNCTION SWAP (A)
The major differences between FUNCTIONS and SUBROUTINES SWAP=A
RETURN
are listed below:
END
FUNCTIONS are used in expressions, while SUBROUTINES
INTEGER FUNCTION SWAP (A)
must be CALLed.
FUNCTIONS require at least one parameter; SUBROUTINES do SWAP = IFIX(A)
RETURN
not require any.
The name on the FUNCTION statement must be the object of a END
replacement statement somewhere in the FUNCTION; this is FUNCTION SWAP (A)
not the case for a SUBROUTINE. INTEGER SWAP
WARNING: If a constant is passed as an argument in either a SWAP=AI2
CALL or FUNCTION reference, and the corresponding parameter RETURN
in the SUBROUTINE or FUNCTION is modified, then the value of END
the constant that was passed will be changed, and remain that of DOUBLE PRECISION VALUE(WHA n
the new value. VALUE= WHATI4*7 + 5
NOTE: All SUBROUTINES and FUNCTIONS must be compiled at RETURN
END
the same time.

SUBROUTINE STATEMENT CALL STATEMENT

The general format of the SUBROUTINE statement is: The general format of the CALL statement is:

SUBROUTINE name(list) CALL name(list)

The SUBROUTINE statement is used to identify the beginning of a The CALL statement is used to transfer control to a SUBROUTINE.
logical routine. This statement is required at the beginning of List specifies the parameters to be passed to the SUBROUTINE
every SUBROUTINE. The list that is to receive the values being and may be omitted if no parameters are to be passed.
passed to the subroutine is optional if no parameters are to be The number of parameters in a CALL and SUBROUTINE statement
passed. referring to the same subprogram must be the same. Otherwise, a
runtime error will result.
Example
SUBROUTINE ADDIT (RESULT,X,Y) Example
RESULT=X+Y CALL XSWAP (NUM1,NUM2,TOTAL)
RETURN CALLXSWAP
END

42
43
Example
RETURN STATEMENT
CALL X(&1,Y,2,&2)
There are two types of RETURN statements:

Normal RETURN
Multiple RETURN SUBROUTINE X(I,A,IC,J)

Normal RETURN C
C THE FOLLOWING RETURN WILL TRANSFER TO THE
The format for a normal RETURN is: C STATEMENT LABELLED '1' IN THE CALLING PROGRAM.
RETURN C
The RETURN statement is used to terminate execution of a RETURN I
subprogram whether it is a FUNCTION or a SUBROUTINE. Return
is transferred to the next statement following the CALL statement, C
or in the case of a FUNCTION, return is transferred back to the C THE FOLLOWING RETURN WILL TRANSFER TO THE
point where it was called with the value of the FUNCTION C STATEMENT LABELLED '2' IN THE CALLING PROGRAM.
returned. A RETURN statement is not valid in the MAIN routine C
and will cause an error during compilation if encountered in the RETURN J
END
MAIN routine.
NOTE: Multiple RETURNS are only valid for SUBROUTINES.
Example
SUBROUTINE ZERO(I,J)
1=0 BLOCK DATA SUBPROGRAM
J=O The BLOCK DATA subprogram is used to initialize variables in
RETURN named COMMON. The BLOCK DATA subprogram must contain no
END executable statements. It may contain only declaration statements
FUNCTION ZZ(VAL) for specifying variable types, array dimensions, COMMON blocks
COMMON IAI A,B,C and DATA statements.
ZZ= A+ BIC- VAL
Example
RETURN
END BLOCK DATA
INTEGER FIRST,LAST
COMMON lONE! NAMES(100) /TWOI FIRST,LAST
Multiple RETURN DATA FIRST 11/, LASTI101
The general format of the Multiple RETURN statement is: DATA NAMES 11,2.0,4,5,6,7,8,9,10,90*999991
END
RETURN I
NOTE: The variable in named COMMON can be initialized in any
This variation of the RETURN statement is used to transfer back routine. The BLOCK DATA subprogram appears only for
from a SUBROUTINE to a point other than the statement that compatibility with other FORTRAN systems.
immediately follows the CALL. The I in the RETURN is the name
of a variable in the argument list of the subroutine and must have
been passed as a label in the CALL. The CALL statement that
invokes a routine that contains a multiple return must pass the
label as one of the parameters. The statement label is indicated in
the argument list by preceding the label with an ampersand (&).

44 45
10 INPUT/OUTPUT This allows a FORMAT statement to be input at runtime and then
The following is some information concerning NEVADA to be used in either READ or WRITE statements within the
FORTRAN 110_ program. Thus, a particular FORMAT can be changed at runtime
instead of having to recompile the program. The FORMAT should
GENERAL INFORMATION be input using an A6 format specification as imbedded blanks
Input/Output (1/0) under FORTRAN may take one of the following (added if using less than an A6) will cause a runtime error.
forms:
Example
Standard Formatted 110 DIMENSION FORM(10)
Free Format 1/0 READ (0,10) 'ENTER DATA FORMAT ',FORM
Binary 1/0 10 FORMAT (10A6)
In standard formatted 1/0, input and output is defined in terms of
fields which are right justified on the decimal pOint, with zero
suppression. In a FORMAT statement, no more than three levels
of nested parentheses are allowed (outer set and two nested inner READ (4,FORM) A,B,C
sets).

Free Format 1/0 is used as in BASIC. All the values are entered
using commas (,) or carriage returns to delimit the numbers. WRITE (5,FORM) R1,R2,R3
Binary 110 is a third option that allows passing of large files
between FORTRAN programs, with the minimal amount of wasted 110 LIST SPECIFICATION
disk space. Each variable written in binary format uses six bytes of The 110 List is used to specify which variables are to be READ or
disk space.
WRITTEN in a particular 1/0 statement. The list has the same form
FORTRAN logical units 0 and 1 are dedicated to console input and for both READ and WRITE statements. The list can be composed
output and cannot be either opened or closed. An attempt to open of one or more of the following:
or close 0 to 1 will result in a runtime error. Logical unit 0 is used Simple (non-subscripted) variable
for console input and logical unit 1 is used for console output. Array element
Binary 110 cannot be specified for logical units 0 or 1 and dOing so Array name
will result in a runtime error.
Implied DO loop
There are two special 1/0 statements: Literal
TYPE Constant (WRITE only)
ACCEPT The above types are combined to form the 1/0 list specification.
The implied DO loop is used mainly to output sections of one or
Both of these are followed by a standard 110 list. TYPE is
more arrays and functions in the same way as does a regular DO
equivalent to WRITE (1, *) and ACCEPT to READ (0,*). This is just a loop. An example of an implied DO loop is:
convenient method of dOing console 1/0.
Example WRITE (1,*) (F(I),I = 1,3,1)
It should be noted that the outer parentheses and the comma
TYPE I,J,(A,(I),I= 1,10)
preceding the DO index are always necessary when using an
ACCEPT 'INPUT THE MAX COUNT',COUNT
implied DO loop. Nested DO loops can also be used. Each loop
A RUNTIME FORMAT can be specified for any formatted 1/0 must be enclosed in parentheses. An example follows:
statement by substituting an ARRAY name for the FORMAT
number. At runtime, the array is assumed to contain a valid
WRITE (1,*) (J,(F(I,J),I = 1,4),J = 1,30,2)
FORTRAN FORMAT (complete with its outer set of parentheses). The inner DO (I) is performed for each iteration of the outer DO (J).
Note that other than array elements can be included within the
range of an implied DO. Implied DO's can be nested to any depth,
each within its own set of parentheses.

46 47
END = is the label to which transfer of control is to be made
LITERALS (character strings enclosed in quotes) can be used in should an end-of-file condition be encountered. ERR = is the label
any WRITE statement and in READ statements that reference the to which control will be transferred, should an error other than
system console. The literals can be used as prompts for input or end-of-file occur during input, such as a bad sector. The ERR =
identification on output. does not handle input format errors (such as a decimal point in an
Example integer field). Use ERRSET to handle these input errors. 1/0 list is
the string of variables which accept the data to be read.
WRITE (1,*) 'A= ',A
TYPE 'The answer is ',ANS Example
WRITE (5,3) 'X = ',X READ (0,2)A Read from the system console
READ (0,*) 'A= ',A,' B= ',B the variable 'A' under FORMAT
ACCEPT 'Enter quantity ',QUANT number 2

NOTE: An attempt to use a literal in a READ statement that READ (0,*)A Read from the system console
doesn't reference the console will result in an INPUT ERR runtime the variable 'A' in free format.
error. READ (4)A Read from logical file 4, the
variable A in binary.
READ (4"END = 10)A Read from logical file 4, the
READ STATEMENT
variable A in binary. If end-of-
READ(unit{ ,format} {,END = end} {,ERR = error}) 1/0 list file is encountered, go to
The READ statement is required in order for the user to do input statement label 10
through the FORTRAN system. If a unit number of 0 is used, there READ (4,* ,END = 10,ERR = 100)A Read from logical file 4, the
is no need to open this file as it is assumed to be system console variable A in free format.
input. Should end-of-file be
Note: Do not use one as the logical unit. It is reserved for the encountered, go to statement
system console output. Any other unit number must first have label 10. If an error occurs, go
been opened by the user through the OPEN or LOPEN subroutine. to statement label 100.
The FORMAT entry may take one of the following forms: READ (4"ERR = 100)A Read from logical file 4, the
The FORMAT number is the label on the FORMAT statement variable A in binary format. If an
error occurs, go to statement
which is to be used,
An asterisk (*) in the FORMAT entry indicates that input is to be label 100.
free format. The exact format of the output depends on the NOTE: The EN D = and ERR = parameters are optional and can
value of the number being output and is determined at runtime.
appear in any order.
Binary input is assumed if the FORMAT entry is left blank (or
not specified).
If an array name is specified, that array contains the FORMAT
to be used.

A8
49
ENCODE statement
WRITE STATEMENT
The general form of the ENCODE statement is:
WRITE (unit{,format} {,END = end} {,ERR = error}) 1/0 list
ENCODE (variable,length,format) 1/0 list
The WRITE statement is used to output to either disk files or the
console. It performs a function that is the oPPosite of the READ The ENCODE statement is similar to a WRITE statement in that it
statement. The 1/0 list is specified exactly the same as for the is used for a memory to memory formatted WRITE. Variable is
READ statement with the exception that a string can always be either an unsubscripted variable name or an array name. Length is
used in the 1/0 list. However, the END =serves no function and the number of bytes (or characters) that the output record is to
will never be used by the WRITE statement. contain. If the number of characters generated by the ENCODE
statement is less than length, then the record will be blank
Example padded to length. If the number of characters in the generated
WRITE (1,2) I,J,PAY,WITHOLD record is greater, successive records of length character will be
WRITE =
(1) (1,1 1,10) placed in memory starting at variable. FORMAT is either an
asterisk for free formatting or the number of a FORMAT
WRITE (10, *) THIS
WRITE = =
(6,12,END 99,ERR 66) LOOP,COUNT statement.
Example

MEMORY TO MEMORY 110STATEMENTS DIMENSION A(15)

The ENCODE and DECODE statements allow 1/0 to be performed


=
ENCODE (A,80, *) (1,1 1,5)

to or from a specified memory location. This allows data in


memory to be read (using DECODE) with perhaps a different FORMAT STATEMENT AND FORMAT SPECIFICATIONS
format code depending on the data itself. The ENCODE statement
is similar to a WRITE statement in that data is formatted The general form of the FORMAT statement is:
according to the specified format type. However, with ENCODE, n FORMAT (s1,s2, ...sn)
instead of being output to a file, data will be placed in memory at
The FORMAT statement is used in FORTRAN to do formatted
the specified location for further processing.
input and output. Through the use of this statement, the
programmer has the ability to select the fields in which to read, or
DECODE statement
specify the columns on which to write. It is the use of this
The general form of the DECODE statement is: statement which gives FORTRAN its 1/0 power. On FORMATTED
DECODE (variable,length,format) 1/0 list input, blanks are treated as zeros except when reading in A
format. A constant enclosed in backslashes (i.e. \A \) can be used
The DECODE statement is similar to a READ statement in that it to enter a binary constant from a string within a FORMAT
causes data to be converted from external ASCII format to internal
statement.
FORTRAN type. Variable is either an unsubscripted variable name
or an array name. Length is the number of bytes to process for If a number cannot be written in the specified field width, then the
this READ starting at variable. If multiple records are required by entire field will be filled with asterisks(*)to indicate the error
the 1/0 list, successive records of length will be retrieved from condition.
memory. Input records will be blank padded on the right end as Note: Some FORTRAN will print a negative number even when
necessary, as in a READ statement. FORMAT is either an asterisk there is not enough room to place the negative sign in the field.
for free formatting or the number of a FORMAT statement. The negative sign will simply be omitted. In this case, NEVADA
FORTRAN will fill the field with asterisks. Using asterisks to fill a
Example
field that is not large enough to output a number, applies on all
DIMENSION A(15) output specifications.
READ (1,10) A
10 FORMAT (15A6) A zero will always be printed as 0.0 under a F, E or D field
DECODE (A,80,11) KNT1,KNT2,CNT3 specification. If a field is printed as 0.000 ... this indicates that the
11 FORMAT (110,13,F10.5) digits have been truncated because the D portion of the field
specification was not large enough.

51
50
All floating numbers output using the F, E or D (and G with a NOTE: Data can be read in the F format using the E or D format
floating pOint number) specifications will be rounded to the specification without causing an error.
appropriate number of digits specified by the D portion of the field When the E format is used for input, the data must be right
specifier. justified in the field. If it is not, then the blanks appearing in the
exponent field will be interpreted as zeros.
A-Type (Aw)
The A-Type specification is used to perform the input of F-Type (Fw.d)
alphanumeric data in ASCII character form. Up to six ASCII The F-Type specification is one of several specifications for
characters may be stored per variable name. However, this is performing 1/0 with floating point numbers. The digit portion of
entirely under program control. For example the user may choose the decimal number works the same as in the I-Type format. The
to store only one character per variable in a dimensioned array, in fractional part of the number is always printed, including trailing
order to do character manipulation. Characters are stored in the zeros. During input, the decimal point is assumed to be at the
variable left justified and zero filled. On output, these padding indicated pOSition, unless explicitly overridden in the input field.
zeros will be printed as blanks. It is not advisable to perform any The number ZERO will always print as 0.0 (with the decimal point
arithmetic operations on a variable that contains character data as aligned where specified) regardless of the field width or decimal
unpredictable results may occur. A format code of A6 is the digits specified. Remember to consider the decimal point and
maximum field width for both input and output. negative sign of the number when specifying the width of the
Example output field.
10 FORMAT (A10,110,A6) Example
Output
D-Type (Dw.d)
F4.1 32.2
The D-Type format is treated exactly the same way as the E format
F7.5 0.00001
code, except on output, a D is inserted into the number instead of
F3.0 7.
an E. On input, they are treated exactly the same.
F7.2 bbb4.50
E-Type (Ew.d) Input
The E-Type specification is another method of performing 1/0 with F7.2 b4.5bbb
floating pOint (real) numbers. It is through this specification that F2.1 70
the programmer may perform 1/0 using an exponential format. F7.5 bbbb001
That is a mantissa followed by an exponent of ten. As with the F F4.1 32.2
type, the decimal pOint is assumed to be at the indicated position NOTE: The b is used to indicate a blank position. During input, the
if not overridden in the input field. The exponent part of the input F field specifier reads w characters. If a decimal point is not read
number can be omitted, in which case it is treated as if it were an in the field, a decimal is inserted d digits from the right. A decimal
F type specification. The number will be printed as d digits point in the input field overrides the field specifications.
followed by the letter E, exponent sign, and a three digit exponent.
The d part cannot be zero for output.
GType (Gw.d)
Example The G-Type can be used on either input or output and for both
Output integer and real values where wand d have the same meaning as
in the E, D and F type formats. The G format is treated as follows:
E9.2 O.OOE+ 000
E9.2 0.12E + 004 Output
E10.0 invalid If the output element is of type integer, then the format code used
Input will be Iw.
E10.0 1000.
E9.2 1.23E + 004
E9.2 O.

53
52
If the output element is of type real, the actual format code used K-Type (Kw)
depends on the value of the number being output. The K-Type format code is used to transmit data in hexadecimal
format. Each byte of internal memory occupies 2 hexadecimal
Ew.d will be used if the number is outside the range of
characters. If w is less than 12 characters (6 bytes/variable, 2 hex
0.1 < = number < 10**d, or
characters/byte), the hexadecimal characters will be either input or
F(w - 5).d,5X if.1 <= number <1 output starting from the low order memory address (beginning of
F(w - 5).(d -1),5X if 1< = number < 10 the variable).
Example
WRITE (1,99) 1
F(w - 5).1,5X if 10* *(d - 2) < = number < 10* *(d -1) 99 FORMAT (K12)
F(w - 5).0,5X if 10**(d -1) < = number < 10**d
will output the line:
In general, in this range:
100000000081
F(w - 5).(d - (exponent of number)),5X
L-Type (Lw)
Input The L-Type specification is used with LOGICAL variables, where w
If the input element is of type integer: Iw, then the format code is the width of the field. On output, the letter T or F is printed (for
used will be Iw. .TRUE. or .FALSE. respectively). The T or F will be right justified in
the field. On input, the field is scanned from left to right until aT
If the input element is of type real: Ew.d, then the format code or F is found. The T or F can be located anywhere in the field and
used is Ew.d. all characters that follow the Tor F in the remainder of the field
are ignored. If the first character found is not a Tor F, an error will
Example be generated. If the input field is completely blank, then a .FALSE.
A=5.67 value will be used.
WRITE (1,34) A
Example
34 FORMAT (G10.5)
LOGICAL WHICH
READ (0,9) A
WRITE (1,11) WHICH
9 FORMAT (G9.3)
11 FORMAT (8L10)
I-Type (lw)
The I-Type specification is used as a method of performing 1/0 T-Type (Tw)
with integer numbers. On input, the number must be right justified
The T-Type code can be used on both input and output. It is used
in the specified field with leading zeros or blanks. On output, the
to move to an explicit column within the input or output buffer. W
leading zeros are replaced by blanks and the number is right
specifies an absolute column number that the next character is to
justified in the field. be read from (on input) or to be placed upon (on output). The first
Example column number is 1. On input, the T format code can be used to
re-read a particular set of columns in different format codes in the
10 FORMAT (10110)
same read statement. Tabbing beyond the end of the input record
causes the input record to be blank padded. On output, the output
cursor can be moved back (to the left) over text already inserted
into the output buffer, thus causing text already there to be over
written with new data. Tabbing beyond the maximum character
inserted into the output buffer will cause blanks to be inserted
into the output buffer to the indicated column. The maximum
value of w is 255.

54 55
Example Repeating field specifications
WRITE (1,56) I,LOT A field specification can be repeated in a FORMAT statement by
56 FORMAT (110,T50,14) preceding it with the number of times that it should be repeated.
Thus 4110 is the same as 110,110,110,110.The following FORMATS
=
J 1234
are equivalent:
WRITE (1,34) J
34 FORMAT (,$$$$$$$$$$',T5,14) 10 FORMAT (314,2F10.4)
will produce: 10 FORMAT (14,14,14,F10.4,F10.4)

$$$$$1234$ A single field specification or a group of field specifications can


be enclosed in parentheses and preceded by a group count. In this
X-Type (wX) case, the entire group is repeated the specified number of times.
The following FORMATS are equivalent:
The X-Type specification is used to space over any number of
19 FORMAT (14,2(13,F4.1))
columns with a maximum of 255 character positions. The w may
have any value from 1 to 255. 19 FORMAT (14,13,F4.1,13,F4.1)
The FORMATS:
On output, the columns spaced over will be set to blanks. On
input, w characters of the input record will be skipped. 10 FORMAT (15,2(13,F5.1))
Example 10 FORMAT (15,13,F5.1,13,F5.1)

10 FORMAT (10X,110,3X,15) execute exactly the same for output, but differ for input. In a
FORMAT without group counts, control goes to the beginning of
99 FORMAT (1X,'THIS IS A LlTERAL',5X,'$$$$')
the FORMAT statement for reading or writing of additional values.
Z-Type In a FORMAT with group counts, additional values are read
according to the last complete group.
Only used for output, the Z-Type specification indicates to the
system that a carriage return/line feed is not to be written at the Example
end of the record. The Z specification is ignored on input. READ (2,10) KNT,(Z(I),I = 1,KNT)
Example 10 FORMAT (151(F10.5))

WRITE (1,10) The 15specification will be used once and the array values will be
10 FORMAT ('INPUT X ',Z) read using the F10.5 specification.
READ (0, *) X Group counts can be nested to a maximum depth of two. Thus:
10 FORMAT (2(15,3(110)) is ok, while
I-TYPE (I)
10 FORMAT (2(15,3(110,2(11))) is not legal.
The I-Type specification is used to cause I/O to skip to the next
record. During input, this causes a new input record to be read
even though the previous one was not fully used. On output, the String Output
slash will cause the current line to be written out to the Character strings are written using a FORMATted write. The string
associated file. to be written is enclosed in SINGLE QUOTES (') and may not
Example contain a backslash (\). To output a single quote within the string,
two single quotes in a row must be entered. The string format type
54 FORMAT (1101) is only valid on output and if used with a READ will result in a
WRITE (1,100) 1,20,45 runtime error being produced.
100 FORMAT (13/213) A character string can also be specified using the H (or Hollerith)
will generate field specification. This is an awkward method of specifying a
character string, as the number of characters in the string must be
1 specified in front of the H. The H type should be avoided as it can
20 45
lead to problems.

56 57
The hexadecimal code for any character (except 0) can be inserted
in a string by enclosing it in backslashes (\). The backslash Free format 1/0 can also be used to any file, not just the console.
character can be changed using the CON FIG program. The file must first be opened using either the OPEN or LOPEN
routine. Then, specifying an asterisk as the FORMAT number will
Placing an ampersand (&) in front of a character in a string causes perform free format 110 to the specified file.
the character to be treated as a control character. To output an
ampersand, two ampersands in a row must be used. Example
Example CALL OPEN (2,'INFILE')
CALL OPEN (4,'B:FILE')
WRITE (1,46) CALL OPEN (3,'LST:')
46 FORMAT ('THIS IS A TEXT STRING') READ (2,*) (A(I),I = 1,10)
65 FORMAT (21HTHIS IS A TEXT STRING) WRITE (3,*) (A(I),I = 10,1, -1)
48 FORMAT ('This is an exclamation point \21 \')
generates: This is an exclamation point! BINARY 110
99 FORMAT ('This is a control L: &L') BINARY 1/0 provides a quick and efficient means of transferring
information to and from a file. The variables are READ or
generates: This is a control L: (followed by a control/L)
WRITTEN in BINARY format. That is, six bytes for each item in the
11 FORMAT (This is an ampersand: &&') 1/0 list. WRITE causes the item in the 1/0 list to be written exactly
generates: as it is stored in memory without any additional conversion. READ
This is an ampersand: &
does the opposite, reading six bytes directly into the 1/0 list item.
FREE FORMAT 110 No conversion or check is made on the data being read.

Input Example
WRITE (1) (1,1 = 1,100)
FREE format input is similar to BASIC. Blanks in this mode of
WRITE (1"ERR = 66) ARRAY
input are ignored completely. Numbers are entered in any format
(F, D, I or E) and can be intermixed as desired. Numbers must be READ (1"END=99) VALUE
separated from each other by a comma or a carriage return. A READ (1) THIS,IS,IT
comma may appear after the last number on an input line and is
NOTE: The binary READ and WRITE transfers six bytes from the
ignored if present. If the 1/0 list specifies more variables than
file specified directly to the variable in the 1/0 list. No check on
there are in an input record, succeeding records will be read until
the validity of the data is performed and the user should be sure
the last is satisfied. Blank input records and blanks imbedded in
that the variable contains valid numerical data before any
numbers are ignored in this mode. The last number in any input
arithmetic operations are done on the variable. An end-of-file is
record does not have to be followed by a comma.
indicated by either the physical end of the file or a six byte field of
Output all FF (hex). This is the value that ENDFILE will place at the end of
a file that has had binary writes performed on it.
With FREE format output, the exact output format used depends
on the type of the variable or constant being output. An integer
will result in an I type format being used, and a real will use a REWIND STATEMENT
G-type. (The actual format used in this case depends on the value The general format of the REWIND statement is:
being output).
REWIND unit
Example
The REWIND statement is used to position the file pointer
ACCEPT I associated with unit to the beginning of the file. Essentially, this
ACCEPT 'PLEASE ENTER ID NUMBER',ID,'HOW MUCH', statement closes and then re-opens the file at the beginning.
AMOUNT
READ (0,*) A,B,C Example

TYPE THE RESULTING VALUE IS ',VALUE REWIND 3


WRITE (0,*) THE RESULTING VALUE IS',VALUE REWIND INFILE
TYPE '1 + 1 = ',2 REWIND OUTF

58 59
GENERAL COMMENTS ON FORTRAN 110 UNDER CP/M
BACKSPACE STATEMENT The OPEN or LOPEN subroutine is used to associate a file with a
The general format of the BACKSPACE statement is: FORTRAN logical unit. Eight files are available, numbers 0 through
7 with 0 being permanently open and associated with input from
BACKSPACE unit {,error} the CPIM console, logical file 1 also is permanently open and
The BACKSPACE statement is currently not implemented and will associated with output to the CPIM console. Logical files 0 and 1
produce a message to that effect if encountered at runtime. cannot be opened or closed. Additionally, any logical unit
associated with the CPIM console (through the use of the
filename CON:) cannot have binary 110 done to it, cannot be
ENDFILE STATEMENT rewound (using REWIND), endfiled (using ENDFILE) or see ked
The general format of the ENDFILE statement is: (using the SEEK routine).
A file that is going to be written on should first be deleted, using
ENDFILE unit the DELETE subroutine before the file is opened. The OPEN
The ENDFILE statement is used to force an end-of-file on unit. routine does not delete a file as it does not know what type of 1/0
Any data that existed beyond the point in the file where the wi II be performed on it.
ENDFILE was executed will be lost.
The CLOSE routine will not place any end-of-file indicator in a file
Note: The ENDFILE file statement will also CLOSE the specified that was written to; the ENDFILE statement must be used to write
file. Essentially, ENDFILE is equivalent to closing the file. an end-of-file indicator to a file. The ENDFILE statement will write
the normal CPIM end-of-file indicator (control-Z) if the file specified
Example in the ENDFILE has been written to and no binary 1/0 was done to
ENDFILE 4 the file. If binary 1/0 has been done to the file, then an end-of-file
ENDFILE FILE of six bytes of FF (hex) will be written instead. If a file is written
and then read without being ENDFILEd, it is possible to encounter
unwritten data of unknown characters that may cause an error
during the READ (illegal character, end-of-file, etc.) All files that
are written to should be ENDFILEd.
When SEEKing within a file, remember that it is a BYTE position
that is specified in the call to SEEK. Each record written to a file
will contain a carriage return and line feed appended to the end of
it. Remember that the carriage return and line feed MUST be
included in the count of characters that make up a record. If
SEEKing on a record, it is up to the user to insure that each record
written contains the same number of characters. If the records do
not contain the same number, SEEKing can become a very
complicated task.

SPECIAL CHARACTERS DURING CONSOLE 110


Entering a CONTROL-X during input from the CPIM console will
cancel the current line and echo an exclamation point (!) followed
by a carriage return and line feed.
End-of-file from the CPIM console is indicated by a CONTROL-Z
being entered as the first character of an input line during console
1/0.
Entering a DELETE (7F hex) or CONTROL-H will erase the last
character entered.

61
60
11 GENERAL PURPOSE SUBROUTINE/FUNCTION The following is a list of possible errors that may be returned
through the optional error parameter.
LIBRARY
0= OK
The following list of FORTRAN subroutines and functions are 1 = Specified file not found
available: 2 = Disk is full
SUBROUTINE Name 3 = End-of-file encountered
4 = New filename for RENAME already exists
BIT 5 = Seek error
CHAIN 6 = Seek error (but file is closed)
CIN 7 = Format error in CHAIN or LOAD file
CLOSE
CTEST
DELAY AVAILABLE FORTRAN SUBROUTINES
DELETE
EXIT
BIT
LOAD
LOPEN CALL BIT(variable,bit displacement,'S'
MOVE 'R'
OPEN 'F'
OUT 'T',value
POKE The BIT subroutine allows the setting (S), resetting (R), flipping (F),
PUT or testing (T) of individual bits.
RENAME
RESET The bit at bit displacement from the start of variable will be set if
SEEK S is specified, reset if R is specified, flipped (1 will become 0 and
SETIO o will become 1) if F is specified; and, finally, the value of the
selected bit will be returned in value if T is specified. Value must
FUNCTION Name be present only for T. Displacement is specified starting with the
CALL leftmost bit.
CBTOF Example
CHAR
COMP CALL BIT (ZAPIT,O,'S')
INP CALL BIT (ZAPIT,O,'T',VALUE)
PEEK
CHAIN
For details as to the parameters required, see the following
descriptions of the individual routines. CALL CHAIN ('program name' {error})
If the error is present in the CALL statement and a CPIM error The CHAIN routine is used to load in another program overwriting
should occur, return will be to the statement following the call and the existing one in memory. This is NOT an overlay. The program
error will contain the appropriate error code as listed below. If an that issues the CALL CHAIN will be overwritten by the new
error is present and the routine completes successfully, then a program. If the program name specified does not exist, and an
zero will be returned for error. However, if error is not specified error was not specified, a CHAIN FL runtime error will be
and the routine encounters an error, the program will terminate produced. If the format of the program name file is incorrect,
with a runtime error. program execution will be terminated. The new program to be
loaded is assummed to have the .OBJ extension. The CHAIN
routine will NOT close any files that may be open. Thus, the new

62 63
routine will be able to use the same files as the routine that CTEST
issued the CHAIN without having to reopen them.
CALL CTEST (status)
Example The CTEST routine is used to test the status of the system
CALL CHAIN ('GRAPH') console. A zero is returned in status if there is no character ready
CALL CHAIN ('NXTPGM',ERROR) to input on the system console. A one is returned if there is a
CALL CHAIN (NEXT) character.
Example
CIN
C WAIT IN A LOOP UNTIL A CHARACTER IS HIT ON THE
The CIN routine enables the user to obtain a single character from C SYSTEM CONSOLE, THEN CHECK THE CHARACTER FOR A
the system console. The character is returned as the left most C LINE FEED (OAH) BEFORE CONTINUING.
byte of variable. The left most bit of value read will be zeroed. The
ARAND= .3478
other 5 bytes of variable remain unchanged. 10 ARAND = RAND (ARAND)
Example CALL CTEST (STATUS)
IF (STATUS .EQ. O)GO TO 10
C WAIT FOR A CARRIAGE RETURN (ODH) FROM THE CONSOLE
C
C BEFORE CONTINUING.
C CHARACTER HIT, READ IT
80 CALL CIN(CHAR)
IF (COMP(CHAR,#ODOO,1) .NE. O)GO TO 80
C
CALL CIN(CHAR)
In the above example, #DOOOmust be specified like this as the # IF (COMP(CHAR,#OAOO,1) .NE. O)GO TO 10
operator stores the number as OD 00 00 00 00 00 in memory. This
forces the hex value of a carriage return (OD) to be placed in the
left most byte for the COMP routine. DELAY
CALL DELAY(wait time)
CLOSE
The DELAY routine enables the user to implement a time DELAY
CALL CLOSE(unit) of 11100 of a second to 655.36 seconds. Wait time must be in
The CLOSE routine is used as a method of closing FORTRAN files range of 0 to 65535 with 0 being the maximum delay time, 1 being
which were previously opened through the OPEN and LOPEN the shortest and 65535 being 11100 less than O. This time is based
routine. Once the file has been closed, the file number is then on a 2 MHZ 8080 processor.
available for reuse. Example
Example CALL DELAY(10)
CALL CLOSE(3) CALL DELAY (HOWMUCH)
CALL CLOSE (FILE) CALL DELAY (WAIT)

DELETE
CALL DELETE ('file' {,error})
The DELETE routine is used by the FORTRAN user to remove a
file from the CPIM system. Note that once a file is deleted it
cannot be recovered. No error is generated if the file does not
exist and the error is not present.
Example
CALL DELETE('OUTFILE')
CALL DELETE('OUTFI LE' ,ERROR)
CALL DELETE (FILE)

64 65
LOPEN
EXIT
CALL LOPEN(unit,'file' {,error})
CALL EXIT
This subroutine is functionally the same as OPEN in that it
The EXIT routine will terminate execution of the FORTRAN associates a FORTRAN unit with a CPIM file except that the first
program in the same manner as the STOP statement, except that character of all output records will be processed as the printer's
EXIT does not output STOP to the system console. carriage control. This is usually used for a listing device such as a
Example printer. The first character of the record will not be output to the
file but processed as follows:
CALL EXIT
First Character Action
+ overprint the last record
LOAD blank (space) single skip
CALL LOAD('file to 10ad',load-type{ ,error}) o double skip
- triple skip
The LOAD routine is used to load either a standard CPIM .HEX file
1 page eject
or a NEVADA ASSEMBLER .OBJ file. If load-type is zero, then the
type of the file to be loaded will be .HEX. If load-type is non-zero, If none of the above characters are present, then single-line
then the type will be .OBJ. This routine can be used to load spacing will be assumed. Overprinting is implemented by only
assembly language routines into memory that can then be generating a carriage return at the end of the line (not followed by
accessed through the CALL function. No check is made during a line feed). A page eject generates a form feed character (OCH).
the loading process to see whether the object code being read The output device that finally prints the output from this file must
into memory overlays the program or runtime package. respond in the following manner:
It is left up to the user to insure that it does not occur. Normally, ODH (carriage return) - return to beginning of this line
the routine package occupies memory from 100H to 4000H. If the OAH (line feed) - space 1 line, do not return to
file to load does not exist and an error is not specified, a CHAIN beginning of line
FL runtime error will be produced. If the format of the program OCH (form feed) - space to the top of the next page
name file is incorrect, program execution will be terminated.
A carriage return must cause the line to be printed on a line
Example oriented device.
CALL LOAD ('ASMFILE',O)
Example
CALL LOAD ('ASMOBJ',1,ERROR)
CALL LOPEN (2,'LST:')
C
C PAGE EJECT TO TOP OF NEW PAGE
C
WRITE (2,1)
1 FORMAT (,1THIS SHOULD BE ON THE TOP OF A NEW
PAGE')
C
WRITE (2,2)
2 FORMAT ('OONE BLANK LINE ABOVE THIS ONE'I
* '+ ','THIS LINE WILL OVERPRINT THE ONE ABOVE'I
* '- ',5X,'THIS LINE WILL HAVE 2 LINES ABOVE IT')
STOP
END

67
66
Example
MOVE
CALL OPEN (3,'CON:')
CALL MOVE(count,from,displacement,to,displacement)
WRITE (3,*) 'A =
',A
The MOVE routine allows direct access to memory for both reads will output the text to the system console. Files opened with the
and writes. The count specifies the number of bytes to be moved. name CON: can also use a literal in an input statement such as:
The arguments from and to specify either a memory address to be
used or a character string to be moved. Which interpretation of, CALL OPEN (4,'CON:')
from, and to is based on the respective displacement. If the READ (4,*) 'INPUT QUANTITY ',QUANT
displacement is negative, then the associated from or to specifies Output can be directed to the CPIM LST device by opening the file
an address to be used in memory access. If the displacement is LST: as in the following example:
positive, then the from or to that is associated with it is a string.
CALL OPEN (2,'LST:')
Example =
WRITE (2,*) (1,1 1,123)
CALL MOVE(2,A, - 1,$CCOO,- 1)
This MOVES 2 bytes from the address specified by A to To open a disk file, just the filename needs to be specified such
address CCOO(H EX). as:

CALL MOVE(6,'STRING',0,$CCOO, - 1) CALL OPEN (4,'C:FILE.BAS')


This MOVES 6 bytes of the string 'STRING' to address CALL OPEN (2,'DISKFILE')
CALL OPEN (3,'B:INPUT')
CCOO(HEX).
READ (3,*) VALUE
CALL MOVE(1024,$CCOO, - 1,A,0) WRITE (2,22) VALUE
This MOVES 1024 bytes from address CCOO (HEX) to the 22 FORMAT (F10.4)
address of A. WRITE (4,55)
NOTE: The DOLLAR ($) sign indicates a hexadecimal constant. 55 FORMAT ('THIS LINE WILL BE WRITTEN TO THE FILE')
This hexadecimal constant is converted to floating point notation To open a file and check if the file exists, the optional error
internally. parameter must be specified such as:
CALL OPEN (3,'INPUT',IERROR)
IF (IERROR .NE.O)THEN
OPEN TYPE 'CANNOT OPEN INPUT FILE'
CALL OPEN(unit,'file' {,error} ) STOP 'RUN ABORTED'
The OPEN routine is used to open a CPIM file the user may wish ENDIF
to access. The unit and file are required entries. If the CPIM file NOTE: The filename (whether a character string or array name) is
does not exist and error is not specified, then the file will be defined as terminating when:
created. However, if error is specified and the file does not exist,
the appropriate CPIM error code will be returned and the file will 13 characters are encountered
A NULL is encountered
not be opened.
There are two special filenames that are recognized by the OPEN
routine: OUT
CON: Used to specify either CPIM console input or output CALL OUT (port,value)
LST: Used to specify CPIM list device This routine allows access to the 8080180851Z80 output ports.
Value will be converted to an 8 bit number and output to port.
Example
CALL OUT(10,1)
CALL OUT (PORT,10)
CALL OUT (CONTROL,BITVL)

68 69
RESET
POKE
CALL RESET
CALL POKE(memory location,value)
The RESET routine is used to inform CPIM that a disk has been
This routine allows changing of memory locations. Value will be changed at runtime. This routine must be called if a disk is
converted to an 8 bit quantity and stored at the location specified changed and you wish to write on the new disk. If the RESET
by memory location. routine is not called, then a BDOS: RIO will occur and the program
will abort if a write is attempted on the changed disk. This routine
Example will prompt for a change in disk and wait for the change to occur.
CALL POKE (0,34) Also, all open files on the disk to be changed should be closed
CALL POKE (1,PEEK(1)+ 1) (using the CLOSE routine) before RESET is called. The
The last example will increment the contents of memory location programmer is responsible for closing the files. They can be done
0001. as follows:
Example
PUT
CALL CLOSE (4)
CALL PUT(value) CALL CLOSE (5)
The PUT routine is used to output a character to the console C
without the FORTRAN system interpreting it. Using this routine, it C THE "RESET" ROUTINE WILL PROMPT FOR THE
is possible to do such things as control the position of the cursor. CHANGE
Value must be a number or variable and cannot be a string. C
CALL RESET
Example
CALL PUT(27)
CALL PUT(61) will clear the screen on an ADM 3A
CALL PUT (CHAR('A',O)) will output an A SEEK
CALL SEEK (unit,position {,error} )
The SEEK routines allow random positioning within a file. The file
RENAME
associated with unit will be positioned to position which specifies
CALL RENAME('old file','new file',{ error}) a displacement in bytes from the beginning of the file. If error is
The RENAME routine will rename old file to new file. A runtime specified, there are two possible values that may be returned on a
error occurs if old file does not exist and error is not specified or seek error. A five indicates a seek to a part of the file that doesn't
new file already exists. exist, and a six indicates a seek to an extent of the file that does
not exist. The difference between the two is that if error code six
Example is return, the file associated with unit is closed. The file will have
CALL RENAME ('OLD','NEW') to be re-opened before it can be used again.

DIMENSION OFILE(2),NFILE(2) Example


READ (0,1) OFILE,NFILE CALL SEEK (FILE,IPOS*10+ 4)
1 FORMAT (2A612A6) CALL SEEK (3,100,ERROR)
CALL RENAME (OFILE,NFILE,ERROR)

71
CBTOF
SETIO
A = CBTOF(from,displacement {,8-bit} )
CALL SETIO(new 1/0)
The CBTOF function is used to convert either a 16 bit or 8 bit
This routine allows changing how the runtime package performs
binary number to its equivalent floating point value. The number to
console 1/0. The default method is setup using the CONFIG
be converted is located at from + displacement if displacement is
program, however it can be changed as follows:
positive. If displacement is negative, then from contains the
new 1/0 = 0 to use direct BIOS 1/0 address to be used. The number is assumed to be a 16 bit value
new 1/0 = 2 to use CPIM function 1&2 (stored in standard 8080 format) unless 8-bit is present, in which
new 110 <> 0 or 2 to use CPIM function 6 (should be used case it will be assumed to be an 8 bit value. The binary number is
with CPIM 2.x only). considered to be unsigned.
The use of CPIM functions 1&2 permits the use of the control-p Example
ability of CPIM to echo all the console output to the LST device.
BIOS= CBTOF($0006,1)- 3
Use of other options will bypass this ability.
gets the base address of the CPIM BIOS jump table by reading the
Example 16 bit address at location 0001 and subtracting 3 from it.
CALL SETIO (2)
CALL SETIO (10)
CHAR
A = CHAR(variable,displacement)

Available FORTRAN Functions The CHAR routine is used to return the numerical value of an
ASCII character located at variable + displacement where
CALL displacement is a byte displacement from the beginning of
variable. For example:
A = CALL(address,argument)
The CALL function causes execution of assembly language Example
routines that have been loaded into memory (usually by the LOAD A='ABCDEF'
subroutine). Address is the memory location to be CALLed. B = CHAR(A,O) returns 61
Argument will be converted to a 16 bit binary number and then B = CHAR(A,1) returns 62
passed to the called routine in both the BC and DE register pairs. B = CHAR(A,5) returns 66
The assembly routine places the value to be returned in register
pair HL. The return address is placed on the 8080 stack and the
CALLed routine can just issue a standard RET instruction to return COMP
to the FORTRAN program. A = COM P(string1 ,string2,length)
Example The COMP routine is used to compare character strings in the
CALL LOAD ('ASMFILE',1) following manner:
A = CALL ($DEOO,VALUE) A = COMP('string1' ,'string2' ,length).
The strings will be compared on a byte basis for a byte count of
length. The routine returns the following:
- 1 if string1 < string2
o if string1 = string2
+ 1 if string1 > string2

72
73
INP
A = INP(port)
This routine allows access to the 8080180851Z80 input ports. This
is a function whose value is the current setting of the input port
specified by port. No wait is done using the INP routine. It will
return the current value that the input port contains.
Example
1= INP(10)
10 IF (INP(CONSOLE) .NE. O)GO TO 10
VALID =
INP(CLOCK) .AND. 48

PEEK
A = PEEK(memory location)
The PEEK routine is used to read an 8 bit value from a memory
location. The byte at the address specified by memory location
will be returned as the value of the function.
Example
NEVADA ASSEMBLER™
BIOS = (PEEK(1) + PEEK(2)*256) - 3
This is equivalent to the example of using CBTOF. User's Reference Manual

Copyright© 1982,1983 by Ellis Computing, Inc.


Copyright© 1983 Commodore Electronics Limited

75
74
12 INTRODUCTION TO NEVADA ASSEMBLER
13 OPERATING PROCEDURES
HARDWARE REQUIREMENTS
The assembler translates a symbolic 8080 assembly language
program "source code" into the binary instructions "object code" Your Commodore 64 Computer
required by the computer to execute the program. The Commodore Z80 microprocessor
The assembler operates on standard CP/M text files. Each line of a A Commodore 1541 single disk drive
normal text file consists of the characters of that line followed by
A video display monitor such as the Commodore color monitor
a carriage return (0DH) and a line feed (0AH).
model 1701/1702
When the assembler is invoked, it is loaded into memory starting
at location 100H. It processes the source code file in two passes. SOFTWARE REQUIREMENTS
On the first pass, it builds a symbol table containing all of the
Commodore's CP/M Operating System disk
labels defined in the source program. The symbol table begins at
the memory location immediately following the assembler; each
FILE TYPE CONVENTIONS
entry in the table is seven bytes long. Certain errors may be
detected during the first pass, causing error messages to be Assembly source code files .ASM
output to an error file (usually the console). On the second pass, COBOL source code files .CBL
the object code is generated and usually output to an object code FORTRAN source code files .FOR
file. In addition, a formatted listing of both source and object code Object code run time files .OBJ
may be output to a listing file and the symbol table may be output Printer listing files .PRN
to a file. Any errors detected during this pass cause messages to Symbol table listing files .SYM
be output to the error file. Error files .ERR
Work files .WRK
To abort the assembly process at any time, press the CTRL and C
keys. GETTING STARTED
After the assembly runs to completion and no errors are detected,
Refer to the Getting Started section in your Commodore 64
the resulting object code file (type .OBJ) can be executed by
NEVADA FORTRAN manual.
typing RUNA and its name.
EXAMPLE: EXECUTING THE ASSEMBLER
RUNA PROG loads and executes a file called PROG. The assembler is invoked by a CP/M command with the following
formats.
FORMAT-1:
ASSM file <CR>
FORMAT-2:
ASSM file[.uuu u$#LP0] <CR>

77
76
DESCRIPTION: +L The source file has line numbers in column
where: 1-4 of each line.
file = [unit:] source-file-name -L The source file has no line numbers.
The name of the source code input file. This
If neither of these is specified, the assembler
parameter must be present; all others are
will examine the first line to determine if the
optional. file has line numbers.
[]= optional parameters # Instructs the assembler to generate its own
unit: disk drive unit letter. If this parameter is not line numbers in the listing in place of those in
included the default drive is used. the source file (if any).
u = the disk drive unit letter or the letter "X" for P Instructs the assembler to paginate output to
output to the console, or the letter "Z" for no the listing file. The file name of the source
output. code file will be printed on the top left-hand
corner of each page. A page number will be
u for position one.
printed on the top right-hand corner of each
This single character code, if present,
page. If a TITL pseudo-operation occurs in the
represents the drive onto which the listing file
source code, a one- or two-line title will be
is to be written. If this argument is absent,
centered at the top of each page.
then the listing will be written on the default
drive. Also, if the character is an X, the listing 0,1,2, or 3 Specifies the spacing on the listing:
will be sent to the console. If the character is
o= no additional spaCing
a Z, then no listing is produced.
1 = 72 column output
u for position two. 2 = 80 column output (default)
The second letter of the file type represents 3 = 132 column output
the drive for the object (.OBJ) file. If this S Specifies output symbol table in format for
argument is absent, then the file will be SID.
written on the default drive. If this character is
a Z, then no object code file will be produced. EXAMPLES:
ASSM TST
u for position three. ASSM TST.AAX A$- L#P0
The third letter of the file type represents the
drive for the error (.ERR) file. If this argument STARTUP
is absent, the console will be used to display
the errors. This argument must be followed by To assemble your program, type ASSM and the source file name.
a space or carriage return. The first thing that happens is the copyright message is displayed
on the screen and the disk drive(s) begins working. When the
u for position one of the second set. assembly process is complete, a message will be displayed and
The first letter of the second set of arguments machine control will return to the operating system.
represents the drive for the symbol (.SYM) file.
If this argument is absent, no symbol table A>ASSM source-file <CR>
file will be produced. NEVADA ASSEMBLER (C) COPYRIGHT 1982
ELLIS COMPUTING, INC.
<$options> REV 2.1 ASSEMBLING
Various assembler options may be controlled
by following the $ with one or more of the NO ASSEMBLY ERRORS. 4 LABELS WERE DEFINED.
following option specifiers. The list of options A>
is terminated by a carriage return. For those
options that may be preceded by + or -, the
+ is optional and will be assumed if absent.

78 79
EXECUTING THE _OBJ FILE 14 STATEMENTS
To execute the program, type RUNA and the file-name. The INTRODUCTION
assembly process creates a file with the extension type of (.OBJ).
This object program file will be loaded into memory and executed. An assembly language program (source code) is a series of
statements specifying the sequence of machine operations to be
A>RUNA file-name performed by the program.
There are several options that also can be specified with the Each statement resides on a single line and may contain up to
RUNA command. four fields as well as an optional line number. These fields, label,
RUNA file-name [.ZLC] operation, operand, and comment, are scanned from left to right
by the assembler, and are separated by spaces. The assembler
Z = zero memory before loading the .OBJ file.
can handle lines up to 80 characters in length.
L = load the program but don't execute it. Control returns to
CP/M.
LINE NUMBERS
C = create a .COM file for later execution. Control returns to
CP/M. Remember .COM files always begin execution at Line numbers in the range 0000-9999 may appear in columns 1-4.
location 100H. Line numbers need not be ordered and have no meaning to the
assembler, except that they appear in listings. Line numbers may
Example:
also make it easier to locate lines in the source code file when it
A>RUNA PROG.ZC this will zero memory and create a file is being edited. The disk and memory space required for normal
named PROG.COM. text files will be increased by five bytes per line if line numbers
A>RUNA PROG.L this will load PROG but not execute it. are used; this may become Significant for large files.
NOTE: These object code files (.OBJ), if properly orged (assembled If line numbers are not used, the label field starts in column 1 and
with proper origin), can also be loaded and executed by the the operation field may not start before column 2. If line numbers
NEVADA COBOL and NEVADA FORTRAN run time packages. are used, they must be followed by at least one space, so the label
However, NEVADA COBOL and NEVADA FORTRAN generated field starts in column 6 and the operand may not start before
type (.OBJ) files cannot be converted to (.COM) files by RUNA column 7.
because of runtime package requirements. Please see the Nevada
Once the starting column for the label has been established, the
FORTRAN manual for the procedure to generate a FORTRAN
same format must be followed throughout the file: either all of the
(.COM) file.
lines or none of the lines can have line numbers. Any other file(s)
assembled along with the main file (usng COPY pseudo-operation)
MEMORY USAGE must conform to the format of the main file.
The ASSEMBLER program is read into memory starting at location Example of source statements with line numbers:
100H and uses all memory available up the bottom of CP/M. Column
The runtime package RUNA loads into memory at location 100H 1234567
and relocates itself to just below CP/M and then begins loading 0001 LABEL ORA A label field must start at column 6.
your program. 0002 JNZ NEXT operation field starts at column 7
0003 ; (minimum).
0004 LOOP MOV A,B operation field starts one space after
TERMINATION
0005 * label.
The normal termination of the assembly is signaled by the display
of the following messages and returned to CP/M.
Example of source statements without line numbers:
Column
NO ASSEMBLY ERRORS. 4 LABELS WERE DEFINED.
1234567
A>
LABEL ORA A label field must start at column 1.
The assembly process can be interrupted at any time by pressing JNZ NEXT operation field starts at column 2 (minimum).
the CTRL and C keys. LOOP MOV A,B operation field starts one space after label.

80 81
LABEL FIELD Register Names
The label field must start in column 1 of the line (column 6 if line Many 8080 machine instructions require one or two registers or a
numbers are used). A label gives the line a symbolic name that register pair to be deSignated in the operand field. The symbolic
can be referenced by any statement in the program. Labels must names for the general-purpose registers are A, B, C, D, E, Hand L.
start with an alphabetic character (A-Z,a-z), and may consist of any SP stands for the stack pointer, while M refers to memory location
number of characters, though the assembler will ignore all whose address is in the HL register pair. The register pairs BC, DE
characters beyond the sixth; e.g. the labels BRIDGE, BRIDGE2, and HL are designated by the symbolic names B, D, and H,
and BRIDGET cannot be distinguished by the assembler. A respectively. The A register and condition flags, when operated
duplicate label error will occur if any two labels in a program begin upon as a register pair, are given the symbolic name PSW.
with the same six letters. The values assigned to be register names A, B, C, D, E, H, L, M,
A label may be separated from the operations field by a colon (:) PSW and SP are 7, 0, 1, 2, 3, 4, 5, 6, 6, and 6, respectively. These
instead of, or in addition to, a blank. constants, or any label or expression whose value lies in the range
The labels A, B, C, D, E, H, L, M, PSW, and SP are pre-defined by
o to 7, may be used in place of the pre-defined symbolic register
names where a register name is required; such a substitution of a
the asembler to serve as symbolic names for the 8080 registers.
value for the pre-defined register name is not recommended,
They must not appear in the label field.
however.
An asterisk (*) or semi-colon (;) in place of a label in column 1
(column 6 if line numbers are used) will deSignate the entire line Labels
as a comment line. Any label that is defined elsewhere in the program may be used as
an operand. If a label is used where an 8-bit quantity is required
(e.g., MVI C,LABEL), its value must lie in the range - 256 to 255, or
OPERATION FIELD it will be flagged as a value error.
The operation field contains either 8080 instruction mnemonics or
If a label is used as a register name, its value must lie in the range
assembler pseudo-operation mnemonics. Appendix 1 summarizes o to 7, or be 0, 2, 4, or 6 if it designates a register pair. Otherwise,
the standard instruction mnemonics recognized by the assembler,
it will be flagged as a register error.
and Appendix 4 lists several references to consult if more
information on the 8080 machine instructions is needed. During each pass, the assembler maintains an instruction location
Assembler pseudo-operations are directives that control various counter that keeps track of the next location at which an
aspects of the assembly process, such as storage allocation, instruction may be stored; this is analogous to the program
conditional assembly, file inclusion, and listing control. counter used by the processor during program execution to keep
track of the location of the next instruction to be fetched.
An operation mnemonic may not start before column 2 (column 7
if line numbers are used) and must be separated from a label by at The special label $ (dollar sign) stands for the current value of the
least one space (or a colon). assembler's instruction location counter. When $ appears within
the operand field of a machine instruction, its value is the address
of the first byte of the next instruction.
OPERAND FIELD Example:
Most machine instructions and pseudo-operations require one or FIRST EQU $ The label FIRST is set to the address
two operands, either register names, labels, constants, or TABLE DB ENTRY of the entry in a table and LAST
arithmetic expressions involving labels and constants. * points to the location immediately after
The operands must be separated from the operator by at least one * the end of the table. TABLN is then
space. If two operands are required, they must be separated by a the length of the table and will remain
comma. No spaces may occur within the operand field, since the LAST EQU $ correct, even if later additions or
first space following the operands delimits the comments field. TABLN EQU LAST-FIRST deletions are made in the table.

82 83
CONSTANTS EXPRESSIONS

Decimal, hexadecimal, octal, binary and ASCII constants may be Operands may be arithmetic expressions constructed from labels,
used as operands. constants, and the following operators:
The base for numeric constants is indicated by a single letter + addition or unary plus
immediately following the number, as follows: - subtraction or unary minus
* multiplication
D= decimal / division (remainder discarded)
H= hexadecimal
o= octal Values are treated as 16-bit unsigned 2's complement numbers.
Q = octal Positive or negative overflow is allowed during expression
B = binary evaluation, e.g., 32767+ 1= 7FFFH + 1 = - 32768 and
=
- 32768- 1 7FFFH = 32767. Expressions are evaluated from left
If the letter is omitted, the number is assumed to be decimal. Q is to right; there is no operator precedence.
usually preferred for octal constants, since 0 is so easily
confused with 0 (zero). Numeric constants must begin with a If an expression is used where an 8-bit quantity is required (e.g.,
numeric character (0-9)so that they can be distinguished from MVI C,TEMP+ 10H), it must evaluate to a value in the range - 256
labels; a hexadecimal constant beginning with A-F must be to 255, or it will be flagged as a value error.
preceded by a zero. Examples:
ASCII constants are one or two characters surrounded by single MVI A,255D/10H- 5
quotes ('). A single quote within an ASCII constant is represented LDA POTTS/256*OFFSET
by two single quotes in a row with no intervening spaces. For LXI SP,30*2+ STACK
example, the expression '''', where the two outer quote marks
represent the string itself, i.e., the single quote character. A single
character ASCII constant has the numerical value of the
corresponding ASCII code. A double character ASCII constant has High- and Low-Order Byte Extraction
the 16-bit value whose high-order byte is the ASCII code of the If an operand is preceded by the symbol <, the high-order byte of
first character and whose low-order byte is the ASCII code of the the evaluated expression will be used as the value of the operand.
second character. If an operand is preceded by the symbol >, the low-order byte will
If a constant is used where an 8-bit quantity is required (e.g., MVI be used.
C,10H), its numeric value must lie in the range - 256 to 255 or it Note that the symbols < and> are not operators that may be
will be flagged as a value error. applied to labels or constants within an expression. If more than
If a constant is used as a register name, its numeric value must lie one < or> appears within an expression, the rightmost will be
in the range 0 to 7, or be 0, 2,4, or 6 if it designates a register pair. used to determine whether to use the high- or low-order byte of
Otherwise, it will be flagged as a register error. the evaluated expression as the value of the operand. That is, the
rightmost < or> is treated as if it preceded the entire expression,
Examples: and the others will be totally ignored.
MVI A,128 Move 128 decimal to register A. Examples:
MVI C,10D Move 10 decimal to register C.
LXI H,2FH Move 2F hexadecimal to registers HL. MVI A,>TEST Loads register A with the least
MVI B,303Q Move 303 octal to register B. * significant 8 bits of the value of
Move the ASCII value for Y to register A. * the label TEST.
MVIA,'Y'
MVI A,101B Move 101 binary to register A. MVI B,<0CC00H Loads register B with the most
Jump to address FF hexadecimal. * significant byte of the 16-bit value
JMP OFFH
* CC00H, i.e., CCH.
MVI C,<1234H Loads register C with the value 12H.
MVI C,>1234H Loads register C with the value 34H.

84 85
COMMENT FIELD
15 PSEUDO-OPERATIONS
The comment field must be separated from the operand field (or
operation field for instructions or pseudo-operations that require
Pseudo-operations appear in a source program as instructions to
no operand) by at least one space. Comments are not processed
the assembler and do not always generate object code. This
by the assembler, but are solely for the benefit of the programmer.
section describes the pseudo-operations recognized by the
Good comments are essential if a program is to be understood NEVADA ASSEMBLER.
after it is written or is to be maintained by someone other than its
author. In the following pseudo-operation formats, <expression> stands
for a constant, label, arithmetic expression constructed from
An entire line will be treated as a comment if it starts with an
constants and labels. Optional elements are enclosed in square
asterisk (*) or semicolon (;) in column 1 (column 6 if line numbers brackets [].
are used).
Equate < label> EQU < expression>
Examples
This pseudo-operation sets a label name to the 16-bit value that is
0001 , is input ready? represented in the operand field. That value holds for the entire
0002 LOOP IN STAT input device status assembly and may not be changed by another EQU.
0003 AN I 1 test status bit
0004 JZ LOOP wait for data Any label that appears in the operand field of an EQU statement
0005 * data is now available must be defined in a statement earlier in the program.

If listing file formatting is specified in the ASM command Examples:


=
($ options contains 1, 2, or 3), the comment field must be BELL EQU 7 The value of the label BELL is set to 7.
preceded by at least two spaces to ensure proper output BELL2 EQU BELL *2 The label BELL2 is set to 7*2.
formatting. Furthermore, instructions and pseudo-operations
Set Origin [<label>] ORG <expression>
requiring no operand must be followed by a dummy operand (a
period is recommended). This pseudo-operation sets the asembler's instruction location
Examples: counter to the 16-bit value specified in the operand field. In other
words, the object code generated by the statements that follow
MVI A,10 comments must be loaded beginning at the specified address in order to
RZ comments execute properly. The label, if present, is given the specified 16-bit
value.

Any label that appears in the operand field of an ORG statement


must be defined in a statement earlier in the program.
If no origin is specified at the beginning of the source code, the
assembler will set the origin to 100H. If no ORG pseudo-operation
is used anywhere in the source program, successive bytes of
object code will be stored at successive memory locations.
Examples:
ORG 4000H Determines that the object code generated
* by subsequent statements must be loaded
* in locations beginning at 4000H.
START ORG 100H Determines that the object code generated
* by subsequent statements must be loaded
* in locations beginning at 100H.

86 87
Set Execution Address XEQ < expression> Define Word [< label>] DW < expression>
This pseudo-operation specifies the entry point address for the This pseudo-operation sets two memory locations to a 16-bit
program, i.e., the address at which it is to begin execution. If a quantity. The least significant (low-order) byte of the value is
program contains no XEQ pseudo-operation, the object code file stored at the current address and the most significant byte (high-
will contain a starting address of 100H. If more than one XEQ order) is stored at the current address + 1.
appears in a program, the last will be used.
Examples:
An example of the difference between ORG and XEQ is that a
program whose first 100 bytes are occupied by data will have an SAVE DW 1234H 1234H is stored in memory, 34H in the
ORG address 100 bytes lower in memory than its XEQ address. low-order byte and 12H in the high-order
* byte.
Example: YES DW 'OK' The ASCII value for the letters '0' and 'K'
XEQ 100H The entry point address for the assembled * is stored with the 'K' at the lower memory
* program is set to 100H. * address.

Define Storage [<label>] DS <expression> Define Double Byte [<label>] DDB <expression>
[< label>] RES < expression> This pseudo-operation is almost the same as DW, except that the
Either of these pseudo-operations reserves the specified number two bytes are stored in the opposite order: high-order byte first,
of successive memory locations starting at the current address followed by the low-order byte.
within the program. The contents of these locations are not Example:
defined and are not initialized at load time.
FIRST DDB 1234H 1234H is stored in memory, 12H in the
Any label that appears in the operand field of a DS or RES
; low-order byte and 34H in the high-order
statement must be defined in a statement earlier in the program. ; byte.
Examples:
SPEED DS 1 Reserves one byte.
DS400 Reserves 400 bytes. Define ASCII String [<label>] ASC #<ASCII string>#
RES 177Q Reserves 177 (octal) bytes. [< label>] ASCZ #< ASCII string >#
The ASC pseudo-operation puts a string of characters into
Define byte [< label>] DB < expression> [,< expression> , ] successive memory locations starting at the current location. The
This pseudo-operation sets a memory location to an 8-bit value. If special symbols # in the format are "delimiters"; they define the
the operand field contains multiple expressions separated by beginning and end of the ASCII character string. The assembler
commas, the expressions will define successive bytes of memory uses the first non-blank character found as the delimiter. The
string immediately follows this delimiter, and ends at the next
beginning at the current address. Each expression must evaluate
to a number that can be represented in 8 bits. occurrence of the same delimiter, or at a carriage return.

Examples: The ASCZ pseudo-operation is the same except that it appends a


NUL (00H) to the end of the stored string.
DB1 one byte is defined.
Examples:
DB OFFH,303Q,100D,11010011B,3*BELL,-10 multiple bytes.
TABLE DB 'A','B','C','D',0 multiple bytes are defined. WORDS ASC "THIS IS AN ASCII STRING"
ASCZ "THIS IS ANOTHER STRING"

88 89
Set ASCII List Flag ASCF0 List Conditional code IFLS
ASCF 1
This pseudo-operation enables listing of conditional source code
If the operand field contains a 0, the listing of the assembled even though no object code is being generated because of a false
bytes of an ASCII string will be suppressed after the first line (four IF condition. The assembler will not list such conditional source
bytes). Likewise, only the first four assembled bytes of a DB code if this pseudo-operation is not used.
pseudo-operation with multiple arguments will be listed. If a
program contains many long strings, its listing will be easier to Copy file COpy [<unit:>]<file-name>
read if the ASCF pseudo-operation is used.
This pseudo-operation copies source code from a disk file into a
If the operand field contains a 1, the assembled form of program being assembled. The code from the copied file will be
subsequent ASCII strings and DB pseudo-operations with multiple assembled starting at the current address. When the copied file is
arguments will be listed in full. This is the default condition. exhausted, the assembler will continue to assemble from the
See Appendix 3 for an example of the listing format. original file. The resulting object code will be exactly like what
would be generated if the copied source code were part of the
Conditional Assembly IF <expression> original file, but the COPY pseudo-operation does not actually
alter any source file.
source code
A copied file may not copy another file. And, all files that are
ENDF accessed by the COpy pseudo-operation must be of the same
format as the main source file, i.e., either having or not having line
The value of the expression in the operand field governs whether numbers. The files must be type (.ASM).
or not subsequent code up to the matching ENDF will be
assembled. If the expression evaluates to a 0 (false), the code will ExAMPLES:
not be assembled. If the expression evaluates to a non-zero value COPY FILE1
(true), the code will be assembled. Blocks of code delimited by IF COPY B:FILE2
and ENDF ("conditional code") may be nested within another
block of conditional code. Listing Control NLST
Any label that appears in the operand field of an IF ...ENDF LST
pseudo-operation must be defined in a statement earlier in the The NLST pseudo-operation suppresses all output to the listing
program. file. Object code will still be output to the object code file and the
Example: lines containing errors will still be output to the error file. The LST
pseudo-operation re-enables output to the listing file.
YES EQU 1 Sets the value of the label 'YES' to 1.
NO EQU 0 Sets the value of the label 'NO' to 0. Listing Title TITL <first line>"<second line>
*
IFYES The expression here is true (1), so the If the P option is specified in the ASM command, the one- or two-
MVIA,'Y' code on this line will be assembled. line title specified by this pseudo-operation will be printed
IF NO The expression here is false (0), so the centered at the top of each page of the listing.
MVIA, 'N' code on this line will not be assembled.
This terminates the NO conditional. Page Eject PAGE
ENDF
ENDF This terminates the YES conditional. If the P option is specified in the ASM command, this pseudo-
operation causes a skip to the top of the next page of the listing.

End of Source file EN D


This pseudo-operation terminates each pass of the assembly. Only
one END statement should be in the file or files to be assembled,
and it should be the last statement encountered by the assembler.
Since an end-of-file on the source code input file will also
terminate each pass, the END statement is unnecessary in most
cases.

90 91
16 ERROR CODES AND MESSAGES o OPCODE ERROR The symbol in the operation field is
not a valid 8080 instuction mnemonic
ASSEMBLER COMMAND ERRORS or an assembler pseudo-operation
A number of console messages may be generated in response to mnemonic.
errors in the ASM command. When an error of this sort occurs, the R REGISTER ERROR An expression used as a register
assembly is aborted and control returns to CP/M. designator does not have a legal
EXPECTED NAME The source code input file name is value.
missing. S SYNTAX ERROR A statement is not in the format
ILLEGAL OPTION An unrecognized option specifier follows $. required by the assembler.
91 ERROR IN EXTENDING THE FILE U UNDEFINED SYMBOL A label used in the operand field is
92 END OF DISK DATA - DISK IS FULL not defined, i.e., does not appear in
93 FILE NOT OPEN the label field anywhere in the
94 NO MORE DIRECTORYSPACE - DISK IS FULL program, or is not defined prior to its
95 FILE CANNOT BE FOUND use as an operand in an EQU, ORG,
96 FILE ALREADY OPEN DS, RES, or IF pseudo-operation.
97 READING UNWRITTEN DATA
V VALUE ERROR The value of the operand lies outside
ASSEMBLY ERRORS the allowed range.
If a statement contains one of the following errors, there will be a
Single letter error code in column 19 of the line output to the
listing and/or error files. An error detected during both the first and
second pass of the assembler will be flagged twice in the
listing(s). If the error is not an opcode error, NULs will be output
as the second and, if appropriate, third bytes of object code for
that instruction. If the error is an opcode error, the instruction will
be assumed to be a three-byte instruction, and three NULs will be
written to the listing and/or error files. The error codes are:

A ARGUMENT ERROR An illegal label or constant appears in


the operand field. This might be
• a number with a letter in it, i.e. 2L
• a label that starts with a number,
i.e.,3STOP
• an improper representation of a
string, i.e. "'A"' in the operand field
of a statement containing the ASCII
pseudo-operation.
D DUPLICATE LABEL The source code contains multiple
labels whose first five characters are
identical.
L LABEL ERROR The symbol in the label field contains
illegal characters, e.g., it starts with a
number.
M MISSING LABEL An EQU instruction does not have a
symbol in the label field.

92 93
APPENDIX A - STATEMENT SUMMARY END
ACCEPT input list This statement must be the last statement of every routine.
Reads values from the system console and assigns them to the ENDFILE unit
variables in the input list. Write an end-of-file at the current position of unit.
ASSIGN n TO V ERRCLR
Assigns a statement label to a variable to be used in an
Clears the effect of the ERRSET statement.
Assigned GO TO.
ERRSET n,v
BACKSPACE unit
When a runtime error occurs, control goes to the statement
Positions the specified unit to the beginning of the previous
labelled n with variable v containing the error code.
record.
FORMAT (field specifications)
BLOCK DATA
Used to specify input and output record formats.
Begin a BLOCK DATA subprogram for initializing variables in
COMMON. FUNCTION name(argument list)
Begins the definition of a function subprogram.
CALL name(argument list)
Call the subroutine passing the argument list. GOTO n
Transfer control to the statement labelled n.
COMMON /label1/list1 /label2/list2
Declares the variables and array that are to be placed in GO TO v,(n1,n2,_._),v
COMMON with the various routines. The COMPUTED GOTO transfers control to n1 if v= 1, n2 if
v= 2, etc.
CONTINUE
Causes no action to take place, usually used as the object of a GO TO v,(n1,n2, ..)
GOTO or DO loop. The ASSIGNED GOTO transfers control to statement n1, n2, ..
COpy filename depending on the value of v. V must have appeared in an
ASSIG N statement.
The specified filename is inserted into the source at the point
of the COpy statement. IF (e)n1,n2,n3

CTRL DISABLE The arithmetic IF transfers control to n1 if e< 0, n2 if e = 0 or n3


if e>0.
Disables program termination by control/c from the console.
IF (e)statement
CTRL ENABLE
The logical IF executes statement if the value of expression e is
Enables program termination by control/c from the console. true (non-zero).
Control C being enabled is the default.
IF (e) THEN statement1 ELSE statement2 ENDIF
DATA /var1/const1 ,const2/var2/c1 ,c2 /
The IF-THEN-ELSE executes blocks of statements _
Initializes the specified variable, array element or arrays to the
statement1 if e is true, or blocks of statements - statement2 if
specified constants. e is false.
DIMENSION v(n1 ,n2,_.),v2(n1,n2,._) IMPLICIT type(letter list)
Sets aside space for arrays v and v2.
Changes the default type of variables that start with the letters
=
DO n i n1 ,n2,n3 in the letter list.
Executes statements from DO to statement n, using i as index, INTEGER v1,v2_.
increasing or decreasing from n1 to n2 by steps of n3. Declares v1, v2, etc, to be integer variables.
DOUBLE PRECISION v1,v2, __ LOGICAL v1,v2,_._
Declares v1, v2, etc, to be DOUBLE PRECISION variables. Declares v1, v2, etc, to be logical variables.
DUMP /id/ output list PAUSE 'character string'
When a runtime error occurs, displayed id and items in output Suspends program execution until any key is hit, displaying
list. PAUSE and character string.

94 95
READ (unit,format{,ERR =} {,END =}) input list
Readsvalues from unit according to format and assigns them
APPENDIX B - SUMMARY OF SYSTEM FUNCTIONS
to the variables in input list.
Name Function Arg Result Argument
REAL v1,v2, _
Declares v1, v2, etc, to be real variables. ABS Absolute (x) 1 real real
ALOG Log Base e (x) 1 real real
RETURN ALOG10 Log base 10 (x) 1 real real
Returns control from a subprogram to the statement following AMAX0 Maximum <255 either either
either the call or the function reference. AMAX1 Maximum <255 either either
RETURN i AMINO Minimum <255 either either
The multiple return statement returns control from a AMIN1 Minimum <255 either either
subprogram to statement i in the calling routine. AMOD Remainder(x/y) 2 real real
ATAN Arctangent(x) 1 real real
REWIND unit ATAN2 Arctangent(y/x) 2 real real
The file associated with unit is closed, then reopened at the
BIT Bit handling 3/4 either either
beginning of the same file. CALL Execute asm pgm 2 either either
STOP 'character string' CBTOF Convert to real 2/3 real both
Terminates program execution and displays character string on CHAR Character value 1 either character
the system console. COMP Compare strings 3 either either
COS Cosine(x) 1 real real
STOPn
DIM Positive difference 2 real real
Terminates program execution and displays n on the system
EXP e * * (x) 1 real real
console.
FLOAT Make real (x) 1 real integer
SUBROUTINE name(argument list) lABS Absolute (x) 1 integer integer
Begins the definition of a subroutine subprogram. 101M Positive difference 2 real real
TRACE OFF IFIX Truncate (x) 1 integer real
Turns statement tracing off. INP Input from a port 1 either either
ISIGN Transfer of sign 2 integer integer
TRACE ON MAX0 Maximum < 255 either either
Turns statement tracing on. MAX1 Maximum <255 either either
TYPE output list MIN0 Minimum < 255 either either
Displays the value of the variables in output list on the system MIN1 Minimum <255 either either
console. MOD Remainder (x/y) 2 integer integer
PEEK Examine mem loc. 1 either either
variable = expression RAND Random Number (x) 1 real real 0.0< R< 1.0
Assigns the value of the expression to the variable. SIGN Transfer of sign 2 real real
Write (unit,format {,ERR = })
output list SIN Sine(x) 1 real real
Writes the values of the variable in output list to unit according SQRT Square Root (x) 1 real real
to format. TAN Tangent(x) 1 real real

Most of the above functions are ANSI standard except for RAND.
This function behavesas if it were returning an entry from a table

96 97
of random numbers. The argument of RAND determines which APPENDIX C - SUMMARY OF SYSTEM
entry of this table will be returned: SUBROUTINES
Rand Arg. Value returned for RAND CALL BIT (variable,disp,code)
o The next entry in the table Set, resets or flips bit 0+ disp of variable according to the code.
- 1 The first entry in the table. Also, the pointer for CALL CBTOF(loc1,disp1,loc2{,flag})
the next entry (arg = 0) is reset to the second Converts a binary number to its floating pOint equivalent
entry in the table.
n Returns the table entry following n. CALL CHAIN('program name' {,error})
Loads another program and executes it.
CALL CIN(var)
Reads a single character from the system console.
CALL CLOSE(unit)
Close the file associated with unit.
CALL CTEST(status)
Determines if a character has been entered on the system
console.
CALL DELAY(time)
Delays execution the specified time in 1/100ths of a second.
CALL DELETE('filename'{,error})
Delete the specified filename from the disk.
CALL EXIT
Terminates program execution.
CALL MOVE(n,loc1 ,disp1 ,loc2,disp2)
Moves n bytes from loc1 to loc2.
CALL OPEN(unit,'filename' {,error})
Opens the specified filename and associates it with unit.
CALL LOAD('filename',load-type{,error})
This routine is used to load a file of type .HEX or .OBJ into
memory depending on the value of load-type. It is usually used
to load assembly language routines into memory. No check is
made to see if the code that is loaded into memory would
overwrite the program or CP/M.
CALL LOPEN(unit, 'filename' {,error} )
Opens the specified filename and associates it with unit. This
file is also treated as a printer file with the first character of
each output record controlling paper movement.
CALL POKE(LOCATION,VALUE)
The POKE routine is used to change a memory location. Value
will be stored in memory at location.
CALL OUT(port,value)
The value is converted to an 8 bit number and output to port.

98 99
CALL PUT(CHARACTER)
The PUT routine is used to output a character to the system
APPENDIX D - RUNTIME ERRORS
console directly. It is commonly used to do such things as clear
During execution of a program, there are numerous conditions
the screen or position the cursor.
that can occur which cause program termination. When one of
CALL RENAME('old name','new name'{,error}) these conditions is encountered, a RUNTIME ERROR message
Renames old name to be new name. will be generated to the system console file. The message has the
format:
CALL RESET
The RESET routine allows for the changing of a disk at runtime Runtime error: XXXXXXXX, called from loc. YYYYH
and then being able to write on the changed disk. Without using
pgm was executing line LLLL in routine NNNN
this function, an attempt to write on a disk that has been
changed will result in a BDOS read only error. where: XXXXXXXX is the ERROR, YYYY is the memory location of
the CALL to the runtime package in which the error occurred.
CALL SEEK(unit,position)
Positions the file associated with unit to the byte position The second line of the error message will be generated as a
specified by position. traceback of CALL statements that have been executed. The LLLL
is the FORTRAN generated line number (shown on the listing of
CALL SETIO (new 110)
Allows changing the way that console 110 is performed during the source from the compiler) of the statement which caused the
error, and NNNN if the name of the routine in which that line
program execution.
number corresponds. The line number will be output as ???? if the
X option was not specified on the $OPTIONS statement for a
given routine. If multiple 'PGM WAS ...' lines are printed, the first
one specifies the line in which the error actually occurred.

SUMMARY OF RUNTIME ERRORS


ARG CNT
ARGUMENT COUNT ERROR: a subprogram call had too many
or too few arguments. In other words, the number or arguments
in the CALL or function reference is not the same as the
number of parameters specified for this SUBROUTINE or
FUNCTION.
ASN GOTO
ASSIGNED GO TO ERROR: the value of the variable specified in
an ASSIGNED GO TO does not match that of one of the
statement labels listed.
CALL POP
CALL STACK POP ERROR: this error should never occur (This
means that a RETURN has been executed that does not have a
corresponding CALL or FUNCTION reference. Usually caused
by user assembly language programs).
CALL PSH
CALL STACK PUSH ERROR: this error is caused by a recursive
subprogram CALLS of depth greater than 36. Only in very
special cases should a subprogram CALL itself or one of those
that has CALLED it.

100 101
CHAIN FL INPT ERR
CHAIN FILE ERROR: the filename specified in a call to the INPUT ERROR: during a READ, an invalid character has been
CHAIN or LOAD routine was not found on the disk. encountered for the number being processed. This will be
COM GOTO generated for such things as: two decimal points in a number,
COMPUTED GO TO INDEX OUT OF RANGE: the variable an E in an F type field, decimal pOint in an I type field, etc.
specified in a computed GOTO is either zero or greater than the INT RANG
number of statement labels that were specified. INTEGER OVERFLOW: a result greater than 8 digits has been
CON BIN generated in an expression.
BINARY 110 TO CONSOLE: binary 110 is not supported to the 110 ERR
system console. 110 ERROR: an error occurred during a READ or WRITE
CONTRL/C operation and the ERROR label was not specified in the
CONTROL/C error: CONTROL/C was hit and the CONTROL/C statement. It will also be generated during a READ if END OF
was not trapped. FILE is encountered and an EOF label was not specified.
CONVERT 110 LIST
16 BIT CONVERSION ERROR: in converting a number from INVALID 110 LIST: this error indicates an error in the l/Olist
integer to internal 16 bit binary, an overflow has occurred. This specification of a formatted WRITE or READ. This error will not
can occur on all statements associated with 110 (unit number), normally occur.
subscript evaluation and anywhere that a number has to be LINE LEN
converted from floating to 16 BIT binary. Also, subscripting LINE LENGTH ERROR: an attempt has been made to READ or
outside of the DIMENSIONED space for an array can cause this WRITE a record whose length exceeds 250 characters. This
error. count also includes a carriage return at the end of the line.
DIV ZERO LOG NEG
DIVIDE BY ZERO: an attempt has been made to divide by zero. LOG OF NEGATIVE NUMBER: argument of the log either
DSK FULL (ALOG or ALOG10) function is negative.
DISK FULL: either the disk is full or the directory is full. OVERFLOW
FILE OPR FLOATING POINT OVERFLOW: the result of a floating point
FILE OPERATION ERROR: an error has occurred while trying to operation has resulted in a number whose value is too large to
do some file operation, such as renaming when the new file be stored.
already exists. SEEK ERR
FORMAT SEEK ERROR: an error has occurred while positioning a file to
FORMAT ERROR: an unrecognized or invalid FORMAT the specified position and no error variable was specified in the
specification has been encountered in a FORMATTED READ or CALL.
WRITE. The most likely error is an unrecognized format SQRT NEG
specification or blanks in a variable format. SQRT OF NEGATIVE NUMBER: argument of the square root
ILL CHAR function is negative.
ILLEGAL CHARACTER: an illegal character has been UNIT CLO
encountered during a READ. UNIT CLOSED: the unit number passed to the CLOSE routine
ILL UNIT specifies a unit number that has not been OPENed.
ILLEGAL UNIT NUMBER «2 or >7): the unit number in a READ, UNIT OPN
WRITE, OPEN, LOPEN, REWIND, CLOSE, SEEK is either less UNIT ALREADY OPEN: this is generated by the OPEN or
than 2 or greater than 7. LOPEN routine when an attempt is made to open a file on an
already open FORTRAN logical unit. This error will also occur if
unit 0 or 1 is specified in the OPEN or LOPEN call.

102 103
28 unit not integer constant or variable
APPENDIX E - COMPILE TIME ERRORS
29 Array size exceeds 32K
2A invalid use of unary operator
The following is a list of errors that may occur during the 2B variable DIMENSION not valid in MAIN program
compilation of a FORTRAN program. If the G option is not 2C variable dimensioned array must be argument
selected, a two digit error number will be printed instead. This 2D DO/END/LOGICAL IF cannot follow LOGICAL IF
number can be found at the beginning of each line. 2E undefined label
00 *FATAL* compiler error 2F unreferenced label
01 Syntax error, 2 operators in a row 30 FUNCTION or ARRAY missing left parenthesis
02 unexpected continuation (column 6 not blank or 0) 31 invalid argument of FUNCTION or ARRAY
03 input buffer overflow (increase B = compiler option) 32 DIMENSION specification must precede first executable
04 invalid character for FORTRAN statement statement
05 unmatched parenthesis 33 unexpected character in expression
06 statement label> 99999 34 unrecognized logical opcode
07 invalid character encountered in statement label 35 argument count for FUNCTION or ARRAY wrong
08 invalid HEX digit encountered in constant 36 *COMPILER ERROR* poped off bottom of operand stack
09 expected constant or variable not found 37 expecting end of statement, not found
0A 8 bit overflow in constant 38 statement too complex; increase P and/or 0 table
0B unidentifiable statement 39 invalid delimiter in ARITHMETIC IF
0C statement not implemented 3A invalid statement number in IF
0D quote missing 3B HEX constant> FFFF (HEX)
0E SUBROUTINE/FUNCTION/BLOCK DATA not first statement 3C replacement not allowed within IF
in routine 3D multiple assignment statement not implemented
0F columns 1-5of continuation statement are not blank 3E subscripted-subscripts not allowed
10 cannot initialize BLANK COMMON 3F subscript stack overflow; increase P = or 0 =
11 RETURN is not valid in main program 40 missing left ( in READ/WRITE
12 syntax error on unit specification 41 invalid unit specified
13 missing comma after) in COMPUTED GO TO 42 invalid FORMAT, END= or ERR= label
14 missing variable in COMPUTED GO TO 43 invalid element in I/O list
15 invalid variable in ASSIGNED/COMPUTED GO TO 44 built-in function invalid in I/O list
16 invalid LITERAL, no beginning quote 45 cannot subscript a constant
17 number of subscripts exceeds maximum of 7 46 variable not dimensioned
18 invalid SUBROUTINE or FUNCTION name 47 invalid subscript
19 subscript not POSITIVE INTEGER CONSTANT 48 missing comma
1A FUNCTION requires at least one argument 49 index in IMPLIED DO must be a variable
1B syntax error 4A invalid starting value for IMPLIED DO
1C invalid argument in SUBROUTINE/FUNCTION call 4B invalid ending value of IMPLIED DO
1D first character of variable not alphabetic 4C invalid increment of IMPLIED DO
1E ASSIGNED/COMPUTED GOTO variable not integer 4D illegal use of built-in function
1F label has already defined 4E variable cannot be dimensioned in this context
20 specification of array must be integer 4F invalid or multiple END = or ERR=
21 invalid variable name 50 invalid constant
22 invalid DIMENSION specification 51 exponent overflow in constant
23 dimension specification is invalid 52 invalid exponent
24 variable has already appeared in type statement 53 character after. invalid
25 invalid subroutine name in CALL 54 integer overflow
26 SUBPROGRAM argument cannot be initialized 55 integer underflow (too small)
27 improperly nested DO loops

104 105
56 missing = in DO 84 *FATAL* value exceeds 255 in $OPTIONS
57 string constant not allowed 85 *FATAL* COMMON table overflow, increase C=
58 invalid variable in DATA list 86 * FATAL * unknown option (letter before =)
59 DATA symbol not used in program, line 87 * FATAL * missing END statement
5A invalid constant in DATA list 88 * FATAL * LABEL TABLE overflow, increase L=
5B error in DATA list specification 89 *FATAL* SYMBOL TABLE overflow, increase S=
5C FUNCTION invalid in DATA list 8A *FATAL* ARRAY STACK overflow, increase A=
50 no filename specified on COpy 8B * FATAL * DO LOOP STACK overflow, increase 0=
5E runtime format not array name 8C * FATAL * stack overflow (compiler error)
5F DUMP label invalid or more than 10 characters 80 * FATAL * stack overflow (compiler eror)
60 more than 1 IMPLICIT is not allowed 8E *FATAL* internal tables exceed user memory
61 IMPLICIT not first statement in MAIN, 2nd statement in 8F *FATAL* MEMORY ERROR
SUBPROGRAM 90 * FATAL * OPEN error on COPY file
62 data type not REAL, INTEGER or LOGICAL 91 * FATAL * too many routines to compile (> 62)
63 illegal IMPLICIT specification 92 *FATAL* no more room to store DATA statements
64 improper character sequence in IMPLICIT 93 *FATAL* IF-THEN stack overflow, increase 1=
65 variable already DIMENSIONED 94 *FATAL* Nested "COPY" statements not permitted
66 Q option must be specified for ERRSETIERRCLR 95 * FATAL * Disk write error (disk probably full)
67 Hex constant of zero (0) invalid in 1/0 statement 96 *FATAL* Cannot close file (disk probably full)
68 Argument cannot also be in COMMON 97 *FATAL* Input file not found
69 Illegal COMMON block name 98 * FATAL * Invalid drive specifier
6A Variable already in COMMON 99 *FATAL* No filename found on COpy statement
6B Array specification must precede COMMON 9A *FATAL* File specified on COpy not found
6C Executable statement invalid in BLOCK DATA
60 Hex constant of 27H (') invalid in FORMAT
6E Invalid number following STOP or PAUSE
6F invalid TRACE statement (operand not ONIOFF)
70 invalid 10STAT = variable
71 missing, in ENCODE/DECODE
72 invalid label in ASSIGNED GOTO
73 invalid variable in ASSIGNED GOTO
74 label not allowed on this statement
75 multiple RETURN not valid in FUNCTION
76 UNUSED
77 no matching IF-THEN for ELSE or ENDIF
78 invalid ELSE or ENDIF
79 missing ENDIF
7A initialization of non-COMMON variable
7B "DOUBLE PRECISION" not supported, treated as "REAL"
7C UNUSED
70 UNUSED
7E UNUSED
7F UNUSED
80 *FATAL* no program to compile
81 *FATAL* missing $OPTIONS statement
82 *FATAL* missing = in $OPTIONS statement
83 * FATAL * invalid digit in number in $OPTIONS

106 107
APPENDIX F - ASSEMBLY LANGUAGE INTERFACE
APPENDIX G - GENERAL COMMENTS
ASSEMBLY statements can be directly inserted into a
1. In the description of the individual routines, anywhere that a
FORTRAN program by preceding the statement with an asterisk
character string is specified, a variable or array name can be
(*). The line that contains that asterisk will be directly output to
used. The variable or array can be set to the desired character
the assembly file without further processing (the asterisk is
string.
deleted first). Because of the nature of the FORTRAN compiler (it
actually reads one statement ahead of where it is processing), it is 2. A variable can be set to a character string using an assignment
ALWAY a good idea to put a CONTINUE statement immediately statement such as:
preceding the first assembly statement in each separated group of
A= 'STRING'
assembly statements. The CONTINUE will cause the assembly
statements to be inserted at the expected place. FORTRAN No more than six characters will be retained for any variable
maintains nothing in the registers between statements, but does and if less than six, will be zero filled in the low order bytes of
use the 8080 stack for saving RETURN addresses for user called the variable.
FUNCTIONS and SUBROUTINES. 3. If a variable or array name is used to reference a CPIM file (such
Example as in the OPEN routine) the filename itself within the variable or
array) is terminated after:
CONTINUE
* MVI A,'A' • the first 13 characters,
* STA STRING • a NULL is encountered.
4. Hexadecimal constants can be used anywhere that a constant
or variable is permitted. A hexadecimal constant is specified by
preceding it by a dollar sign ($). Examples are:
A=$E060
A= -$CCOO
Hexadecimal constants are limited to a maximum value of
FFFF. An error is generated if a hexadecimal constant exceeds
this limit. Internally, a hexadecimal constant is treated as any
other INTEGER constant would be.
5. A hexadecimal constant that is preceded by # instead of a $ will
be stored internally in binary format in the first two bytes of the
variable. Numbers of this form should not be used in any
expression as they are not stored in the normal floating point
format. The number is stored in standard 8080 format (HIGH
byte followed by LOW byte).

108 109
6. A backslash (\) can be used in a literal to specify an 8 bit binary APPENDIX H - COMPARISON OF NEVADA
constant to be inserted at that point. The constant is enclosed FORTRAN AND ANSI FORTRAN
in backslashes and is assumed to be a hexadecimal constant.
The backslash can be changed using the CONFIG program NEVADA FORTRAN includes the following extensions to version
supplied. X3.9-1966 of ANSI Standard FORTRAN:
Example 1. Free-format input and output.
A= 'THIS \32\ IS AN EXAMPLE' 2. IMPLICIT statement for setting default variable types.
CALL OUTIT (3,1,' \ 7F \ \ FF \ ',2,32) 3. Options end-of-file and error branches in READ and WRITE
10 FORMAT ('IT IS ALLOWED \ 1\ HERE \FF\ ALSO') statements.
4. COPY statement to insert source files into a FORTRAN
NOTE: The backslash is the default character and can be program.
changed using the CONFIG program. 5. Direct inline assembly language.
7. Eight FORTRAN files may be open at anyone time (file 6. Access to file system for such functions as creating, deleting,
numbers 0-7). Remember that files 0 and 1 are permanently and renaming files
open. 7. Random access on a byte level to files.
8. Access to absolute memory locations.
9. Program controlled time delay.
10. A pseudo random number generator function.
11. Program control of runtime error trapping.
12. Ability to chain a series of programs.
13. Ability to load object code into memory.
14. CALL function to execute previously loaded code.
15. Program tracing.
16. IF-THEN-ELSE statement.
17. Enabling and disabling console abort of program.
18. ENCODE and DECODE memory to memory 1/0.
19. Multiple returns from subroutines.
20. K format specification.
NEVADA FORTRAN does not include the following features of
ANSI standard FORTRAN:
1. Double precision, double precision functions. (Double
precision is treated as single precision).
2. Complex numbers, complex statements and functions.
3. EQUIVALENCE statement.
4. Extended DATA statement of the form:
DATA A,B,CI1 ,2/31
5. The P format specifications.
6. Statement functions.
7. The following are reserved names and cannot be used for
functions, subroutines, or COMMON block names:
A, B,C,D, E, H, L, M,SP, PSW
8. EXTERNAL statement.
9. Subscripted subscripts.
10. Certain of the numerical library functions such as the
hyperbolic functions and others.

110 111
APPENDIX 1- 8080 Operation Code ACCUMULATOR*
ROTATEt MOVE (Cont.)

07 RLC 58 MOV E,B 80 ADD B A8 XRA B


OF RRC 59 MOV E,C 81 ADD C A9 XRA C
JUMP CALL RETURN RESTART 5A MOV E,D ADD D AA XRA D
17 RAL 82
C3 JMP CD CALL 1F RAR 5B MOV E,E 83 ADD E AB XRA E
C9 RET C7 RST 0
C2 JNZ C4 CNZ 5C MOV E,H 84 ADD H AC XRA H
CO RNZ CF RST 1
CA JZ CC CZ 5D MOV E,L 85 ADD L AD XRA L
C8 RZ D7 RST 2
D2 JNC D4 CNC 5E MOV E,M 86 ADD M AE XRA M
DO RNC DF RST 3
DA JC Adr DC CC Adr 5F MOV E,A 87 ADD A AF XRA A
D8 RC E7 RST 4 CONTROL
E2 JPO E4 CPO EO RPO EF 60 MOV H,B ADC B BO ORA B
RST 5 00 NOP 88
EA JPE EC CPE E8 RPE F7 61 MOV H,C ADC C B1 ORA C
RST 6 76 HLT 89
F2 JP F4 CP FO RP FF 62 MOV H,D ADC D B2 ORA D
RST 7 F3 DI 8A
FA JM FC CM F8 RM 63 MOV H,E ADC E B3 ORA E
FB EI 8B
E9 PCHL 64 MOV H,H ADC H B4 ORA H
8C
65 MOV H,L 8D ADC L B5 ORA L
MOVE Acc LOAD 66 MOV H,M 8E ADC M B6 ORA M
IMMEDIATE IMMEDIATE* IMMEDIATE STACK OPS 67 MOV H,A 8F ADC A B7 ORA A
MOVE
06 MVI B, C6 ADI 01 LXI B C5 PUSH B
MOV B,B 68 MOV L,B 90 SUB B B8 CMP B
40
OE MVI C, CE ACI 11 LXI D, D5 PUSH D MOV L,C 91 SUB C B9 CMP C
41 MOV B,C 69
16 MVI D, D6 SUI 21 LXI H, D16 E5 PUSH H 92 SUB D BA CMP D
42 MOV B,D 6A MOV L,D
1E MVI E, D8 DE SBI 31 LXI SP, F5 PUSH PSW MOV L,E 93 SUB E BB CMP E
43 MOV B,E 6B
26 MVI H, E6 ANI D·8 MOV L,H 94 SUB H BC CMP H
C1 POP B 44 MOV B,H 6C
2E MVI L, EE XRI DOUBLEADDt MOV L,L 95 SUB L BD CMP L
D1 POP D 45 MOV B,L 6D
36 MVI M, F6 ORI MOV L,M 96 SUB M BE CMP M
09 DAD B E1 POPH 46 MOV B,M 6E
3E MVI A, FE CPI 6F MOV L,A 97 SUB A BF CMP A
19 DAD D F1 POP PSW* 47 MOV B,A
29 DAD H 70 MOV M,B 98 SBB B
INCREMENT* * DECREMENT* * E3 XTHL 48 MOV C,B PSEUDO
39 DAD SP 71 MOV M,C 99 SBB C
F9 SPHL 49 MOV C,C INSTRUCTION
04 INR B 05 DCR B
4A MOV C,D 72 MOV M,D 9A SBB D
OC INR C OD DCR C ORG Adr
4B MOV C,E 73 MOV M,E 9B SBB E
14 INR D 15 DCR D SPECIALS END
4C MOV C,H 74 MOV M,H 9C SBB H
1C INR E 10 DCR E LOAD/STORE
EB XCHG 4D MOV C,L 75 MOV M,L 9D SBB L Eau D16
24 INR H 25 DCR H OA LDAX B .......
27 DAA* 4E MOV C,M 9E SBB M DS D16
2C INR L 2D DCR L 1A LDAX D 2F CMA 4F MOV C,A 77 MOV M,A 9F SBB A DB D8
34 INR M 35 DCR M 2A LHLD Adr 37 STC t DW D16
3C INR A 50 MOV D,B 78 MOV A,B AO ANA B
3D DCR A 3A LDA Adr 3F CMCt
51 MOV D,C 79 MOV A,C A1 ANA C
03 INX B OB DCX B 02 STAX B MOV A,D ANA D
52 MOV D,D 7A A2
13 INX D 1B DCX D 12 STAX D INPUT/OUTPUT
53 MOV D,E 7B MOV A,E A3 ANA E
23 INX H 2B DCX H 22 SHLD Adr MOV A,H A4 ANA H
D3 OUT D8 54 MOV D,H 7C
33 INX SP 3B DCX SP 32 STA Adr DB MOV A,L A5 ANA L
IN D8 55 MOV D,L 7D
56 MOV D,M 7E MOV A,M A6 ANA M
57 MOV D,A 7F MOV A,A A7 ANA A
D8 constant, or logical/arithmetic expression that evaluates
to an 8 bit data quantity.
* all Flags (C.Z.S.P) affected

D16 = constant, or logical/arithmetic expression that evaluates


to a 16 bit data quantity.
t = only CARRY affected
Adr = 16 bit address
* * = all Flags except CARRY affected;
(exception: INX and DCX affect no Flags)

112
113
00 NOP 28 ... 50 MOV D,B 79 MOV A,C AO ANA B C8 RZ
01 LXI B,D16 29 FO RP
DAD H 51 MOV D,C
02 7A MOV A,D A1 ANA C C9 RET F1 POP PSW
STAX B 2A LHLD Adr 52 MOV D,D 7B MOV A,E A2 ANA D
03 INX B CA JZ F2 JP Adr
2B DCX H 53 MOV D,E
04 INR B
7C MOV A,H A3 ANA E CB ... F3 DI
2C INR L 54 MOV D,H 7D MOV A,L A4 ANA H CC CZ Adr F4 CP Adr
05 DCR B 2D DCR L 55 MOV D,L 7E MOV A,M
06 MVI A5 ANA L CD CALL Adr F5 PUSH PSW
B,D8 2E MVI L,D8 56 MOV D,M 7F MOV A,A A6 ANA M CE ACI D8 F6 ORI D8
07 RLC 2F CMA 57 MOV D,A 80 ADD B
08 ... A7 ANA A CF RST 1 F7 RST 6
30 '" 58 MOV E,B 81 ADD C
09 DAD B A8 XRA B DO RNC F8 RM
31 LXI SP,D16 59 MOV E,C 82 ADD D A9 XRA C D1 POP D F9 SPHL
OA LDAX B 32 STA 5A MOV E,O
Adr 83 ADD E
OB OCX B AA XRA D 02 JNC Adr FA JM Adr
33 INX SP 5B MOV E,E 84 ADD H AB XRA E D3 OUT D8 FB EI
OC INR
C 34 INR 5C MOV E,H
M 85 ADD L
00 OCR
C 50 AC XRA H 04 CNC Adr FC CM Adr
35 OCR M MOV E,L 86 ADD M AD XRA L D5 PUSH D FD ...
OE MVI
C,D8 36 MVI 5E MOV E,M
M,D8 87 ADD A
OF RRC 5F AE XRA M D6 SUI D8 FE CPI 08
37 STC MOV E,A 88 AOC B
10 ... ... 60 AF XRA A 07 RST 2 FF RST 7
38 MOV H,B 89 AOC C
11 LXI 61 BO ORA B D8 RC
0,D16 39 DAD SP MOV H,C 88 ADC B
12 STAX 0 62 B1 ORA C D9 ...
3A LDA Adr MOV H,O 89 ADC C
13 INX 63 MOV H,E B2 ORA D DA JC Adr
D 3B DCX SP 8A AOC 0
14 INR 64 MOV H,H B3 ORA E DB IN D8
D 3C INR A 8B AOC E
15 65 MOV H,L B4 ORA H DC CC Adr
DCR D 3D OCR A 8C AOC H
16 MVI 66 MOV H,M B5 ORA L DD ...
0,08 3E MVI A,D8 80 AOC L
17 RAL 67 MOV H,A B6 ORA M DE SBI 08
3F CMC 8E ADC M
18 68 MOV L,B B7 ORA A DF RST 3
'"
40 MOV B,B 8F AOC A
19 69 MOV L,C B8 CMP B EO RPO HEX·ASCII TABLE
DAD D 41 MOV B,C 90 SUB B
1A 6A MOV L,D B9 CMP C E1 POP H Non·Printing
LOAX D 42 MOV B,O 91 SUB C
1B 6B MOV L,E BA CMP 0 E2 JPO Adr 00
DCX 0 43 MOV B,E 92 SUB 0 NULL
1C INR 6C MOV L,H BB CMP E E3 XTHL 07
E 44 MOV B,H 93 SUB E BELL
10 60 MOV L,L BC CMP H E4 CPO Adr 09 TAB
DCR E 45 MOV B,L 94 SUB H
1E 6E MOV L,M BD CMP L E5 PUSH H OA
MVI E,D8 46 MOV B,M 95 SUB L LF
6F MOV L,A BE CMP M E6 ANI D8
1F RAR 47 MOV B,A 96 SUB M OB VT
20 70 MOV M,B BF CMP A E7 RST 4
'"
48 MOV C,B 97 SUB A OC FORM
21 71 MOV M,C CO RNZ E8 RPE
LXI H,D16 49 MOV C,C 98 SBB B 00 CR
72 MOV M,O C1 POP B E9 PCHL
22 SHLD Adr 4A MOV C,D 99 SBB C 11 X·ON
73 MOV M,E C2 JNZ Adr EA JPE Adr
23 .INX H 4B MOV C,E 9A SBB 0 12 TAPE
74 MOV M,H C3 JMP Adr EB XCHG
24 INR H 4C MOV C,H 9B SBB E 13 X·OFF
75 MOV M,L C4 CNZ Adr EC CPE Adr
25 OCR H 40 MOV C,L 9C SBB H 14
26
76 HLT 90 SBB L C5 PUSH B ED ... 1B ESC
MVI H,08 4E MOV C,M 77 MOV M,A C6 ADI D8 EE XRI 08
27 DAA 4F 9E SBB M 7D ALT MODE
MOV C,A 78 MOV A,B 9F SBB A C7 RST 0 EF RST 5 7F RUB OUT

D8 = constant, or logical/arithmetic expression that evaluates


to an 8 bit data quantity.

D16 = constant, or logical/arithmetic expression that evaluates


to a 16 bit data quantity.

Adr = 16 bit address

114 115
APPENDIX J - TABLE OF ASCII CODES (Zero Parity)
APPENDIX J - TABLE OF ASCII CODES (Zero Parity)
Upper
Octal Octal
(Continued)
Decimal Hex Character
Upper
0000 000 0 00 ctrlONUL Octal Octal Decimal Hex Character
0004 001 1 01 ctrlA SOH Startof Heading
0010 002 2 02 ctrlB STX Startof Text 0274 057 47 2F /
0014 003 3 03 ctrlC ETX End of Text 0300 060 48 30 0
0020 004 4 04 ctrlD EOT End of Xmit 0304 061 49 31 1
0024 005 5 05 ctrlE ENa Enquiry 0310 062 50 32 2
0030 006 6 06 ctrlF ACK Acknowledge 0314 063 51 33 3
0034 007 7 07 ctrlG BEL Audible Signal 0320 064 52 34 4
0040 010 8 08 ctrlH BS Back Space 0324 065 53 35 5
0044 011 9 09 ctrllHT HorizontalTab 0330 066 54 36 6
0050 012 10 OA ctrlJ LF Line Feed 0334 067 55 37 7
0054 013 11 OB ctrlK VT VerticalTab 0340 070 56 38 8
0060 014 12 OC ctrlL FF Form Feed 0344 071 57 39 9
0064 015 13 OD ctrlM CR CarriageReturn 0350 072 58 3A
0070 016 14 OE ctrlN SO ShiftOut 0354 073 59 3B ,
0074 017 15 OF ctrlO SI ShiftIn 0360 074 60 3C <
0100 020 16 10 ctrlPOLE Data Line Escape 0364 075 61 3D =
0104 021 17 11 ctrla OC1 XOn
0110
0370 076 62 3E >
022 18 12 ctrlR DC2 Aux On 0374 077 63 3F ?
0114 023 19 13 ctrlS DC3 X Off 0400 100 64 40 @
0120 024 20 14 ctrlT OC4 Aux Off 0404 101 65 41 A
0124 025 21 15 ctrlU NAK NegativeAcknowledge 0410 102 66 42 B
0130 026 22 16 ctrlV SYN Synchronous File 0414 103 67 43 C
0134 027 23 17 ctrlW ETB End of Xmit Block 0420 104 68 44 0
0140 030 24 18 ctrlX CAN Cancel 0424 105 69 45 E
0144 031 25 19 ctrlY EM End of Medium 0430 106 70 46 F
0150 032 26 1A ctrlZ SUB Substitute 0434 107 71 47 G
0154 033 27 1B ctrl[ ESC Escape 0440 110 72 48 H
0160 034 28 1C ctrl\ FS FileSeparator 0444 111 73 49 I
0164 035 29 10 ctrl)GS Group Separator 0450 112 74 4A J
0170 036 30 1E ctrl RS Record Separator 0454 113 75 4B K
0174 037 31 1F ctrl_ US UnitSeparator 0460 114 76 4C L
0200 040 32 20 Space 0464 115 77 40 M
0204 041 33 21 ! 0470 116 78 4E N
0210 042 34 22 " 0474 117 79 4F 0
0214 043 35 23 # 0500 120 80 50 P
0220 044 36 24 $ 0504 121 81 51 a
0224 045 37 25 % 0510 122 82 52 R
0230 046 38 26 & 0514 123 83 53 S
0234 047 39 27 0520 124 84 54 T
0240 050 40 28 ( 0524 125 85 55 U
0244 051 41 29 ) 0530 126 86 56 V
0250 052 42 2A * 0534 127 87 57 W
0254 053 43 2B + 0540 130 88 58 X
0260 054 44 2C 0544 131 89 59 Y
0264 055 45 2D - 0550 132 90 5A Z
0270 056 46 2E 0554 133 91 5B [
0560 134 92 5C \

116
117
APPENDIX J - TABLE OF ASCII CODES (Zero Parity) APPENDIX K - SAMPLE ASSEMBLER LISTING
(Continued)

Upper
Octal Octal Decimal Hex Character

0564 135 93 5D )
0570 COMMENT
136 94 5E t
0574 137 95 5F
0000 *
0600 140 96 60
0001 *SEARCH TABLE FOR MATCH TO STRING
0604 141 97 61 a 0002 * EACH TABLE ENTRY IS FOLLOWED BY A TWO·BYTE
0610 142 98 62 b DISPATCH ADDRESS.
0614 143 99 63 c 0003 *TABLE MUST HAVE AT LEAST ONE ENTRY AND IS
0620 144 100 64 d 0004 *TERMINATED BY A ZERO BYTE.
0624 145 101 65 e 0005 *ON ENTRY: HL POINTS TO STRING
0630 146 102 66 f 0006 * DE POINT TO TABLE
0634 147 103 67 g 0007 * C IS NUMBER OF CHARACTERS IN
0640 150 TABLE ENTRIES
104 68 h
0008 *ON RETURN:ZERO FLAG SET IF NO MATCH, ELSE DE
0644 151 105 69 i
0009 * POINTS TO DISPATCH ADDRESS
0650 152 106 6A j 0010 *
0654 153 107 6B k 0100 E5 0011 TSRCH PUSH H SAVE STRING ADDRESS
0660 154 108 6C I 0101 41 0012 MOV B,C INITIALIZE CHARACTER
0664 155 109 6D m COUNT
0670 156 110 6E n 0102 1A 0013 TS1 LDAX D COMPARE CHARACTERS
0674 157 111 6F 0 0103 BE 0014 CMP M
0700 160 112 70 0104 C211 01 0015 JNZ TS3
P
0704 0107 23 0016 INX H CHARACTER MATCH, GO ON
161 113 71 q
TO NEXT
0710 162 114 72 r
0108 13 0017 INX D
0714 163 115 73 s 0109 05 0018 DCR B
0720 164 116 74 t 010A C2 02 01 0019 JNZ TS1
0724 165 117 75 u 010D F601 0020 ORI 1 MATCHING ENTRY FOUND
0730 166 118 76 v 010F E1 0021 TS2 POP H
0734 167 119 77 w 0110 C9 0022 RET
0740 170 120 78 x 0111 B7 0023 TS3 ORA A TEST FOR END OF TABLE
0744 171 121 79 y 0112 CA OF 01 0024 JZ TS2
0115 13 0025 TS4 INX D SKIP TO NEXT ENTRY
0750 172 122 7A z 0116 05 0026 DCR B
0754 173 123 7B } 0117C21501 0027 JNZ TS4
0760 174 124 7C 011A 13 INX
0028 D
0764 175 125 7D } 011 B 13 0029 INX D
0770 176 126 7E Prefix 011C E1 0030 POP H
0774 177 127 7F DEL Rubout 0110 C3 00 01 0031 JMP TSRCH
0032 *
0033 * EXAMPLE OF TSRCH USE:
0034 *
0035 *(ASSUME HL POINTS TO A FOUR·CHARACTER
COMMAND STRING)
0120 11 3501 0036 LXI, D,CTABL DE POINTS TO COMMAND
TABLE
0123 OE 04 0037 MVI C,4 TABLE ENTRIES ARE FOUR
CHARACTERS LONG
0125 CD 00 01 0038 CALL TSRCH
0128 CA 00 00 U 0039 JZ ERROR COMMAND NOT IN TABLE
012B EB 0040 XCHG SET UP STACK FOR RETURN TO
MAIN ROUTINE

118 119
APPENDIX L - SAMPLE PROGRAM OF LOADER
SOURCE CODE
0001 **************************************************

0002 *
0003 * RUNA file-name [.ZCL]
0004 *
COMMENT 0005 * An .OBJ file consists of one of more segments that
0006 * have the format:
012C 1100 00 U 0041 LXI D,COMMAND
012F 05
0007 * #BYTES DECRIPTION
0042 PUSH D
0130 7E 0043 0008 * 2 Number of code and data bytes in
MOV A,M DISPATCH TO APPROPRIATE
COMMAND ROUTINE 0009 * segment
0131 23 0044 INX H 0010 * 2 Load address of code and data
0132 66 0045 MOV H,M 0011 * belonging to the segment.
0133 6F 0046 MOV L,A
0134 E9 0047
0012 * Variable Code and/or data.
PCHL
0048 * 0013 *
0049 *COMMAND TABLE 0014 * The run time package will load each segment at the
0050 * 0015 * specified address until a starting address is
0135 43 4F 4D 31 0051 CTABL ASC 'COM1' FIRST ENTRY 0016 * encountered. A starting address is represented as
0139 00 00 U 0052 DW SUB 1 ADDRESS OF SUB1
013B 43 4F 40 32 0053 ASC 0017 * load address with a zero byte count.
'COM2' SECOND ENTRY
013F 00 00 U 0054 DW SUB2 ADDRESS OF SUB2 0018 *
0019 **************************************************
0141 00 0055 DB oEND OF TABLE MARK
0020 *
0021 RELOC EQU 0 ;4200H FOR TRS-80 MOD 1
SYMBOL TABLE LISTING 0022 BOOS EQU 5 + RELOC ;CPIM
Label Addr. Label
0023 BLKSIZ EQU 128
Addr. Label Addr. Label Addr.
CTABL 0135 TS1 0102
0024 OFCB EQU 5CH + RELOC ;IN CPIM
TS2 010F TS3 0111
TS4 0115 TSRCH 0100 0025 OEX EQU OFCB + 12
0026 OCR EQU OFCB + 32
0027 OBUF EQU 80H + RELOC ;IN CPIM
0028 *
0029 CST ART EQU $
0030 LXI SP,STK
0031 MVI C,OCH ;RETURN VERSION #
0032 CALL BOOS
0033 MOV A,L
0034 ORA A
0035 JNZ VER2X
0036 LOA 4 + RELOC ;CPM 1.4 DEFAULT DRIVE
0037 CPI5
0038 JC SETDF
0039 XRA A
0040 SETDF EQU $ ;11-30-81 FOR MPIM II
0041 STA ODRIVE ;DEFAULT DRIVE
0042 * GET OPTIONS FROM TYPE FIELD
0043 LXI H,5CH + 8
0044 MVI C,4
0045 NEXT EQU $
0046 INX H

120 121
0047 OCR C
0048 JZ NOOPTIONS 0096 DCX H
0049 MOV A,M 0097 MOV M,E
0050 CPI" 0098 NOREL EQU $
0051 JZ NOOPTIONS 0099 POP PSW
0052 CPI 'Z' 0100 POP 0
0053 JZ ZEROFIL 0101 POP H
0054 CPI 'C' 0102 RET
0055 JZ COMFILE 0103 *
0056 CPI'L' 0104 VER2X EQU $
0057 JZ NOEXEC 0105 MVI C,19H ;GET CPM 2.X DEFAULT DRIVE
0058 * ERROR ILLEGAL OPTION 0106 CALL BOOS
0059 LXI H,MESGA 0107 JMP SETDF
0060 CALL DISPLAY 0108 *
0061 JMP 0 + RELOC 0109 MESGA ASC 'ILLEGAL OPTION'
0062 * GET SIZE OF INSTRUCTION 0110 DB ODH,OAH
0063 GETSZ LXI H,TBL-1 0111 ASC 'RUN D:FILE.ZCL<CR>'
0064 AGAIN MOV A,C 0112 DB ODH,OAH,O
0065 INX H 0113 *
0066 MOV B,M 0114 TBL DB -1,11101001B,1
0067 ANA B 0115 DB -1,11001101B,3
0068 JZ BYTE1 0116 DB 11000111B,11000100B,3
0069 INX H 0117 DB -1,11000011B,3
0070 MOV B,M 0118 DB 11000111B,11000010B,3
0071 XRA B 0119 DB 11000111B,11000111B,1
0072 INX H 0120 DB -1,11001001B,1
0073 JNZ AGAIN 0121 DB 11000111B,11OOOOOOB,
1
0074 MOV A,M 0122 DB 11001111B,1,3
0075 RET. EXIT 0123 DB 11100111B,00100010B,3
0076 BYTE1 MVI A,1 0124 DB 11110111B,11010011B,2
0077 RET. EXIT 0125 DB 11000111B,6,2
0078 * 0126 DB 11000111B,11000110B,2
0079 REL EQU $ RELOCATION 0127 DB 0 END OF TABLE
0080 PUSH H 0128 *
0081 PUSH 0 0129 BASE OW 0 BASE ADJ TO ADD TO ADDRESS TO BE
0082 OPUSH PSW RELOCATED
0083 INX H 0130 START OW 0 STARTING ADDR OF RELOCATED CODE
0084 MOV E,M 0131 *
0085 INX H 0132 ZEROFILL EQU
0086 MOV A,M 0133 STA ZX
0087 ORA A WE DON'T RELOCATE BELOW 100+ RELOC 0134 JMP NEXT
0088 JZ NOREL 0135 *
0089 MOV D,A 0136 COMPILE EQU $
0090 PUSH H 0137 STA CX
0091 LHLD BASE 0138 JMP NEXT
0092 DAD 0 ADDRESS IS NOW ADJUSTED 0139 *
0093 XCHG 0140 NOEXEC EQU $
0094 POP H 0141 STA LX
0095 MOV M,D PUT IT BACK 0142 JMP NEXT

122
123
0143 * 0190 MOV H,A
0144 OSET EQU $ 0191 ; H&L= STARTING ADDRESS
0145 LXID,OBUF 0192 SHLD START
0146 MVI C,26 :SET DMA 0193 PUSH H
0147 CALL BOOS 0194 LXI D,LOADFILE
0148 LOA ODRIVE 0195 MOV A,L
0149 MVID,O 0196 SUB E
0150 MOV E,A 0197 MOV L,A
0151 MVI C,14 :SET DRIVE 0198 MOVA,H
0152 CALL BOOS 0199 SBB 0
0153 LXI D,OFCB 0200 MOVE H,A
0154 RET 0201 SHLD BASE
0155 * 0202 POP H
0156 NOOPTIONS EQU $ 0203 LXI B,CONSTANTS-LOADFILE SIZE OF INSTRUCTION
0157 LXI H ,080H + 3 + RELOC MOVE
0158 MOV A,M 0204 XCHG
0159 CPI ':' ;WAS DRIVE REQUESTED? 0205 NXTI EQU $
0160 JNZ DEFDRIVE ;DEFAULT IS SET 0206 PUSH H
0161 DCX H 0207 PUSH 0
0162 MOV A,M 0208 PUSH B
0163 CPI'A' 0209 MOV C,M GET OPCODE
0164 JC DEFDRIVE 0210 CALL GETSZ GET SIZE OF INSTRUCTION
0165 SUI 'A' 0211 POP B
0166 STA ODRIVE 0212 POP 0
0167 DEFDRIVE EQU $ 0213 POP H
0168 CALL SETFCB 0214 CPI3
0169 MVI M,'O' 0215 JC SKPREL
0170 INX H 0216 CALL REL RELOCATE ADDR IN THIS 3 BYTE INST
0171 MVI M,'B' 0217 SKPREL EQU $
0172 INX H 0218 PUSH B
0173 MVI M,'J' 0219 PUSH PSW
0174 CALL OSET 0220 MOV C,A SIZE
0175 MVI C,15 ;OPEN 0221 NXTM EQU $
0176 CALL BOOS 0222 MOV A,M
0177 CPI-1 0223 STAX 0
0178 JZ OERR ;OPEN ERROR 0224 INX H
0179 XRA A 0225 INX 0
0180 STA OCR 0226 DCRC
0181 * RELOATE CODE TO JUST BELOW CPIM 0227 JNZ NXTM
0182 LHLD 6 + RELOC 0228 POP PSW
0183 DCX H HIGHEST ADDR 0229 POP B
0184 LXI B,LAST-LOADFILE SIZE OF CODE TO BE 0230 NXTD EQU $
RELOCATED 0231 DCX B
0185 MOV A,L 0232 DCRA
0186 SUB C 0233 JNZ NXTD
0187 MOV L,A 0234 MOV A,C
0188 MOV A,H 0235 ORA B
0189 SBB B 0236 JNZ NXTI

124 125
0237 * RELOCATE CONSTANTS 0285 JNZ MAO
0238 LXI B,LAST-CONST ANTS SIZE OF CONSTANTS 0286 ; H&L = BUFFER C = COUNT
0239 NXTC EQU $ 0287 XCHG
0240 MOV A,M 0288 LHLD OWRK ;SIZE OF NEXT READ
0241 STAX 0 0289 MOV A,L
0242 INX H 0290 ORA H
0243 INX 0 0291 JZ CLOSE
0244 DCX B 0292 SHLD OSIZE
0245 MOV A,C 0293 LHLD OWRK+ 2
0246 ORA B 0294 XCHG
0247 JNZ NXTC 0295 MAOA MOV A,M ;MOVE FROM BUF TO OBJ ADDR
0248 LH LD START 0296 STAX 0
0249 PCHL. CODE HAS BEEN RELOCATED NOW GO TO IT 0297 INX H
0250 * 0298 INX 0
0251 **************************************************
0299 OCR C
0252 * RUNA A:FILE.OBJ<CR> 0300 CZ ORO
0253 * 0301 PUSH H
0254 * MOVE PARAMETERS AND CHECK 0302 LHLD OSIZE
0255 **************************************************
0303 DCX H
0256 * 0304 SH LD OSIZE
0257 LOADFILE EQU $ 0305 MOV A,L
0258 LXI SP,STK SET STACK AFTER RELOCATION 0306 ORA H
0259 LOA ZX ZERO FILL MEMORY? 0307 POP H
0260 ORA A 0308 JNZ MAOA
0261 JZ SKPCLR 0309 CALL SAVOP
0262 LXI D,LOADFILE-1 0310 JMP OLOAD
0263 MVI H,1 STARTING ADDR + RELOC 0311 *
0264 MVI L,O 0312 GETOP EQU $ ;GET 0 POINTERS
0265 CLEAR EQU $ 0313 LXID,OWRK
0266 XRA A 0314 LHLD OCBA ;BUF AD DR
0267 MOV M,A 0315 MVI B,4 :LENGTH OF WRK
0268 INX H 0316 LOA OCBC ;BUF CNT
0269 MOV A,L 0317 MOV C,A
0270 SUB E 0318 RET
0271 MOV A,H 0319 *
0272 SBB 0 0320 ORO EQU $
0273 JC CLEAR 0321 PUSH B
0274 SKPCLT EQU $ 0322 PUSH 0 ;OPNT
0275 CALL ORO ;GET 1ST RECORD OF .OBJ FILE 0323 LXI D,OFCB
0276 OLOAD EQU $ 0324 MVI C,20 ;READ
0277 CALL GETOP 0325 CALL BOOS
0278 MAO MOV A,M ;MOVE 4 BYTES FROM BUF TO WORK 0326 POP 0
0279 STAX 0 0327 POP B
0280 INX H 0328 ORA A
0281 INX 0 0329 JNZ RERR
0282 OCR C 0330 LXI H,OBUF
0283 CZ ORO 0331 MVI C,BLKSIZ
0284 OCR B 0332 RET

126 127
0333 * 0381 RNZ
0334 SAVOP EQU $ 0382 OERR EQU $
0335 SHLD OCBA ;BUFF ADDR 0383 LXI H,MESGO OPEN ERROR
0336 MOV A,C 0384 CALL DISPLAY
0337 STA OCBC ;BUF CNT 0385 JMP OXT1
0338 LOA HIGH 0386 *
0339 CMP 0 0387 GENCOM EQU $ GENERATE .COM FILE
0340 RNC 0388 CALL SETFCB
0341 MOV A,D 0389 MVI M,'C'
0342 STA HIGH 0390 INX H
0343 RET 0391 MVI M,'O'
0344 * 0392 INX H
0345 CLOSE EQU $ 0393 MVI M,'M' .COM IN FCB
0346 LXI D,OFCB 0394 * OPEN
0347 MVI C,16 ;CLOSE 0395 LXI D,OFCB
0348 CALL BOOS 0396 MVI C,15 OPEN .COM FILE
0349 LOA CX 0397 CALL BOOS
0350 ORA A 0398 CPI -1
0351 JNZ GENCOM 0399 CZ CREATE
0352 LOA LX 0400 XRA A
0353 ORA A 0401 STA OCR
0354 JNZ 0+ RELOC LOAD BUT DON'T EXECUTE 0402 * WRITE
0355 LHLD OWRK+ 2 ;STARTING ADDRESS 0403 LOA HIGH
0356 PCHL 0404 OCR A
0357 * 0405 MOV H,A
0358 SETFCB EQU $ 0406 MVI L, OFFH
0359 XRA A 0407 SHLD SIZ OF THIS WRITE
0360 STA OFCB 0408 MVID,1 STARTING ADDRESS + RELOC
0361 STA OCR 0409 MVI E,O
0362 LXI H,OEX 0410 LXI H,OBUF BUFFER ADDRESS
0363 MVI C,4 0411 MVI C,BLKSIZ BUFFER SIZE
0364 EXLUP EQU $ ;10-2-81 ZERO CPM EXT AREA 0412 NXTW EQU $
0365 MOV M,A 0413 LDAX 0
0366 INX H 0414 MOV M,A
0367 OCR C 0415 INX H
0368 JNZ EXLUP 0416 INX 0
0369 LXI H,OBUF 0417 OCR C BUFF COUNT
0370 SHLD OCBA 0418 CZ WRITE
0371 MVI A, BLKSIZ 0419 PUSH H
0372 STA OCBC 0420 LH LD SIZ
0373 LXI H, 5CH + 9 + RELOC ;CPIM FILE TYPE 0421 DCX H
0374 RET 0422 SHLD SIZ
0375 * 0423 MOV A,L
0376 CREATE EQU $ 0424 ORA H
0377 LXI D,OFCB 0425 POP H
0378 MVI C,22 CREATE 0426 JNZ NXTW
0379 CALL BOOS 0427 CALL WRITE LAST BLOCK
0380 CPI -1 0428 * CLOSE

128 129
0429 LXI D,OFCD 0476 JMP 0+ RELOC RETURN TO CPIM
0430 MVI C,16 CLOSE 0477 *****.********************************************

0431 CALL BOOS 0478 CONSTANTS EQU $


0432 JMP 0 + RELOC 0479 HIGH DB 0 HIGHEST PAGE USED FOR .COM
0433 * 0480 ZX DB 0 DEFAULT NO CLEAR ;Z= ZERO FILL BEFORE
0434 WRITE EQU $ LOADING
0435 PUSH 0 0481 CX DB 0 DEFAULT NO .COM ;C = .COM FILE
0436 LXI D,OFCB 0482 LX DB 0 DEFAULT EXECUTE ;L = LOAD BUT NO
0437 MVI C,21 WRITE EXECUTION
0438 CALL BOOS 0483 ODRIVE DB 0
0439 POP 0 0484 OWRK DB 0,0,0,0
0440 ORA A 0485 OCBA OW OBUF ;CURRENT BUFFER ADDRESS
0441 JNZ ERRW 0486 OCBC DB BLKSIZ ;CURRENT BUFFER COUNTER
0442 LXI H,OBUF 0487 OSIZE OW 0 ;SIZE OF NEXT OBJ BLOCK
0443 MVI C,BLKSIZ 0488 SIZ OW 0 SIZE OF COM FILE CODE
0444 RET 0489 MESGO ASC 'OPEN ERROR'
0445 * 0490 DB 0
0446 * + + ********************************************* 0491 MESGR ASC 'READ ERROR'
0447 *$$ DISPLAY A MESSAGE TO THE CONSOLE 0492 DB 0
0448 * ENTRY H&L CONTAIN STARTING ADDRESS OF 0493 MESGW ASC 'WRITE ERROR'
THE MESSAGE 0494 DB 0
0449 * THE MESSAGE TEXT IS TERMINATED BY 0 HEX 0495 OS 30
0450 * CALL DISPLAY 0496 STK DB'S'
0451 * - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** 0497 LAST DB 0
0452 *
0453 DISPLAY EQU $
0454 MOV A,M
0455 ORA A
0456 RZ. EXIT TO CALLING ROUTINE * *
0457 MOV E,A
0458 MVI C,2
0459 PUSH H
0460 CALL BOOS ;PUT THE CHAR TO THE CONSOLE
0461 POP H
0462 INX H
0463 J M P DISPLAY
0464 *
0465 ERRW EQU $
0466 LXI H,MESGW WRITE ERROR
0467 CALL DISPLAY
0468 JMP OXT1
0469 *
0470 RERR EQU $
0471 LXI H,MESGR READ ERROR
0472 CALL DISPLAY
0473 OXT1 EQU $
0474 LXI H,OFCB + 1 ;FILE NAME
0475 CALL DISPLAY

130 131
APPENDIX M - SUGGESTED REFERENCES NEVADA FORTRAN and NEVADA ASSEMBLER INDEX

A GUIDE TO FORTRAN PROGRAMMING A


Daniel D. McCracken A-Type, 52
Addison-Wesley Publishing Co., 1961. A= n, 92,107
ABS, 97
CP/M USER'S GUIDE ACCEPT,94
T. Hogan ALOG,97
OSBOURNE,1981. ALOG10,97
FORTRAN IV AMAXO,97
Elliot I. Organick and Loren P. Meissner AMAX1,97
Addison-Wesley Publishing Co., 1966. AMINO, 97
AMIN1,97
FORTRAN IV WITH WATFOR AND WATFIV AMOD,97
Cress, Dirksen, and Graham ARG CNT, 101
Prentice-Hall, Inc., 1970. Arithmetic IF, 28
FORTRAN SELF-TEACHING COURSE Arithmetic Operators, 22
Ian D. Kettleborough Array, 105
ELLIS COMPUTING, INC., 1983. Assembly Errors, 92
Assembler Command Errors, 92
PROGRAMMING PROVERBS FOR FORTRAN PROGRAMMERS
ASSIGN, 27, 94, 104
Henry F. Ledgard
ASSIGNED GOTO, 27, 101, 106
Hayden, 1975. ASSM.COM, 91
SOFTWARE TOOLS Asterisk, 108
Brian W. Kernigham and P. J. Plauger ATAN,97
Addison-Wesley Publishing Co., 1976. ATAN2,97
8080/8050 ASSEMBLY LANGUAGE PROGRAMMING MANUAL
B
INTEL CORPORATION
Backslash, 58, 109
SANTA CLARA, CA., 1977.
BACKSPACE, 60, 94
8080A/8050 ASSEMBLY LANGUAGE PROGRAMMING Binary 1/0, 59
Lance A. Leventhal BIT, 62-63, 97, 99
OSBORNE,1978. Blank COMMON, 104
Blank padding, 10
BLOCK DATA, 45,94,106

C
C=XXXX, 107
CALL, 42-44, 62, 72, 94, 97, 104, 111
CALL POP, 101
CALL PSH, 101
CBTOF, 62,73,97,99
CHAIN, 6, 21, 33, 62-63,99
CHAIN FL, 63, 66,102
CHAR, 62, 73, 97
CIN,34,62,64,99
CLOSE, 60, 62, 64, 99
COM GO TO, 102

132 133
Comment Field, 86 ENDF,90
COMMON, 20, 39-40, 94,106,111 ENDFILE, 59-61, 95
COMP, 62, 73, 97 ENDIF, 29-30, 95, 106
Comparison Operators, 22 EQU, 87
COMPUTED GO TO, 27,104 Equate, 87
CON BIN, 102 ERR =,49, 105
Conditional Assembly, 90
ERRCLR, 32, 34, 95, 106
CONFIG, 3, 13-14,72, 109 Error Codes, 63, 92
Constant, 15·16, 84 Error (.ERR) file, 3, 77
CONTINUE, 26, 31-32, 94 ERRORS, 3
CONTROL-C, 33-34, 76, 80, 94, 102 ERRSET, 32-34, 49, 95, 106
CONTROL-H, 61 Executing the Assembler, 77
CONTROL-X, 61
Executing the .OBJ File, 8, 80
CONTROL-Z, 61 EXIT, 38, 62,66, 99
CONVERT,102 EXP, 97
COPY, 12,91,94,106-107,111 Expressions, 22, 23, 41, 85
COpy file, 91
CPIM OPERATING SYSTEM, 1 F
COS, 97 F-Type,53
CTEST, 62, 65, 99 FILE OPR, 102
CTRL DISABLE, 34, 94 FLOAT, 97
CTRL ENABLE, 34, 94 FORMAT, 51, 95,102
o Formatted 1/0, 46, 51, 58-59
FORT.COM,3
D-Type,52
FORT.ERR,3
0= n, 92,107
Free Format 1/0, 58
DATA, 19,94,106-107,111
DECODE, 50, 111 FUNCTION, 62,72,95,105
FUNCTION statement, 43
Define ASCII String (ASC), 99
Define Byte (DB), 88
Define Double Byte (DDB), 89 G
Define Word (OW), 89 G,104
Define Storage (OS), 88 G-Type,53
DELAY, 62, 65, 99 Getting Started, 1
DELETE, 61-62, 65, 99 GO TO, 26-27, 31-33, 97
DIM, 97
H
DIMENSION, 39-40, 94,104,106
Disk is full, 92,102 H,57
DIV ZERO, 102 Hardware Requirements, 1, 77
00,28,31,94,104 Hexadecimal, 109
DOUBLE PRECISION, 17-18,21,39,43,94,106 High-Order Byte Extraction, 85
DUMP, 36, 94, 106
I
E I-Type, 54
E-Type,52 1/0 ERR, 103
ENCODE, 50-51, 111 110 LIST, 46-47, 103
lABS, 97
END, 19,28,31,38,91,95,105,107
IDIM,97
END =,49-50, 105
IF,28,95
END of Source File, 91

134 135
IF-THEN-ELSE, 29-31, 95,106,111 N
IFIX, 97 NLST,91
IFLS,91 Normal return, 44
ILL CHAR, 102
ILL UNIT, 102 o
1MPLICIT, 21, 95, 106, 111 0= n, 93,105
Implied DO loop, 105 Object (.OBJ) Code, 76
INP, 62, 74, 97 OPERATION FIELD, 82
INPT ERR, 103 OPEN, 59, 61-62, 64, 68, 99, 107
INT RANG, 23, 103 Operand Field, 82
INTEGER, 17,21,23,39,43,95,106,109 Options, 3, 13, 32
ISIGN,97 ORG,87
OUT, 62, 69, 99
K OVERFLOW, 103
K-Type,55
P
L P= n, 79,105,111
L-Type,55 Page Eject, 91
L=, 92,107 PAUSE, 37, 95, 106
Label Field, 82 PEEK, 62,74,97
Labels, 83, 107 POKE, 62, 70, 99
Line Length, 103 Pseudo-Operations, 87
Line Numbers, 81 PUT, 62,70,100
List Conditional Code, 91
Listing Control, 91 Q
Listing Title, 91 Q,32
LOAD, 33, 62, 66, 99
LOG NEG, 103 R
LOGICAL, 17-18,21,39,43,95,106 R=,93
Logical IF, 28, 105 RAND,97
Logical Operators, 22, 24-25 READ, 47-49, 96, 111
LOPEN, 59, 61-62, 64, 67, 99 REAL, 17-18,23-24,39,43,96, 106
Low-Order Byte Extraction, 85 Register Names, 83
RENAME, 62, 70,100
M RESET, 62,71,100
M=XXXX,92 RETURN, 31,44,96
MAXO,97 REWIND, 59,61,96
MAX1,97 RUNA, 76, 80
Memory Usage, 80 Runtime error, 33, 101
MINO,97 Runtime Format, 21, 46
MIN1,97
Mixed mode expressions, 25 s
MOD,97 S =, 79, 93, 107
MOVE, 62, 68, 99 Sample Program, 119-131
Multiple RETURN, 44 SEEK, 61-62,71,100
SEEK ERR, 103
Set ASCII List Flag, 90
Set Execution Address, 88

136 137
Z
Set Origin, 87 Z-Type,56
SETIO, 62, 72, 100
SIGN,97 #, 79, 109
SIN,97 $, 78, 106, 109
Software Requirements, 1, 77
*,108
Source Code, 76
I-Type, 56
SQRT, 97, 103
.AND., 22, 24
Statements, 81
.EQ., 22, 24
STOP, 31, 38, 66, 94, 96,106
.FALSE.,28
Strings, 57
.GE., 22, 24
Subprograms, 42
.GT., 22, 24
SUBROUTINE, 42-43, 62, 96, 99-100
.LE., 22, 24
Subscripts, 41
.LT., 22, 24
.NE., 22, 24
T .NOT.,22
T-Type,55
.OR., 22, 24
TAN,97
.TRUE., 28
Termination, 37, 80
.XOR., 22, 24
TITL,91
TRACE OFF, 35, 96,106
TRACE ON, 35, 96,106
TYPE, 17,96

U
U=,93
Unconditional GO TO, 26
UNIT CLO, 103
UNIT OPN, 103

V
V,93
Variable, 17,21-22,33,45,47,50-51,63,96

W
WRITE, 36, 47, 50, 96, 111

X
X-Type, 56
XEQ,88

138
Commodore Business Machines. Inc.
1200 Wilson Drive West Chester. PA 193BO
Commodore Business Machines. Limited
3370 Pharmacy Avenue Agincourt. Ontario. M1W 2K4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy