Download - MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

Transcript
Page 1: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

MICRO-COBOLA SUBSET OF

NAVY STANDARD HYPO-COBOLFOR MICRO-COMPUTERS

Phil «p Russell My let

Page 2: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 3: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

NAVAL USUI ATE SGHOO

Monterey, California

THEMICRO-COBOLA SUBSET OF

NAVY STANDARD HYPO-COBOLFOR MICRO-COMPUTERS

by

Philip Russell Mylet

September 1973

Thesis Advisor: G. A. Kildall

Approved for public release; distribution unlimited,

• X ?

Page 4: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 5: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

UNCLASSIFIEDSECURITY CLASSIFICATION OF THIS PAGE (Wnen Data Entered)

REPORT DOCUMENTATION PAGE READ INSTRUCTIONSBEFORE COMPLETING FORM

1. REPORT NUMBER 2. GOVT ACCESSION NO 3. RECIPIENT'S CATALOG NUMBER

4. TITLE (mnd Subtitle)

MICRO-COBOL a Subset of Navy StandardHypo-Cobol for Micro-Computers

S. TYPE OF REPORT a PERIOD COVERED

Master's Thesis;Spphpmhpr 1Q7P

6. PERFORMING ORG. REPORT NUMBER

7. AUTHORfaJ t. CONTRACT OR GRANT NLMBERf.J

Philip Russell Mylet

9. PERFORMING ORGANIZATION NAME ANO ADDRESS

Naval Postgraduate SchoolMonterey, California 93940

10. PROGRAM ELEMENT. PROJECT TASKAREA a WORK UNIT NUMBERS

II. CONTROLLING OFFICE NAME AND ADDRESS

Naval Postgraduate SchoolMonterey, California 93940

12 REPORT DATE

September 197813 NUMBER OF PAGES

J£9_14 MONITORING AGENCY NAME a AOORESSf// dlllerent tram Controlling Oltlce) IS. SECURITY CLASS, (at thin ripoi-l)

Unclassified

ISa. OECL ASSIFICATION' DOWNGRACisGSCHEDULE

16. DISTRIBUTION STATEMENT (at title Report)

Approved for public release; distribution unlimited.

17. DISTRIBUTION STATEMENT (at the mbmtrmcl entered In Black 30, It different train Report)

18. SUPPLEMENTARY NOTES

19. KEY WORDS (Conflnua on rmvmrem etdo It nacaaaajy and Identity by block number)

MICRO-COBOLNavy Standard Hypo-CobolMicro-ComputersCompiler

20. ABSTRACT (Continue an ravaraa a/da If neceeemy mnd Identity by block number)

A MICRO-COBOL interpretive compiler has been implementedon an 8080 micro-computer based system running under CP/M.The implementation is a subset of ADPESO standard HYPO-COBOLin that the interprogram communication module has not beenincluded. HYPO-COBOL provides nucleus level constructs andfile options from the ANSII COBOL package along with the

DO | JAn"73 1473 EDITION OF 1 NOV 61 IS OBSOLETES/N 0103-014- 6601

I

UNCLASSIFIEDSeCUHITY CLASSIFICATION OF THIS F»Ot (Whan Dala tntered)

Page 6: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 7: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

UNCLASSIFIEDfucu»«Tv cl »m»ic»Tiox or this »>atf»»i»i

PERFORM UNTIL construct from a higher level to give increasedstructural control. MICRO-COBOL can be executed on an 8080or Z-80 micro-computer system with 16K of memory. Althoughlargely completed and tested, all features are not implemented.File I/O features have not been tested and the numeric editinstruction has not been implemented in the interpreter.

DD Form 14731 Jan 73

S/N 0102-014-6601

UNCLASSIFIED»etu»itv CLAtuncATioN o* t mi» p»oerw.«. o«

Page 8: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 9: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

Approved for public release; distribution unlimited.

MICRO-COBOLA Subset of

Navy Standard HYPO-COBOLfor Micro-Computers

by

Philip Russell MyletB.S., Pennsylvania State University, 1967

Submitted in partial fulfillment of the

requirements for the degree of

MASTER OF SCIENCE IN COMPUTER SCIENCE

from the

NAVAL POSTGRADUATE SCHOOLSeptember 1978

Page 10: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 11: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ABSTRACT

A MICRO-COBOL interpretive compiler has been implemented

on an 8080 micro-computer based system running under CP/M.

The implementation is a subset of ADPESO standard HYPO-COBOL

in that the interprogram communication module has not been

included. HYPO-COBOL provides nucleus level constructs and

file options from the ANSI I COBOL package along with the

PERFORM UNTIL construct from a higher level to give increased

structural control. MICRO-COBOL can be executed on an 80 80

or Z-80 micro-computer system wi-ch 16K of memory. Although

largely completed and tested, all features are not implemented.

File I/O features have not been tested and the numeric edit

instruction has not been implemented in the interpreter.

Page 12: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 13: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

TABLE OF CONTENTS

I. INTRODUCTION 7

A. BACKGROUND 7

B. APPROACH 7

II. MICRO-COBOL INTERPRETER 10

A. GENERAL DESCRIPTION 10

B. MEMORY ORGANIZATION 11

C. INTERPRETER INSTRUCTIONS 11

1. Format 11

2. Arithmetic Operations 12

3. Branching — 13

4. Moves 16

5. Input-output 19

6. Special Instructions 22

III. MICRO-COBOL COMPILER 25

A. GENERAL 25

B. CONTROL FLOW 25

C. INTERNAL STRUCTURES 25

D. PART ONE 27

E. PART TWO 35

APPENDIX A 45

APPENDIX B 93

APPENDIX C 97

APPENDIX D 99

COMPUTER LISTINGS 101

LIST OR REFERENCES 168

INITIAL DISTRIBUTION LIST 169

5

Page 14: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 15: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ACKNOWLEDGMENTS

I wish to express my appreciation to my advisor, Gary

Kildall who cheerfully accepted the responsibilities of

thesis advisor while on leave of absence. My thanks also

to John Pierce of Digital Research for his contributions

and hours of assistance early in the project. Finally, I

wish to express my gratitude to Mark Moranville who

continuously provided technical assistance and moral support

during the times when it was most needed.

Page 16: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 17: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

I. INTRODUCTION

A. BACKGROUND

MICRO-COBOL is an implementation of ADPESO standard

MYPO-COBOL with the major exception that the interprogram

communication module is not included. It has been imple-

mented as an interpretive compiler in that the compiler

itself generates intermediate code which is then executed

by a separate interpreter program. Both compiler and inter-

preter run under CP/M on an 8080 or Z-80 micro-computer system

with 16K of memory. Much credit for this work goes to Allen

S. Craig who did the original design and implementation of

MICRO-COBOL for his thesis submitted in March 1977. Craig's

work is contained in Reference 1. Most of the coding had

been completed, but many of the constructs did not work or

worked incorrectly. Since much of the compiler had not been

debugged and some areas not completed, thesis work was con-

tinued in March 1978 with the goal of producing a working

MICRO-COBOL compiler and interpreter.

B. APPROACH

As a first step, the program listings and thesis were

studied to gain familiarity with the original project goals

and resolve several areas of conflict between the thesis and

the listings. The remaining effort consisted of running test

programs, isolating bugs, and making additions, corrections

Page 18: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 19: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

and small design changes. The problems discovered were

primarily errors in the code, however, there were also

missing routines and grammar problems which necessitated

reconstructing the original grammar. Appendix D lists the

features that did not work at the start of this project and

the bugs that are known to remain.

The HYPO-COBOL Compiler Validation System (HCCVS) was

obtained from the Automatic Data Processsing Equipment Selec-

tion Office (ADPESO) to be used in testing the compiler.

The HCCVS is intended to determine the degree to which the

individual language elements conform to the HYPO-COBOL

Specification. The validation system is made up of audit

routines, their related data, and an executive routine which

prepares the audit routines for compilation. Each audit

routine is a HYPO-COBOL program which includes tests and

supporting procedures that print out the results of each

test. The audit routines collectively test the features of

the HYPO-COBOL Language Specification. Since MICRO-COBOL

does not support the interprogram communication module

feature of HYPO-COBOL, the HCCVS is not useful in its existing

form; however, it contains numerous routines which can be

used to create small test programs that should run on MICRO-

COBOL as it currently exists.

A language construct in question was tested by writing

a test program, compiling it, and executing it on the inter-

preter. If problems were encountered, the intermediate code

Page 20: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 21: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

was examined to determine if the difficulty was in the com-

piler or the interpreter. Having made this determination,

the program was examined to isolate the bad code using SID

(see Reference 12). Changes were then made and the source

program recompiled using the ISIS editor and the PLM80

compiler on the INTEL MDS System. Appendix B describes the

procedure used to construct the executable compiler and

interpreter files from the edited PLM80 source files.

The following sections describe the implementation of

the compiler and interpreter. This material should be read

in conjunction with Reference 1 which contains additional

background information.

Page 22: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 23: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

II. MICRO-COBOL INTERPRETER

A. GENERAL DESCRIPTION

The following sections describe the MICRO-COBOL pseudo-

machine architecture in terms of allocated memory areas and

pseudo-machine operations. The machine operators contain

all of the information required to perform one complete

action required by the language. The machine contains mul-

tiple parameter operators and a program counter that

addresses the next instruction to be executed. Three

eighteen digit registers are used for arithmetic and logic

operations. A subscript stack is used to compute subscript

locations, and a set of flags are used to pass branching

information from one instruction to another. The registers

allow manipulation of signed numbers of up to eighteen

decimal digits in length. Included in their representation

is a sign indicator and the position of the assumed decimal

point for the currently loaded number. The HYPO-COBOL

specification requires that there be no loss of precision

for operations on numbers having eighteen significant digits.

Numbers are represented in "DISPLAY" and "packed decimal" formats

DISPLAY format numbers are represented in memory in ASCII

and may have separate signs indicated by "+" and "-" or may

have a "zone" indicator, denoting a negative sign. In

packed decimal format the numbers are represented in memory

as sequential digit pairs and the sign is indicated in the

right-most position.

10

Page 24: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 25: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

B. MEMORY ORGANIZATION

Memory is divided into three major sections: (1) the

data areas defined by the DATA DIVISION statements, (2) the

code area, (3) and the constants area. No particular order

of these sections is required. The first two areas assume

the ability to both read and write, but the third only

requires the ability to be read. The code area requires

write capability because several instructions store branch

addresses and return addresses during execution.

The data area contains variables defined by the DATA

DIVISION statements, constants set in the WORKING STORAGE

SECTION, and all file control blocks and buffers. These

elements will be manipulated by the machine as each instruc-

tion is executed.

C. INTERPRETER INSTRUCTIONS

1. Format

All of the interpreter instructions consist of an

instruction number followed by a list of parameters. The

following sections describe the instructions, list the

required parameters, and describe the actions taken by the

machine in executing each instruction. In each case,

parameters are denoted informally by the parameter name

enclosed in brackets. The BRN branching instruction, for

example, uses the single parameter <branch address> which

is the target of the unconditional branch.

11

Page 26: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 27: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

As each instruction number is fetched from memory,

the program counter is incremented by one. The program

counter is then either incremented to the next instruction

number, or a branch is taken.

The three eighteen digit registers which are used

by the instructions covered in the following section are

referred to as registers zero, one, and two.

2 . Arithmetic Operations

There are five arithmetic instructions which act

upon the three registers. In all cases, the result is

placed in register two. Operations are allowed to destroy

the input values during the process of creating a result,

therefore, a number loaded into a register is not available

for a subsequent operation.

ADD: (addition) . Sum the contents of register zero

and register one.

Parameters: no parameters are required.

SUB: (subtract) . Subtract register zero from register

one.

Parameters: no parameters are required.

MUL: (multiply). Multiply register zero by register

one.

Parameters: no parameters required.

DIV: (divide) . Divide register one by the value in

register zero. The remainder is not retained.

Parameters: no parameters are required.

12

Page 28: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 29: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

RND: (round) . Round register two to the last signifi-

cant significant decimal place.

Parameters: no parameters are required.

3 . Branching

The machine contains the following flags which are

used by the conditional instructions covered in this

section.

BRANCH flag — indicates if a branch is to be taken;

END OF RECORD flag — indicates that an end of input

condition has been reached when an attempt was made to read

input;

OVERFLOW flag -- indicates the loss of information from

a register due to a number exceeding the available size;

INVALID flag -- indicates an invalid action in writing

to a direct access storage device.

All of the branch instructions are executed by

changing the value of the program counter. Some are uncondi-

tional branches and some test for condition flags which are

set by other instructions. A conditional branch is executed

by testing the branch flag which is initialized to false.

A true value causes a branch by changing the program counter

to the value of the branch address. The branch flag is then

reset to false. A false value causes the program counter

to be incremented to the next sequential instruction.

BRN: (branch to an address) . Load the program counter

with the <branch address >.

Parameters: <branch address>

13

Page 30: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 31: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

The next three incstructions share a common format.

The memory field addressed by the <memory address> is checked

for the <address length> , and if all the characters match the

test condition, the branch flag is complemented.

Parameters: <memory address> <address length> <branch

address>

CAL: (compare alphabetic) . Compare a memory field for

alphabetic characters.

CNS : (compare numeric signed). Compare a field for

numeric characters allowing for a sign character.

CNU: (compare numeric unsigned) . Compare a field for

numeric characters only.

DEC: (decrement a counter and branch if zero)

.

Decrement the value of the <address counter> by one; if the

result is zero before or after the decrement, the program

counter is set to the <branch address>. If the result is

not zero, the program counter is incremented by four.

Parameters: <address counter> <branch address>

EOR: (branch on end-of-records flag) . If the end-

of-records flag is true, it is set to false and the program

counter is set to the <branch address>. If false, the

program counter is incremented by two.

Parameters: <branch address>

GDP: (go to - depending on) . The memory location

addressed by the <number address> is read for the number of

bytes indicated by the <memory length> . This number

indicates which of the <branch addresses> is to be used.

14

Page 32: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 33: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

The first parameter is a bound on the number of branch

addresses. If the number is within the range, the program

counter is set to the indicated address. An out-of-bounds

value causes the program counter to be advanced to the next

sequential instruction.

Parameters: <bound number - byte> <memory length> <memory

address> <branch addr-l> <branch addr-2> . . . <branch addr-n>

INV: (branch if invalid-file-action flag true) . If the

invalid-file-action flag is true, then it is set to false,

and the program counter is set to the branch address. If it

is false, the program counter is incremented by two.

Parameters: <branch address>

PER: (perform) . The code address addressed by the

<change address> is loaded with the value of the <return

address>. The program counter is then set to the <branch

address>

.

Parameters: <branch address> <change address> <return

address

>

RET: (return) . If the value of the <branch address> is

not zero, then the program counter is set to its value, and

the <branch -address> is set to zero. If the <branch address>

is zero, the program counter is incremented by two.

Parameters: <branch address>

REQ: (register equal) . This instruction checks for a

zero value in register two. If it is zero, the branch flag

is complemented. A conditional branch is taken.

Parameters: <branch address

>

15

Page 34: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 35: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

RGT: (register greater than) . Register two is checked

for a negative sign. If present, the branch flag is comple-

mented. A conditional branch is taken.

Parameters: <branch address>

SER: (branch on size error) . If the overflow flag is

true, then the program counter is set to the branch address,

and the overflow flag is set to false. If it is false,

then the program counter is incremented by two.

Parameters: <branch address>.

The next three instructions are of similar form in

that they compare two strings and set the branch flag if

the condition is true.

Parameters: <string addr-l> <string addr-2> <length -

address> <branch address>

SEQ: (strings equal). The condition is true if the

strings are equal.

SGT: (string greater than) . The condition is true if

string one is greater than string two.

SLT: (string less than) . The condition is true if

string one is less than string two.

4. Moves

The machine supports a variety of move operations

for various formats and types of data. It does not support

direct moves of numeric data from one memory field to another.

Instead, all of the numeric moves go through the registers.

The next seven instructions all perform the same

function. They load a register with a numeric value and

16

Page 36: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 37: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

differ only in the type of number that they expect to see

in memory at the <number address>. All seven instructions

cause the program counter to be incremented by five. Their

common format is given below.

Parameters: <number address> <byte length> <byte decimal

count> <byte register to load>

LOD: (load literal) . Register two is loaded with a

constant value. The decimal point indicator is not set in

this instruction. The literal will have an actual decimal

point in the string if required.

LD1: (load numeric). Load a numeric field.

LD2 : (load postfix numeric). Load a numeric field with

an internal trailing sign.

LD3 : (load prefix numeric). Load a numeric field with

an internal leading sign.

LD4 : (load separated postfix numeric). Load a numeric

field with a separate leading sign.

LD5: (load separated prefix numeric). Load a numeric

field with a separate trailing sign.

LD6: (load packed numeric). Load a packed numeric

field.

MED: (move into alphanumeric edited field) . The edit

mask is loaded into the <to address> to set up the move, and

then the <from address> information is loaded. The program

counter is incremented by ten.

Parameters: <to address> <from address> <length of move>

<edit mask address> <edit mask length>

17

Page 38: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 39: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

MNE: (move into a numeric edited field) . First the

edit mask is loaded into the receiving field, and then the

information is loaded. Any decimal point alignment required

will be performed. If truncation of significant digits is a

side effect, the overflow flag is not set. The program

counter is incremented by twelve.

Parameters: <to address> <from address> <address length of

move> <edit mask address> <address mask length> <byte to

decimal count> <byte from decimal count>

MOV: (move into an alphanumeric field) . The memory

field given by the <to address> is filled by the from field

for the <move length> and then filled with blanks in the

following positions for the <fill count>.

Parameters: <to address> <from address> <address move

length> <address fill count>

STI : (store immediate register two). The contents of

register two are stored into register zero and the decimal

count and sign are indicators set.

Parameters: none.

The store instructions are grouped in the same order

as the load instructions. Register two is stored into memory

at the indicated location. Alignment is performed and any

truncation of leading digits causes the overflow flag to be

set. All five of the store instructions cause the program

counter to be incremented by four. The format for these

instructions is as follows.

Parameters: <address to store into> <byte length> <byte

decimal count>

18

Page 40: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 41: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

MNE: (move into a numeric edited field) . First the

edit mask is loaded into the receiving field, and then the

information is loaded. Any decimal point alignment required

will be performed. If truncation of significant digits is a

side effect, the overflow flag is not set. The program

counter is incremented by twelve.

Parameters: <to address> <from address> <address length of

move> <edit mask address> <address mask length> <byte to

decimal count> <byte from decimal count>

MOV: (move into an alphanumeric field) . The memory

field given by the <to address> is filled by the from field

for the <move length> and then filled with blanks in the

following positions for the <fill count>.

STI : (store immediate register two). The contents of

register two are stored into register zero and the decimal

count and sign are indicators set.

Parameters: none.

The store instructions are grouped in the same order

as the load instructions. Register two is stored into memory

at the indicated location. Alignment is performed and any

truncation of leading digits causes the overflow flag to be

set. All five of the store instructions cause the program

counter to be incremented by four. The format for these

instructions is as follows.

Parameters: <address to store into> <byte length> <byte

decimal count>

18 a.

Page 42: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 43: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

STO: (store numeric) . Store into a numeric field.

ST1: (store postfix numeric) . Store into a numeric

field with an internal trailing sign.

ST2 : (store prefix numeric). Store into a numeric

field with an internal leading sign.

ST3: (store separated postfix numeric). Store into

a numeric field with a separate trailing sign.

ST4 : (store separated prefix numeric). Store into a

numeric field with a separate leading sign.

ST5 : (store packed numeric). Store into a packed

numeric field.

5. Input-Output

The following instructions perform input and output

operations. Files are defined as having the following

characteristics: they are either sequential or random and,

in general, files created in one mode are not required to

be readable in the other mode. Standard files consist of

fixed length records, and variable length files need not be

readable in a random mode. Further, there must be some

character or character string that delimits a variable length

record.

ACC: (accept) . Read from the system input device into

memory at the location given by the memory address . The

program counter is incremented by three.

Parameters: <memory address> <byte length of read>

19

Page 44: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 45: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

CLS : (close). Close the file whose file control block

is addressed by the <fcb address>. The program counter is

incremented by two.

Parameters: <fcb address>

DIS: (display). Print the contents of the data field

pointed to by <memory address> on the system output device

for the indicated length. The program counter is incremented

by three.

Parameters: <memory address> <byte length>

There are three open instructions with the same

format. In each case, the file defined by the file control

block referenced will be opened by the mode indicated. The

program counter is incremented by two.

OPN: (open a file for input)

.

0P1: (open a file for output) . (

0P2: (open a file for both input and output). This is

only valid for files on a random access device.

The following file actions all share the same format.

Each performs a file action on the file referenced by the

file control block. The' record to be acted upon is given by

the record address . The program counter is incremented by

six.

Parameters: <fcb address> <record address> <record length -

address>

DLS : (delete a record from a sequential file). Remove

the record that was just read from the file. The file is

required to be open in the input-output mode.

20

Page 46: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 47: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

RDF: (read a sequential file) . Read the next record

into the memory area.

WTF : (write a record to a sequential file). Append a

new record to the file.

RVL: (read a variable length record)

.

WVL: (write a variable length record)

.

RWS : (rewrite sequential). The rewrite operation

writes a record from memory to the file, overlaying the

last record that was read from the device. The file must

be open in the input-output mode.

The following file actions require random files

rather than sequential files. They all make use of a random

file pointer which consists of a <relative address> and a

<relative length>. The memory field holds the number to

be used in disk operations or contains the relative record

number of the last disk action. The relative record number

is an index into the file which addresses the record being

accessed. After the file action, the program counter is

incremented by nine.

Parameters: <fcb address> <record address> <record length -

address> <relative address> <relative length - byte>.

DLR: (delete a random record) . Delete the record

addressed by the relative record number.

RRR: (read random relative) . Read a random record

relative to the record number.

21

Page 48: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 49: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

RRS : (read random sequential). Read the next sequential

record from a random file. The relative record number of the

record read is loaded into the memory reference.

RWR: (rewrite a random record)

.

WRR: (write random relative) . Write a record into the

area indicated by the memory reference.

WRS : (write random sequential). Write the next sequen-

tial record to a random file. The relative record number

is returned.

6 . Special Instructions

The remaining instructions perform special functions

required by the machine that do not relate to any of the

previous groups.

NEG: (negate) . Complement the value of the branch

flag.

Parameters: no parameters are required.

LDI: (load a code address direct). Load the code

address located five bytes after the LDI instruction with

the contents of <memory address> after it has been converted

to hexidecimal.

Parameters: <memory address> <length - byte>

SCR: (calculate a subscript) . Load the subscript stack

with the value indicated from memory. The address loaded

into the stack is the <initial address> plus an offset.

Multiplying the < field length> by the number in the <memory

reference> gives the offset value.

Parameters: <initial address> <field length> <memory

reference> <memory length> <stack level>

22

Page 50: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 51: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

STD: (stop display) . Display the indicated information

and then terminate the actions of the machine.

Parameters: <memory address> < length - byte>

STP: (stop). Terminate the actions of the machine.

Parameters: no parameters are required.

The following instructions are used in setting up

the machine environment and cannot be used in the normal

execution of the machine.

BST: (backstuff ) . Resolve a reference to a label.

Labels may be referenced prior to their definition, re-

quiring a chain of resolution addresses to be maintained in

the code. The latest location to be resolved is maintained

in the symbol table and a pointer at that location indi-

cates the next previous location to be resolved. A zero

pointer indicates no prior occurrences of the label. The

code address referenced by <change address> is examined

and if it contains zero, it is loaded with the new address .

If it is not zero, then the contents are saved, and the

process is repeated with the saved value as the change

address after loading the <new address>.

Parameters: <change address> <new address>

INT: (initialize memory) . Load memory with the <input

string> for the given length at the <memory address>.

Parameters: <memory address> <address length> <input

string>

SCD: (start code) . Set the initial value of the

program counter.

Parameters: <start address>

23

Page 52: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 53: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

TER: (terminate) . Terminate the initialization process

and start executing code.

Parameters: no parameters are required.

24

Page 54: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 55: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

III. MICRO-COBOL COMPILER

A. GENERAL

The compiler is designed to read the source language

statements from a diskette, extract the needed information

for the symbol table, and write the output code back onto

the diskette all in one pass. The compiler is defined in

two parts which run in succession. Part one builds the

symbol table and leaves it in memory to be used by part two.

The output from part two of the compiler is the intermediate

code file.

B. CONTROL FLOW

After part one of the compiler has completed its task

it loads part two without operator intervention. Internal

control of the compiler is the same for both part one and

two. The parser is called after initialization and runs

until it either finishes its task or reaches an unrecoverable

error state. The major subroutines in the compiler are the

scanner and the production case statement which are both

controlled by the parser.

C. INTERNAL STRUCTURES

The major internal structure is the symbol table, which

was designed as a list where the elements in the list are

the descriptions of the various symbols in the program. As

25

Page 56: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 57: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

new symbols are encountered they are added to the end of the

list. Symbols already in the list can be accessed through

the use of a "current symbol pointer". The location of items

in the list is determined by checking the identifier against

a hash table that points to the first entry in the symbol

table with that hash code. A chain of collision

addresses is maintained in the symbol table which links

entries which have the same hash value. All of the items in

the symbol table contain the following information: a colli-

sion field, a type field, the length of the identifier, and

the address of the item. If an item in the symbol table is

a data field, the following information is included in the

table: the length of the item, the level of the data field,

an optional decimal count, an optional multiple occurrence

count, and the address of the edit field, if required. If the

item is a file name then the following additional information

is included: the file record length, the file control block

address, and the optional symbol table location of the relative

record pointer. If the item is a label, then the only addi-

tional information is the location of the return instruction

at the end of the paragraph or section.

In addition to the symbol table, two stacks are used for

storing information: the level stack and the identifier

stack. In both cases, they are used to hold pointers to

entries in the symbol table. The identifier stack keeps

track of multiple identifier occurrences in such statements

26

Page 58: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 59: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

as the GO TO DEPENDING statement. The level stack is used

to hold information about the levels that make up a record

description.

The parser has control of a set of stacks that are used

in the manipulation of the parse states. In addition to the

state stack that is required by the parser, part one has a

value stack while part two has two different value stacks

that operate in parallel with the parser state stack. The

use of these stacks is described below.

D. PART ONE

The first part of the compiler is primarily concerned with

building the symbol table that will be used by the second

part. The actions corresponding to each parse step are explained

in the sections that follow. In each case, the grammar rule

that is being applied is given, and an explanation of what pro-

gram actions take place for that step has been included. In

describing the actions taken for each parse step there has

been no attempt to describe how the symbol table is constructed

or how the values are preserved on the stack. The intent of

this section is to describe what information needs to be

retained and at what point in the parse it can be determined.

Where no action is required for a given statement, or where

the only action is to save the contents of the top of the

stack, no explanation is given. Questions regarding the

actual manipulation of information should be resolved by

consulting the programs.

27

Page 60: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 61: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

1 <program> ::= <id-div> <e-div> <d-div> PROCEDURE

Reading the word PROCEDURE terminates the first part

of the compiler.

2 <id-div> ::= IDENTIFICATION DIVISION. PROGRAM-ID.

<comment> . <auth> <date> <sec>

2 <auth> ::= AUTHOR . <comment> .

4|<empty>

5 <date> ::= DATE-WRITTEN . <comment> .

6|

<empty

>

7 <sec> : := SECURITY . <comment> .

8;

<empty>

9 <comment> ::= <input>

10|

<comment> <input>

11 <e-div> ::= ENVIRONMENT DIVISION . CONFIGURATION SECTION,

<scr-obj> <i-o>

12 <src-obj> ::= SOURCE-COMPUTER . <comment> <debug> .

OBJECT-COMPUTER . <comment> .

13 <debug> : := DEBUGGING MODE

Set a scanner toggle so that debug lines will be

read.

14\<empty>

15 <i-o> ::= INPUT-OUTPUT SECTION . FILE-CONTROL .

<file-control-list> <id<

16|<empty>

17 <file-control-list> : := <file-control-entry>

18|

<f ile-control-list> <file-

control-entry>

28

Page 62: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 63: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

19 < file-control-entry > : := SELECT <id> <attribute-list> .

At this point all of the information about the file

has been collected and the type of the file can be

determined. File attributes are checked for compata-

bility and entered in the symbol table.

20 <attribute-list> ::= <one attrib>

21|<attribute-list> <one attrib>

22 <one-attrib> ::= ORGANIZATION <org-type>

23|ACCESS <acc-type> <relative>

24|ASSIGN <input>

A file control block is built for the file using an INT

operator.

25 <org-type> : := SEQUENTIAL

No information needs to be stored since the default

file organization is sequential.

2 6|

RELATIVE

The relative attribute is saved for production 19.

27 <acc-type> ::= SEQUENTIAL

This is the default.

2 8|

RANDOM

The random access mode needs to be saved for produc-

tion 19.

29 <relative> : := RELATIVE <id>

The pointer to the identifier will be retained by the

current symbol pointer, so this production only saves

a flag on the stack indicating that the production did

occur.

29

Page 64: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 65: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

30|

< empty

>

31 <id> ::= I-O-CONTROL . <same-list>

32|

< empty

>

33 <same-list> : := <same-element>

34|

<same-list> <same-element>

35 <same-element> ::= SAME <id-string> .

36 <id-string> : := <id>

37|<id-string> <id>

33 <d-div> ::= DATA DIVISION . <file-section> <work> <link>

39 <file-section> ::= FILE SECTION . <file-list>

Actions will differ in production 64 depending upon

whether this production has been completed. A flag

needs to be set to indicate completion of the file

section.

40 <empty>

The flag, indicated in production 39, is set.

41 <file-list> ::= <f ile-element>

42 <file-list> <file-element>

43 <files> : := FD <id> <file-control> . <record-description>

This statement indicates the end of a record descrip-

tion, and the length of the record and its address can

now be loaded into the symbol table for the file

name.

44 <file-control> : := <file-list>

45 <empty

>

46 <file-list> ::= <f ile-element>

47 I <file-list> <f ile-element>

30

Page 66: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 67: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

48 <file-element> :: = BLOCK <integer> RECORDS

49|

RECORD <rec-count>

The record length can be saved for comparison with the

calculated length from the picture clauses.

50|

LABEL RECORDS STANDARD

51|

LABEL RECORDS OMITTED

52 I VALUE OF <id-string>

53 <rec-count> ::= <integer>

54 <integer> TO <integer>

The TO option is the only indication that the file

will be variable length. The maximum length must be

saved.

55 <work> ::= WORKING- STORAGE SECTION . <record-description>

56 <empty>

57 <link> ::= LINKAGE SECTION . <record-description>

58 I < empty

>

59 <record-description> : := <level-entry>

60 <record-descrption> <level-entry>

61 <level-entry> : := <integer> <data-id> <redef ines>

<data-type> .

The level entry needs to be loaded into the level

stack. The level stack is used to keep track of the

nesting of field definitions in a record. At this

time there may be no information about the length of

the item being defined, and its attributes may depend

entirely upon its constituent fields. If there is a

pending literal, the stack level to which it applies

31

Page 68: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 69: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

is saved.

62 <data-id> ::= <id>

63|

FILLER

An entry is built in the symbol table to record infor-

mation about this record field. It cannot be used ex-

plicitly in a program because it has no name, but its

attributes will need to be stored as part of the total

record.

64 <redefines> ::= REDEFINES <id>

The redefines option gives new attributes to a previ-

ously defined record area. The symbol table pointer

to the area being redefined is saved so that informa-

tion can be transfered from one entry to the other.

In addition to the information saved relative to the

redefinition, it is necessary to check to see if the

current level number is less than or equal to the lev-

el recorded on the top of the level stack. If this is

true, then all information for the item on the top of

the stack has been saved and the stack can be re-

duced.

65 <empty>

As in production 64, the stack is checked to see if

the current level number indicates a reduction of the

level stack. In addition, special action needs to be

taken if the new level is 01. If an 01 level is en-

countered at this production prior to production 39 or

40 (the end of the file area) , it is an implied

32

Page 70: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 71: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

redefinition of the previous 01 level. In the working

storage section, it indicates the start of a new

record.

66 <data-type> ::= <prop-list>

67|

<empty>

68 <prop-list> ::= <data-element>

69 <prop-list> <data-element>

70 <data-element> : := PIC <input>

The <input> at this point is the character string that

defines the record field. It is analyzed and the ex-

tracted information is stored in the symbol table.

71|

USAGE COMP

The field is defined to be a packed numeric field.

72|

USAGE DISPLAY

The DISPLAY format is the default, and thus no special

action occurs.

73 I SIGN LEADING <separate>

This production indicates the presence of a sign in a

numeric field. The sign will be in a leading posi-

tion. If the <separate> indicator is true, then the

length will be one longer than the picture clause, and

the type will be changed.

74|

SIGN TRAILING <separate>

The same information required by production 73 must be

recorded, but in this case the sign is trailing rather

than leading.

75 I OCCURS <integer>

33

Page 72: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 73: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

The type must be set to indicate multiple occurrences,

and the number of occurrences saved for computing the

space defined by this field.

76|

SYNC <direction>

Syncronization with a natural boundary is not required

by this machine.

77|VALUE <literal>

The field being defined will be assigned an initial

value determined by the value of the literal through

the use of an INT operator. This is only valid in the

WORKING- STORAGE SECTION.

78 <direction> : := LEFT

79|

RIGHT

80|<empty>

81 <separate> ::= SEPARATE

The separate sign indicator is set on.

82|<empty>

83 <literal> ::= <input>

The input string is checked to see if it is a valid

numeric literal, and if valid, it is stored to be used

in a value assignment.

84|

<lit>

This literal is a quoted string.

85|

ZERO

As is the case of all literals, the fact that there is

a pending literal needs to be saved. In this case and

the three following cases, an indicator of which

34

Page 74: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 75: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

literal constant is being saved is all that is re-

quired. The literal value can be reconstructed

later.

86|SPACE

87|

QUOTE

88 <integer> : := <input>

The input string is converted to an integer value for

later internal use.

89 <id> : := <input>

The input string is the name of an identifier and is

checked against the symbol table. If it is in the sym-

bol table, then a pointer to the entry is saved. If

it is not in the symbol table, then an entry is added

and the address of that entry is saved.

E. PART TWO

The second part includes all of the PROCEDURE DIVI-

SION, and is the part where code generation takes place. As

in the case of the first part, there was no intent to show

how various pieces of information were retrieved but only

what information was used in producing the output code.

1 <p-div> ::= PROCEDURE DIVISION <using> .

<proc-body> EOF

This production indicates termination of the compila-

tion. If the program has sections, then it will be

necessary to terminate the last section with a RET

instruction. The code will be ended by the output of

a TER operation.

35

Page 76: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 77: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

2 <using> ::= USING id-string

Not implemented.

3|

< empty

>

4 <id-string> : := <id>

The identifier stack is cleared and the symbol table

address of the identifier is loaded into the first

stack location.

5|

<id-string> <id>

The identifier stack is incremented and the symbol

table pointer stacked.

6 <proc-body> : := <paragraph>

7 <proc-body> <paragraph>

8 <paragraph> : := <id> . <sentence-list>

The starting and ending address of the paragraph are

entered into the symbol table. A return is emitted as

the last instruction in the paragraph (RET 0) . When

the label is resolved, it may be necessary to produce

a BST operation to resolve previous references to the

label.

9|

<id> SECTION .

The starting address for the section is saved. If it

is not the first section, then the previous section

ending address is loaded and a return (RET 0) is

output. As in production 8, a BST may be produced.

10 <sentence-list> : := <sentence>.

11 <sentence-list> <sentence> .

36

Page 78: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 79: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

12 <sentence> ::= <imperative>

13|<conditional>

14|ENTER <id> <opt-id>

This construct is not implemented. An ENTER allows

statements from another language to be inserted in

the source code.

15 <imperative> ::= ACCEPT <subid>

ACC <address> <length>

16 <arithmetic>

17|

CALL <lit> <using>

This is not implemented.

18 CLOSE id

CLS file control block address

19|

<file-act>

20|DISPLAY <lit/id> <opt-lit/id>

The display operator is produced for the first literal

or identifier (DIS <address> <length>) . If the second

value exists, the same code is also produced for it.

21|

EXIT <program-id>

RET

22|GO <id>

BRN <address>

23|GO <id-string> DEPENDING <id>

GDP is output, followed by a number of parameters:

<the number of entries in the identifier stack> <the

length of the depending identifier> <the address of

37

Page 80: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 81: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

the depending identifier^ <the address of each

identifier in the stack>.

24 |MOVE <lit/id> TO <subid>

The types of the two fields determine the move that is

generated. Numeric moves go through register two

using a load and a store. Non-numeric moves depend upon

the result field and may be either MOV, MED or MNE

.

Since all of these instructions have long parameter

lists, they have not been listed in detail.

25|OPEN <type-action> <id>

This produces either OPN, 0P1, or 0P2 depending upon

the <type-action> . Each of these is followed by a

file control block address.

26|PERFORM < id> <thru> <finish>

The PER operation is generated followed by the <branch

address> <the address of the return statement to be

set> and <the next instruction address>.

27|

<read-id>

2 8 STOP <terminate>

If there is a terminate message, then STD is produced

followed by <message address> <message length> . Other-

wise STP is emitted.

29 <conditional> : := <arithmetic> <size-error> <imperative>

A BST operator is output to complete the branch around

the imperative from production 65.

30|<file-act> <invalid> <imperative>

38

Page 82: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 83: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

A BST operator is output to complete the branch from

production 64.

31 <if-nonterminal> <condition> <action>

ELSE <imperative>

NEG will be emitted unless <condition> is a

"NOT <cond-type>" , in which case the two negatives

will cancel each other.

Two BST operators are required. The first fills in

the branch to the ELSE action. The second completes

the branch around the <imperative> which follows ELSE.

32 <read-id> <special> <imperative>

A BST is produced to complete the branch around the

<imperative>

.

33 <Arithmetic> : := ADD <l/id> <opt-l/id> TO <subid> <round>

The existence of multiple load and store instructions

make it difficult to indicate exactly what code will

be generated for any of the arithmetic instructions.

The type of load and store will depend on the nature

of the number involved, and in each case the standard

parameters will be produced. This parse step will in-

volve the following actions: first, a load will be em-

itted for the first number into register zero. If

there is a second number, then a load into register

one will be produced for it, followed by an ADD and a

STI. Next a load into register one will be generated

for the result number. Then an ADD instruction will

39

Page 84: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 85: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

be emitted. Finally, if the round indicator is set, a

RND operator will be produced prior to the store.

34|DIVIDE <l/id> INTO <subid> <round>

The first number is loaded into register zero. The

second operand is loaded into register one. A DIV

operator is produced, followed by a RND operator prior

to the store, if required.

35|MULTIPLY <l/id> BY <subid> <round>

The multiply is the same as the divide except that a

MUL is produced.

36|SUBTRACT <l/id> <opt-l/id> FROM

<subid> <round>

Subtraction generates the same code as the ADD except

that a SUB is produced in place of the last ADD.

37 <file-act> : := DELETE <id>

Either a DLS or a DLR will be produced along with the

required parameters.

38 REWRITE <id>

Either a RWS or a RWR is emitted, followed by parame-

ters .

39 WRITE <id> <special-act>

There are four possible write instructions: WTF , WVL,

WRS, and WRR.

40 <condition> : := <lit/id> <not> <cond-type>

One of the compare instructions is produced. They are

CAL, CNS, CNU, RGT, RLT, REQ , SGT, SLT, and SEQ. Two

40

Page 86: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 87: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

load instructions and a SUB will also be emitted if

one of the register comparisons is required.

41 <cond-type> : := NUMERIC

42|

ALPHABETIC

43j<compare> <lit/id>

44 <not> : := NOT

NEG is emitted unless the NOT is

part of an IF statement in which case the NEG in

the IF statement is cancelled.

45|

< empty

>

46 <compare> : := GREATER

47|LESS

48|EQUAL

4 9 <ROUND> ::= ROUNDED

50S

< empty

>

51 <terminate> : := <literal>

52|RUN

53 <special> : := <invalid>

54|END

An ERO operator is emitted followed by a zero. The

zero acts as a filler in the code and will be back-

stuffed with a branch address. In this production and

several of the following, there is a forward branch on

a false condition past an imperative action. For an

example of the resolution, examine production 32.

55 <opt-id> : := <subid>

56 empty

41

Page 88: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 89: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

57 <action> : := <imperative>

BRN

58 |NEXT SENTENCE

BRN

59 <thru> ::= THRU <id>

60 empty

61 <finish> ::= <l/id> TIMES

LDI <address> <length> DEC

62|UNTIL <condition>

63 empty

64 <invalid> ::= INVALID

INV

65 <size-error> : :- SIZE ERROR

SER

66 <special-act> ::= <when> ADVANCING <how-many>

67 <empty>

68 <when> ::= BEFORE

69|AFTER

70 <how-many> : := <integer>

71|

PAGE

72 <type-action> : := INPUT

7 3|OUTPUT

74|

1-0

75 <subid> ::= <subscript>

76|

id

77 <integer> : := <input>

42

Page 90: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 91: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

The identifier is checked against the symbol table, if

it is not present, it is entered as an unresolved la-

bel.

79 <l/id> ::= <input>

The input value may be a numeric literal. If so, it

is placed in the constant area with an INT operand.

If it is not a numeric literal, then it must be an

identifier, and it is located in the symbol table.

80;

<subscript>

81|ZERO

82 <subscript> ::= <id> ( <input> )

If the identifier was defined with a USING option,

then the input string is checked to see if it is a

number or an identifier. If it is an identifier, then

an SCR operator is produced.

83 <opt-l/id> ::= <l/id>

84|

<empty>

85 <nn-lit> : := <lit>

The literal string is placed into the constant area

using an INT operator.

86|SPACE

87|

QUOTE

88 <literal> ::= <nn-lit>

89I

<input>

The input value must be a numeric literal to be valid

and is loaded into the constant area using an INT.

90 I ZERO

43

Page 92: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 93: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

91 <opt-lit/id> ::= <lit/id>

94 ! <empty>

95 <program-id> ::= <id>

96|

<empty>

97 <read-id> ::= READ <id>

There are four read operations: RDF, RVL, RRS , and

RRR.

98 <if-nonterminal> : :=IF

The intermediate code file is the only product of the

compiler that is retained. All of the needed information

has been extracted from the symbol table, and it is not re-

quired by the interpreter. The intermediate code file can

be examined through the use of the DECODE Program which

translates the output file into a listing of mnemonics fol-

lowed by the parameters

.

44

Page 94: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 95: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

APPENDIX A

MICRO-COBOL USER'S MANUAL

45

Page 96: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 97: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

TABLE OF CONTENTS

I. ORGANIZATION 47

II. MICRO-COBOL ELEMENTS 48

III. COMPILER PARAMETERS 84

IV. RUN TIME CONVENTIONS 85

V. FILE INTERACTIONS WITH CP/M 86

VI. ERROR MESSAGES 88

A. COMPILER FATAL MESSAGES 88

B. COMPILER WARNINGS 88

C. INTERPRETER FATAL ERRORS 90

D. INTERPRETER WARNING MESSAGES 91

46

Page 98: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 99: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

I. ORGANIZATION

The MICRO-COBOL compiler is designed to run on an 8080

system in an interactive mode, and requires at least 16K

of RAM memory along with a diskette storage device. The

compiler is composed of two parts, each of which reads a

portion of the input file. Part one reads the input

program and builds the symbol table. At the end of the

Data Division, part one is overlayed by part two which uses

the symbol table and the Procedure Division of the source

program to produce the intermediate code which is written

to the diskette as it is generated.

The BUILD Program reads the intermediate code file and

creates the executable code memory image which is used by

the interpreter. After the memory image has been created,

the BUILD Program loads and passes control to the inter-

preter which then executes the intermediate code.

47

Page 100: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 101: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

II. MICRO-COBOL ELEMENTS

The procedure to compile and execute a MICRO-COBOL

source program is covered in the next section. This

section contains a description of each element in the

language and shows simple examples of its use. The follow-

ing conventions are used in explaining the formats:

elements enclosed in broken braces < > are themselves

complete entities and are described elsewhere in the

manual. Elements enclosed in braces { i are choices, one

of the elements which is to be used. Elements enclosed in

brackets [ ] are optional. All elements in capital

letters are reserved words and must be spelled exactly.

User names are indicated as lower case.. These names

have been restricted to 12 characters in length. The

HYPO-COBOL specification requires that each name start

with a letter. There are no restrictions in MICRO-COBOL

on what characters must be in any position of a user name.

However, it is generally good practice to avoid the use of

number strings as names, since they will be taken as

literal numbers wherever the context allows it. For

example a record could be defined in the Data Division

with the name 1234, but the command MOVE 1234 TO RECORDl

would result in the movement of the literal number not

the data stored.

48

Page 102: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 103: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

The input to the compiler does not need to conform to

standard COBOL format. Free form input will be accepted

as the default condition. If desired, sequence numbers

can be entered in the first six positions of each line.

When sequence numbers are used, a compiler parameter must

set to cause the compiler to ignore them.

49

Page 104: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 105: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

IDENTIFICATION DIVISION

ELEMENT:

IDENTIFICATION DIVISION Format

FORMAT:

IDENTIFICATION DIVISION.

PROGRAM-ID. <comment>

.

[AUTHOR. < comments.]

[DATA-WRITTEN. <comment> .

]

[SECURITY. <comment> .

]

DESCRIPTION:

This division provides information for program

identification for the reader. The order of the

lines is fixed.

EXAMPLES

:

IDENTIFICATION DIVISION.

PROGRAM-ID. SAMPLE.

AUTHOR. PHIL MYLET

.

50

Page 106: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 107: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ENVIRONMENT DIVISION

ELEMENT:

ENVIRONMENT DIVISION Format

FORMAT:

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

SOURCE-COMPUTER. <comment> [DEBUGGING MODE]

.

OBJECT-COMPUTER. <comment>

.

[INPUT-OUTPUT SECTION.

FILE-CONTROL.

<file-control-entry> . . .

[I-O-CONTROL.

SAME file-name-1 file-name-2 [file-name-3]

[file-name-4] [file-name-5] . ] ]

DESCRIPTION:

This division determines the external nature of a

file. In the case of CP/M all of the files used

can be accessed either sequentially or randomly

except for variable length files which are sequential

only. The debugging mode is also set by this section.

51

Page 108: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 109: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

<file-control-entry >

ELEMENT

:

<file-control-entry>

FORMAT

:

1.

SELECT file-name

ASSIGN implementor-name

[ORGANIZATION SEQUENTIAL]

[ACCESS SEQUENTIAL]

.

2.

SELECT file-name

ASSIGN implementor-name

ORGANIZATION RELATIVE

[ACCESS {SEQUENTIAL [RELATIVE data-name]}].

{RANDOM RELATIVE data-name }

DESCRIPTION:

The file-control-entry defines the type of file

that the program expects to see. There is no

difference on the diskette, but the type of reads

and writes that are performed will differ. For

CP/M the implementor name needs to conform to the

normal specifications.

EXAMPLES

:

1.

SELECT CARDS

ASSIGN CARD.FIL.

52

Page 110: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 111: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

2.

SELECT RANDOM-FILE

ASSIGN A. RAN

ORGANIZATION RELATIVE

ACCESS RANDOM RELATIVE RAND-FLAG,

53

Page 112: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 113: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

DATA DIVISION

ELEMENT

:

DATA DIVISION Format

FORMAT:

DATA DIVISION.

[FILE SECTION.

[FD file-name

[BLOCK integer-1 RECORDS]

[RECORD [integer-2 TO] integer-3]

[label records (standard)]

(omitted)

[VALUE OF implementor-name-1 literal-1

[implementor-name-2 literal-2] ... ].

[ record-description-entry ] . . . ] ...

[WORKING-STORAGE SECTION.

[< record-description-entry>

] ... ]

[LINKAGE SECTION.

[<record-description-entry>] ... ]

DESCRIPTION:

This is the section that describes how the data is

structured. There are no major differences from

standard COBOL except for the following: 1. Label

records make no sense on the diskette so no entry

is required. 2. The VALUE OF clause likewise has

no meaning for CP/M. 3. The linkage section has

not been implemented.

54

Page 114: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 115: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

If a record is given two lengths as in RECORD 12 TO

128, the file is taken to be variable length and can

only be accessed in the sequential mode. See the

section on files for more information.

55

Page 116: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 117: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

<conunent>

ELEMENT

:

<comment>

FORMAT:

any string of characters

DESCRIPTION:

A comment is a string of characters. It may include

anything other than a period followed by a blank or

a reserved word, either of which terminate the

string. Comments may be empty if desired, but the

terminator is still required by the program.

EXAMPLES:

this is a comment

anotheroneallruntogether

8080b 16K

56

Page 118: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 119: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

< data-description-entry>

ELEMENT

:

<data-description-entry> Format

FORMAT:

level-number {data-name}

(filler)

[REDEFINES data-name]

[PIC character-string]

[usage {comp} ]

{display}

[sign {leading} [separate]]

{trailing}

[OCCURS integer]

[SYNC [LEFT ]

]

[RIGHT]

[VALUE literal]

.

DESCRIPTION:

This statement describes the specific attributes of

the data. Since the 8080 is a byte machine, there

was no meaning to the SYNC clause, and thus it has

not been implemented.

57

Page 120: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 121: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

EXAMPLES:

01 CARD-RECORD.

02 PART PIC X(5)

.

02 NEXT-PART PIC 99V99 USAGE COMP

.

02 FILLER.

03 NUMB PIC S9(3)V9 SIGN LEADING SEPARATE,

03 LONG-NUMB 9 (15) .

03 STRING REDEFINES LONG-NUMB PIC X(15)

.

02 ARRAY PIC 99 OCCURS 100.

58

Page 122: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 123: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

PROCEDURE DIVISION

ELEMENT

:

PROCEDURE DIVISION Format

FORMAT:

1.

PROCEDURE DIVISION [USING namel [name2] ... [name5] ]

.

section-name SECTION.

[paragraph-name. <sentence> [<sentence> ... ] ... ] .

2.

PROCEDURE DIVISION [USING namel [name2] ... [name5]

.

paragraph-name. <sentence> [<sentence> ...] ...

DESCRIPTION:

As is indicated, if the program is to contain

sections, then the first paragraph must be in a

section. The USING option is part of the inter-

program communication module and has not been

implemented.

59

Page 124: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 125: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

<sentence >

ELEMENT:

< sentence>

FORMAT:

< imperative- statement>

< conditional-statement>

ENTER verb

DESCRIPTION:

All sentences other than ENTER fall in one of the

two main categories. ENTER is part of the inter-

program communication module.

60

Page 126: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 127: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

< imperative-statement^

ELEMENT

:

"^imperative-statement 3"

FORMAT

The following verbs are always imperatives:

ACCEPT

CALL

CLOSE

DISPLAY

EXIT

GO

MOVE

OPEN

PERFORM

STOP

The following may be imperatives:

arithmetic verbs without the SIZE ERROR statement

and DELETE, WRITE, and REWRITE without the INVALID

option.

61

Page 128: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 129: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

^conditional-statements^

ELEMENT:

< conditional-statements >

FORMAT:

IF

READ

arithmetic verbs with the SIZE ERROR statement

and DELETE, WRITE, and REWRITE with the INVALID

option

.

62

Page 130: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 131: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ACCEPT

ELEMENT

:

ACCEPT

FORMAT:

ACCEPT <identifier>

DESCRIPTION:

This statement reads up to 72 characters from the

console. The usage of the item must be DISPLAY.

EXAMPLES:

ACCEPT IMMAGE

ACCEPT NUM(9)

63

Page 132: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 133: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ADD

ELEMENT

:

ADD

FORMAT:

ADD (identifier) [{ identif ier-1 ) ] TO identifier-2

(literal) (literal }

[ROUNDED] [SIZE ERROR < imperative-statement>

]

DESCRIPTION:

This instruction adds either one or two numbers to

a third with the result being placed in the last

location

.

EXAMPLES:

ADD 10 TO NUMB1

ADD X Y TO Z ROUNDED.

ADD 100 TO NUMBER SIZE ERROR GO ERROR-LOC

64

Page 134: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 135: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

CALL

ELEMENT

:

CALL

FORMAT:

CALL literal [USING namel [name2] ... [name5]

DESCRIPTION:

CALL is not implemented.

65

Page 136: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 137: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

CLOSE

ELEMENT

:

CLOSE

FORMAT:

CLOSE file-name

DESCRIPTION:

Files must be closed if they have been written.

However, the normal requirement to close an input

file prior to the end of processing does not exist.

EXAMPLES

:

CLOSE FILE1

CLOSE RANDFILE

66

Page 138: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 139: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

DELETE

ELEMENT

:

DELETE

FORMAT:

DELETE record-name [INVALID < imperative-statement

]

DESCRIPTION:

This statement requires the record name, not the

file name as in the standard form of the statement.

Since there is no deletion mark in CP/M, this would

normally result in the record still being readable.

It is, therefore, filled with zeroes to indicate

that it has been removed.

EXAMPLES

:

DELETE REC0RD1

67

Page 140: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 141: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

DISPLAY

ELEMENT

:

DISPLAY

FORMAT:

DISPLAY (identifier) [ C identif ier-ll

]

(literal } (literal }

DESCRIPTION:

This displays the contents of an identifier or

displays a literal on the console. Usage must be

DISPLAY. The maximum length of the display is

72 positions.

EXAMPLES:

DISPLAY MESSAGE-1

DISPLAY MESSAGE-3 10

DISPLAY 'THIS MUST BE THE END'

63

Page 142: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 143: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

DIVIDE

ELEMENT:

DIVIDE

FORMAT

:

DIVIDE (identifier) INTO identif ier-1 [ROUNDED]

(literal }

[SIZE ERROR <imperative-statement>]

DESCRIPTION:

The result of the division is stored in identif ier-1

;

any remainder is lost.

EXAMPLES:

DIVIDE NUMB INTO STORE

DIVIDE 25 INTO RESULT

69

Page 144: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 145: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

EXIT

ELEMENT

:

EXIT

FORMAT:

EXIT [PROGRAM]

DESCRIPTION:

The EXIT command causes no action by the interpreter

but allows for an empty paragraph for the construction

of a common return point. The optional PROGRAM state-

ment is not implemented as it is part of the inter-

program communication module.

EXAMPLES:

RETURN

.

EXIT.

70

Page 146: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 147: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

GO

ELEMENT

:

GO

FORMAT:

1.

GO procedure-name

2.

GO procedure-1 [procedure-2 ] ... procedure-20

DEPENDING identifier

DESCRIPTION:

The GO command causes an unconditional branch to the

routine specified. The second form causes a forward

branch depending on the value of the contents of

the identifier. The identifier must be a numeric

integer value. There can be no more than 20 procedure

names

.

EXAMPLES:

GO READ-CARD.

GO READ1 READ2 READ3 DEPENDING READ- INDEX.

71

Page 148: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 149: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

IF

ELEMENT:

IF

FORMAT:

IF <condition> (imperative) ELSE imperative-2

(NEXT sentence)

DESCRIPTION:

This is the standard COBOL IF statement. Note that

there is no nesting of IF statements allowed since

the IF statement is a conditional.

EXAMPLES

:

IF A GREATER B ADD A TO C ELSE GO ERROR-ONE.

IF A NOT NUMERIC NEXT SENTENCE ELSE MOVE ZERO TO A.

72

Page 150: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 151: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

MOVE

ELEMENT

:

MOVE

FORMAT:

MOVE (identifier-l) TO identifier-2

(literal 1

DESCRIPTION:

The standard list of allowable moves applies to this

action. As a space saving feature of this implementa-

tion, all numeric moves go through the accumulators.

This makes numeric moves slower than alphanumeric

moves, and where possible they should be avoided.

Any move that involves picture clauses that are

exactly the same can be accomplished as an alpha-

numeric move if the elements are redefined as

alphanumeric; also all group moves are alphanumeric.

EXAMPLES

:

MOVE SPACE TO PRINT-LINE.

MOVE A (10) TO B(PTR)

.

73

Page 152: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 153: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

MULTIPLY

ELEMENT

:

MULTIPLY

FORMAT:

MULTIPLY (identifier) BY identifier-2 [ROUNDED]

(literal }

[SIZE ERROR < imperative-statement 5,]

DESCRIPTION:

The multiply routine requires enough space to calcu-

late the result with the full number of decimal

digits prior to moving the result into identifier-2.

This means that a number with 5 places after the

decimal multiplied by a number with 6 places after

the decimal will generate a number with 11 decimal

places which would overflow if there were more than

7 digits before the decimal place.

EXAMPLES:

MULTIPLY X BY Y.

MULTIPLY A BY B(7) SIZE ERROR GO OVERFLOW.

74

Page 154: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 155: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

OPEN

ELEMENT:

OPEN

FORMAT:

OPEN (INPUT file-name }

(OUTPUT file-name)

(i-O file-name )

DESCRIPTION:

All three types of OPENs have the same effect on

the diskette. However, they do allow for internal

checking of the other file actions. For example,

a write to a file set open as input will cause a

fatal error.

EXAMPLES:

OPEN INPUT CARDS.

OPEN OUTPUT REPORT-FILE.

75

Page 156: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 157: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

PERFORM

ELEMENT

:

PERFORM

FORMAT

1.

PERFORM procedure-name [THRU procedure-name-2

]

2.

PERFORM procedure-name [THRU procedure-name-2]

(identifier) TIMES

{ integer }

3.

PERFORM procedure-name [THRU procedure-name-2]

UNTIL <condition>

DESCRIPTION:

All three options are supported. Branching may be

either forward or backward, and the procedures

called may have perform statements in them as long

as the end points do not coincide or overlap.

EXAMPLES:

PERFORM OPEN-ROUTINE.

PERFORM TOTALS THRU END-REPORT.

PERFORM SUM 10 TIMES.

PERFORM SKIP-LINE UNTIL PG-CNT GREATER 60.

76

Page 158: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 159: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

READ

ELEMENT

:

READ

FORMAT

:

1.

READ file-name INVALID imperative-statements

2.

READ file-name END < imperative-statement>

DESCRIPTION:

The invalid condition is only applicable to files

in a random mode. All sequential files must have

an END statement.

EXAMPLES:

READ CARDS END GO END-OF-FILE.

READ RANDOM-FILE INVALID MOVE SPACES TO REC-1.

77

Page 160: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 161: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

REWRITE

ELEMENT

:

REWRITE

FORMAT:

REWRITE file-name [INVALID <imperative>]

DESCRIPTION:

REWRITE is only valid for files that are open in

the 1-0 mode. The INVALID clause is only valid

for random files. This statement results in the

current record being written back into the place

that it was just read from. Note that this requires

a file name not a record name.

EXAMPLES:

REWRITE CARDS.

REWRITE RAND-1 INVALID PERFORM ERROR-CHECK.

78

Page 162: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 163: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

STOP

ELEMENT

:

STOP

FORMAT:

STOP (RUN )

(literal)

DESCRIPTION:

This statement ends the running of the interpreter.

If a literal is specified, then the literal is

displayed on the console prior to termination of

the program.

EXAMPLES

:

STOP RUN.

STOP 1.

STOP "INVALID FINISH".

79

Page 164: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 165: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

SUBTRACT

ELEMENT

:

SUBTRACT

FORMAT:

SUBTRACT { identifier-l) [identif ier-2 ] FROM identifer-3

(literal-1 } [literal-2 ]

[ROUNDED] [SIZE ERROR <imperative-statement >]

DESCRIPTION:

Identifier-3 is decremented by the value of

identifier/literal one, and, if specified,

identifier/literal two. The results are stored

back in identifier-3. Rounding and size error

options are available if desired.

EXAMPLES:

SUBTRACT 10 FROM SUB (12).

SUBTRACT A B FROM C ROUNDED.

30

Page 166: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 167: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

WRITE

ELEMENT

:

WRITE

FORMAT:

1.

WRITE file-name [{ BEFORE) ADVANCING (INTEGER)]

(AFTER ) (PAGE }

2.

WRITE file-name INVALID <imperative-statement>

DESCRIPTION:

There is no printer on the 8080 system here, so the

ADVANCING option is not implemented. The INVALID

option only applies to random files.

EXAMPLES:

WRITE OUT-FILE.

WRITE RAND-FILE INVALID PERFORM ERROR-RECOV.

81

Page 168: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 169: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

<condition>

ELEMENT

:

<condition>

FORMAT:

RELATIONAL CONDITION:

(identifier-1) [NOT] {GREATER} { identif ier-2

i

(literal-1 } (LESS } (literal-2 }

{ EQUAL )

CLASS CONDITION:

identifier [NOT] (NUMERIC 1

(ALPHABETIC)

DESCRIPTION:

It is not valid to compare two literals. The class

condition NUMERIC will allow for a sign if the

identifier is signed numeric.

EXAMPLES:

A NOT LESS 10.

LINE GREATER "C".

NUMB1 NOT NUMERIC.

82

Page 170: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 171: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

Subscripting

ELEMENT

:

Subscripting

FORMAT:

data-name (subscript)

DESCRIPTION:

Any item defined with an OCCURS may by referenced

by a subscript. The subscript may be a literal

integer, or it may be a data item that has been

specified as an integer. If the subscript is signed,

the sign must be positive at the time of its use.

EXAMPLES

:

A(10)

ITEM (SUB)

83

Page 172: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 173: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

III. COMPILER PARAMETERS

There are four compiler parameters which are

controlled by entries on the first line of the program.

A parameter consists of a dollar sign followed by a letter.

$L — list the input code on the screen as the program

is compiled. Default is on. Error messages will be

difficult to understand with this parameter turned off,

but it may be desirable when used witha slow output device.

$S — sequence numbers are in the first six positions

of each record. Default is off.

$P — list productions as they occur. Default is off.

$T — list tokens from the scanner. Default is off.

84

Page 174: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 175: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

IV. RUN TIME CONVENTIONS

This section explains how to compile and execute

MICRO-COBOL source programs. The compiler expects to see

a file with a type of CBL as the input file. In general,

the input is free form. If the input includes line numbers

then the compiler must be notified by setting the appro-

priate parameter. The compiler is started by typing

COBOL <file-name>. Where the file name is the system

name of the input file. There is no interaction required

to start the second part of the compiler. The output file

will have the same file name as the input file, and will

be given a file type of CIN. Any previous copies of the

file will be erased.

The interpreter is started by typing EXEC < file-name>

The first program is a loader, and it will display "LOAD

FINISHED" to indicate successful completion. The run-time

package will be brought in by the build program, and

execution should continue without interruption.

35

Page 176: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 177: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

V. FILE INTERACTIONS WITH CP/M

The file structure that is expected by the program

imposes some restrictions on the system. References 3 and

4 contain detailed information on the facilities of CP/M,

and should be consulted for details. The information that

has been included in this section is intended to explain

where limitations exist and how the program interacts with

the system.

All files in CP/M are on a random access device, and

there is no way for the system to distinguish sequential

files from files created in a random mode. This means that

the various types of reads and writes are all valid to any

file that has fixed length records. The restrictions of

the ASSIGN statement do prevent a file from being open for

both random and sequential actions during one program.

Each logical record is terminated by a carriage return

and a line feed. In the case of variable length records,

this is the only end mark that exists. This convention was

adopted to allow the various programs which are used in

CP/M to work with the files. Files created by the editor,

for example, will generally be variable length files. This

convention does remove the capability of reading variable

length files in a random mode.

All of the physical records are assumed to be 128

bytes in length, and the program supplies buffer space for

36

Page 178: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 179: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

records in addition to the logical records. Logical

records may be of any desired length.

37

Page 180: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 181: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

VI. ERROR MESSAGES

A. COMPILER FATAL MESSAGES

BR Bad read -- disk error, no corrective action can

be taken in the program.

CL Close error -- unable to close the output file.

MA Make error — could not create the output file.

MO Memory overflow -- the code and constants generated

will not fit in the alloted memory space.

OP Open error — can not open the input file, or no

such file present.

ST Symbol table overflow — symbol table is too large

for the allocated space.

WR Write error — disk error, could not write a code

record to the disk.

B. COMPILER WARNINGS

EL Extra levels — only 10 levels are allowed.

FT File type — the data element used in a read or

write statement is not a file name.

IA Invalid access — the specified options are not an

allowable combination.

38

Page 182: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 183: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ID Identifier stack overflow -- more than 20 items in

a GO TO — DEPENDING statement.

IS Invalid subscript -- an item was subscripted but

it was not defined by an OCCURS.

IT Invalid type -- the field types do not match for

this statement.

LE Literal error -- a literal value was assigned to an

item that is part of a group item previously assigned

a value.

NF Mo file assigned -- there was no SELECT clause for

this file.

NI Not implemented — a production was used that is

not implemented.

NN Non-numeric — an invalid character was found in a

numeric string.

NP No production — no production exists for the

current parser configuration; error recovery will

automatically occur.

NV Numeric value — a numeric value was assigned to a

non-numeric item.

PC Picture clause — an invalid character or set of

characters exists in the picture clause.

39

Page 184: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 185: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

PF Paragraph first — a section header was produced

after a paragraph header, which is not in a section.

Rl Redefine nesting — a redefinition was made for an

item which is part of a redefined item.

R2 Redefine length — the length of the redefinition

item was greater than the item that it redefined.

SE Scanner error -- the scanner was unable to read an

identifier due to an invalid character.

SG Sign error -- either a sign was expected and not

found, or a sign was present when not valid.

SL Significance loss — the number assigned as a value

is larger than the field defined.

TE Type error — the type of a subscript index is not

integer numeric.

VE Value error — a value statement was assigned to an

item in the file section.

C. INTERPRETER FATAL ERRORS

CL Close error -- the system was unable to close an

output file.

ME Make error - the system was unable to make an

input file on the disk.

90

Page 186: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 187: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

NF No file — an input file could not be opened.

WI Write to input -- a write was attempted to an

input file.

D. INTERPRETER WARNING MESSAGES

EM End mark — a record that was read did not have a

carriage return or a line feed in the expected

location.

GD Go to depending -- the value of the depending

indicator was greater than the number of available

branch addresses.

IC Invalid character — an invalid character was loaded

into an output field during an edited move. For

example, a numeric character into an alphabetic-only

field.

SI Sign invalid -- the sign is not a "+" or a "-".

Ujfl.

91

Page 188: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 189: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

LIST OF REFERENCES

1. Mylet, P. R. MICRO-COBOL a subset of Navy StandardHYPO-COBOL for Micro-computers, Master's Thesis; NavalPostgraduate School, September 1978.

2. Craig, A. S. MICRO-COBOL an implementation of NavyStandard HYPO-COBOL for microprocessor-based computersystems, Master's Thesis, Naval Postgraduate School,March 1977.

3. Digital Research, An Introduction to CP/M Features andFacilities, 1976.

4. Digital Research, CP/M Interface Guide, 1976.

5. Intel Corporation, 8008 and 8080 PL/M ProgrammingManual, 1975.

6. Intel Corporation, 8080 Simulator Software Package,1974.

7. Software Development Division, ADPE Selection Office,Department of the Navy, HYPO-COBOL, April 1975.

9 2

Page 190: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 191: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

APPENDIX B

MICRO-COBOL FILE CREATION

The MICRO-COBOL compiler and interpreter source files

currently exist in PLM80 and are edited and compiled under

ISIS on the INTEL MDS System. This is a description of the

procedure used to create the executable files required to

compile and interpret MICRO-COBOL programs. The MICRO-COBOL

compiler and interpreter run under CP/M by executing the

following four object code files.

1. COBOL.COM

2. PART2.COM

3. EXEC.COM

4. INTERP.COM

These four files are created from the following six

PLM80 source programs.

1. PARTI. PLM

2

.

PART2 . PLM

3. BUILD. PLM

4. INTERP.PLM

5. INTRDR.PLM

6. READER. PLM

The procedure used to create the four object files

involves compiling, linking, and locating each of the six

source files under ISIS. The DDT program is then used under

CP/M to construct the executable files. Each of the

93

Page 192: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 193: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

following steps describe the action to be taken and, where

appropriate, the command string to be entered into the

computer.

1. An ISIS system diskette containing the PLM80 compiler

is placed into drive A and a non-system diskette containing

the source programs is placed into drive B.

2. Compile the PLM source file under ISIS.

PLM80 :Fl:<filename>.PLM DEBUG

DEBUG saves the symbol table and line files for later

use during debugging sessions.

3. Link the PLM80 object file.

LINK :Fl:<filename>.OBJ, TRINT.OBJ, PLM80.LIB TO

:F1: <filename> .MOD

4. Locate object file.

LOCATE :Fl:<filename>.MOD CODE(103H)

5. Replace ISIS system diskette in drive A with a CP/M

system diskette and reboot the system.

6. Transfer the located ISIS file from the diskette

in drive B to the CP/M diskette in drive A.

FROMISIS <filename>

7. Convert the ISIS file to CP/M executable form.

OBJCPM <filename>

94

Page 194: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 195: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

At this point the object file is in machine readable

form and will run under CP/M when called properly.

INTERP.COM and PART2.COM are called by EXEC.COM and PART1.COM

and need no further work. EXEC.COM and PART1.C0M need to

be constructed from the remaining four files.

EXEC.COM is created by entering the following commands

under CP/M.

1. DDT BUILD.COM

2. IINTRDR.HEX

3. R1C00

4. A1CB5

5. JMP 5

6. A1CC1

7. JMP 5

8. CONTROL-

C

9. SAVE 2 9 EXEC.COM

PART1.COM is created by entering the following commands

under CP/M.

1. DDT PART1.COM

2. IREADER.HEX

3.In

'

RFBOO

4. A1F90

5. JMP 3100 DP

6. Control-C

7. SAVE 4 4 C0B0L.COM

95

Page 196: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 197: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

MICRO-COBOL programs may now be executed in the following

manner. The source program is named, <filename> . CBL . The

command, "COBOL <filename>", causes the MICRO-COBOL source

program, <filename> . CBL, to be read in from diskette and

compiled. During the compile, the intermediate code file,

<f ilename> . CIN, is written out to diskette as it is generated.

The command, "EXEC <filename>", causes the file,

<filename> . CIN, to be executed.

96

Page 198: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 199: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

APPENDIX C

LIST OF INOPERATIVE CONSTRUCTS

The following is a list of MICRO-COBOL elements that

were not implemented at the beginning of this project. In

most cases code had been written to implement the element

but is was either incomplete or incorrect. The elements

marked with an asterisk still have bugs and need additional

work.

MULTIPLY

<condition>

STOP <literal>

IF

PERFORM <procedure 1> THRU <procedure 2>

PERFORM <procedure> <n> TIMES

PERFORM <procedure> UNTIL <condition>

FILE I/O *

Numeric Edit *

The following HYPO-COBOL elements are part of MICRO-

COBOL only to the extent that they are defined in the

grammar. No code has been written to support them.

USING

CALL

ENTER

<when> ADVANCING <how-many>

97

Page 200: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 201: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

It must be pointed out that this information is based

only on informal testing with very simple programs. MICRO-

COBOL is only now at a stage at which it is appropriate to

conduct exhaustive testing using the HYPO-COBOL Compiler

Validation System.

93

Page 202: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 203: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

APPENDIX D

MICRO-COBOL PARSE TABLE GENERATION

The parse tables for MICRO-COBOL were generated on the

IBM 360 using the LALR(l) parse table generator described

in Reference 11. There are basically two steps involved

in generating the tables. First, a deck of cards containing

the grammar is entered into the computer using the following

JCL:

//GO EXEC PGM= LALR,REGION=2 20K

//STEPLIB DD DSN-F0963.LALR,UNIT=2314,

VOL=SER=LINDA, DISP=SHR

//SYSPRINT DD SYSOUT=A, DCB= (RECFM=FB,

LRECL=133,BLKSIZE=3325)

,

//SPACE=(CYL, (1,1)

)

//NONTERM DD SPACE=(CYL, (1,1) ) , UNIT=SYSDA

//FSMDATA DD SPACE= (CYL, (1,1)) ,UNIT=SYSDA

//PTABLES DD SYSOUT=B,

DCB= ( RECFM=FB , LRECL= 8 , BLKSI ZE= 8 0)

//SYS IN DD *

The output from this run is a listing and deck

containing the tables in XPL compatible format. This deck

is then translated into PLM compatible format using the

following JCL and an XPL program which is available in the

card deck library in the Computer Science Department at the

Naval Postgraduate School.

99

Page 204: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 205: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

//EXEC XCOM

//COMP.SYSIN DD *

//GO.SYSPUNCH DD SYSOUT=B,

DCB= ( RECFM=FB , LRECL=8 , BLKS I ZE= 8 )

//GO.SYSIN DD *

The tables are then transferred to a diskette and edited

into the PLM80 source program using the ISIS COPY and EDIT

features on the INTEL MDS System.

100

Page 206: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 207: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ISIS-II PL.-M-B8 VS. 1 COMPILATION OF MODULE READEROBJECT MODULE PLACED IN Fl READER OBJCOMPILER INVOKED BV PLIliO PI READER PLM

I PAGELENGTH..9a,1 READER

.

DO;

/- OOSOL COMPILER - PART 2 READER ••

.-» THIS PROGRAM IS 1.GADED III KITH THE PART 1 PROGRAMAND IS CALLED UnEN PART 1 IS FINISHED THIS PROGRAMOPENS THE PART2. COM FILE THAT CONTAINS THE CODE FORPART 2 OF THE COMPILER- AND READS IT INTO CORE ATTHE END OP THE READ OPERATION. CONTROL IS PASSED TOTHE SECOND PART PROGRAM *.-

/* 3100H LOAD POINT «/

2 1 DECLARE

START LITERALLY 130H . /» STARTING LOCATION FOR PASS 2 •/

ADR ADDRESS INIT1HLCSTBRT3,FC3 C3S5 evTE initials. PASS2 com . 3. 3. a. 3. 3. 3. a. a, a. a. a. a. 3. a. a. a. a. a. a. a. 0;I ADDRESS.

2 1 MON1 PROCEDURES, A; EXTERNAL*4 2 DECLARE F SVTE. A ADDRESS.I 2 END MONi,

6 1 M0N2 PROCEDURECF, flJBVTE EXTERNAL,7 2 DECLARE F BVTE. ft ADDRESS.3 2 END M0N2j

9 1 BOOT PROCEDURE EXTERNAL-13 2 END,

11 1 OPEN PROCEDURE iFCBi BVTE.12 2 DECLARE FOB ADDRESS.13 2 RETURN M0N2 CIS. FCBj14 2 END.

II 1- READ PROCEDURE SADDR.. BVTE.Li 2 DECLARE ADDR ADDRESS.17 2 CALL MON1 C26. ADDRy. K* SET DMA ADDRESS */13 2 RETURN N0N2 ..23. FCB>. ,- READ, AND RETURN ERROR CODE -/

19 2 END,

23 1 ERROR PROCEDURES CODE i.

21 2 DECLARE CODE ADDRESS.22 2 CALL MOHl'.i, . HIG+KCOOE.' >>,

22. 2 CALL MOH1C2. •; LOU >. CODE )) >i

24 2 CALL TIMEC13),21 2 CALL BOOT.25 2 END ERROR;27 1 CALL MON1 --2S. 3130H*.

.-•» OPEN PASS2- COM */2E 1 IP OPEN<. FC6>"253 THEN CALL ERROR <-OS'5i

/» READ IN FILE */

38 1 I - 0103H, .-- INITIAL ADDRESS *'

II 1 DO WHILE READ^l:' » 3. .-« READ 1 SECTOR «V22 2 I » I » 33cOH, ,-» BUMP DMA ADDRESS -/

C3 2 END.

}4 I CALL MONI <2<S. 3GB0H,. .-* RESET DMA ADDRESS15 1 CALL ADR.

ZS 1 END.

MODULE INFORMATION

CODE AREA SI2E - 009DH 1S70vARIA&LE AREA SIZE = 002BH 42DMAXIMUM STACK SIZE = 3304H 4D€7 LINES READ3 PROGRAM ERROR <

S

END OP PL/TI-SS COMPILATION

101

Page 208: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 209: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ISIS-II PL. M-36 •2.1 COMPILATION 3? MODULE INTr.OR^oJcCT MODULE PLACED IN -1 INTRCR OBJCOMPILES INVOKED 3V PLN80 Fl, [NTRDR PLM

fPAGELoNGTHC JO;INTROR .-« NAME OF MODULE

DO.

.'• COSGL COMPILER - INTERP =EADEP -•

'* THIS PROGRAM 13 CALwED 8V THE EUILD RRCuAAM AFTERCINTERP COM HAS SEEN OPENED. AND READS THE CODE INTO HEMORV

LOAD POINT

START L1TERAL..V ' 100H . - STARTING LOCATION FOR PASS I

INTERP ADDRESS INITIAL'.STARTj.I AG0RE33 INITIAL >OOiOH,.

S 1 MONA PROCEDURE-:?, A;.L Z DECLARE F 3VTE. A ADDRESS.3 2 L. 00 TO I— ' « PATCH TO -D "JMP 8003" "'•3 2 END MONA,

7 l M0N6 PROCEDURE':?, A>SVTEj3 2 DECLARE P 3VTE. A ADDRESS.} 2 L.OO TO L- .-'" PATCH TO -> "JMP 600S" "

ia 2 RETURN 0; / - 2AP -;• "NO-OP" »/

li 2 ENO M0N6.

12 1 DO UHILE I.

22 2 CALL NOMA :2a. ' I "I-eO^eM I i. /- SET DMA ADDRESS14 2 IF nONS '.20. ICH,' O then15 2 CALL INTERP.

END.END.

VODULE INFORMATION

CODE AREA SIZE » -J0-4TH no.ARIA&LE AREA SIZE » OOOAA 100MAXIMUM STACK SIZE » -J002H 2DCo LINES READa PROGRAM ERROR'. 3;

END OF PL. M-BO COMPILATION

102

Page 210: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 211: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ISIS-II PL/M-38 71 i COMPILATION Or MODULE BUILDOBJECT MODULE PLACED I M Fl BUILD OBJCONP I LEF I NVOKED SV PLI ISO Fl . 6U I LD FLM

IFAGEL£NOTH',.-0:-

BUILDDC..'* NORMALLY ORG

.'* THIS PPGGRAM TAKES THE CODE OUTPUT FROM THE COBOL COMPILESAND BUILDS THE ENVIRONMENT FOP THE COEGL INTERPRETER »•

I DECLARE

LIT LITERALLY LITERALLY -

,

BOOT LIT a-.6C/0S LIT 3

'

TRUE LIT 'i'.FALSE LIT •a',

FOREVER LIT •UHILE TRUE'.FCB ADDRE SS INITIAL ^JCH).FCBiBVTE BASED FCB BVTE.FfEiBVTEJA BASED FCB 12.' BVTE.I bvte.ADDR ADDRESS INITIAL '.iuflH^.

CHF1R BASED ADDS BVTE.BUFFSEND LIT luOH .

INTEFPSFCS C53) BVTE INITIALS. CINTERP COM'.CGDEiNOTlSET EVTE INITIAL 'TRUE:'.READEP5LGCAT tOH LIT ICoWH .

INTERPtADDRESI ADDRESS INITIAL HOOCH;.INTERP*CONT£ IT BASED INTERPfADDRESS ADDRESS.I »BVTE BASED INTERPiADDRESS C2> BVTE.CODEiCTR ADDRESS.c*evTS BASED CGDE*CTR BVTE.BASE ADDRESS.BJADDR BASED BASE ADDRESS.B-tBVTE BASED BASE <*l BVTE.

1 MOM PROCEDURE <F A j EXTERNAL,2 DECLARE F BVTE, A ADDRES 5.

2 END MOH1,

o. 0. 3. o >.

H0N2 PROCEDURE ''F.fl> BVTE EXTERNAL.DECLARE F BVTE, fl ADDRESS;

END NGN2,

PP I f IT*CHAR PROCEDURE-. CHAR >

DECLARE CHAR EVTE-.

CALL MONKS. CHAR •.

END PPINTfCHAP,

11 1 CPLF PROCEDURE.14 1 CALL PRINTiCHAR'.ll,.IS z CALL PRINTfCHARClO.'-IS i END CRLF.

17 1 PRINT PROCEDURE ^H.'.

IS 1 DECLARE A ADDRESS.is 2 CALL CRLF.10 2 CALL M0M1' ?. A ..

11 2 END PRINT.

OPEN" PROCEDURE 'A-1 3VTE,C'ECl»ARE A ADDPESS-RETURN MOMS' 13- "-'*

END OPEMj

REBOOT PROCEDURE-ADDR =007. CALL ADOSEND REBOOT,

HOVE PROCEDURE' "ROM, DEST. COUNT >,

DECLARE CFROMi C'ESTi COUNT > ADDRESS,-F BASED PROM- D EASED DEST i BVTE;

DO WHILE- COUNT -COUNT-l.- :: OFFFFn,D-P-PP0M*FP0M»1,

103

Page 212: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 213: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

END.END MOVEj

3339

GETJCHAR FROCEDURE BYTE.IF (SOOR -ADDR » 1J>«BUFF*EN0 THEN

41 I IF M0M2C2B; FCE.'OO THEN42 3 DO,43 4 CALL PRINT' ( END OF INPUT s * ;

44 4 CFiLL REBOOT.4; 4 END.43 3 ADDR-30H;47 z END;46 2 RETURN CHAR;49 2 El© GETJCHSRj

50 1 NEXTICHAR PROCEDURE.SI 2 CHAR GETJCHAR.

EMO NEXTJCHftRj

'3 1 STORE. PROCEDURE t COUNT;..54 2 DECLARE COUNT BYTE.51 2 IF CODE*NOT*SET THEN56 2 DO;57 3 CALL PRINTC .-'CODE ERROR!58 2 CALL NEXTtCHAR.59 7 RETURN;60 3 END.61 z DO I«l TO COUNT.62 3 CS8VTE-CHAR,63 2 CALL NEXT*CHAR,64 3 CODE*CTR"C00E*CTR*li6Z 2 END.6© 2 END STORE,

67 1 BACKJSTUFF PROCEDURE.63 2 DECLARE 1 HOLD". STUFF > ADDRESS.69 2 BASE- HOLD;70 2 DO 1-3 TO 3.

71 3 B*BVTE< I J-GETJCHAR,72 3 END;7T, 2 DO FOREVER.74 3 BASE-HOLD.75 2 HOLD-&*ROOR;76 3 SJADOR-STUFF.77 3 IF HOLD-e THEN76 2 DO.79 4 CALL NEXTtCHRlR;ea 4 RETURN;si 4 END.32 2 END;33 2 END BACK.ISTUFF,

34 1 STARTtCODE PROCEDURE;35 2 '200E*NCT*SET»rALSE.36 2 I JBVTE < 3 ; -GET*CHAfi.S7 2 HBVTE i 1 1 -GETJCHAR,S3 2 COOEiCTR-INTERPiCOMTENT.39 2 CALL NEXTfCHAR.90 2 END STARTXCOOE,

OOiDEPENDINO PROCEDURE.CALL STORED! >.

CALL STORE : SAL; CHAR. 1; - 4;.

END GO*0EPEND I NQ.

?5 1 INITIALIZE PROCEDURE.96 2 DECLARE '. COUNT. WHERE. HGujnANY97 2 BASE- WHERE.93 2 DO I"« TO 3.

99 Z BJBVTE-. I >-GET*CHAR.100 3 END.101 2 BASE-WHERE - 1;

102 2 DO COUNT - 1 TO HOUSPIflNV;103 3 BfBVTE-; COUNT .-GET iCHAR,104 3 END.105 2 CALL nextjchar.106 2 SMC INITIALIZE.

104

Page 214: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 215: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

L87103

189 2

na z112 z

11

J

z

lis z.

113 3126 3

122 312-1 3126 Z

128 z

138 Z

122 Z

134 2

135 Z

13a s

13? 3140 4

141 4

142 4

141 3

14J 3

14= 4148 4

149 4

BUILD PROCEDURE,DECLAREF2 LIT 9'.

n LIT 9 ,

u LIT 21'.PS LIT 24'.FS LIT '32".

FT LIT 29'.F9 LIT -49',

FIB LIT '54'.

Fll LIT 50'.F13 LIT 61',>3DP LIT 6* '

INT LIT S3'.BST LIT 64 ,

TER LIT ' 65 '

.

;co .-IT 66 .

00 FOREVER;IF CHfiR < F£ THEN CALL STORE ^l;.ELSE IF CHfiR ; F3 THEN CALL STORE':!).ELSE IF CHfiR C F4 THEN CALL STORE: 3...

ELSE IF CHAR •: F3 THEN CALL 5T0REv4>.ELSE IF CHAR : F6 THEN CALL STORE':".'.

ELSE IF CHfiR < F7 THEN CALL STORE'' 6>.

ELSE IF CHfiR ." F9 THEN CALL STOREw).ELSE IF CHfiR < F10 THEN CALL STORE-:?'.ELSE IF CHfiR -; Fl_l THEN CALL STORE'.IO.'.

ELSE IF CHfiR < F13 THEN CALL STORE < 11);ELSE IF CHfiR < SDP THEN CALL STORE. 13),ELSE IF CHfiR • GDP THEN CALL GO.IOEPEND I NGELSE IF CHfiR - BST THEN CALL BAO-JSTUFF,ELSE IF CHfiR - INT THEN CALL INITIALIZE-ELSE IF CHfiR - TER THENDO.

CALL PRINTS ^'LOfiO FINISHED*";;;RETURN;

END.ELSE IF CHfiR - SCD THEN CALL STARTJCOOE,ELSE DO.

IF CHfiR © OFFH THEN CALL PRINTC. < LCALL NEXTiCHAR;

END.END

END BUILD.

LOAD ERROR*' >>

/- PROGRAM EXECUTION STARTS HERE

112 1

113 1

1S4 1

115 1

116 2

117 2

15i 2159 1

160 1

161 1162 1

163 1

164 1165 2166 2

167 2

16o 1

16? 1

171 1

FCBSBVTE*A<32.., FCB*6VTE»0.CALL MOVE*. ( 'CIN', 0. 0. a. 0). FCB 9,7);IF CPENCFCB/-2SS THENDO.

CALL PRINT.. ^ 'FILE NOT FOUND i'tt.CfiLL REBOOT.

END.CALL ne>:t*char,CALL BUILD.CALL HOVEC INTERPJFCB. FCB. 33/.FCB*BVTE*A-:32> a.

IF 0PEN<FC6>"255 THENDO.

CALL PRINT.: ;• INTERPRETER NOT FOUNDCALL REBOOT.

END.CALL tlOVE'.READERJLGCATION. B6H. S8H;.ADDR = SaH, CALL ADOR, /- BRANCH TO 30HEND.

nODULE INFORMATION

CODE AREA SICE - 0402H 1026DVARIABLE AREA SICE » O043H 67Dmaximum stack size * aai2H 1SD237 LINES READ

PROGRAM ERROR' S)

END OF PL.'M-%a COMPILATION

105

Page 216: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 217: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ISIS—II PL/M-88 V3. 1 COMPILATION OP MODULE PfiRTlOBJECT MODULE PLACED IN Fl PfiRTl. OBJCOMPILER INVOKED BV PLII30 Fl PARTI PLM

«PA0ELENGTHi30.'PflRTlDO..-'* NORMALLY ORG ED AT 160H

/» COBOL COMPILER - PART 1

GLOBAL DECLARATIONS AND LITERALS

DECLARE LIT LITERALLY 'LITERALLY',DECLARE

MAX*MEMGRY LIT 2186H',INITIALfPOS LIT "2C66H"

.

RDRiLENGTH LIT 253',PASS1SLEH LIT '46'.

CR LIT '13'.

LF LIT IB'.QUOTE LIT '22H-,POUND LIT '23H'.TRUE LIT '1'.

FALSE LIT a-

.

FOREVER LIT WHILE TPUt

TOP OF USEABLE MEMORY

DECLARE MAXRNC LITERALLY 164'. /» MAX READ COUNT «/

MAXLNO LITERALLY '123'. /* MAX LOOK COUNT */MAXPNO LITERALLY 143'. /» MAX PUSH COUNT -rMAXSNO LITERALLY '234'. /» MAX STATE COUNT «/STARTS LITERALLY '!'./- START STATE ••

DECLARE READ1 C»5 BYTEDATA<0. 37, 48. 36, 32. 3. 25. 39, 2- IS. IT. 22- 23. 33. 38. 11. 32- 32. 39. 33. 34, 44. 9, IS. 32- 37. 6, 33. 3. 14, 13. 18. 20. 32- 2S. 49. 32. 1. 42, 33, 36, 43. 1

, 1- 1- 1- 1- 1- 1. 1- 1- ia, 1. 39, 1, 1. X. 3S, 46, 49, 36. 39, 1- 1- 33. 23. 24, 33, 32, 41, 33. 45. 1. 7, 30, 1- 32-J_ 32, 32. 43, 1- 32- 1. 32. 1- 32- 47. 37. 4, 26. 32- 34, 46. 1. 1, 32, 3. 12. 13. 21- 22. 27. t- BO. 1- 23. 24, 33, 30, SIjj

DECLARE LOOKK»J BYTEDATAkfl, 8. 0. 23, 6. 9, 19, fl, 42, 8, 42. fl, 1- 3, 32- 6, 41, 8, 33, 6. 1- 6. 47, a- 4, a. 34. a, 4B, a, 33, ••». bb. a. 1, a. 32- a, 1, a, 1, a. u. 0. bb. 0. 7. a. 32- a. 32. a. 32- a>i

DECLARE APPLYK-) BYTEDATAvB. 0. a. a. a. a. 9. ia. 12. 14. 19. a. a. a. a. 9. a. xei. a. a. lee. a. a. e. a. 0. 0. 97. a. 27. a. a- a. 89, a, 91. 92- a, 0, 91- 92- a. a, a, a, 13- it- a, 102. 1B3, 104. 6. a, a, a, a, 93, a, a. 34, a, a, 23, ie. 3s. 33. a. 21- 40. 32. 35. 37, 53. 34, B)i

DECLARE REf»2C*J BYTEDATAO, 83, 37, 84, 134, 28, 37, 87, 21- 3B, 31- 33, 39, 81- 88. 27, 234, 213, 31, 43. 1B8, 109, £23, 224, 233, 43, 218, 117. 22, 230. 223. 232- 231- 228. 173. 172, 183. 3. 228. 47, 138. 193. 7, B. 11. 13. 13, 2, 3, 103, 14. 133. 4. 30, 20, 12- IB. 43, 171, 170, 44. 49, 19, 16, 48, 33, 38, 83. 8B. 33. 42. 148. 18. 23. 38. 108. 133. 143. 133. 133. 33. 130. 133, 132, 133, 137. 133. 38. 193. 23. 208. 234. 82. 32- 2B8. IBB. 234, 24. 2B. 107. 32, 34, 38, 17, 83, 184, 33, 38, 83, 46. 39J>

DECLARE L00K2':». BYTEDATA<6. 3. 130, 8. 131, 29, 23, 132- 41, 133, 34, 134. 133. 83, 71, 135. 72- 137. 73. 13S. 139. 3B. 34. 14B, 38. 196. 33. 141. 69. 142- 134. 134. 134, 31. 183. 32. 93. 137, 211, 33, 143, 98, 97, 176, 99, 144, 143. 101. 162. 206. 133. 202. 104. 183;.

DECLARE APPLY2k«) 3YTEDATA<6. 0. 77. Ill, 112- 147, 73. 114, 31- 32- S3. 73. 76. 117, 73, 136, 126. 183- 182- 166. 166. 163. 187. 113. 163. 166. 124. 179. 173. 34. 121. 74. 123. 12B. 119. 137. 137. 136. 98. 132. 192. 191. 194, 113, 183, 123, 123, 127, 203- 263, 203. 264. 113. 123. 36. 122. 214, 213, 221. 213. 216. 222. 133. 35, 226. 116. 87, 116. 70. 174, 263, 237, 182, 132, 18131

DECLARE INDEXli*. BYTEDATA<6. 1, 2, 3, 4, 3, 6, 7, 8. 4, 4. 24, 4, 24. 4. 13. 14. 24. 163. 4. 13. 16. 16. 24, 17, 16. 13. 16. 20. 22. 24, 23, 26, 23, 29. 34, 36. 37. 24, 24. 16. 38. 33. 46, 42, 43. 44. 43. 46- 47. 43. 43. 16. 36. 38. 31, 16. 32- 33. 34, 33. 36. 37, 38. 66- 61. 62. 63. 84. 3. 63, 6&. 69. 70. 71- 72- 73, 74, 73, 77, 73, 31- 33, 33, 37, 33, 39, 96, 92. 93. 94. 3, 3, 16. 93. 97. 97, IS, 103, 104. 163. 163, 24. 24, 24, 1- 3, 3, 8, 16. 12, 14. 16. 13. 20. 22. 24, 26, 25. 36, 34, 36, 38, 40, 42, 44, 46, 48, 36, 32, 133, 143, 223, 227, 227, 198, 131. 133. 203. 139. 216. 161, 173. 112- 201. 177, 1. 2. 3. 3. 4. 4. 3. 3- 6. 6. 12- 13- 14. 14. 13. 13. 16. 16. 17, 19. 13. 20. 20. 26. 22. 22. 23. 23. 24, 24, 23, 23. 26. 26. 27. 23. 23. 11, 32. 32. 33. 23. 33. 38. 38. 23. 33. 33. 39, 33. 35, 35, 4242- 43, 43- 44. 44, 43. 43, 48- 32, 32, 33, 53, 34, 54, 33. 33. 36. 56. 36. 36. 36. 36

. 36. 36, 33, 38. 38, 35, 39, 61, 61, 61. 61. 61. 62- 87''.

DECLARE INDEX2'. », BYTEDATA, 0, 1, 1, 1- 1- 1, 1. 1. 3. 1, 1. 1. 1. 1. 1- 1. 1- 1, 1, 1, 1, L. 1. 1. 1, 1

106

Page 218: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 219: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

i, 1/ 1. 1, V 1- 1. 1. 1. 1. 1. 1. L. 1- 1, 1" "- 1. 1. i, 2, 1, 1, 1, S. S. 12, 2. 2. 4, 2, 2- 2, 2. 2- 2, 2, 2

2. SO. 34. i£, 3?, 3©. 33. 101- 2. 3* 2. 6* 2. 6, 3.

- v 4.< -. v. i. j.* u i 0. 0> 6* 0' 1. 8- 2. 0, 0, 1* 2* 9. 1* 3. 3- 0* a. 1

. 4. 0. 0. 0« 1- 2- If 2- 2- 2- Of 2, 2, Of 3f Of Of 1- 4- Of 0. If a. Of e. e. L L L L 2 2 L 1, j.. a. o. o. o. a. o. o. o. o, o. a. a).

, 1. If 2. 2. 1- If 2f 1. J. 2f If 1- I- 1, 1- 1- 1. 2.

. i. i, 1, 2, i. if if i, i. i. 3. i. i- if I, if i. l. ;

. 2. 6. 6. i. i. if 4, 2. if i. if 2, 2- i. 2. 2, 2- 2, 2. 2f 2. 2f .

. 2f 2. I. 6. 23. 4i, 14, 53. 71. 7

- a. i, 7. 3. i- a. 6. o. a. i. :. o. i, 1-

.

/• END OF TABLES /DECLARE

.-'» JOINT DECLARATIONSTHESE ITEMS ARE DECLARED TOGETHER IN THIS SECTIONIN ORDER TO FACILITATE THEIR BEING SAVED FORTHE SECOND FART OF THE COMPILER

OUTPUTIFCB <c:> BVTE INITIAL'.0. -

DEBUGGING BVTE INITIAL < FALSE)PRINT*PRGD BVTE INITIAL'. FALSE/.PRINTiTOKEN BVTE IHITIfiH FALSE).LI ST* INPUT BVTE INITIAL CTRUE5.SEQSNUM BVTE INITIAL '.FALSE)NEXTSSVM ADDRESS.POINTER ADDRESS INITIAL ;ieoH),NEXT*AVAILABL£ ADDRESS INITIAL >.20a2H)MAX*INT*NEM ADDRESS INITIAL <3208H)FILEJSECJEND BVTE INITIAL ( FALSE >

FREEiSTGRAGE ADDRESS INITIAL •:2500H..

cin'. a. o. a. a;.

.'» I BUFFERS AND GLOBALS -/INiADDR ADDRESS INITIAL -3CH).INPUTiFCB BASED INADDR C53J BVTE,OUTPUTfPTR ADDRESS.0UTPUTS6UFF ^iiS) BVTE-OUTPUT-fEND ADDRESS.OUTPUTICHAR BASED OUTPUTIPTR BVTE,

nONl PROCEDURE •. F. A ) EXTERNAL.DECLARE A ADDRESS. F BVTE-

END MONif

i7 1

IS 213 2

20 1

21 2

22 2

:; ,__

24 225 2

2€ 2

27 i

2S 22? 233 *

21 1

22 2

23 2

34 2

23 1

26 237 23S 2

33 240 2

M0N2. PROCEDURE '.-F. A) BVTE EXTERNAL-DECLARE F BVTE- A ADDRESS;

END M0N2.

BOOT: PROCEDURE EXTERNALfDECLARE A ADDRESS.END BOOT-

PR I NTCHAR PROCEDURE <CHAR).DECLARE CHAR BVTE.CALL M0N1 < 2. CHAR ) .

END PRIHTCHAR,

CRLF . PROCEDURE,CALL PRINTCHARCCR);CALL PRINTCHARCLF);

END CRLF.

PRINT PROCEDURE (A).DECLARE A ADDRESS.CALL MONi < 3, A )

.

END PRINT.

PRINTJERROR PROCEDURE iCODE).DECLARE CODE ADDRESS.CALL CRLF)CALL PP. I HTCHAR < H I GH « CODE ) -

.

CALL PRINTCHARfXOUKCODE.'.'.END PRINTJERROR.

FATALJERROR PROCEDURE': REASON/DECLARE REASON ADDRESS.CALL PRINTJERROP'-REASGN

,

CALL TIME'.IO-.CALL BOOT.

END FATALiERROR.

474S10

OPEN PROCEDURE,IF MONi CIS- IN*ADDR)«25

END OPEN,THEN CALL FATALSERROR^ "OP'

MORE* INPUT PROCEDURE BVTE..-'« READS THE INPUT FILE AND RETURNS TRUE IF A RECORD

NAS -EAD PALJE IMPLIEf END OF r ILE •

107

Page 220: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 221: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

58 Z

59 2

61 2

DECLARE DCNT BVTE,IF <DCNT -MCN2^20. INRUTJFC8 > »1 THEN CALL FATAL.(ERROR>: 'BR ' ,

RETURN NOT < DCNT) J

END MORS* INPUT.

MAKE PROCEDURE,.-- DELETES ANY EXISTING COPY OP THE OUTPUT FILE

HUD CREATES A NEW COPY-,-CALL MONK 13. OUTPUTJFCE.'.IF M0N2C22, OUTRUTJFCEj-255 THEN CALL FATBLJERRORC MB '

>

.

END MAKE,

62 i URITEtuUTPUT PROCEDURE./* URITES OUT ft BUFFER -/

63 2 CBLL MONK 26, OUTPUTJB(JFF'.', / - SET DMB *•64 2 IF M0N2C21, 0UTPUTJFC95O8 THEN CALL FATALJERRGRi WR- 1.

65 2 CBLL MONK 26. BOH;. /* RESET DMA *•67 2 END URITEiOUTPUT.

63 1 MOVE PROCEDURE •.SOURCE, DESTINATION. COUNT;,.,* MOVES FOR THE NUMBER OF BYTES SPECIFIED BV COUNT ••

6? 2 DECLARE < SOURCE, DESTINATION/ ADDRESS.vSJBVTE BASED SOURCE. D16VTE BASED DESTINATION. COUNT) BVTE.

70 2 DO UHILE '.COUNT -COUNT - 1, O 255.71 3 D*8VTE"SJBVTE,72 3 SOURCE-SOURCE •Jj73 3 DESTINATION » DESTINATION » 1,

74 2 END,75 2 END MOVE.

76 1 FILL PROCEDURE CBODR, CHAR. COUNT.'./- MOVES CHAR INTO ADDR FOR COUNT BYTES -/

77 2 DECLARE ADDR ADDRESS.( CHAR. COUNT. DEST BASED ADDR.' BYTE.DO UHILE < COUNT -COUNT -l.'OiSS.

DEST -CHAR.ADDR-ADDR U

END.END FILL,

rs 2

73 3so 3

31 3

32 2

/» - - - . . SCANNER LITS - » - - ••DECLARE

LITERAL LIT '15'.INPUTJSTR LIT '32-.PERIOD LIT '1',INVALID LIT -6'.

/» .... SCANNER TB8LES • » • » ••DECLARE TOKENJTABLE • - 1 BYTE DATA

.-'* CONTAINS THE TOKEN NUMBER ONE LESS THAN THE FIRST RESERVED -iORD

FOR EACH LENGTH OF UORD */:0. 0. 1, 4, 5. 15. 22, 32. 3S. 44, 47, 4S, 51. 55. 56. 57.'.

TABLE <'J BYTE DBTBC -FD . OF ' . ' TO' . 'PIC '. COMP' . 'DATA ' . FILE

'

. LEFT'. -MODE . 'SAME'. 'SIGN'. SYNC. ZERO'. 'BLOCK'. 'LABEL

. QUOTE'. 'RIGHT'. 'SPACE', USAGE'. 'VALUE'. 'ACCESS , ASSIGN'. AUTHOR". FILLER", OCCURS', RANDOM". RECORD'. SELECT. 'DISPLAY ', -LEADING . LINKAGE', OMITTED'. RECORDS'. "SECTION '. DIVISION'. "RELATIVE". SECURITY .'SEPARATE . STANDARD. "TRAILING , DEBUGGING'. PROCEDURE'. REDEFINES. 'PPOGrftM-ID 'SEQUENTIAL". ENVIRONMENT '. " I-0-CONTROL. DATE-WRITTEN". 'FILE-CONTROL .

' INPUT -.OUTPUT . "ORGANIZATION', " CONF I GUPBT ION', I DENT I F I CAT I ON ' . ' OeJECT-COMPUTER

'

'SOURCE-COMPUTER'. WORK ING-STORAGE ' >.

OFFSET C16/ ADDRESS•- NUMBER OF 3VTES TO INDEX INTO THE "ABLE FOR EACH LENGTH --

INITIAL • 0, 0. 0, 6. i. 45. 36. 123. 170. 213. 245, 265,2B7. 335. 348. 362.'.

WGRD#CGUNT '.*/ BYTE DATA/- NUMBER OF WORDS OF EACH SIZE .,'

:a. B. 3. 1. i, 7, 3. 6. 6, 3. 2, 2, 4. 1. 1. 3).

MRXJLEN LIT 16 •

ADDlEMDi-.' BVT F DATA - PROCEDURE ' >,

LOOKED BYTE INITIAL Q>.HOLD BYTE.BUFFERJEND ADDRES.t INITIAL C2.00H>,NEXT BASED POINTER BYTE,IN3UFF i-IT '38H-.CHAR BYTE,ACCUNILENG LIT '50'.

ACCUMiLENfpIl LIT '51. -- - TO ACCUM*LENG

ACCUM • BCCUN*LENSPfl BYTE.PLUS 1 -.-

108

Page 222: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 223: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

DISPLAVC74:. BVTE INITIAL <l»,TOKEN BVTE, ••RETURNSD FROM SCANNER

PROCEDURES USED BV THE SCANNER

3! 1 NEXTiCHRR PROCEDURE BVTE.36 2 IF LOOKED THEN37 2 DO.38 3 lOoked-frlse,S3 3 RETURN CCHAR "HOLD ) J

33 3 END;31 2 IF < POINTER -POINTER » 1J '.—

31 2 DOj33 2 IF NOT MOREflNPUT THEN?4 2 DO,31 4 BUFFERfEND- nEMORV.36 4 POINTER" ADDXEND.37 4 END;33 2 ELSE POINTER-INBUFFj39 3 END.

100 2 RETURN < CHAR ' -NEXT >

;

101 2 END rJEXTICHAR;

103 2

..^4 *

ias t

106 2

138 2

109 2ii a 2

lil 2

112 1

113 2114 2

HI 2

116 2

117 1113 2119 2

12B 2

121 2

122 1

12; 2124 2

121 2

126 2

127 1

12S 2

123 2

133 :

132-

133 2

134 4

131 4

133 4

139 5140 5141 4

143 4

144 4

14^ z>

147 s148 '

no j

111 -

132 :

113 l

154 2

tss 2

BUFFERJEND THEN

GETICHAR PROCEDURE,.-'- THIS PROCEDURE IS CULLED WHEN ft NEU CHAR IS NEEDED UITHOUTTHE DIRECT RETURN OF THE CHARACTER",CHAR»NEXT SCHAR,

END GET*CHAR,

DI3PLAVSLINE PROCEDURE-IF NOT LISTtlNPUT THEN RETURN.OISPLAVCDI3PLAV<:0> * IV • '*';

CRLL PRINT< DISPLAV<1,>.OISPLAVO, - a.

END OISPLAVJLINE.

LOAOJDISPLAV PROCEDURE.IF DISPLAV<ej < 72 THEN

DISPLAV<DI3PLAV>:a.> "0ISPLAVC3) » 1> - CHAR.CALL GETtCHPR,

END LOflDfO I SPLAV;

PUT PROCEDURE.IF ftccuncoi : accunjleng thenftCCUMCACCUfKa.. -ftCCUrKO,-l^-CHflRjCftLL LOAD*DI3PLAV,

END PUT;

ESTJL I HE PROCEDURE,DO UHILE CHAROCR;

CRLL LOADJDI3PLAV,END;

END EATtLINE,

GET*NG*BLA^ . PROCEDURE,DECLARE CH, I.' EYTE,DO FOREVER,

IF CHRR - ' " THEN CALL LOAD*DI SPLAV;ELSEIF CHRR-CR THENDO;

CRLL DISPLAYJLINEjIF SEO*HUM THEN N«S. ELSE N»2,DO I - 1 TO N.

CRLL LCAOiDISPLAV.END.IF CHRR - • THEN CALL EATSLINE,ELSEIF CHRR • ' THEN

DO,IF NOT DEBUGGING THEN CRLL EATfLINE.ELSE CALL LOAD*DISPLAV;

END;END;ELSERETURN;

END; .-- END OF DO FOREVER »•END OETiNO*ELRNK,

3PRCE PROCEDURE BVTE,RETURN CCHAR" -

• OR i CHAR-CR;.ENO SPACE,

DELIMITER PROCEDURE BVTE..-'» CHECKS FOR A PERIOD FOLLOWED BV A SPACE OR C?-s

109

Page 224: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 225: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

157 2

1S9 2

ISO 2

tol 2

162 2163 3164 2

163 3

166 2167 2

166 2

163 1178 2

171 1

171 1

173 2

174 2171 2

176 3177 4

173 4

175 4

130 3131 :

1S2 2

LB3 1

134 I

125 -

136 3137 3

13S 4

198 4

191 3132 2

132 2194 2195 3137 2

134 2

139 2

see 2

202 2

202 2204 2

206 2

206 2

210 2211 2

212 1212 2

214 :

215 2

217 2

213 2219 2

220 2221 2

212 2

222 3

224 2

226 3

227 2

223 1

223 2

220 2231 2

222 3

224 2

226 2227 2

IF CHAR ;: ' THEN RETURN FALSE.hOLL'-NEa'TSCHAR,uGOKED-TRUE,IF SPACE THENDO;

CHBR - '.')

RETURN TRUE.END.CHAR"' '.

RETURN FALSE;END DELIMITER.

ENDJOFJTOKEN PROCEDURE BYTE.RETURN SPACE OR DELIMITER;

END ENDJOFJTOKEN;

GETILITERAL PROCEDURE BVTE,CALL LOAD*OISPLAV;DO FOREVER.

IF CHAR« QUOTE THENDO.

CALL LOADJOISPLAV;RETURN LITERAL.

END.CPU. PUT.

END.END GETJLITERAL.

LOOKJUP PPOCEDURE BVTE.DECLARE POINT ADDRESS.HERE BASED POINT cli BVTE,I BVTE.

MATCH: PROCEDURE BVTE.DECLARE J evTE,DO J-l TO ACCUMO).

IF HERECJ - 13 O ACCUM<j> THEN RETURN FALSE.ENOiRETURN TRUE,

END MATCH;

P0INT-0FFSET<ACCUM<3.'.>» TB8LE;DO 1-1 TO U0RDSC0UNT<ACCUMCa> >.

IF MATCH THEN RETURN I.

POINT - POINT » ACCUM<0.>.END;RETURN FALSE,

END LOOKiUP.

PESERVED*UGRD PROCEDURE BVTE;/" RETURNS THE TOKEN NUM6ER OF A RESERVED WORD IF THE CONTENTS OFTHE ACCUMULATOR IS A RESERVED UORD. OTHERWISE RETURNS ZERO '/DECLARE VALUE BVTE;DECLARE NUMB BVTE.

IF BCCUMCO) > MAXiLSN THEN RETURN 0.

IF CNUMB -TOKEN*TABL£<ACCUM<0>..'«i3 THEN RETURN 0.

IF . VALUE -LOOKiUP > -* THE); RETURN 3.

RETURN CNUMB * VALUE: 1,

END RESERVED*UGRD.

GET*T0KEN PROCEDURE SVTE.ACCUM'SJ-S;CALL GETSNOiSLANK.IF CHAR-iUOTE THEN RETURN GETILITERAL.IF DELIMITER THEN00.

CALL PUT.RETURN PERIOD.

END.DO FOREVER.

CALL PUT;IF ENDiOFJTGKEN THEN RETURN INPUTJSTR.

END; /• OF DO FOREVER •/END GETSTGKEN;

SCANNER PROCEDURE.DECLARE CHECK BVTE,DO FOREVER,

IFvTOKEN »GETiTOKSN., - INPUTJSTR THENIF < CHECK -SESERVEDJWORO -• O THE7I TOKEH-CHECK.

IF TOKEN O THEN RETURN;CALL PRINTJERROR . 'SE

1

.'.

DO WHILE NOT ENDJOFJTOKEN;CALL GETTCHAR,

110

Page 226: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 227: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

22? 4

240 2

241 "

242143 2244 2243 :

246 1

247 2143 224? 2210 ^

211 4

212 4

END.END.

END SCANNER,

PR I NT*ACCUM PROCEDURE,ACCUMilACCUMiu.!>»' »' i

CALL PR I NT < HCCUN<l.o.END PRINTSACCUM;

PRINTfNUMBER PRGCEDUREiNUMB >,

DECLARE '.'NUMB, I, CNT. K> BYTE- J<*JDO I-O TO 1.

CNT-6;DO WHILE NUMB >- <K. "Ji:i)>>

NUMB-NUMB - K,

CHT-CNT 1.

SNOlCALL PRINTCHBR< '0' » CNT).

END;CALL PRINTCHARv 0" * NUMB;.

END PRINT*NUMBER,

BYTE DATAC1O0. 10).

260 2261 2262 2

262 22£4 2

263 2266 2267 2

263 2

16? 2

271 3

272 2273 3

273 3

27? 2

230 2

INITtSCANNER PROCEDURE.DECLARE C0N*CBL C*3 BYTE DATA C'CBL'><• • INITIALIZE POR INPUT - OUTPUT OPERATIONS •/CALL MOVE ' CON.TCEL, IHiAODR - ?. 3).

CALL FILLUNfplDDR 12, 0. 3>;

CALL OPENjCALL MOVE'.'INAODR. OUTPUT «FCB. S>.0UTPUTiFCBO2.> - 0.

OUTPUT-SENO-COUTPUTiPTR . 0UTPUT1BUFF - 1> * 123jCALL MAKEjCALL GET*CHAR, /- PRIME THE SCANNER */DO UHILE CHAR - *",

IP NEXTCHAR 'L THEN LIST* INPUT-NOT LISTJINPUT.ELSE IF CHAR -'S' THEN 5EG*NUM- NOT SEOSNUM.ELSE IF CHAR - -P- THEN PRINT5PR0D - NOT PR1NTJPRGD.ELSE IF CHAR a 'T' THEN PRINTfTOKEN - NOT PRINTfTOKEN.CALL GETiCHAR;CALL GETtNOJBLANK.

END.END INITSSCANNER,

» END OF SCANNER PROCEDURES •/

SYMBOL TABLE DECLARATIONS < •

CURISVM ADDRESS. /•SYMBOL BEING ACCESSEDSYMBOL BASED CUft*SVM .!> BYTE.SVMBGL*ADDR BASED CURJSYM Xj ADDRESS.NE>TT*SVM*ENTP / BASED N£XT#SYM ADDRESS.HASHipTR ADDRESS.DISPLACEMENT LIT 12'.HASH*MASK LIT -IFH-,SSTVPE LIT '2-

.

OCCURS LIT li '.

ADDR2 LIT '4',

PILENGTH LIT '3'.

SSLENGTH LIT 3-.

LEVEL LIT 10'.LOCATION LIT '2'.

RELJID LIT '3 .

START*NAME LIT '11'. /'I LESS-^MA>;iID*LEN LIT

TVOC 1 T TCtfil c

'12'.

DECLARE

1 Th*t L 1 1 bKHLis

SEQUENTIAL LIT -1-,

RANDOM LIT •2".

SEOfRELATIVE LIT '2 ,

VARIABLEfLENG LIT 4 '.

GROUP l;t "5"'.

COMP LIT '2_1'.

YMBOL TABLE ROU TINES * - * */

INITJSVMBOL PROCEDURE.CALL FILL '.FREEfSTOPAGE, O. 120Ji.•'• INITIALIZE HASH TABLE AND FIRST COLLISIONNE'~:TfSVN-FREE*ST0PAGE*12£.;

Ill

Page 228: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 229: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

236 2 NEVTJSVM.SENTRV-6,237 2 END INITJSVMBGL.

233 1 GETipJLENGTH PROCEDURE BYTE.239 2 RETURN SYMBOL <PSLENGTH )j

290 2 END GETiPSLEHGTH.

291 1 SETJADDRESS PROCEDURE vflDDR 5.

292 2 DECLARE ADDS ADDRESS.292 2 SYM6OL*ADDR^LGCATI0N.»=«ADDR;294 2 END SETiADDRESS.

293 1 GETJADDRESS PROCEDURE ADDRESS,29o 2 RETURN SVN6QL*AC'Dftv LOCATION/,297 2 END GETJADDRESS.

GETSTVP6 PROCEDURE BYTE.RETURN SYMBOL SSJTVPE:1

.

END GETJTVPE.

SETiTYPE PROCEDURE < TYPE J.

DECLARE TYPE BYTE.SYMBOL : SiTVPE > "TYPE-

END SETITVPE,

ORtTYPE PROCEDURE C TYPE >.

DECLARE TYPE BYTE.SVM60L>.S*TVPE.'-TYPE OR GETtTYPE.

END ORJTVPE.

GET*LEVEL PROCEDURE BYTE,RETURN SHRvSYMBOLCLEVEL/, 4:>.

END GET1LEVEL,

SETJLEVEL ppocedure <lvl:>.

DECLARE LVL BYTEjSVMBOLvLEVEL/-SHL'.LVL. 4/ OR SYMBOL < LEVEL 1

.

END SETiLEVEL.

GETSDECIMfiL PROCEDURE BYTE.RETURN SYMBOL < LEVEL > AND 3PH;

END GETJDECIMAL.

SETfDECIMAL PROCEDURE <DEC>.DECLARE DEC BVTE;SYMBOLfLEVEL; » DEC Oft SYMBOL v LEVEL;.

END SETtOECIMAL.

SST*S*LENBTH PROCEDURE<HOU*LONG>.DECLARE HOU*LONG ADDRESS.3VMBGL*ADDft<SJLENGTH> HOWSLGNG/

END SETIS1LENGTH.

GETfSfLENGTH PROCEDURE ADDRESS.RETURN SVMBOLJADDR'.'SSLENGTH/.

END QST*SSL£NGTHJ

SETJADDP2 PROCEDURE '.ADDR/,

DECLARE ADDR ADDRESS.SVMBOLiADDR A00R2 > »ADDR;END S£T*ADOR2;

GETJRDDR2 PROCEDURE ADDRESS.RETURN SYMBOL*AD0ft<AD0R2J,

END GETJADDR2;

SETJOCCURS PROCEDURES OCCUR :.

DECLARE OCCUR BYTE,SYMBOL < OCCURS > -OCCUR.

END SETIOCCURS.

GET«JCCURS PROCEDURE BYTE.RETURN SYMBOL S OCCURS J.

END GETJGCCURS.

• » * • * PARSER DECLARATIONS * » » */DECLAREINT LIT "S3'< /» CODE POR INITIALISE »/SCD LIT -oo'. /» CODE POR SET CODE STARTPSTPCKSIZE LIT '20-. /• SIZE OP PARSE STACKS-.-"STATESTACK SPSTRCKSIZE.' BVTE. •'« SAVED STATES »/

VALUE CPSTACK5IZE.' ADDRESS. /» TEMF VALUES »/-ARC '.51/ BYTE. ."»TEMP CHAR STORE •".-

ID*STACK SIS; ADDRESS INITIAL <Oj.tO*ST«CK*PTR BVTE INITIALiflJ.HOLDtLIT . ACCOMJLEN*P»i ' BVTE.

2?& 1

29? 2200 2

381 1

102 2

102 2104 2

201 1

20= 2

207 2

ioe 2

sag 1

113 2Sll 2

212 1212 2214 2

213 2

215 1217 2

213 2

219 1223 2221 2

222 2

222 1224 2223 2

125 2

227 1

223 222? 2

223 1

221 2

222 2222 1

224 1

223 2

226 2

227 1

228 2

22? 2143 2

241 1

242 2342 2

112

Page 230: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 231: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

246 234? 2343 2

349 3

330 3

331 3

352353 I

35-1 1

313 2

33* 2

337 3

333 3

339 3

360 *

361 1262 2

363 2364 2363 2

366 1367 2

368 2369 3

373 3371 *

371 1

373 2374 2

373 2376 237- 2

378 137? 2

330 2

331 2

383 2

334 2

HGLD*SVM ADDRESS,PB-tt>tNO*LITERfiL BYTE INITIAL'.FALSE).PENOING*LIT*ICi ADDRESS.REDEF BVTE INITIAL '[FALSE.'.

REDEF*0NE ADDRESS.REDEFiTUO ADDRESS.TENPIHOLD ADDRESS.TENPSTUO ADDRESS.COMPILING SVTE INITIALv'TRUE).SP SVTE INITIAL C2S3>.PIP evte.nPPi BVTE;NOLOOK SVTE INITIAL<TRUE).<I, J.K) BVTE, y»INDICIES FOR Tl

STATE BVTE INITIALCSTARTS).

. . . . V

BVTEJOUT PROCEDURE <0NE*6VTE)./* THIS PROCEDURE WRITES ONE BVTE OF OUTPUT ONTO THE DISKIF REQUIRED' THE OUTPUT BUFFER IS DUMPED TO THE DISK '/DECLARE ONEiBVTE BVTE,IF ( OUTPUT*PTR OUTPUTiPTR » 1)> OUTPUTJEND THENDOj

CALL URITEXOUTPUT;OUTPUTSPTR" 0UTPUTJ6UFF,

END.0UTPUT*CHAR-GNE*8VTE.

END BVTEtOUT.

STRING-JOUT PROCEDURE '.ADDR. COUNT);DECLARE CAODR, I, COUNT) ADDRESS. <CHAR BASED ADDR) BVTE.DO 1-1 TO COUNT.

CALL BVTE*OUT..CHAR>.ADOR-AODR-H.

END.END STEIHGiGUT;

addrjout procedure : addr 1.

declare addr address.call bytexoutiloukaddr)).call 6vtes0ut>:high<addr) );

end adorsout.

fillx3tring. procedure >xount, char);declare 1 1. count) address. char bvte.DO I»l TO COUNT,

CALL BVTE*OUTiCHAR)»END;

END FILLiSTRING,

strrt*ihitiali:e procedure <addr. cnt);declare <addr. cnt) address,call bvteout<int).CALL ADDRW3UT v ADDR >

CALL ADDRXOUT .: CNT >

,

END STARTIINITIALIZE,

BU I LD*SYMBOL PROCEDURE '. LEN .'

.

DECLARE LEN BVTE. TEMP ADDRESS.TEMP-NEXT tSVMjIF CNBXT*SVM = SVMBOL'.L-EN. -LEU-DISPLACEMENT) •

> MAXJMEMORV THEN CALL FATALXERRGRk ' ST ' ) .

CALL FILL ''TEMP. 0. LEN).END BUILDJSVMBOL.

3S3 1 MATCH PROCEDURE ADDRESS./"• CHECKS AN IDENTIFIER TO SEE IF IT IS IN THE SVMBOLTABLE. IF IT IS PRESENT. CUftiSVM IS SET FOR ACCESSOTHERWISE A NEU ENTRV IS MADE AND THE PRINT NAMEIS ENTERED- ALL NAMES ARE TRUNCATED TO MAXXIO*LEN»-

336 2 DECLARE POINT ADDRESS.COLLISION BASED POINT ADDRESS.<HOLD. I) BVTE.

337 2 IF VARC<8)>MAX*ID«LEHTHEN VARCCQ) - MAXJID*LEN,/• TRUNCATE IF REQUIRED •/

3S9 2 HOLD * 0;

390 2 DO 1-1 TO VHRC<0>; •» CALCULATE HASH CODE •/291 3 HOLD-HOLD * VARCCI);232 3 END.393 2 POINT-FPEEJSTOPAGE » SHL'.^HOLD AND HASHJMASK >, I),294 2 DO FORe-.-'ER,

295 3 IF COLLISIGN-0 THEN396 2 DO;397 4 CUR-ISVM. COLLISION-NEXT*SVM.298 4 CALL BUILD* SVMBOL'. VARCfO; •.

113

Page 232: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 233: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

— LORD PRINT NAME -.-

-QQ 4 3YMBOL ^ PJLENGTH : -VARC <l J

4t>e 4 DO I « 1 TO VfiRCOM;401 z SYMBOL CSTART*NANE * I .' "VfiRC : I > •

402 3 END48; 4 RETURN CUR*SYMl404 4 ENDj

ELSE403 3 DO)406 4 CUft*SVM-COLL I S I ON.407 4 IF '-HOLD -GET*p*L£NGTH?-VARCCGj THEN40S 4 DO.40* 5 1-1.410 S DO UHILE SYMBOL I.STARTJNAME I >- VARC'II.'.

411 6 IF <l -1»1>>H0LD THEN RETURN .CURiSYN "COLLISION413 6 ENDj414 5 END.413 4 END.416 3 POINT-COLLISION.417 3 END.413 2 END MATCH.

41? 1 ALLOCATE PROCEDURE ':BVTES.SREQ; ADDRESS./*> THIS ROUTINE CONTROLS THE ALLOCATION OF SPACEIN THE MEMORY OF THE INTERPRETER -/

420 2 DECLARE cHOLD. SVTESJPEQ > ADDRESS.411 2 HOLD-NEXT IAVA I LA6LE.422 2 IF CNEXTJAVAILABLE -NEXT*AVAILABLE BVTES^REQ >l MAXS INT JMEM

THEN CALL FATAL-fERROR^ '110' )l

424 2 RETURN HOLDj42! 2 END ALLOCATE,

426 1 SeTJREDEF PROCEDURE v OLD. NEU.>.

427 2 DECLARE COLD. NEUj ADDRESS.IF CREDEF -NOT REDEF; THENDO.

REDEr«ONE-OLD.REDEF«TUO-NEU.

END;ELSE CALL PRINTSERROR< "Rl" >.

END SETiREDEF,

SETICURfSYN : PROCEDURE.CURJSVN- I DfSTACK < I D JSTACh:JPTR > ,

END SETJCURISVM,

STACK-tLEVEL PROCEDURE BYTE.CALL SETJCURJSVfl;RETURN GETJLEVEL.

END STACKiLEVEL.

LOAOILEVEL PROCEDURE.DECLARE HOLD ADDRESS.

LOAD*REDEF*ADOR PROCEDURE.CUR*SVN-REDEF*ONE.HGLD-GETfADDRESS.

END LOAD*REDEF*ADDR.

IF IDtSTACKCO) O THENDO.

IF VALUE<SP-2>-0 THENDO.

CALL SET*CUR*SVMiHaLD-GETfS.H_ENCiTH • GETJADDRESS.

ENO.ELSE CALL LOADIREDEFJADDR.IF <ID*STACK*PTR » ID*STACK.SPTR»1,>9 THENDO.

CALL PRINT*ERROR< 'EL >.

ID*3TACK*PTR»9lENDi

END.ELSE HOLD-NEXTJAVA I LA6LE.ID*STACK-:ID»STACK*PTR>-VALUE^MPP1.^.CALL 3ET*CUR*SVn.CALL SET»ADDRE3S<H0LDj.

END LGAD*LEVEL.

457 1 REDEF»OR*VALUE PROCEDURE.46© 2 DECLARE HOLD ADDRESS.

iDEC. t, J. SIGN; bvte.469 2 IF REDEF THEN479 2 DO.471 2 IF REDEFITUO-CURJSVM THEN472 3 DO.

423 2429 2430 3431 3

432 3

422 2434 2

423 1426 2427 2

42S 1

439 2

448 2441 2

442 1

4*2 2

444 2

44J 24*6 24*7 3

4*S 2449 2430 2431 -

432 4

432 4434 44 33 2

436 3

4 37 3

438 4

439 4

468 4

461 2

462 2

463 246* 2463 2

466 2

114

Page 234: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 235: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

4 73 4

474 4

473 4476 4

477 34 73 3479 3480 3461 3432 4

432 4434 3

483 2

433 2430 2431 2492 3434 24 96 2

497 3433 3

499 2300 2

501 7

332 2

SBS 3564 4533 4

306 4

307 3

303 2

HOLD-GETJSfLENGTH.CUR*SVri-REOEF *0N6jIF H0U»G£T*S*L£N6TH THENDO;

CfiLL PRINT.JERROR>. R2'.'.

H0LD-GETJ3.TLENGTH,CUR*SVM-REOEFJGNE.CfiLL SET JS.JLENGTH.: HOLD}.

END)REDEF-FALSE.

END.ENDjelse if penoingjliterfll-0 then return;if pending*litsidoid*stfick*ptr then returniCfiLL STfiRTJIHITIfiLIZE'.GETJfiOORESS. HOLD «GET*SiLENGTH.'.IF PENDINGSLITEfiflL>2 THENDO.

IF PENOINGILITERfiL-2 THEN CHHR-'fl'.ELSE IF PENOINGiLITERfiL—* THEN CH8R-- '.

ELSE CHflR-GUOTE-CflLL r I LL-tSTR I NG < HOLD. CHfiR ) .

END.ELSE IF f»EHDIN6*LITSWL « 2 THENDO.

IF HOLD > HOLDJLIT<0.< THENCSLL STRING-iOUTi HGLDJLITCl 1. HOLD; .

ELSE DO.CfiLL STRINGiOUTi HOLDiL I T : 1 .> . HOLDiLITC Bi,.CfiLL FILLSSTRINGcHOLD - ^HOLDJUTO; * lJ. ' 'I.

ENOiEND;ELSE 00.

/» THE NUMBER HfiNDELER ••DECLfiRE cOEC. rllNUSJSIGN. I. J. LITJOEC. NILENGTH.

NUniBEFORE, MUMIfiFTER. TYPE) 3VTE. "ONE LIT • 10H '

.

IFCCTYPE -GETITVPEX16) OR iT^OIO; THENCfiLL PRINTtERRORv ' Nv ' :>.

M*L£N8TH»G£T*S*LSNQTHlDEC-GETIDEC I M8L.H I MUSTS I GN-FP.LSE.IF H0LD«_IT<1> - '-' THENDO;

n I NUSSS I GN-TRUE,J-l.

ENO.ELSE IF HOLDiLITCl.) . '*' THEN J-UELSE j-e<LITIDEC-9;DO 1-1 TO H0LD*LI7<B>;

313 4 IF HGLO*LITCI>-- ' THEN LITIOEC-I.327 4 END;128 2 IF LITIDEC-0 THEN325 3 DO.330 4 NUn*6EF0RE-H0LD*LlTClJ-J.321 4 NUrtSHFTER-O.332 4 END.322 2 ELSE DO.334 4 NUriJBEFORE-LITJDEC -J-l.323 4 NUM*fiFTER-HOLD*L I T : 1 .• - LITSOEC.336 ' 4 ENO.337 3 IF CI -NILENGTH - DEC.'-:NUr«BEFORE THEN338 3 CfiLL PRINT*ERROR': SL'>;333 3 IF IDNUn*BEFORE THEN3-M3 3 DO.341 4 I-I-NUMJ6EFGRE,342 4 IF MINUSJSIGN THEN343 4 DO.344 3 I-I-i.343 3 CfiLL BVTEJGUT'. 8- - ZONE:>.3-16 3 ENO.347 4 CfiLL F ILUSTRING CI. '3'>;

343 4 END;343 3 ELSE IF rtlNUSJSIGN THEN HOLD*LlT.; J»1.>-HGLD*LIT.. J-l .-20NE.

CfiLL STRINGiOUT: HCw*L I T< 1.' * J. NUrUBEr ORE .'

.

332 2 IF NUMSfiFTER ': Z'ZZ THEN NUMSfiFTER DEC.334 3 CfiLL STFINGJGUT. HOLDJLIT^i.. » LITJOEC. NUM*ftFTER '

333 2 IF a -OEC - NUN*rtFTER>s>fi THEN336 3 CfiL_ FILL-fSTRING' I. 0'.337 2 ENO.333 2 rENDIfJGJLITERRL-3.333 I END FEDEFiuRJVfiLUE.

360 1 REDUCE-fSTfiCK PROCEDURE.361 2 DECLftRE HOLO*LENGTh ADDRESS.352 2 CfiLL SETJCjRfSvrl.

310 2

311 3312 2312 2

314 3

313 3316 3

317 4

313 4

313 4

320 3

322 3

323 3324 3

115

Page 236: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 237: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

334 I HOLD*i_ENGTH"GET*S.ILENGTh.333 2 IF aET*TVPg :• 123 THEN333 2 00.337 3 HOLD*LENGTH»HGLDJLENGTH « GETtOCCURS.333 J ENO.169 2 IO.*STACK.tPTR-ID.«STACk*PTR - 1.

570 i CALL 3ETJCURSSVN.171 2 CALL SETISfLENGT-KGETIS-JLENGTH » HOL&SLENOTH 1

;

572 2 CALL SET*TVP6 < GROUP ..

37" 2 -END REDUCEfSTACK.

174 1 ENDJGFiRECGRD PROCEDURE.573 2 00 WHILE lOfSTACK-IRTROj,373 2 CALL REOUCESSTACI'..

573 2 CALr. SETiCURiSvn,379 2 CALL = EDEFJOR*VALUE,

331 2 7Er:F*riGwl—ALLOCATE' TZj'tRSTUG -GETiSJuENGTHj,712 2 END ENDSORiRECCRD.

332 1 C0Ii»EPTi:,.7E;EP PROCEDURE.33-1 2 DEC-ARE INTEGER ^DIPESS.7-1" 2 H^EGEF^.533 2 00 I • 1 TO VSRCC6J.737 5 IN7EGER»SnL INrEGER. 3>*SHL' INTEGER. i^CVfiRC' I •-

til 2 END.535- 2 VALUE'. 3r .'• INTEGER-,330 2 END CGNVER7J INTEGER.

552 1 GRiVALUE PROCEDURE' =7-. iTTRlB...

532 2 DECLARE P7R 3YTE, A77= IB ADO= ESS.532 2 VALUE<P7R>".,ALUE''.RTR GP ATTRIS.534 2 END GR*vAi_uE,

533 1 SUILDiFCB PROCEDURE,593 2 DECLARE TEMP ADDRESS.397 L DECLARE SUFF-R<H) B'-TE, '.CHAR, I. Jj 3 t 7c.393 1 CALi. R I LH. BUFFER. ' .11.'.

393 2 2. I»3l302 2 DO UHILE 'iJ < 11.' AND '. K VARC'S.';,321 : if <char * ,arc>:i i-i.'-'-' TtEn j»a.3C2 2 ELSE 00.504 4 3UF- ER ^ 2 ' -CHfift;

©03 4 J»j"*1j6wo 4 EJ4D,

SG7 2 SHOj506 1 Ci=il_w SETSROZ-?-l< TEMP "HU-CCnTS-;!**. >

533 1 CftU_ STfiSTJrNITInLIZE'.TErTP, 16" .

6x0 1 CAl.u 3'/TEtuLfT-:0>--"11 *. CPU- STRlNGiojT: 5uFr^ U^£1.2. 2 Cftu. fili_*str:;j.j- 4. c>iH.Z I C«Li_ 0fiJv'n 1_.J£..2?-lJ. 1J.

Si- 2 END iUILi'JFCi.

31" 1 5E7JSIGN PROCEDURE' NUr.B.>'

313 2 DECLARE Nur'E BVTE,317 I IP GE7i7'TpE-l7 THEN CA^_ SE T i7VRS': VALUE' LP~> * NUNS319 2 E4SE CALL RRiN7*ERRGR'. 3G >;

32C 2 IP VAi_UE\3P;0'3 THEN GALL 2E7f SjlENGTHCGET*SJLENGT322 2 E)>D 3ETJ3IGN.

322 1 PIC*ANALI2ER PROCEDURE.324 2 DECLARE '• WGR>: AREAS AND VARIABLES -^

PLAG BVTE.FIRST BYTE,COUNT ADDRESS.BUFFER Ol.' 3V7E,SAVE 3V7E.REPITI7ICN3 ADDRESS.J BVTE,DECJCGUNT BVTE,CHAR BVTE.I BVTE.TEMP ADDRESS.-VPE BV7E,

* * « HASK3 * " -

A»_RHA LIT '

.

AJEDIT LIT Z .

AIM LIT ' 4 "

.

EDI7 LIT 3 .

riJM LIT 'to'.(KjniEDIT LIT 22 .

DEC LIT 34 .

SIGN LIT 123 .

116

Page 238: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 239: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

NU'l*MftSK LIT lOieiiiiBNijruED*MASk LJT luOuolulSSSWJNSI IASK LIT •julull 1 IBrtitXMMSK -IT 11111 106BAJNfnASK LIT liiuioieeA*N-»EiMASK -IT UluOGtfltie

/* TVPE3 «/NETVPE LIT 80NTVPE LIT ISSNTVPE LIT 17RTVPE LIT S'B6TVPS LIT '72

AHTVPE LIT 9*'

ANETVP6 LIT '72 '.

S23 2 INCICOUNT PPOCEDURE'ISUITCH);S2S 2 DECLARE SWITCH BVTEj427 2 FLAG-FLAG OR SWITCH.£23 2 IF < COUNT -COUNT * 1j < Zl THEN BUFFER '. COUNT , » CHAR,SCO 3 END IHCSCOUNT.

SIX 2 CHECK PROCEDURE MASK) BVE./* THIS ROUTINE CHECKS H MASK AGINST THEFLAG &VTE AND RETURNS TRUE ID THE FLAGHAD NO BITS IN COMttON UITH THE MASK -/

S32 3 DECLARE HASk 3VTE*SCS 3 RETURN NOT , <FLAG AND MASK; O O;.sc- : END CHECK,

SCI 2 PICiALLOCATE PROCEDURE ' AMT i ADDRESS.S3S 2 DECLARE AMT ADDRESS.S27 C IF <MAXJINT*MEM -TIAXJINTiNEM - AMT'> -I UEXTSAVAILABLE

THEN CALL FATALJERROR MO'.'.

S23 3 RETURN MAXJINTW1EM.S40 2 END PICtALLGCATE.

.-» PROCEDURE EXECUTION STARTS HERE -''

' S41 2 COUNT, FLAG, DECJCOUNT-3,/- CHECK FOR EXCESSIVE LENGTH -^

542 2 IF VARC<0> > 30 THEN543 2 DO;s44 2 CALL PR INT TERROR < 'PC ;.

S4S 3 RETURN,S4S I END.

•'» SET FLAG SITS AND COUNT LENGTH •/S47 2 I -1,

543 2 DO WHILE X-VARC<0>;S49 2 IF v CHAR -VARC :!.»>-' A' THEN CALL INCJCOUNT< ALPHA;

.

Sli 3 ELSE IF CHAR -'B' THEN CALL INCICOUNT'. AiED IT).

S~3 2 ELSE IF CHAR -'9' THEN CALL INCJCOUNTCNUM)

.

S5S 3 ELSE IF CHAR •'X" THEN CAL- INC*COUNT>' A*N>,S"7 3 ELSE IF >.CHAR-'S'> AND '.COUNT-e;- THENS"3 2 FLAG-FLAG OR SIGN,S3? 2 ELSE IF -.'CHAR » 'VO AND <:DEC-*CCUNT-e> THENSSw 2 DECJCOUNT-COUNT.SSI 2 ELSE IF. CHAR- /'J OR >. CHAR- ' ' ' THEN CALL INCJCOUNT<EDIT553 2 ELSE IF

vCHAR-2"> OR <CHAR-', '; OR vCHAR-"-'. OR<: CHAR- ' ' .. GR <CHAR-'-'; OR >.CHAR--»-> THEN

554 2 CALL INCtCGUNT.NUMJEDIT';.SS" 2 ELSE IF -:CHAR»' '; AND v DECJCCUNT-a > THEN555 2 DO;SS7 4 CALL INCJCOUNTCNUMJEDIT).SSB 4 DECJCOUNT -COUNT,SSS 4 END,570 2 ELSE IF ^iCHAR-'C.. AND CVARC< I»1;-'R J J OR

:<CHRR-'D'. AND CVARC-. I»l;-'3 ' > .' THEN571 2 DO;572 4 CALL INC*CGUNT':NUn*EDIT>,573 4 CHAR-VARCCI -1*1...

574 4 CALL INCtCOUNT^NUMSEDIT).S7J 4 END.575 3 ELSE IF <CHAR--^-> AND vC0UNTO9> THEN577 2 DO.578 4 SAVE-VARCa-1;.579 4 REPITITIONS-0.SS£ 4 DO WHILE^CHAR -VARC.I -1*1: .'O' ;

'.

531 I REPITITIONS-SHL.'REPITITIONS, 15 -

SHLCREPITITIONS. 1 .' -.CHAR -'8'Jl532 I END.SE2 4 CHAR-SAVE.534 J DO J-l TO REPITITIONS-1.535 J CALL INCtCOUNTvB;;S3S 3 END.SB7 4 END.

117

Page 240: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 241: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

666 2

£39 4

s$e 4

6?i 4

692 2

693 3

694 26?3 I

696 2

o>6 2

o3? 2

701 2

793 2703 2707 270? 2

713 2714 2716 2"17 2"18 2719 3"20 3

ELSE OOiCALL PRINTtERRORi PC>.RETURN,

END,

END) /* END OF DO WHILE I<» VfiRC «V.-» ST THIS POINT THE TYPE CAN BE DETERMINED -/IF HOT CHECK •: NUMSED I T ) THENDO.

IF CHECK :NUM*EDIMASK,. THEN TVPE-NETVPE,END,ELSE IF CHECK INUfWIflSIO THEN TVPE-NTVPE.ELSE IF CHECK . SNUMJMASK 1 THEN TVPE-S.»N*TVPE.ELSE IF CHECK i NOT ( ALPHA ) ) THEN TVPE-ATVPE.ELSE IF CHECK<A*EJMASK> THEN TYPE "AETVPE.ELSE IF CHECK kA*N*MASK> THEN TVPE=»ANTYPE.ELSE IF CHECK <nstlsg.snPSK> THEN TVPE-ANETVPE,IF TYPE-0 THEN CALL PRINTJEKRORC 'PC .•

.

ELSE DO.IF REDEF THEN CUR4SVM-RE0EFSTU0.ELSE CURJSVM - HGL1>*SVM.CALL SETJTVPE'.'TYPEi.CALL 3ET*SLENGTH.-COUNT • GET*S*LENGTH'.'

.

IF -.'TYPE AND 64 > O 3 THENDO.

721 4 CALL SETJADDR2< TEMP -PIC*ALLOCATE;COUNT) J;

722 4 CALl. STARTJINITIALIZE TEMP. COUNTS;722 4 CALL 3TRIHG*GUTi BUFFER * 1. COUNT i

.

724 4 END.721 2 IF DEC-ICOUNTOO THOJ CALL SET*DECIMAL<C0UNT-OEC«C0UNT .

727 2 END.723 2 END P I CJANAL I 2ER-

729 1 SETiFILEiATTRIB PROCEDURE;730 2 DECLARE TEMP ADDRESS. TYPE BYTE.721 2 IF CUR*SYriOVALUE>:nPF-lj THEN722 2 DO.722 2 TEMP-CURtSVrt;734 2 CURJSVM-VHLUEv'nPPl),723 3 SVMBOL-tADDRvPELJID^-TEMP,

END.IF NOT i TEMP -VALUE <SP-±>> THEN CALL PRINTiERROR C'NF'>;ELSE DOi

IF TEMP"! THEN TYPE-SEQUENTIAL.ELSE IF TEMP-13 THEN TYPE-RANDOn.

744 2 ELSE IF TEMP-9 THEN TVPE-3EQ*RELATIVE.746 2 ELSE DO)747 4 CALL PRINTJERRORi 'IA'ij748 4 TVPE-1,749 4 END.753 2 END.7J1 2 CALL ScTITVPE.:TVPS>.752 2 END SET5FILE*ATTRI6.

753 1 LOAD*LITERAL PROCEDURE,754 2 DECLARE I BYTE.

IF PEND I NGfL I TERAL O THEN CALL PRINTlERROR C'LE'JiELSE DO I - TO VARCCO).

HOLD*LIT<I/-VARCCIJ.END.

END LOADILITERAL.

CHECKSFORiLEVEL PROCEDURE.DECLARE NEUJLEVEL BYTE,H0LD*SVM, CURJSVM-VALUE'.' MP-1 1

,

CALL SETJLEVELiNEUULEVEL "VRLUECMP-2) 1,

IF NELJ.tLEVEL-1 THENDO.

IF IDSSTACK<a>03 THEN00.

IF NOT FILEJSECfEND THENDO.

CALL SETtREDEFU DISTBCK > > . VALUE <nP-l>>,77-2 5 VALUE >MP>-1, /« SET REDEFINE FLAG m,

773 3 END.774 4 CALL ENOiOFJRECCRD.775 4 END;776 3 END.777 2 ELSE DO UHILE STACKiLEVEL > NEiJiLEVEL.773 3 CALL REDUCEJSTACK.77? 3 END.-30 2 END' CHECKJFORJLEVEL,

731 1 CODMGEN PROCEDURE PRODUCT I ON...

732 2 DECLARE PRODUCTION BYTE.

736 3

727 2729 2740 3742 3

755 2-37 2738 2"59 2

760 2

761 1

762 2763 2

764 2

763 2

766 2767 3

768 376? 4

770 47-1 3

118

Page 242: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 243: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

"33737766

73a 3

791 3

792 3

793 3

794 3

793 3

796 3

"97 3

79* 3

799 3

300 3

301 3

802 3

303 3

604 3

303 3

306 -

807 '-

608 3

309 3

310 3

311 3

312 3

313 3

314 3

315 ;

616 3

317 2

313 3

319 2

620 2

IF PRINTJPP.uD THEN00.

CALL CRLF.CALL PRINTCHAR<POUND.>.CFILL PRINT*NUN36R 'PRODUCT 1 0N>

.

END;

do case production;

» productions-/case i40t used

1 .^program} - <id-0iv> <e-div> <d-0iv.' procedurecompiling-false.

2 iid-div:- - identification division program-id2 <c0mment3> <auth3> -idfiie3 <3ec:-/* ho action required -/3 ^authi- - author <xomm£nt:>/» no action required '/4 \ ! •:emptv>/•« no action required */i <date> - date-uritten <comment>/• no action required •/3 \

' ':emptv;>,— no action required •/t <3ec> » securitv ccomhent>/* no action required */5 \ ! «:smptv>.-- NO ACTION REQUIRED •/

9 CC0MMENT5 - <:INPUTI-/•> NO ACTION REQUIRED */

io n 1 <comment:> < inputs• HO ACTION REQUIRED -/

11 «E-OIV> - ENVIRONMENT DIVISION CONFIGURATION11 SECTION <SRC-OBJ> <II-0>/» HO ACTIOH REQUIRED ••/

12 -:SRC-OBJ> - SOURCE-COMPUTER ^COMMENT-.- <DE3UO12 OBJECT-COMPUTER <COMMENT>

i /» HO ACTION REQUIRED -/13 <0EBUG> - DEBUGGING MODE

DEBUGGING- TRUE. /' SETS A SCANNER TOGGLE -/

14 S ! <EMPTV>; /- NO ACTIOH REQUIRED »•

15 <l-V> .:• INPUT-OUTPUT SECTION FILE-CONTROL15 <FILE-COHTROL-LIST> <IC>/» HO ACTION REQUIRED -/

16 S ! <EMPTY>/» NO ACTION REQUIRED -/

17 <rILE-C0NTR0L-LIST3>; /* HO ACTION REQUIRED *•

18IS/• HO ACTION REQUIRED -/

19 <FILE-C0HTROL-ENTRV>CALL SETIFILEfATTRIB.

20 CATTRIBUTE-LISTV - -lONE-ATTRIB}.-- HO ACTIOH REQUIRED •/

2i si •:attribute-list> :ohe-attrib>VALUED MP >="VALUE':S?> OR VALUE <np:..

22 CONE-ATTRIB:- :» ORGANIZATION <ORG-TVPE>VALUE-.' MP ) -VALUE < SP >

.

23 S! ACCESS <ACC-TVPE3 CRELATIVE3-VALUE CMP i -VALUE (MPP15 OR VALUE <SP>.

24 S! ASSIGN <INPUT>CALL BUILDiFCB.

25 -;ORG-TVPE> . SEQUENTIAL/' NO ACTION REQUIRED - DEFAULT */

2S s 1 RELATIVECALL ORiVALUEiSP. 4,.

27 <ACC-TVPE> - SEQUENTIALi /* NO ACTIOH REQUIRED - DEFAULT •/

28 \ ! RANDOMCALL ORSVALUE<SP. 2>.

29 ^RELATIVE;- « RELATIVE <ID>CALL Oft*VALUE'.'MP 8>.

30 \' ^EMPT'/I-

/' NO ACTION REQUIRED - DEFAULT -,

31 •:ic:- - I-G-CONTROL ISAME-LlST,

32 X • <EMPTV>

33 CSAME-LISTO - CSAME-ELEMENT>

34 S' CSAHE-LISTO <SAME-ELEMENT;-

35 ISAME-ELEMENT; - SAME ;ID-rTRIHG>

-

•."file-control-entrv}

<f i le-control-l i st.<:fil£-control-entrv>

select <io;> cattribute-listv

119

Page 244: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 245: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

/- 28 :ID-STRIMG> • CID>

/«• 27 S! <ID-STRINg;- CID>S27 2 ;

/» 36 CD-OJV> DATA DIVISION <FIL.E-SSCTION> vUORIO/* 23 CLINK2-

328 I . .'- "0 ACTION REQUIRED */s~ S3 «FtLS-SECTI0N> = RILE SECTION CrTLE-LIST5

829 2 FILE*SECt£ND - TRUE,/* 46 S! vEMPTV>

320 3 FILEfSECJEND-TRUE./» 41 <file-list:- » cfiles;

321 3 . /» no action required «//« 42 v -cfile-list:- «file33

532 3 . ,* no action reouired "v'

/» 43 <files> » fd <id> <file-cgntr0l2-.-» 42 vRECORD-OESCR I FT 1 0(0

822 2 DO.324 4 CALL END*OFiRECGRD.S3* 4 CURS3VP1«VALUE-:HPP1.»,328 4 CALL SETJADDRESS'.TEnp-tHOLD.'.837 4 CALL SET*S*LENGTHvTEnP*TUG->.323 4 END.

/« 44 <FIL8-C0NTR0O - vFILE-LIST}323 3 . /• NO ACTION REOUIRED -/

/« 4

J

\| <ENPTV>i /- NO ACTION REOUIRED »/

/» 48 <FILE-LIST> = ^FILE-ELEnENT,— NO ACTION REOUIRED -.

/* 47 v <FIL£-LIST> <FIL£-SL3MENT2>; /- NO ACTION REOUIRED »/

/*• 43 <FILE-ELEMENT> = BLOCK -IINTEGER;- RECORDS; /- NO ACTION REQUIRED - FILES NEVER SLOCKED ••

.'* 43 S! RECORD CREC-COUWOCALL SET*SLENGTH.:vALUE-:SP:>>.

/* 30 S! LABEL RECORDS STANDARD/- NO ACTION REQUIRED •/

/* 31 \! LABEL RECORDS OHITTED/» NO ACTION REQUIRED -'

/* 32 s! VALUE OF vID-STRINCC-/- NO ACTION REQUIRED •/

/• 12 -IREC-COUNTV » C1NTEGSR5/» NO ACTION REQUIRED - VBLUECSP5 CORRECT •/

/* 54 S! <IIHTEGERi> TO <INTEGEF.>DO.VALUE < PIP > -VALUE 'ISP.'. •» VARIABLE LENGTH •/CALL SET»TVPE<4>. /. SET TO VARIABLE »l>

END./» 33 <U0RK2> - WORKING-STORAGE SECTION/• 33 -IRECORD-DESCRIPTION}

•» NO ACTION REQUIRED '//* Sg \' <EMPTV>

i / + NO ACTION REQUIRED *//» 17 CLINO « LINKAGE SECTION :R£C0RC—CESCRIPTI0N3-

CALL PRINT*ERROR< NI ">, .* INTER PROG COMM '/.-» 33 S! •ienpty:-

•* NO ACTION REQUIRED ••/* I? •."RECORD-DESCRIPTION;- . <LEVEL-ENTRV>

357 2 . •* NO ACTION REOUIRED -//- 80 V -CRECGRD-DESCR I PT I 0(0.'* 8e •CLEVEL-ENTRV;.

353 2 , NO ACTION REQUIRED •//' 81 <LEVEL-ENTRY> - '-.INTEGER:- !DATA-!D> PREDEFINES;/- 81 vDATA-TVPE2>

33? 2 DO.386 4 CALL LOADiLEVEL.381 4 IF FENDING*LITERALOe> THEN PENOING*L I T*ID- IDJSTACKJPTR882 4 END.

.'» 82 -:data-id> - -:id>384 2 . /» no action required -.

/» 83 V FILLER383 2 DO.i£6 4 CUR*SVM. V'ALUE-: 3P -'NEXTiSVf-L387 4 CALL BUILD*SVn60L':a/.383 4 END.

/* 84 PREDEFINES;- - REDEFINES <IS»38? : DO,370 4 CALL SETJREDEF-:VALUE-:3P -. VALUE-: 3P-2.' ;-

.

371 4 VALUE -:MP.'-1. i>* SET REDEFINE FLAG ON •/372 4 CALL CHECKJFORtLEVEL.373 4 END.

/* 83 S! -CEMPTv;.

374 2 call checkjfcr-tle'-el..* 88 -idata-tvfe;- ;prop-list:-

373 2 . no action required «/•'

^40 -

341 4

342 2

542 2

344 2

343 :

348 2

84 7 2

348 2

349 2

338 4

331 4

332 4

333 T

334 2

333 2

338 2

120

Page 246: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 247: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

•• 67 si .:empty>375 S ; .— NO ACTION REQUIRED *r

/» 63 ^PROP-LIST; » XATA-ELEnENTt.877 3 , i"> NO ACTION REQUIRED »/

.-'» 69 V ^PROP-LIST} CDATA-ELEMENT:-37S 2 , /» NO ACTION REQUIRED -/

/+ 70 <Dl=lTH-ELEMEriT> - PIC <INPUT>373 3 CPU. PIC*Artf(LI3ERL;

/• 71 S

!

380 5 CPU. SET*TVPE:COnp>./* 72

331 J , /» NO PCTION REQUIRED - DEFAULT -/SIGN LEADING ;3EPARATE> »/

332 3 CPU. SET*SIGN<18).SIGN TRAILING ^SEPARATE} */

OCCURS < INTEGERS •/382 S CALL SETJSIGN^17>.

USPGE COMP -/

USAGE DISPLAY -/

884 3 00;

351 4 CALu 0R*TYPE<12S>.336 4 CALL SETIOCCURSi VALUE iSP> .

337 4 END./» 76 S' SVNC ^DIRECTION} »•

S38 3 . /* NO ACTION REQUIRED - SVTE MACHINE *//<• 77 X' VALUE ^LITERAL} •/

339 3 DO.390 4 IF NOT FILEJSECIEND THEN391 4 DO.

832 J CALL PRINTSERRGRC'VE"'.393 I PENOINGiLITEEAL-0.394 5 END.395 4 END.

,-'* 73 ^DIRECTION} - LEFT -/396 2 , .-- NO ACTION REQUIRED -/

.-* 79 \! RIGHT ••337 2 ; /" HO ACTION REQUIRED */

/' S8 V <EMPTY> »/338 3 . /« HO ACTION REQUIRED */

/- 91 ^SEPARATE} - SEPARATE */399 2 "ALUECSP>-2-

/» 32 S] <EHPTV> -/900 3 . /* NO ACTION REQUIRED -•

S* 32 <LITERRL> - <IHPUT> -/301 2 DO.382 4 CALL LOAD*LITERRL.903 4 PENDING*. I TERAL-1.984 4 END.

/» 34 S! <LIT2> -/903 2 DO;

90S 4 CALL L0AD4LITERAL.387 4 PENDING*LITERAL«2;90S 4 END;

/» 85 S! ZERO -•999 2 PENDING*LITERAL-2.

•» 36 S! SPACE »/918 2 PENDINGfLITERAL".

/» 37 S! QUOTE »/311 2 peh0ihg*literal«3.

/•* ss <integ£r2* -cinpuo •,912 2 call convert* i titeger.

/" 39 -:id:. - <ihput> -;312 2 value <sp> -hatch. /• store svneol table pointers »/

914 2 end, •« end of case statement »/311 2 END CODEiGEH;

916 1 GETIN1 PROCEDURE BYTE.917 2 RETURN INDEXl<STBTE>i913 2 END GETIN1,

919 1 GETIN2 PROCEDURE BYTE.920 2 RETURN I NDEX2 ESTATE'.'.

921 2 END GETIN2.

922 1 INCSP PROCEDURE.922 2 SP-SP L.

324 2 IF SP > PSTACK3I2E THEN CALL FATALJERRCRi 'SO' >.

325 2 VALUE<SP'-U. /* CLEAR VALUE STACK ••

327 2 END INCSP.

323 1 LOOkAHEAD =>ROCEDURE-323 2 IF NOLOOk THEN32B 2 DO.321 3 CALL SCANNER.922 2 NGL0GK-FAL3E.922 3 IF PRINTJTuk'EN THEN324 : DOi

121

Page 248: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 249: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

933 4

936 4

937 4

938 4

939 4

?40 -i

341 2

948 i

943 2344 2

.-4 5 2946 2

947 j

94 9 2

953 2

351 2

352 1

953 2

954 2

CALL CRLr.CALL PRINT*NUM6ER^T0KEN.>.CALL PRINTSCHAR^' ...

CALL RP.INTiACOUM.END.

END.END LGOKAHEAD.

NGICONFLICT PROCEDURE ..CSTATE; BVTE,OECLARE CSTATE. I. J. k .> SVTE.J-INDEXl^CSTATEj,K-J * I HDEX2.: CSTATE > - 1.

C'O l-J TO tIF RSfiDKI)"TOKEN THEN RETURN TRUE.

END.RETURN FALSE;END NOiCONFLICT.

RECOVER PROCEDURE SVTE-DECLARE iTSP. RS7ATE) SVTE.DO FOREVER;

913 2 TSP-SP)916 3 DO UHILE TSP O 233.937 4 IF NGiCONFLICTiRSTATE.-STATESTACK.-TSP>.. THEN933 4 DO. -'- STATE WILL READ TOKEN */339 3 IF SPOTSP THEN SP - TSP - l.

361 3 RETURN RSTATE.362 3 END.363 4 TSP - TSP - tl

964 4 EMO.963 1 CALL SCANNER. /•» TPV ANOTHER TOKEN -/366 3 END.367 2 END RECOVER.

368 1 ENDSPASS PROCEDURE..-'• THIS PROCEDURE STORES THE INFORMATION REQUIRED 3V =AS32IN LOCATIONS ABOVE THE SVnBOL TABLE. THE FOLLOWINGINFORMATION IS STORED

OUTPUT FILE CONTROL BLOCKCOMPILER TOGGLESINPUT BUFFER POINTER

THE OUTPUT BUFFER IS ALSO FILLED SO THE CURRENT RECORD IS URIT~EN.•X

CALL BVTEIOUT ( SCD >

.

CALL ADDRIOUT ( NEXT *AVA I LAeLE >

.

DO UHILE OUTRUTiPTPO OUTPUTIBUFF.CALL 8VTEI0UTC0FFH>,

END,

CALL MOVEi OUTPUT JFCB. MAXiMEMCRV-PASSlXLSN. PASSltLENJ.L GO TO L. .'- PATCH TO -JMP 31O0H" -,

END ENDIPASS.

969 2378 2971 2

372 .i

373 3

974 2975 2976 2

PROGRAM EXECUTION STARTS HERE

977 1 CALL MOVEilHITIAL-lPOS. MAXIMEMORV. RORILENGTH

;

973 1 CALL INITJSCANNER.979 1 CALL INITISVM60L.

989 1 DO UHILE COMPILING,981 2 IF STATE :- MAXRNO THEN /* READ STATE »/9S2 2 DO.333 3 CALL INCSP.984 3 STATESTACKiSP) - STATE. /- SAVE CURRENT STATE */933 3 CALL LGOKAHEAD.986 3 I -GET I Ml,387 3 J « I * GETIN2 - 1.

383 3 DO I-I TO J,

939 4 IF READKI; - TOKEN THEN396 4 DO.

/- COPV THE ACCUMULATOR IF IT IS AN INPUTSTRING. IF IT IS A RESERVED UORD IT DOESNOT NEED TO BE COPIED -^

931 3 IF i TOKEN- INPUTtSTR; OR <TOKEN-LI TERAL .'

392 3 DO K-a TO ACCUM..O.,993 6 VARCvKj-ACCUM<K/,394 6 END.993 3 STATE-READ2<I>,996 3 HOLOOK-TRUE.997 3 I-J.398 3 END.

ELSE999 4 IF I-J THEN

122

Page 250: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 251: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

1000 4 OOi1001 5 CALL PRIMTSERROR< NP' ..

,

1002 5 CBLL print; :- ERROR nebr «-',,,

1003 3 CRLL PRINT*BCCUMj1004 5 IP CSTBTE =RECOVER;-0 THEN COMPILING-FALSE,lOOo 3 END;

ENOj1008 3 END. /* END OP READ STBTE •/

ELSE100? i IF STBTE>MBaPNO THEN /* APPLY PRODUCTION STBTE */1010 z DO.1011 Z MP-SP - 0ETIH2J1012 2 mppi-mp + i.

1012 3 CBLL CODE*GEN< STBTE - MAXPNO).1014 Z SP-MP.101! 2 I -GET INI,1016 2 J-STATESTBCK<:SP>.1017 2 DO WHILE <K -BPPLVICI^/ O AND JOK,1013 4 I-I - U1013 4 END;1020 2 IF < K -BPPLV2 C I

>

, -6 THEN COMP I L I NG-FBLSE.1022 3 STBTE-K,1022 : END,

ELSE1024 2 IF STBTEOMBXLNO THEN /•LOOKBHEBD STBTE-/1021 2 DO.1026 3 I "GET INI,

102? 2 CBLL LOOKBHEBD.1023 3 DO WHILE CK:»LOOK1<I>>00 AND TOKEN OK.1023 4 1-1*1,1030 4 END,1031 2 3TBTE-L00K2<I>;1032> ' END.

ELSE1033 Z DO. /•PUSH STATES-/1024 Z CBLL INCSP.1035 3 STBTESTBCK < SP > -CET I N2j1036 2 STBTE-GETIN1,1027 3 ENDi1023 2 EN&J /» OF WHILE COMPILING »/1039 1 CBLL CP.LF.

1040 1 CBLL PR I NT i v - PROCEDURES ') j I

1041 1 CALL ENDfPASS.1042 1 ENOj

MODULE INFORMATION

CODE BR6B SIZE - 1ES1H 7e2TOVARIABLE BREB SIZE - 02FCH 7640MAXIMUM STACK SIZE - 001CH 2eO1317 LINES REAOPROGRAM ERROR >. 3)

END OF PL/M-80 COMPILATION

123

Page 252: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 253: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ISIS— II PL/-M-68 ;: 1 COMPILATION OF MODULE IMTERPOBJECT MODULE PLACED IN Fl INTERP OEJCOMPILER INVOKED BV PLMoO Fl INTERP PLM

IPAGELENGTHiSe?INTERP -*

DO.MODULE I N T E R P

COBOL INTERPRETER _ -

HORMAL.LV ORG'ED TO :-.-iee-

GLOBAL DECLARATIONS AND LITERALS

LIT LITERALLV 'LITERALLY-

.

BOOS LIT -3H', • ENTRV TO OPERATIHO SVSTEM •/SOOT LIT 3'.

CR LIT '13',

LF LIT -IB'.TRUE LIT -1-,

FALSE LIT a-.FOREVER LIT -UHILE TRUE-

- - JTILITV VARIABLES -^

DECLARE

BOOTES ADDRESS INITIAL <&Q&k>H>-I NDEX BVTE.AiCTR ADDRESS.CTR BYTE.BASE ADDRESS.B»BVTE BASED BASE <13 BVTE.BiADDR BASED BASE £15 ADDRESS.HOLD ADDRESS.AIBVTE BASED HOLD C13 BVTE.H*AODR EASED HOLD ^l> ADDRESS.

/' CODE POINTERS

C0DE5START lit -2eeaH ,

PRGGRAM-tCOUHTER ADDRESS.CIBVTE BASED PROGRAM*COUHTER Cli BYTE,CJADOR BASED PRCGRAniCGUNTER CD ADDRESS.

GLOBAL INPUT AND OUTPUT ROUTINES

7 2

'i 19 2

10 2

11 1

12 2

13 214 2

IS 1IS 21? 2

2

19 1

10 2

11 222 2

DECLARECURRENT JFCB ADDRESS.STARTIGFF3ET LIT '26',

MO(U. PROCEDURE CF, A3 EXTERNAL.DECLARE F BVTE- A ADDRESS.

END M0N1,

M0N2. PROCEDURE OF. RO BVTE EXTERNAL.DECLARE F BVTE. fi ADDRESS.

END M0H2.

PRINTJCHAR PROCEDURE <CHAR>.DECLARE CHAR BVTE.CALL M0N1 •. 2. CHAR ,

.

END PRINTiCHAR.

CRLF PROCEDURE.CALL PRINT*CHAR^CR '.

CALL PPINTtCHAR<LF>.END CRLF.

PRINT PROCEDURE (Aj.

DECLARE A ADDRESS.CALL CRLF.CALL MONIES. A;.

END PRINT.

READ PROCEDURE-. A>.DECLARE A ADDRESS.CALL rlONl.,10. A;.

END READ.

124

Page 254: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 255: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

28 1 FRINTSERROR PROCEDURE CCOOE5I29 2 DECLARE CODE ADDRESS.30 2 CALL CP.LP.

;i 2 CALL PRIHT*CHflRCHIGH<COOE5 5j

32 2 CALL PRINTSCHAR<LQU<COOE:'.'.33 2 END PRINTJERROR-

34 1 FATALiERROR PROCEDURE': CODE >;

II 2 DECLARE CODE ADDRESS.35 2 CALL PRINTJERRORvCGDE}.37 2 CALL BOOTER.33 2 END FATAL-fERROR.

39 1 SETJDnA, PROCEDURE.40 2 CALL nONl <2a. CURRENTJFCE 3TART*GFFSET >,

41 2 END SETiDNAJ

42 1 OPEN PROCEDURE CADDR) SVTE.43 2 DECLARE ADDR ADDRESS.44 2 CALL SETJDMAl /» INSURE DIRECTORY PESO UON'T CLOBBER CORE -r

45 2 RETURN nON2<15. ADDRJ,46 2 END OPEN,

47 1 CLOSE PROCEDURE <ADOR>)48 2 DECLARE ADDR ADDRESS.49 2 IF MGN2(16, ADDR,»255 THEN CALL FATALSERRORv 'CL' ).

51 2 END CLOSE,

52 1 DELETE PROCEDUREj53 2 CALL MONl':i9. CURRENTIPCS)

.

54 2 END DELETE.

53 1 MAKE: PROCEDURE 'ADDR>>36 2 DECLARE ADDR ADDRESS.57 2 IP M0N2C22. ADDRJ-233 THEN CALL FATALJERRORv PIE ' J .

59 2 END riAKE.

DISKtREAD PROCEDURE SVTE.RETURN MON2<2a. CURRENTSFC3);

END DISK.IREAD,

60 161 2

62 2

63 1

64 2•53 2

D I SKJUft I TE PROCEDURE BVTE.RETURN MON2':2X- CURRENT JFC3;

END DISKiURITE,

UTILITY PROCEDURES

ai 1 DECLARESUBSCRIPT <3> ADDRESS.

£7 1 RES PROCEDURE<ADGP> ADDRESS./* THIS PROCEDURE RESOLVES THE ADDRESS OP A SUBSCRIPTEDIDENTIFIER OR A LITERAL CONSTANT •/

88 2 DECLARE ADDR ADDRESS.89 2 IF ADDR > 32 THEN RETURN AODR,71 2 IF ADDR : 9 THEN RETURN SU33CRIFT-: ADDR ,.

73 2 DO CASE ADDR - 9j

74 3 RETURN <%'>>73 3 , RETURN ',' 1

,

78 3 RETURN C '>,

77 3 END.73 2 RETURN 9;

79 2 END RES.

£0 1 MOVE PROCEDURE < FROM. DESTINATION. COUNT,.31 2 DECLARE : FROIT. DEST I NAT I ON. COUNT > ADDRESS.

CF BASED PROM. D BASED DESTINATION/ SVTE.32 2 DO UHILE (COUNT -COUNT -DO OFFFFH,33 3 D-Fi84 3 FROM-FROH * 1,

35 3 DESTINATION-DESTINATION * i.

36 3 END-

125

Page 256: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 257: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

53 1-*

2

:-a 2:-i .>

9S -

=•; 2

>4 2

95 1

96 2

97 2

98 2

99 2

ISO 2101 -

102 2

102 2

END MOVE,

FILL. PROCEDURE C&ESTINHT I ON. COUNT, CHAR/.DECLARE CDBSTINflTION. COUMTJ ADDRESS.

<CHAR. D BASED DESTINATION) BVTEJDO WHILE 'COUNT -COUNT - 1;<D OFFFFH,

D-CHAft.DESTINATION-DESTINATION - 1.

END.END FILL.

CONVERT!TOiHEX PROCEDURE ^ PO I NTER. COUNT ) ADDRESS.DECLARE POINTER ADDRESS. COUNT avTE.R*CTR»8jBASE"POINTER,DO CTR - TO COUNT-1;

fl.»CTR-SHL>.A*CTR. 3> » SHL '- AJCTR. 1 .' • BI6YTECCTR)END.RETURN A*CTRj

END CONVERTITOiHEX,

/..-.....-- rcDE CONTROL PROCEDURES

DECLARE

BRANCHJFLAG BYTE INITIAL. < FALSE >

.

IHCIPTR PROCEDURE .COUNT;.,DECLARE COUNT BYTE.PROGRANSCOUNTER-PROGRAMSCOUNTER - COUNT,

END INCIPTR,

GETJOPJCGOE PROCEDURE BYTE.CTR-CJ6VTE<a).CALL. tNCJPTRd.'.RETURN CTRj

END GETfOPICOOE.

COND*eRANCH PROCEDURE •; COUNT '.<

,

,* THIS PROCEDURE CONTROLS BRANCHING INSTRUCTIONSDECLARE COUNT BYTE,IF BRANCH.JFLA& THEHDO.

BRANCH*FLAG"FALSE.PROGRAMJCOUNTER-CJADDR •. COUNT 5 .

END,ELSE CALL INCtPTPC SHL .COUNT. 1;»2).

END C0ND*9RANCH,

122 1 INCRiORiBRANCH PPOCEDURE '. MARIO

.

124 2 DECLARE MARK BYTE.125 2 IF HARK THEN CALL INC*PTR<2/.127 2 ELSE PPOGRAM*COUNTER-CSAODR<:0.>.123 2 END INCRJ0RI6RAHCH,

103 1loo 2

107 2

IDs 2

io:- 1

110 2

ill 2

111 2

116 2

117 2116 3

US 2

120 2

-COMPARISONS

123 1 CHARJCOMPARE PROCEDURE BYTE.138 2 BASE-OtADDR>0.'.131 2 H0LD*C*AD0R\1);122 2 DO A*CTR»6 TO C*A0DP''.2> - 1.

133 2 IF B»BVTE<A*CTP.. > HJBVTE-.AiCTR? THEN RETURN i.

12s 2 IF b*bvtE';ajctr . •: hsbvtS':a*ctr^ then return o.

127 2 END.12S 2 PETURN 2..

123 2 END CHARJCOMPARE,

140 1 STRING-JCOnPARE PROCEDURE'.PIVOT i,

141 2 DECLARE PIVOT BYTE.142 2 IF CHARJCOMPARE-PIVOT THEN BRANCH*FLAG-NGT BRANCH*FLAG.14-1 2 CALL C0ND16RANCHC2.'.14

J

2 END STR I NGiCOnPARE.

14,5 1 NUMERIC PPOCEDURE^'CHAP • BYTE.147 2 DECLARE CHAR EVTE

126

Page 258: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 259: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

148 214* 2

US 1

151 2

152 2

153 2

1S« 1

115 2116 2

117 *

ITS 1

159 2

160 2

161 2

162 2

163 4

164 4

165 4

loo 2

167 :

163 1

169 1

179 2

171 2

172 2

„_

174 4

175 4

176 4

177 2

130 1

181 2

182 2133 3134 2

is; 4

136 4

137 4

133 3

189 ;136 2

RETURN >:CHAP >-'0'.' AND <CHAR ->'3')iEND NUMERIC.

LETTER PROCEDURE>.ChAR.' BVTE,DECLARE CHAR BVTE.RETURN ^CHAR >-'«-> AND < CHAR <»-7"j

END LETTER;

SIGN PROCEDURE CCHSRi BVTE;DECLARE CHAR BVTE.RETURN ..CHAR-'-'/ OR XHAR-'

END SIGN.

COMPJNUM*UNS I GNED PROCEDURE.&ASE=C.*A00R>.3>.DO AiCTR»a TO ClADDRi2>-l.

IF NOT NUMERIC<B-tBVTE<A*CTRj> THENDO.

BRANCH*FLAG"NOT BRANCHSFLAG.RETURN;

ENDiEND.CALL COND*eRANCH':2>.

END C0MPSNUNSUN3IGNED.

COnPJNUMiSIGN PROCEDURE.EASE-dADDR^..,DO A*CTR-a TO CJADDR<2>-1.

I F NOT : NUNER I C ^ CTR =8iBVTE < A*CTR ) )

OR SIGNiCTR); THENDO.

BRANCHJFLAG-NOT BRANCHSFLAG.RETURN;

END.END.CALL CONDSBRANOKD,

END CONP*Nun*SIGN.

CCMPSALPHA PROCEDURE.BASE-CJADDR<B>.DO AiCTR-a TO C*ADDR<2>-1.

IF NOT LETTER C6*eYTE<ASCnO 5 THENDO.

BRANCHSFLAG-NOT BRANCHiFLAG.RETURN.

£HDjEND.CALL CQND*6RANCH<2>.

END COMPSALPHA;

NUMERIC OPERATIONS

DECLARE

:RO. Ri.R2i <10? BVTE, *SIGNacii BVTE.•:DEC-tPTO, DEOSPT1. DECJPT2? BVTE.DECJPTA :2> BVTE AT ( DECJPTB).OVERFLOW BVTE,RJPTR BVTE,SWITCH BVTE.SIGNIFiHO BVTE.ZONE LIT '10H .

POS ITIVE LIT ' 1 ,

riEGITIVE LIT -a-.

132 1 CHECKiFORISIGN PPOCEDUREiCHAR; BVTE,131 1 DECLARE CHAP BVTE.134 2 IF NUMERIC -.CHAR.' THEN RETURN POSITIVE,1S"5 2 IF NUMEP I C - CHAR - "ONE? THEN RETURN NEGI133 2 CALL PRIHTJERROR' SI"..13? 2 RETURN POSITIVE.20B 2 END CHECK-JFORfSIGN;

281 1 STOREi IMMEDIATE PPOCET'URE.232 2 DO CTR-8 TO 3;

263 2 R8<CTR5"R2(CTR>;

127

Page 260: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 261: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

164 220S 1

105 2207 1

.-.88 1105 2

lie I

211 2

212 3

213 4

214 4

I'll 2

END.C>eC*PT8»0eC*PT2)S I GNG < G ; -s I GNO i. 2 ;

.

END STGREJINI1EDIATE.

ONS*UEFT PROCEDURE;DECLARE 'XTR, FLAG) BVTSiIF I ;FLAG -SHR^BJevTE^G;. 4;;«G; OR FLAG-9) THENDO.

00 CTR-8 TO 3;

BS6VTE<CTR.'-SHL'.8*6VTECC7R;. 4) OR 5HRi BJBVTECCTR -

END.BJBVTE < ? J -SHU ^ B*6VTEO 1 . 4 1 OR FLAG.

216 I END.217 I ELSE OVERFLOW- TRUE.216 2 END ONEtLEFT,

213 1 ONEtRIGHT PROCEDURE.22a 2 DECLARE CTR BVTE;221 2 CTR-1G;222 2 00 IH0SX«1 TO 9;

222 2 CTP-CTR-l;224 2 £iBVTE':CTR)»5HR<BJSVTE<CTF.^. 4j OR SHL ^atSVTECCTR-1), 4) j

221 2 END.225 2 B.iBVTE'.aj-SHRCEitBVTEO). 4).227 2 IF BJEVTEO; . 09H THEN223 2 BJBVTE'.'G) 3S»H,

223 2 END ONEtRIGHT.

2HIFTIRICHT PROCEDURE': COUNT j,

DECLARE COUNT BVTE.00 CTR-1 TO COUNT.

CALL ONEiRIGHT,END.

END SHIFTtRIGHT.

SHIFTILEFT PROCEDUP.E < COUNT;,DECLARE COUNT BVTE.OVERFLGU-FALSE,00 CTR-1 TO COUNT.

CALL ONEILEFT,IF OVERFLOU THEN RETURN;

E?JD.

END SHIFT*LEFT.

ALLIGN PROCEDURE,BASE- R8;IF DECJPT0 > 0ECJPT1 THEN CALL SHIFT tRIGHT;DEC*PT0-OECWTl..

.

ELSE CALL SHIFTiLEFT<DECJPTl-OECJPTe;.END ALLIGN.

ADDiPB procedure; SECOND. DEST),DECLARE .SECOND. DEST) ADDRESS. <CV. A. B. I.J) BVTE.HOLD- SECOND.BASE - DEST.ev-a;CTR-5;DO J«l TO 10;

A-R8<CTR);B-HiBVTECCTR);I-OEC<A»CV>;CV-CARRV.I-DEC<I - 8).CV-<CV OR CARRY) AND 1.

3*BVTE;CTR>-I;25S 2 CTR-CTR-1.255 2 END.257 2 IF CV THEN253 2 DO.253 2 CTR-3;27a 2 DO J - 1 TO 10;

271 4 I-e*evTEvCTR).272 4 I-DEC':I»Cv:..272 4 CV-CARRV AND 1.

274 4 S»8VTEvCTR)-I.271 4 CTR-CTR-L,275 4 END.277 2 END.273 2 END ADD*RG.

22 e 1

221222 2

222 2

224 2

22; 2

225 1227 2223 222? 2240 2241 2

MS 1

245 2247 2243 2

213 1

211 1

212 2212 2

2S4 22" 2

2^5 2

217 2218 2

253 2

25G 2

251 2252 2

252 2

Z~r* 2

128

Page 262: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 263: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

27? I COMPLIMENT PROCEDURE- NUMB.'.

230 2 DECLARE NUMB BVTE.

131 2 signscnumB) - si one <nune.' xor i, . - compliment sign

232 2 DO CASE NUMB.282 2 HOLD" SO,23* 2 HOLD" RL.231 3 HOLD- R2.

235 2 ENO;

237 2 DO CTR-0 TO *-

233 3 H»SVTEvCTR)-?9H - HJSVTE-:CTR:>,

233 2 END;

2SS 2 END COMPLIMENT,

R2JZER0. PROCEDURE 3VTE.DECLARE I BVTE,IF vSHL':R2<0>, 4->O0> OR '.SHR<R2<S':', 4>O0>THEN RETURN FALSE.ELSE DO 1-1 TO Si

IF R2<I)O0 THEN RETURN FALSE.END,

RETURN TRUE,END R2J2ER0,

CHECK*RESULT PROCEDURE;IF SHR<R2CO>. 4;-9 THEN CALL COMPLIMENT^},IF SHR<R2>:0>, 4>09 THEN OVERFLOW"TRUE-

END CHECKiRESULT.

CHECKJ3IGN PROCEDURE.IF 3IGN0*.O.> AND £JGN0<1) THENDOi

SIGNG<2:> -POSITIVE.RETURN!

END.SIGNOC2>-NEGITIVE,IF HOT SIGNSkO) AND HOT SIGN0(1) THEN RETURN;IF SIGNBiB) THEN CALL COMPLIMENT': iJ I

ELSE CALL COMPLINENT<0>;EI4D CHECKJSIGN;

220 1 LEADINGJZEROES PROCEDURE CA0DR> BVTE;321 2 DECLARE COUNT BVTE, ADDR ADDRESS,322 2 CGUNT-0;222 2 BASE-ADOR;324 2 DO CTR-0 TO Ji

22! 2 IF uB-ISVTE-XTR) AND 0FOH) ;3 i THEN RETURN COUNT.32? 3 COUNT-COUNT 1,

323 3 IF >; BJBVTE < CTR ) AND 0FH> " THEN PETURN COUNT,330 3 COUNT-COUNT • 1.

221 3 END,332 2 RETURN COUNT.223 2 END LEAD I lidsZEROES.

234 1 CHECUOEC I MAL PROCEDURE.221 2 IF DEC-tPT20-'.CTR -CJBVTEO > > THEN33= 2 DO,

237 3 BASE- R2.333 3 IF DECSPT2 > CTR THEN CALL SHIFTsR I6HT{DEC*RT2-CTR5j346 3 ELSE CALL SHIFTJUEFT- CTR-0EOPT2.'.341 3 END,342 2 IF LSR0tNO*Z£R0ES< R2 • t IS - C*BVTE^2. THEN OVERFLOW TRUE.344 2 END CHECKJDECINAL.

24! 1 ADD PROCEDURE,246 2 OVERFLGu-FALSE.

CAU- AU.IGN.CALL CHECKJSIGN,CALL. ADDROC PI, R2>;CALL. 2HECK..SRE3ULT.

END ADD,

ADOJSES I ES PROCEDURE . COUNT J i

DECLARE •. I, COUNT, SVTE.DO 1-1 TO COUNT.

CALL ADD*RO< R2. R2

:

£91 12S2 2

£93 2

23Z 2296 3

2?3 2

499 2200 '-

Ml 1:o2 2"04 2

306 2

207 1

206 220? 2

210 2

ill 2

212 2

212 2314 2

216 2313 2

SiS 2

247 2243 2

J49 2

238 2

129

Page 264: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 265: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

;o4 1

JS3 2

266 2

ise 2:76 3

:n 2

S72 2

373 1374 2

S7S 2

277 2

278 2

379 2

END,£N& ADDiSERIES.

?5S 1 SET*MUUT*C'IV PROCEDURE,213 2 GVERFLGU-FALSE,260 2 SIGN0'.2> » ^NGT . 5I0NQC 8 ' XGR SIGN8C1)

3

261 2 CnLL FILL'. R2. 10. 0>.262 2 END SETIMULTtOIV,

P.1JGREATER PROCEDURE BYTE.DECLARE I BVTE.DO CTP-8 TO 9;

IF R1<CTR»<1 "AJH-ROCCTR?.- THEN RETURN TRUE.IF RKCTRXl THEN RETURN FALSE.

END.RETURN TRUE.

END PliGREATER.

MULTIPLY PROCEDURES VALUE J.

DECLARE VALUE 3VTE.IF VALUECO THEN CALL ADDISERIES': VALUE).BASE- RO;CALL GNEJL2.FT.

END MULTIPLY.

230 1 DIVIDE PROCEDURE,381 2 DECLARE CI, J. K, LZZ. I 71. x> BVTE.232 2 CALL SETV1ULTIDIV.232 2 IF '.L20 •LEADINGiZEPOES'; ROj/O

•:X - '.LZ1 » LEADINGJZEROES-: Rl,,, THEN234 2 DO.231 2 IF LZ0>LZ1 THEJJ

236 2 DO.237 4 BASE - RO;233 4 CALL SHIFTiLEFT.. I > LZ3-I &U;233 4 OECJPTO-OECtPTO - I.

294 4 X » in.22-1 4 END.232 2 ELSE DO,233 4 BASE . Rii234 4 CPiLl SHIFTJLEFT ;l .LZJ.-LZ0.>;231 4 • 0ECJPT1-DECPT1 * I.

236 4 X « LZO;237 4 END.236 2 END.233 2 DECPT2- IS - X DECPT1 - DECPTB,468 2 CALL COMPLIMENT (8);431 2 DO I - X TO IS;402 2 J-G.402 2 DO WHILE RiJGREATER,404 4 CALL ADD«e< RSL, PJ..'.

403 4 IF R4.;0.' * 99H THEN406 4 CPU.4 COMPLIMENT '.I;,44D7 4 J-J*l,403 4 END.409 2 H>SHR< I. l/.410 2 IF I THEN R2SIO-R2':!0 OR J,

412 2 ELSE R2 <

K

> -R2 i

K

i OR SHLSJ. 4>.412 2 BASE- RO;414 2 CALL ONEiRIGHT.415 2 END.416 2 END DIVIDE.

417 1 LOADJAJCHAR - PROCEDURES CHAP

.

413 2 D'ECLAPE CHAR BVTE,413 2 IF '.'SWITCH -NOT SWITCH) THEN420 2 3i3VTE<RJPTR,'.eJ3VTE':RiPTR, OR SHLvCHAR421 2 ELSE B*6VTECR*PTR »R*PTP-1 j-CHAR - 20H,422 2 END LGAD*A*CHAR.

^22 1 L0ADJNUM8EPS PROCEDURE': ADDR. CNT5,424 2 DECLARE ADDP ADDRESS. ' "I, CNT .'BVTE.

421 2 HGLD-RES^ADDR,.426 2 CTP-GNT.427 2 DO INDEX - 1 TG CNT-423 2 CTP.CTR-l.423 2 CALL LOAD*A*CHAR>.H*BVTE'. CTR ' ;

420 2 END.421 2 CA..L INCJPTF-?..

130

Page 266: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 267: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

END LOflDifJUMBERS,

423 1 SETiLOAO PROCEDURE : 3 1 ON* IN434 2 CM3CLARE SIGNilN BYTE.'433 2 00 CASE CCTR -CiBVTE<4,.>.4:; 3 BASE" RGj437 3 BASE- RU42S 3 BASE- F-2.

4;? 2 ENDj44u 2 DECtPTAiCTP •-CJBVTEO?.441 2 3IC-NB>.CTP:'-3IGHf IN,

4*2 3 call fill : base, la. a >

,

443 2 RIPTR-5,444 2 SWITCH-FALSE.443 2 END SETfLGAD;

4*5 1 LOAOiNUMEPIC PROCEDURE;447 2 CfiU. 2ET*LDAD<1:',443 2 CALL LOrtO*f4UneER3«:CJrtODfi':0;. cjbvte>;2> >:

445 2 END LOADJNUnERIC,

4 30 1 LGAD*NUN*LIT PROCEDURE,451 2 DECLAREv'LITiSICE. FLAG) BVTE.

412 2 CHflR»SIQH PROCEDURE.432 3 LITISI2E-LIT*SI~E - 1.

434 3 HOLD-HOLD » 1.

411 3 END CHARJSIGN.

415 2 LIT*SXZ£«C*8VTE<2>;417 2 HCLC-CJADDRO,-,433 2 IF H*SVTE<e>«'-' THEN45? 2 DO.460 3 CALL CHARTS I ON.461 3 CALl. 5ET*L0RDvNEGITIVE>.462 2 END.462 2 ELSE DO;464 3 IF H*BVTE •.£!>-' * ' THEN CALL CHARS3IGN,466 2 CALL SETJLOAD^POSITIVE.'i467 2 END.465 2 FLAG-0;46=. 2 CTR«LIT*StZ&47a i 00 tHoax«i to litjsizz,471 2 CTR-CTR-1.472 2 IF HJ3VTE<CTR.,«- THEN FLAG-i_ITiSIZE - CCTR»1j474 2 ELSE CALL LuAD*A*CHARi,H*6VTEvCTR} >,

473 2 END.476 I 0eC*PTfl<C*8VTg<,4>)» FLAG,477 2 CftLL INCJPTRC5>i475 2 END LOAD*NUriSLIT;

475, 1 STOREJONE PROCEDURE.

IF'ISMITCH -NOT SWITCH; THENB*evTE<a3"3HR<HfBVTEC6>. 4) OR 8'

ELSE DO.HOLD-HOLD-1.BsevTE':a>"<HJ3vTE<a> and aFH; or

END.BASE -BASE- 1.

END ST0R£*0NE.

4i-J 3

461 3

432 2432 2

434 3

433 3

436 2437 2

48S 1 3T0REJAS.JCHAR PROCEDURE . COUNT ?

.

43? 2 DECLARE COUNT 3VTE.453 2 SU ITCH-FALSE.451 i HOLD- R2 3.

432 2 DO CTR-1 TO COUNT,4*2 2 CALL STGREfCNE.454 2 END,433 2 END STCREJAS.SCHAR.

43-6 1 SSTJZGNE PROCEDURE ADDP •

.

437 2 DECLARE ADDR ADDRESS,453 2 IF NOT 3IGNtK2; THEN455 2 DO.See 2 oASE-ADOR.301 2 3-*evTE^o;»BJBVTE-.a.'502 3 END,332 2 CALL IHC*PTR*4>;3-34 2 END 3ETJZ0NE,

131

Page 268: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 269: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

joesor

us511512

SeT*SIGNi5EP PROCEDURE -At

DECLAF.E ADDF ADCP.ESS.£A5E"flDDRjIF SIGNG<2." THEN B*BVTEELSE B*8VTE<8>« - .

CALL INC*PTRC4>,END SETJSIGN*SEP.

512

515

STGREJNUMERIC PROCEDURE,CAU_ CHECKJOECIriAL,BASE^JADDR-.O. 1 * CJ8VTE«-2jCALL STCRE*AS*CHAR. C*BVTE<

EMC; STGRE*NUMERIC.

INPUT-OUTPUT ACTIONS

FLAGiOFFSET LIT "22 •.

EXTENTSOFFSST LIT '12',

RECSNO ^:t '22 .

PTRJOFFSET LIT -17'.

EUFFfLENGTH LIT - 128- .

VRRSSHD LIT -CR-.TERMINATOR LIT "IAH',EHD*OF*RECORD BVTE.INVALID BVTE.RANDOM*? I LS EVTE.CURFENTJFLAG BVTE,FCS*EVTE BASED CURRENT SrCB BVTE.FC3*ADDR BASED CORRENTiFCE addre:FCB.EBVTESA BASED CURRENT JFCB CI) 8VTE.FCB*RDDR*A BASED CURRENTiFCB ill? ADDRESS.BUFFJPTE ADDRESS.BUFPJEND score:-S.SUFFSTART ADDRESS.BUPFIBV-E BASED 3UFFJPTP BVTE.CGN*6UFF ADDRESS INITIAL . eoH > ,

C0N46VTE BASED CGN*6Urr BVTE.CON* INPUT ADDRESS INITIAL ,. B2H '

.

513 i. ACCEPT PROCEDURE.C20 ,2 CALL CRLF.

CALL PPINTJCHAR'.SFVO..'» CALL CR-LF. */

CALL r ILLCCONSINPUT, CCONSBVTE -C*8VTEC2jv '

CALL READ-:CON*BUFF>.CALL MOVE --CON* INPUT, RES^ CJADDRv • .' CON*BVTECALL tNC*PTR<3>;

END ACCEPT.

536111532

D I SPLAV PROCEDURE.DECLARE B*CNT BVTE, BLANk LIT 28H-",BASE-CJADDR'O.';CALL CRLP.&*CNT • C*BVTE'.2.-,DO UHILE

B*EVTE'. £*CNT «g*CNT - !. » BLANK.END.DO CTP » u TO 3*CNT.

CALL PRINT*CnAR' 6*SVTECCTR.'>,END.CALL INC*PTK<3>;

END D I SPLAV,

540JETJFILEJTVFS PFGCEDuRE'TVPE^

DECLARE TVRE BVTE.SASE»C*ADDF < '

i

5*EVTE ' PLA.j/OFFSET . »TVFE.END SETiFILEJTVFC.

GET*FILE*TVFE PROCEDURE BVTE.&A£E KCTADDr CO J.

RETURN S*£VT£<PLflG*OrPSETJEND OETJFILEi-T'-RF,

132

Page 270: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 271: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

543 i fETflfO PROCEDURE;343 2 END.50FSRECuRD. INv'ALID*FAL.2E.

330 2 IF CiADDR' 0.,-COF.F.ENT.FFC£ Then RETURN,. * 2T0PE CURRENT POINTERS AND 5ET INTERNAL. WRITE NARK */

151 2 BnSE=CURRENTJRCS.553 I FCS.»AD2'R*A-:FTR.SGFFSET '»SUFFJ:RTR,554 2 FCEiBYTEJA.. FLA6*0FF2ET ».:uRRENT*Fl.AO.

/*• LOAD NEW vALUES */

555 2 BUFFJEND"- EUFFfSTART L.CURRENTSrCB -CJADDR'.O .' '-START JOFFSET j

* 3UFFSLENG7H.555 2 CUFREN7SFLAG»FCE*6VTE*A.. FLAG*OFFSET li

537 2 EUFF*PTR=FCE.*ADDR*Ai.F , TRfOFFSET ',

558 2 END SETflfO.

353 1 GPENJFILE PROCEDURE-. TVPE.'.

360 2 DECLARE TVPE BYTE.361 2 GALL SET*FtLE*TVPSCTVPS);552 2 CTR*OPEN<CURRENT*FCB:«C*flOOR<0>>i362, 2 DO CASE TYPE-Jj

•» INPUT »/

564 2 DO.565 4 IF CTR-255 THEN CALL PRINTJERROR'. NF ,.

557 4 FCB.IADDRJft>RTR*GFFSET.'-CURRENTIFCB»10aH.56S 4 END.

t * OUTPUT */363 2 DO.370 4 CFILL DELETE.371 4 CALL Mfik'E<C*ADDR<0>>.372 4 FCBJADDRSA'.PTRfOFFSET.'aCURRENT.fFCo-STftpTJCFFSET-l.573 4 EJID.

... i-o «/574 2 DO.575 4 IF CTR=255 THEN CALL FATALJERROR> NF >.

377 4 FCB*ADDRSAk FTRJGFFSET .=CURFEN7*FC3 - 1G0H.57S 4 END.57? 2 END.560 2 CURRENT*FCE=»o. /* FORCE ft PftRflnETEB LOAD •'

5S1 2 CfiLL SET.sl.rG.562 2 CALL tf<C*PTR<2>;563 2 END 0PEN5FILE.

584 1 WRITEJMARK PPOCEDURE BYTE.535 2 RETURN POL'.CURPENTJFLAG. 1.'.

586 2 END URITEJMARk.

537 1 SETfUPITEtnPPK PROCEDURE,53S 2 CUPRENTJFLAG-CURRENTIFLAG OR BOH;53? 2 END SETiURITEfHARto

509 l WRITE*RECORD PROCEDURE.39i 2 IF NOT SHR''CURRENT*FLAG. 1 THEN Cfti FATAu-SERROF ' 'Ui J,

392 2 CALL SETJDNft.5?4 2 CUFRENT*FLAG»CORRSNT*FLAG AND OFH,533 2 IF CCTR -DISkJURITE? »0 THEN RETURN;537 2 INVALID-TRUE,53? 2 END UFITEtRECORD.

5«3 1 READSRECGF.O PROCEDURE.600 2 CALL 3ET*DnA;501 2 IF WPITEfMARk THEN GALw ..R ITE1PECGRD.63Z 2 IF '.CTR =OISk*FEAD '»0 THEN RETURN;505 2 IF CTR-1 THEN END*GF*RECGRO-TRUE.607 2 ELSE IHVSLID«TRUE;503 2 END READ*R£CuRD.

603 1 PEAOfSYTE PROCEDURE 3VTE.610 2 IF ':BUFF£PTP "BUFFJPTR * ±> .— BUFFEND THEN611 2 DO.612 2 CRLL READJRECORD.612 2 IF ENDfuFlRECCPD "hEfJ RETURN TERMINATOR.515 J BUFFJPTP-euFFJSTART,616 2 END.617 2 RETURN SUFFjsyTE,61B 2 END PEADiBVTE.

613 1 HAITEJBYTE PROCEDURE 'CHAR>.610 2 DECLARE CHAP BVTE.521 2 IF ' BUFFJRTR •£UFFJFT=»1. :» BUFFfEND ~*&l622 2 DO.622 2 CALL UR'ITE*RE2'2FO

133

Page 272: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 273: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

624 Z £UFF*PTR»SUrF#STAR I-

623 ~ EHD;626 2 CALL SET*URITE*MnRKj£27 2 3UFFf6VTE*CHAF.623 2 END WRITE*8VTEj

62? l WRITE*END*MARK PROCEDURE-623 2 CALL URITE*BVTE<CR>;621 2 CALL WRITE*eVTE'.*LFV;622 2 END URITE*END*MARKi _

£33 i READ*END#MARK PROCEDURE.534 2 IF READ4&VTEOCR THEN CAU_ PR INT* ERROR-- EM -

.

526 2 IP READ*BVTEOLF THEN CALL RRINT*ERROR». EM" >•

625 2 END PEAD*END*MARK.,

533 1 PEP.DfVMPIP.ELE PROCEDURE;64© 2 CfiLL SET* 1*0,

6*1 2 3ASE*C*ADD«Cl?i5-12 2 DO A*CTR»0 70 C*ADDft C2 > -1*542 S IF CCTR <8*8VTE" ASCTR ' «REflDSBVTE> } VAR*EH0 THEN544 3 DO.£45 4 CTP»kEAD*&vTE,646 4 RETURN.•547 4 END,548 Z IF CTR«TERPUNftTOR THEN54? Z 00,

(530 4 EMD#OF*RECORD-TRUEj531 4 RETURN.532 4 END.63- 2 END.634 2 CALL READ*END*nARK-633 2 END READ*VAPIABLEv

636 1 WRITE*VflR I ABLE PROCEDURE.637 2 DECLARE COU'JT ADDRESS;633 2 CALL SET*I SO-

633 2 3ftSE»C*ftODR<l'» -

660 2 C0UNT*C*ADDRC2};661 2 DO UHILE':b*8vteccou*t •COUNT-l^O' ">AND .CQUNTOG>.662 3 END'663 2 DO A*CTR-0 TO COUflT.

664 2 CALL WRITE#SVTECS»8VTE< ASCTR >>

,

663 i END.666 2 CALL URITE#END*MARtO667 2 END URITESVARIASLE'

663 1 READ*T0*MEMORV: PROCEDURE,663 2 CALL SET* 1*0.670 2 BASE"C*AODR' !.>.

671 2 DO A*CTR«0 TO C*ADDR< 2.--1,

672 I IF C8*6VTE< A*CTR »R£AD*3VTE-' -TERMINATOR THEN67*2 Z 00.674 4 END*OF*R£CORD*TRU£j673 4 RETURN.676 4 END.677 2 END.675 2 CALL READ*ENO*MARk,673 2 END R£AD*TG*MEMORV,

633 1 WRITE*FR0M*nEMORV PROCEDURE,531 2 CALL SET* 1*0.632 2 SASE«C*AODR 'l--.

632 2 DO A*CTR"0 TO C*PiDDR |.2.--lv

634 ? CALL idRITE*SVTE'.a*SVTE'.A*CTR/633 2 END,536 2 CALL UR ITE*EN0SMARKJ

637 2 END MR ITE*FROn*MEMORV.

RANDOM I -a PROCEDURES - - *

SET *PAHDG:i*PO INTER PROCEDURE;

THIS PROCEDURE READS THE RANDOM s.£V AND COMPUTESWHICH RECORD NEEDS TO SE AVAILABLE IN THE SUFFERThAT PECORO' IS MADE AVAILABLE AND THE POINTERSSET FOR INPUT OR OUTPUT

DECLARE "or TE*COUNT. RECCr.D > ADDRESS.

134

Page 274: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 275: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

sue S

591 2£92 2

-;?: 2-'?4 2S93 I

o?o 3

399 2

£99 3

7ea 3

-0i 3

-oi 4

TO* 4

703 4-06 2"07 2

"03 2

703 2"13 z:u z

ri2 2-ir. 2

EXTENT 3VTE.CALL SST*I*0;BVTE*C0UNT»< CfADDR *. 2 j ~2 . -CON-.'EFT.fTG.*H£:-. ( CsADDR C2>, CJ6VTE '. o ,

ReC0RO"SHRCEVTE*COUHT, 7 .,

£XT6HT-SHR<REC0RD. 7'j,

IF £XTENTOFCBJBVTE*fi<EXTEIiT*OFFS£TJ THENDO,IF WRITE*MARK THEN CALL URITEfRECORD.CFILL CLOSE ..C.JAD0R'Hi a

FCBsew TE*A •. EXTENTJGFF3ET . CXTENTiif open iCjaddrvO.' .:".-« them00.

IF SHR-. CURRENT JFLAG. i; 7HEN CALl. MAKE' CSAD0R-: .- '.

ELSE INVALID-TRUE.EriD.

END,6UFF*PTR-.:£VTE*COUNT AND ~FH.' * EUFF*57ART -l,IF FCE.*BVTEirnRECiNOjO'.CTR : -LOU :RECORD >AND 7FH/ THENDO,FCEJBVTE*ft<22.>-CTR.

CALL READ*RECOPD.END,

END SETJRAND0I1JPGINTER.

714 1 GETJRECtNljriBEF: PROCEDURE,71 J 2 DECLARE CRECNUPI. kj ADDRESS.

. I.CNT/ 3VTE.J' 4; ADDRESS LATA C10060* 1060. loo- Id >,

BUFFOS.' B't'TE.

715 2 P.ECJNUN-SHLvFCB*BVTE*A..EXTENT.tOFFSET.'. 71—FCBJBVTEfAC RECJNG.'717 2 DO I -8 TO 2,

71S 2 CNT-o,71? 2 C'O WHILE RECJNUf'O- :>* »JCI)>,720 4 REC*NUrv»RECJf*UH - k.

721 4 CNT-CNT » 1,

722 4 END,722 2 BUFF.: I ,-CNT 4 0".

724 I END.721 2 BUFFC4J-RECJNUN* 8'.

72o 2 IF <1 »Ci3VTE^3>,<-3 THEN727 2 CALL nOVEC EUFF-4-I, CiADDR<2i, I >,

723 2 ELSE DO.725 2 CRLL FILL'.CtAODRO). 1-5. ' i.

720 : CfILL MOVE'-" BUFF, CJAODRi: 2>»I—£. 3>,721 2 END.722 2 END GETJRECJNUMEER,

722 1 URITE-fZEROiRECORO PROCEDURE.724 2 DO A*CTR-1 TO CJAOORv.2...723 2 CALL wRITE*EVTE<d>.72E 2 END,727 2 END URITEX2ERGJRECGSD.

723 1 »4RITE*RfiN00M PROCEDURE.725 2 CALL SETJRANOGMJPG INTER.740 2 CALL WRiTSJ>FROM*MEMQRY;741 2 CALL IHCJPTR..?...742 2 END UPITEJRANOGn,

742 1 BACkJONEtRECCRD PROCEDURE.744 2 CALL SETflJO.743 2 IF vBIJFFJPTP -5UFF*P7p-.CfA0DR^2..-2.' -O-EUFFfSTART THEN RETURN.747 2 BUFF«PTR.6UFF«£ND-.EUFFiSTART - BUFFJPTR.'.748 2 IF > FC8*BVTE*A. RECtllG:. "FC8*8VTE*ftCREC*N0>-li"2S5 THEN74? 2 DO.730 2 FCB*SYTE*A^E:-:TENT*CFFSET -FCE.*8VTE*AvEXTErrr*0FFSETj-l.731 2 IF DPEIKCSACCiROVjO THEN732 2 DO,732 4 CALL PRINTJERRORC OP' >.

734 4 INVALID-TRUE,733 4 END,7Zi 2 FCE4!3VTEiA..RECiN0 ,

.-li7.737 2 END.733 2 CALL READJRECORD.73? 2 END BflCK*0M6*REC0RC»

INC1H0LD PPOCEDURE.HOLD-HOLD - 1.

135

Page 276: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 277: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

~ol 2 CTR-CTR - 1.--" 1 END [NOHOLD.

7S4 l LOAD* INC PPOCEDURE,7€Z z ns8VTE .. o > -eJ6VTE < ,

.

~66 2 BASE"6A3E*1.7S7 2 CALL INCJHOLD.733 2 END LOAD* INC.

7S3 1 CHE CKiEDIT PRGCEDURE<CHAR.'.770 2 DECLARE ChAR BVTEjm. I IF .CHAR- . Oft CCHAR»'/"773 2 ELSE IF CHAR" 3' TnEN774 2 Du.77? I H»BVTE<0i"'"76 3 CALL INCJHOLD.-77

L* END.7"*3 1 ELSE IF CHAR" A THEN77$ 2 C>0.

"TO : IF NOT i_ETTER'-B£6VTE':a732 : CALL LOAD* INC.-sr 2 END."S4 2 ELSE IF CHAR- '?' THEN

THEN CALL IttGSHQLOl

THEN CALL PPINTSERRORC ' IC

736 2 IF NOT NUMERIC CB*8VT6i.a>J THEN CAu. PRIfJT*£RROR< IC733 2 CALL L0AO*INC.73? ; END.730 2 ELSE CALt. LOAD* INC.

791 2 END CHECKSEDIT,

/*•-•-.,«••- MACHINE MOTIONS * - ».**»--

7=2 i STOP PPOCEDUPE.792 I CALL PRINT' C'ENO OF JOB 1 >,.

794 2 CALL BOOTERJ795 2 END STOP.

THE PROCEDURE SELOU CONTROLS THE EXECUTION OF THE CODEIT DECODES EACH OP-CODE AND PSRFORHS THE ACTIONS

795 1 EXECUTE PPOCEDURE.797 2 DO FOREVER;798 3 DO CASE GETJOPfCODE.

799 4 . •» CASE 2ER0 NOT USED -.•

•« 01 ADD •/

800 4 CALL ADD,

-- 32: SUE -/

sal 4 do.

SOI Z CALL COMPLIMENTED'.302 Z IF SIGNO^uj THEN SIGNOO)£05 Z ELSE SIGN0-.0j"R03ITIVE-.506 Z CALL ADD.807 Z END,

80S 4 DO.309 Z DECLARE I BYTE.310 * CALL SETJnuLTfOIV.311 Z DECPT1, DECPT2-DECPT1 • DECPTO312 J CALL ALLION.312 Z CALL MULTIPLY': SHR.RK I -9>,4>314 Z DO INDE-.'-l TO j;

31! o CALL M1JLTIPLY'.R1':I -1-1.SIS S CALL MULTIPLY^SnRvRl'.I,,317 E END.313 Z END.

.-'- 04 DIV «^

136

Page 278: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 279: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

320 4 SRfiNCH*FLfiG«NG7 3RfiNCH*FLfiG,

.••* 06 3TP «/

321 4 CALL STOP.

'* 07 STI -,

322 4 CfiLL STGRE*InriEolfiTE,

-- OS RrJO */

313 4 C'O.

324 S CALL STORE* IMPIEO I BTEj325 * CfiLL FILL-. R2. 10, 0>,

326 J R2(9)-l.827 I CALL ADO.323 I END.

- 09 RET •/

32S 4 00.

330 J IF CIfiD0P<0>Oa THEN331 3 00,

822 6 fi*CTP-C*fiOOR<0.>-

3T.T* 5 C-SmOC'R^O.""^334 6 PRGGRfiM*CGUNTER-fi*C7R,331 £ END.3C6 3 ELSE CfiLL INClPTR':i;,317 5 END,

.-'* 10 CLS •/

333 4 00;335 3 CfiLL 3ET1IW.340 3 IF WRITEfnfiRK THEN CfiLL wR i TEiRECORO.342 3 CfiLL CLOSE. CsfiGOR >: > •.

341 3 CfiLL IHCJPTRC2.'.844 5 END)

.-- 11 SER -/

845 4 00,946 5 IF OVERFLOW THEN PRGGRflnfCOUUTER - CtftGC'R^O:'

848 3 ELSE CfiLL INCtPTRv2>.343 3 ENO,

/• 12 BRN */

SSe 4 PROGRfiftiCGUITER-CJfiOGR'.O.*.

/• 12 OPN -'

SSI 4 CfiLL OPENir ILE^l;.

/* 14 GP1 m/

312 4 CfiLL 0PENiFILE'.2.'.

-- II 0P2 »/

833 4 CfiLL OPEN-SFILE-.'S);

.-» 16 RGT ./

334 4 00.

333 3 IF HOT 3IuH0':2.' THEN336 3 SRfiNCHJFLfiG-NOT BftfiNCH*FLfiG,

337 3 CfiLL. CGNOJSRfiNCHt.G.'.338 3 END.

— 17 RLT ».-

333 4 00,360 3 IF SXGNQ' 2. THEN361 3 5RfifiCK*FLfiG"N0T 3RfiNCH*FLfiG,362 3 CfiLL CONDSBRfiNCH. 0/,363 3 ENO.

/ * 13 RES •/

364 4 00,"63 3 IF R2*ZER0 THEN366 3 SPfi^CHJr Lfiu«NoT £RfiNCH.*FLfiG,

867 3 CfiLL CONOAoRfiNCH'.O •-

368 3 ENO

137

Page 280: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 281: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

* 19 INV -/

36? 4 CALL :rJCfi*iJr=Jr&ftnNCH-; IMVALIC'^-

- IB EOR -^

379 -i CALL INCRJGR*6PANCH-ENDiGP*RECCRD.'.

.• » II .ACC '/

371 4 CALL ACCEPT.

/- 22 DIS *•

372 4 CALL DISPLAV.

/» 23 STD •/

873 4 DO.374 3 CALL DISPLAY!371 3 CALL STOP.373 3 END.

/- 14 LDI •/

377 4 00.

373 5 CJADDP 1. 2.'"CONVERT* TOJHEX^ C.SAGOA' 0.. CJ6VTE'.I> '-I.

373 3 CALL inc*ptr<2>;338 3 END.

.-* 23 DEC •/

331 4 DO.

382 Z IP CfPODRvOi'OO THEN CJADDPv G.'-C-tADDR> .-!,

334 3 IP CJADOR- 9>»8 THEN PRGGRAnJCOUNTEP-C.SADDR^l.'.336 I ELSE CALL tNC*PTft<*>;337 3 END.

'* 26 STO */

383 4 DO.

939 5 CALL STORE-INUnERIC.839 5 CALL INCJPTR<4;.391 Z END<

/» 27. 3T1 •'

392 4 DO.

39J 5 ' CALL STOREJNUdERIC.394 Z CALL SETXZ0NE>:C-fADDR<a.'-CievTE'.2>-lJ.393 Z END.

39-3 4 DO.897 3 CALL STOREJNUMERIC.393 Z CALL SETiCCNE.CrADOR' i>> .'.

399 3 END.

-- 25 3TC -^

598 4 DO.

981 3 CALL CHECk'JDECINAL.902 3 BASE"C_JADDR<0/ CtEVTE,.2> - 1.

982 3 CALL STOREJASJCHAP'CsSVTE^I j - Lj-994 3 CALL SETJSI0Ni3EP':CJADDR<o^ » C*SVTE<i> -1J;393 3 END.

/* CO 5T4 -,.

99* 4 DOi987 3 CALL CHECK*DECiMAL.908 3 BASE"C*ADDftvu> » CJSVTE^C.'.999 3 CALL STORE*A£iCHAP. CJ8VTE-:1>-1.'.910 3 CALL ScT*3;GN.*3EP'C*ADDRaO* ..

911 3 END.

.-- CI ST3 ••

512 4 DO,

91C 3 CALL CHECkJOEClnAU914 3 R0O>»ft2t5> OR SIGN0C2-'513 3 CALL novEv P2 - 5 - C*8VTEv2J, C-tADDR<0^. C*6VTE\316 3 CALL INC.JPTR..4,,

317 3 END.

138

Page 282: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 283: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

920921922923924923926927922-

323?T.a

931

4 CAL^ uOADiNUfULIT.

,- 22 L01 */

« CALL LGAO*HUnERIC.

/» 34 LOS -.

5

6

DO.DECLhPE I SVTE.HOLD-CJfiODR ^ G /

.

IF CHECK*FOR*StSM<CTR -nfBVTE'ilDO.

CALL SfT*U)flBi<POSITIVEii66

5

6

END.

END.ELSE

END.CALL

I-I-l.

DO.CALL 3ET*LGAD-.NEGITIVE>.CALL lOAD*A*CHAR<.CTR-20NE:

LGADfNUNoERS^C.SADORCO:'. I >.

- a LC2 •'

4 DO;

!5

HOLD-C*ADDRv0>.IF ChEC*:-*FGR*3IuN-:HSoVTEv0: , TH

937 I 00.938 6 CAU- SETiLGSD' POSITIVE".'.333 6 CALL L0fiO*HUM8ERSCC*RO0R<0>. C*evTE<2>>.940 £ ENOi941 S EL5E DO.942 6 CALL SETIcuADaiEGI'IVE).342 6 CALL LGAO*NLMB£P.S'.C.*ADOR' 0.-1. CJEVTE'-2.'-l

J

344 £ CALL LGAD*ASCHAR..H.*3YTE-:0;-ZGNE>.343 6 END.946 3 END.

/» 26 LD4 «/

947 4 DO.94S I H0LD=C*ADOR < )

,

343" 3 IF HiBVTE . C*8VTE < 2 : - 1? » '*' THEN930 3 CALL 5ETJLGAD<15.911 3 ELSE CALL SET*LOAD<0^,312 3 CALL LOBD*HUMeERS<C#aOPR<a>.C*eVTE<23 -1>.352 5 END,

.-• 27 _D5 »/

334 4 DOl9!5 5 HOLD-CIADC'RCO...35-5 3 IF'IHSBVTE'. u.'- - '- THEN CALL 3ET*L0AD<1-'

.

336 3 ELSE CALi. SETtLOAD'C'.939 3 CALu LGAOSNU IEERS'.C JADDRk u. . CJBVTE< 2>-l}i3*0 3 END.

.' • 23 LD6 •/

961 4 DO.362 3 DECLARE I 3VTE.962 3 HOLD-CiADDRiO>.964 3 CALL SETiLOAD-.HSSVTE' I •Ct8VTEC2>-l>>i963 3 3ASE»8ASE - 3 - I.

366 3 DO CTR TO I

.

367 6 BJEVTE:CTR^-M*6VTE-:CTR^,963 6 END.363 3 B»BVTECCTR>«B*evTE<CTRl AND 0F3H.370 3 CALL tNCJPTRCSij971 3 END.

972 4 DO.972 3 BASE-CtADOftClJ-1;974 3 E*ADDR' G.-*CJADDR':2:-.373 3 PROGRAri*CuUNTER"C*ADD376 3 END.

/» 48 CNU »/

377 4 CALi. C0nP*NUM*UNSIG>4£D;

. - 41 CHS -

139

Page 284: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 285: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

CALL COMPSNUMSSI&N,

Cfiu. COMP*flLPHfi;

42 RW3 •/'

583 49*1 5?82 3?S* 3

DO.CALL 8RCK*0NE*REC0RDj

CALL MRITg*PR0M*M6M0RVJCALL IHC.SPTR..6,.

END.

44 DL3 ».'

983 4586 3937 3sea ssea s

DO;CALL BACMGNEJRECORD.

CALL UR ITEtZERGiRECORD.CALL INC-IPTR<3>.

ENDl

?91992

CALL READ*T0*P1EN0RY.CALL INCJPTRCoJi

??45?3996

CALL URITEJFROruMEMORV,CALL INCJPTRCo...

CALL READJVARIABLE.

/m 43 UVL

CALL URITE*VARIABL£.

y 49 SCR -/

ioee 4

1001 3

10021002

SUBSCRIPT(CJ8VTE<2)>-CONVERT *TG.*HEX •: CJAODR ^flj. C.S8V7E C

3

>

CALL INCJPTR<4>i

CALL STR I NG.ICOMPARE < 1 .

.

'« 31 SLT

CALL STRINGiCOHPARE'.O.:.

'» 32 SEQ •/

CALL 3TR I NGJCGPlPAftE <,;..

33 MOV «/'

ioar10031009

ion1012

CALL MOVE : RES ;CiADDR<lj .'. RESiCMDDRCej J. C-tAD0R>.2.' .'.

IF CJADDROiOO THEN CALLFILL<RE5^CJADDR'. 1, . • CSfl&ORiiJ . CJA0DRC3), ' V.

CALL IHCfPTRlSJi

34 RRS */

1013101410131016101?

CALL READJTOiMEnORY.CALL GETJRECJNUN8ER.CALL IHCiPTROJ.

/* 33 URS ••

1013101910201021

DO.CALL URITE*FROMSMEMCRV.

CALL GETJRECtNUMBER.CALL IMC*PTR<9>i

1£0

Page 286: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 287: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

iois1024loss102=1027

CALL SETiRANOOnjPGINTER^CALL REAO*Tu*MEMGRV,CALL INCJPTR.;a>,

/- 58 RUR

/• 19 DLR

CALL URITEJRANDOM.

CALL URITEiRANOun,

1020ioc-i

10:2lou1024

CALL S6T»RflNe0nsi>0INTERjCALL URITEiZERG-tRECORD.CALL INCJPTRO}.

1035lOio102719281029104010411042104310441041

CALL MOVE <GSA0DR<S)> CsADOR v :> . CJAOOR < 4 , ,

,

6ASE-C.SADDR <: !-

.

HOLD«C-SADOR < Q >

,

CTR-e.DO »MIL£ .CTR.!C*AD0Rk1.'vAND'.CTE<C.»AD0R.:4.

CALL CHECkJEDIT^HISV-EvO.'' ;.

end,if ctr < c-iaddr>.4; then

CALL FlLLCHOLt.. C-SADDR..4 >-CTR. ' "J,

NULL CASE

'• 52. OOP *>/

10471043104910JS1011101210:31C54io:slOSo

CiECLARE OFFSET BYTE.OFFSET-CONVERT*TG*HEX.:CiADOR^l/. Ci8VTE<l/-l),IF OFFSET > OtaVTE'.'O; • 1 THENDO.

CALL PPINTfERRGR': 'S&' '.

CALL INCJPTP..SHHC*SVTE.:o,, 1j • 6>.END.ELSE PROGF.AMJCOUNTES-CJAOORv OFFSET - 2;,

103T10131035

END. /* END OF CASE STATEMENTEND. /- END OF DO FOREVER -/

END EXECUTE.

iO£0 1

10il 1

1052 110*2 1

3A3E-C0DEJSTART.ppGGRAMSCOUNTER-SiADOR t; a , .

CALL EXECUTE.END.

='p<jGRAM EXECUTION STARTS HERE

MODULE INFORMATION

CODE AREA SIZE « 1E8AH 70J00VARIABLE AREA SIZE " 0OC1H 192DMAXIMUM STACK S-I2E * 0016H 22D1J42 LINES READ

PROGRAM ERROR CS,

END OF PL. M-30 COMPILATION

141

Page 288: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 289: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ISIS-II PLXfl-30 VS. 1 COMPILATION or MODULE PART2DEJECT MODULE -LACED !N "1 FART1. OBJCOMPILER INVOKED BV FLM30 Fl FART2 PLM

I PAGELEJ1GTH..50)FAPT2 - * MODULE NAME *t

DO.

/•» C060L COHPILEK - PART 2 «X

/'» 103H * MODULE LORD POINT --

.-'» GLOBAL DECLARATIONS AND LITERALS "X

1 DECLARE LIT LITERALLV ' L '. TERPlLLV

,

1 DECLAREHASHSTABJAOOR LIT , 2;&QH'. X* ADDRESS OF THE BOTTOM.OF

THE TABLES FROM PARTI *x

PRSSISLEN LIT '46',HAX*MEMORV LIT CieeHPASS1.ITOP LIT '3106HCR LIT 13 '.

LF LIT ia-.QUOTE LIT '22H".POUND LIT 23H-.TRUE LIT '1

',

FALSE LIT •a .

FOREVER LIT ' Uh I LEIFJFLAG BVTE INITIAI

DECLARE MAXRNO LITERALLV ' 82 . .•'« MAX READ COUNT •/MAXLNO LITERALLV 1.01'. X- MAX LOOK COUNT •/MAXPNO LITERALLV ' 120 ' .

.-'* MAX PUSH COUNT */MAXSNO LITERALLV 218'. X- MAX STATE COUNT *XSTARTS LITERAi_LV '1, x" START STATE "X

DECLARE READl'-> 3VTEDATA..O. 62. 5. 6. 3. 14, 16. 29. 22. 24, 26. 21, 32, 41, 42, 44. 45. 49, 12

. 54, 58. 63, 4S. 2S. 48. 23, 23. 25, 36, 27. 48. 5?. 11. 2*. 46. 24, 13. 28. 23. 26. 27

. 43, 2, 1, 40. 22. 46. 17. 1. 36. 2. 23. 42. 27, 19, 23, 58, 52. 64, la. 4, 28, 28, 2?. 43

. 61, 53. 1, IS. 7. 12. 10, 51. 3. 9. 14, 16. 23. 22* 24. 26. 31. 41, 42, 4*. 43. 43, 32.

34, 33, 63, 31, 7. 17, 1. 1. 3. 9. 14. 16. 23, 21, 22, 24, 26. 31. 41, 42, 44, 43, 45. 32

, 34, 38, 63, 43. 62, 3. 43. 23. 3. 3>,

DECLARE LOOKIC-.. SVTEDATA-,'0. 48, 8, 43, 3, 2. a, 43, 3. 1. 13. 3. 43, 3, 23, 42. 3. 2, 3. 27. 3. 7

, 3. 17. 3, 1, 13. 0. 33, 3. 33. 3. 33, 3, 33, a, 1. 13, 3. 12, 3. 1, 3. 31, 0. 48. 3. 23. 3. 3,

43. 3j,

DECLARE APPLVlv BVTEDATA<3, 3, 22, 8, 6. 3, 3. 77, 8. 8, 31, 3, 11, 6€. 68, 74, 73, 0. 0. 2. 31

.

, 2, 81, 3, 25, 3, 3. 3, 8, 37, 33, 35. 3, 3, 3, 3. 8, 3, 8, 65, 3, 8. 8, 3, 3, 3. S. 7, 3, 12,14

, 44, 3, 3. 2, 3. 6. 7, 3, 12, 12. 14. IS. 21. 23. 24, 26. 27. 23. 29. 22. 24. 43. 44, 73,

76. 77. 30. 8, 3. 20. 27. 28. 45, 52. 34, 8, 3, 7, 3. 13, 14, 23, 44, 0, 32, 8, 28. 3. 3, 15,

2262, 63. 8. 0, 3, 2, 31, 8, 8.'.

DECLARE REA02t»; SVTEDATA^a, 41, 6. 218. 5. 13. 33. 13. 17, IS, 28. 22, 24. 27. 23. 25. 20, 22

, 22, 34, 37. 38, 21, 231, 35. 34. 231. 203. 287. 236. 85. 173. 154, 132, 152. 133172

. 213. 203. 207. 266. 233. 232, 123. 26. 191, 137, 86, 2. 35- 4. 185. 188. 21, 167163

, 166, 161, 162, 14, 3. 181. 231. 23. 35. 29. 163, 2, H, 7. 164, 174, 184. 6. 5, 13. 33

. 15, 17, IS, 28. 22. 27. 28. 29. 26. 22. 33. 24. 37. 38. 134. 3. 13. 133. 131, 6. 5. 13. 32. 15. 16. 17. 13. 23. 22. 27, 23, 23. 33. 22, 32. 34. 37, 3S, 138. 48. 12a. 138. 13

. 8.a,.

DECLARE L00K2i»^ 8VTE0ATA..8. 12. 186. 22. 107. 153. 155. 26. 163. 142, 142, 124. 44, 135

. 45. 43. 110, 46. 136. 47. Ill, 1X2, 49. 113. 32. 114, 114, 34. 36. 113. 37, 116. S3

, 117. 35. 113, 113. 113, 62. 64. 120. 147, 67. 63. 135. 73. 122, 78. 126. 128. 123. 31,'.

DECLARE APPLV2':-. SVTEDATA-. 8. 8. 127. 66. 76. 103. 77. 127. 126. 183. 73. 72, 151, 153. 152

. 177, 143, 122, 133. 164. 104. 136. 102, 132, 125. 132.. 74, 168. 48. 63. 133. 132. 156. 154. 143. H. 124. 61- 54. 146, H, 172. 75. 155 33. 136, 30, H. 144, 57. 58. 53, 173, 123. 150. 42, 56, 37. 50, 53- 213, 50. 50. 217. 175 133. 38. 124, 33. 36. 137. 91, 153. 143. 53. 123. 123. 42. 143. 42. 52. 50. 51. 52. 202 202. 32. 211

142

Page 290: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 291: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

. 153, 153- 153. 153. 153. 155. 153. 200. 71. 70. 203. Ill, 171. 62. 55. 213. 163. 100

• 140141. 101. 101. 147. 32:..

DECLARE IN6EX1<») BVTEC'ATA.,0. 1- 113. 2. 22, 113. 113. 113. 113. 13. 23. 73. 113. 113. 113,

26LI. 32. 113. 13. 36. 113, 44. 113, 113, £S. 113, 113, 113, 113, 21, 42, 26. 113

. 113. 43. 44, 23. 23. 43, 113. 47, 44, 30, 113, 31. 30, 33. 34, 23, 35, 60. 23, SI. 62, 63,

66. 66. 66. 66. 67, 63- 65, 26, 70, 26, 73. 71, 73, 51, 52, 53, 54, 53, ^6, 113, 113. 117. 115, 73, 113. 2. 26. 1. 3. 3. 7, 5, 12. 14, 17, 15. 21, 23, 23, 23, 30, 32. 34. 36. 35.

41, 43, 43, 47, 45, 216. 123. 123, 176. 167, ISO. 204. 204. 1S3. 170, 173, 170. 170

. 214, 163, 1. 2. 2. 4, 4, 6. 6. 7, 7, 9, 5. 10, 10, 10, 12. 12, 12. 12. 12, 12, 12. 12. 12, li,

12, 12, 12- 12. 16. 18. 13, 18, 15. 15, 15. IS. 22, 22, 22, 23. 27, 27. 27, 23, 23. 25. 25. 29, 30, 30. 34, 34, 33. 33, 36, 36. 37, 37, 36, 33, 35, 35, 35, 40, 42, 43, 43, 44, 44, 43, 43, 46, 46. 46. 47, 47, 34, 33. 30. 30. 80. 68. 96. 56. 53. 56. 58. 100. 100. 100, 161. 101. 106, 106, 107. 107. 108. 111;.

DECLARE INOEXSClO BVTE&ATPK0, 1, 1. 20. 1. 1. 1. 1. 1. 2. 1. 18, 1, 1, 1, 3, 1, 3, 1. 1. 6. 1, 1. 1.

1. 3, 1. 1, 1, 1. 2, 1. 3. 1, 1, ia 1. 2. 2, 2. 1. 1. 2. 1. L. 2. 1. 1. 3, 2- 1. 1, 2, 1. 3. 1, 1. 1

. 1. 1, 1. 1, 1. 3, L. 3. 13. 2. 16, 1. 1. 1. 1. 1. 19, 1. 2. 2, 1. IS, 1, 20, 3. 2. 2, 2, 2, 3. 2.

. 2. 2. 2, 2. 3, 2. 2. 2. 2. 3. 2. 2. 2, 2, 2, 3. 12. 22- 36. 44. 43, 47. 45, 32, 34. 36. 37.

33. 39, 63- 64, 3. 1. O. 0- 1. 0, 1. 2. 2. 1. 2. 0. 0, 2. 1, 0, 2- 1, 0. 2. 1. 1. 3, 3, 2, 3, 0, 1,

2. 2. 4. 2. 3. 4, 4, 3, 1, 1. 2, 2, 0, 0, 1. 0, 0, 0. O, 0, 0. 0. 0, 0, 0, 0. 0, 0, 0, L, 1. 0. 1. 1

,

, 0, 1. 2. 0, 0, 0, 0, 0, 0, 0, O, 0. 0, 0, 0, 0, 0, 0, 3, 8, 0, 0, 0, 0, 0, 0. 0, 0. 0. 0. 0. 0. 8. 1

. 0>.

.'- END OF TABLES ••DECLAPE

/• JOINT DECLARATIONS »•/« THE FOLLOWING ITEMS ARE DECLARED TOGETHER IN THISGROUP IN ORDER TO FACILITATE THEIR BEING PASSED FROMTHE FIRST PART OF THE COMPILER.

0UTPUT1FCB <335 BVTE,DEBUGGING BVTE,PRINTJPROD BVTE.PRINT1T0KEN BVTE.LIST«INPUT BVTE.SEQfNUM BVTE,NEXTJSVM ADDRESS,POINTER ADDRESS, -'• POINTS TO THE NEXT BVTE TO BE READ »/

NEXTtAVAILABLE ADDRESS,NAX*INT*NEM ADDRESS.

.--I BUFFERS AND GLOBALS -/

IN-IAOOP ADDRESS INITIAL >3CH,.INPUTFCB 6ASEI> INADDR <ZZ> BVTE.GUTPUTJSUFF <1285 BVTE.OUTPUTJPTR ADDRESS,OUTPUT JENO ADDRESS,OUTPUTJCHAR BASED GUTFUTJPTR BVTE,

,'- MESSAGES FOR OUTPUT */

DECLAREERROR*NEARSJ ,-> BVTE DATA v' ERROR NEAR s'<.END»0F*PARTi2<«> BVTE DATA i END OF COMPILATION 1 >.

/« GLOBAL COUNTERS -/DECLARE

CTR BVTE,A*CTR ADDRESS,BASE ADDRESS.B-SBVTE BASEL' BASE BVTE,B*A0DR BASED BASE ADDRESS.

M0N1 PROCEDURE >.r, B) EXTERNAL.DECLARE F BVTE, A ADDRESS.

END M0N1,

M0N2 PROCEDURE F, S) BVTE EXTERHRL-DECLARE F BVTE, A ADDRESS,

E7JD M0N2.

143

Page 292: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 293: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

22 1 BOOT PROCEDURE EXTERNAL.23 2 END BOOT,

24 1 PR I NTCHAR P ROCEDURE C CHPiR •

,

23 2 DECLARE CHAR BVTE.26 2 CALL MON1 >:2. CHAR.,.27 2 END PR I NTCHAR,

23 1 CRLF PROCEDURE.29 2 CALL PRINTCHARCCR5;30 2 CFlLL PRINTCHAR,:LF>.21 2 END CRLF.

22 1 PRINT PROCEDURE <A).

21 2 DECLARE Pi ADDRESS.24 2 CALL M0N1 <9. A)

j

23 2 END PRINT,

26 i PRINTfEP.ROR PROCEDURE JCODE>J27 2 DECLARE CODE ADDRESS,23 2 CALL CRLF.23 2 CALL PR I NTCHAR'. HIGH v CODE '. >.

49 2 call printchar<louccode: >i

41 2 END PRINTiERPOR.

42 1 FATPLIERROR PROCEDURE t REASON >,

42 2 DECLARE REASON ADDRESS,44 2 CALL PRINTSEP.ftOR^REASON;-.43 2 CALL TIME<10.'.46 2 CALL EOOT,47 2 END FATALJERROR,

45 1 CLOSE PROCEDURE,45 2 IF M0N2<16. 0UTPUTfFC8^"2I3 THEN CALL PfiTfiUERRORCO.' 1

51 2 END CLOSE.

32 1 MORE* INPUT PROCEDURE BVTE.•* READS THE INPUT FILE AND RETURNS TRUE IF A RECORD

HAS READ FALSE IMPLIES END OF FILE •/

S3 2 DECLARE DCNT BYTE.34 2 IF <OCNT -nON2:2G. INPUT*FC£.>>>1 THEN CALL. FATALJERROP':36 2 RETURN NOT'X'CNT.'.37 2 END MOREJINPUT.

33 1 URITEtOUTPUT PROCEDURE CLGCATIONj..-'- WRITES OUT A 123 SVTE BUFFER FROn LOCATION*/

39 2 DECLARE LOCATION ADDRESS.60 2 CALL M0NK26, LOCATION), '- SET DMA -/

61 2 IF rtON2^21, OUTPUTJFCEiOO THEN CALL FATALJERRORv 'UP' >;

63 2 CALL nONl >: 26. SGH ) . / -RESET DMA -•64 2 END URITEJOUTPUT*

63 1 MOVE PPOCEDURE': SOURCE. DESTINATION, COUNT)./- MOVES FOR THE NUMBER OF BYTES SPECIFIED BV COUNT -/

£6 2 DECLARE SOURCE. DESTINATION:, ADDRESS.<3SEVTE BASED SOURCE, CWBVT6 BASED DESTINATION. COUNT)

67 2 DO UHILE ".'COUNT "COUNT - 1) O 233,63 2 D*BVTE-S-evTE.69 3 SOURCE-SOURCE -1,

70 2 DESTINATION - DESTINATION L,

71 2 END,72 2 END MOVE.

73 1 FILL PROCEDURES ADDR. CHAR, COUNT).-* MOVES CHAR INTO ADDR FOR COUNT EVTES -/

74 2 DECLARE ADDR ADDRESS,CHAR, COUNT. DEST BASED ADDR) BVTE.

73 2 DO WHILE vCOUNT -COUNT -1302S3J75 2 DE3T-CHAR,77 3 ADOR-AODR * 1.

73 2 END.73 2 END FILL.

SCANNER LIT3DECLARE

LITERAL LIT 25

'

INPUTJSTP l;t 43-PERIOD LIT '1 .

RPARIN LIT '3',

LPARIN LI" '2 ,

INVALID LIT 0',

/• * w * * SCANNER Th6i_ES * * -

DECLARE TQiCEMSTABLE ' * .< BVTE DATA/* CONTAINS THE TOKEN NUMBER ONEFQK EACH LENGTH OF WORD «<

144

Page 294: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 295: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

-.0. 0. 2. 7, 15, 25, 41, 46. 56. 60. 62

TABLE C«0 BYTE 0ATA<BV. GONOT . 'RUN. 'CALL ', ELSc'NEXT '. OPEN . PAGE'. 'Re

AFTER-, CLOSE . 'ENTER'.TIMES'. UNTIL'. USING'.

. 'IF', 'TO'. EOF '.

. 'EXIT', -FROM .

'

AD' . SIZE'. STOP-EQUAL'. 'ERROR'.WRITE'. ACCEPT'.

«D0 . END ', I-GINTO'. LESS'. MOVE'. THRU . ZERO"INPUT'. 'QUOTE . 'SPfiCE'3EF0RE'. DELETE'

DIVIDE'. OUTPUT'. DISPLAY'. GREATER"INVALID'. NUMERIC'. 'PERFORM', REWRITE'. ROUNDED . SECTION-DIVISION . MULTIPLY". SENTENCE . 'SUBTRACT . ADVANCING',

'DEPENDING . PROCEDURE'. ' ALPHABETIC 3.

OFFSET CliJ ADDRESS INITIAL/• fiUMBER OF BYTES TO INDEX INTO THE TABLE FOR EACH LENGTH .

0. 0, 0. 8. 26. 36, 146. 176, 222, 264. 2912,

UORDICOUHT <-> BYTE DATA/* NUMBER OF WORDS OF EACH SIIa. a, 4, 6, ii. 12, ;. s. 4, 2, u.

MAXJID*LENMAXJLEJJADDiENDLOOKEDHOLDBUFFERiENDNEXTINBUFFCHARACCUM '.II

J

DISPLAY <74TOKEN

LIT '12',lit -ia-,<-) BYTE DATA v EOFBYTE INITIAL '83.

BYTE.ADDRESS INITIAL C100H3BASED POINTER BYTE,LIT 33H .

BYTE initial;' -i.

BYTE,BYTE INITIAL '03.

BYTE, .'-RETURNED 'ROM SCANNER

/• PROCEDURES USED &V THE SCANNED

32 1 NEXT*CHAP PROCEDURE BYTE,33 2 IF LOOKED THEN34 2 00,£5 2 LOOKED-FRLSE,36 2 RETURN < CHAR -HOLD t.

3? 2 END;33 2 IF CPOINTER -POINTER * 13 >-39 2 DO;38 2 IF NOT MORESINPUT THEN?1 2 DO.32 4 BUFFERSEND- MEMORY92 4 POINTER- ADO*END.?4 4 END.93 2 ELSE PO I NTERi INBUFF.36 2 END.?7 2 RETURN CCHAR -NEXT).38 2 END NEXTSCHAR,

BUF-ERSEND 7HEK

100 2

101 2

182 1

102 2-U->

106 2ior 2

106 1

109 1

110 2

111 2

112 2

112 2

114 1Hi 2

116 2

113

GETiCHAR PROCEDURE./« THIS PROCEDURE IS CALLED WHEN A NEU CHAR IS NEEDED WITHOUTTHE DIRECT RETURN OF THE CHARACTER--CHAR-NEXTJCHAR.

END GETSCHAR,

OISPLAVJLINE PROCEDURE,IF NOT LISTJINPUT THEN RETURN,DISPLAY.; DISPLAY^ 3; - 13 - '*'.

CALL PRINT'' DISPLAV<1,3;D I SPLAY (0 3 -8;

END DISPLAV*LINE,

LOADJOISPLAV PROCEDURE.IF DISPLAV..'03<72 THEN

D I SPLAY ( D I SR LAY ^ 1 -01 SPLAY C 8 3 -1 3 -CHAR.CALL GETJCHAR.

END LOAOfOISPLAV;

PUT PROCEDURE,IF ACCUM <Q.' < 28 THENACCUM : ACCUM ^ .- -ACCUM v 3 *1 > -CrtAR.

CALL LGAD*DISRLAV.END PUT.

11?126121122122

EATJLINE PROCEDURE;DO WHILE CHAROCR.

CALL LOAC'tOISPLAV,END.

END EATJLINE.

124 GETfNOfBLANK PROCEDURE.

145

Page 296: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 297: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

129 3120 :

1-1 4

121 4

133 4126 3127 ;

133 4

140 4

Ml 3

141 2

14; 4

141 4

i*e 4

147 J143 3

149 2

130 1

LSI 2111 1

1S3 1

154 2

1S5 2

156 1

157 2

ne 2

113 1

i6a 2

162 2

163 2

164 2163 2166 3

167 3

163 2

163 2170 2171 2

172 1177. 2174 2

173 1

176 2177 2173 2

17? 3

ISO 4

161 4

132 4

132 2

134 3

131 2

136 1

137 '

133 2133 2

130 2131 4

133 4

134 2

' **

136 2137 2

133 2

IOC 3

201 2

201 2

202 2

DECLflRE i N. I ) BVTE.DO F0REV6RJ

IF CHAR » ' THEN CALL L0AD*OISPLAV,ELSEIF CHAR-CR THENDO.

CALL DISPLAVtLINE,IF SECltMUM THEN N"3; ELSE N-2,DO I - 1 TO Hi

CALL LGAOIDISPLAV.END;IF CHAR » '"' THEN CALL EATJLINE,

END;ELSEIF CHAR • ' ' THENDO.

IF NOT DEBUGGING THEN CALL EATiLINE.ELSECALL LOADiDISPLAV.

END.ELSERETURN;

END. ^* END OF DO FOREVER '/END GET*NG*BLANtO

SPACE. PPOCEDURE BVTE.RETURN :CHAR"' '

': OR : CHAR-CR).END SPACE,

LEFTIPAF.IN PROCEDURE BVTE.RETURN CHAR » <.'

i

END LEFTJPARIN.

PIGHTtPARIN PROCEDURE BVTE.RETURN CHAR * ' 1 ',

END RIGHTfPARIN;

DELIMITER PROCEDURE BVTE,/•* CHECKS FOR A PERIOD FOLLOWED. Bv A SPACE OR Cft»/IF CHAR O ' ' THEM RETURN FALSE,HOLD-NE;-;TfCHARjLOOKEX-TRUE.IF SPACE THB<DO.

CHAR - ' ',

RETURN TRUE,END.CHAR-' ';

RETURN FALSE.END DELIMITER:;

END1OFJT0KEN PROCEDURE BVTE,RETURN SPACE OR DELII1ITER OR LEFT»PBRIN OR RIGHTSPARIN.

END ENDJOFJTOKEN.

GETJLITERAL PPOCEDURE SVTE,CALL LOADED I SPLAV;DO FOREVER.

IF CHAR - QUOTE THENDO.

CALL LOAD*DISPLAV;RETURN LITERAL,

END;CALL PUT.

END.END GETJL.'TERAL,

LOOK-tUP PPOCEDURE BVTE,DECLARE POINT ADDRESS.HERE BASED POINT vl; BVTE, I BVTE.

riATCH PROCEDURE BVTE,DECLARE J SVTE;DO J-l TO ACCOM'. a>.

IF HERE^J - 13 © BCCUIKJ) THEN RETURN FAl.SE,END;RETURN TRUE.

END MATCH,

POINT-OFFSET *.ACCUn-:0) f - TABLE,DO 1-1 TO UORD*COUNT< ACCOM -.0 ) .'

.

IF MATCH THEN RETURN I,

POINT » POINT - ACCUMtoi.END.RETURN FALSE,

END L0OK*UP;

146

Page 298: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 299: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

293 2

zee 1

107 1"5<8 1

203 3

210 1

Hi 4

212 4

112 4

114 4

213 3

RESERVEDSUORD PROCEDURE BVTE./•» RETURNS THE TOKEN NUMBER OF ft RESERVED WORD IF THE CONTENTS OFTHE ACCUMULATOR IS P, RESERVED WORD. OTHERWISE RETURNS ZERO -..

DECLARE VALUE BVTE.DECLARE NUMB BVTE.if Rccuruo; •:- iiaxslen them00.

IF triune "T0KE»*TR6L£<BCCUMCe>55Oe THEN

IF LVALUE -LOOKSUP) O a THEMnumb-numb VALUE.

ELSE NUMB-e;END.

END.RETURN NUMB.

END RESERVEOSUORD;

113 1 GET*TOKEM PROCEDURE BVTE.213 2 ACCur-Ka.'-a.120 2 CALL GETfNOtBLRNKj221 2 IF CHAR-QUOTE THEM RETURN CJETILITEPAL.122 2 IF DELIMITER THEN224 2 DO.223 3 CFILL PUT.126 z RETURN PERIOD.11

7

1 END.113 2 IF LEFTJRARIN THEN229 2 DO;

238 1 CBLL PUT.111 z RETURN Lr-fiRlN.

232 Z END)233 2 IF RIGHTIPARIN THEM234 2 DO.233 2 COLL PUT.126 2 RETURN RpfiRIN.227 2 END.238 2 DO FOREVER.223 3 CALL PUT.248 2 IF END*GFSTGKEN THEN RETURN INPUTSSTR.242 3 END. /* OF DO FOREVER •/243 2 END GETXTOKEN.

/' END OF SCANNER ROUTINES ••

/- SCANNER EXEC m/

244 1 SCANNER PROCEDURE;243 2 IF-'TOKEN »G£T*TOKEN; a INPUTJSTR THEN246 2 IF •ICTR "RE3ERVED*U0RD > O a THEM TOKEN-CTR.243 2 END SCANNER.

243 1 PRIHT*ACCUM PROCEDURE.239 2 Accu;i<PCCuncQ>*i>-'* ,

211 2 CALL PRJNT< ACCUMil>>.212 2 END PPINTIACCUM.

213 1 PRINT*NUM£ER PROCEDURES NUMB j.

234 2 DECLARE-.NUMB. I. CNT, K) BVTE. J '-. BVTE DATA'. 160. li>

.

231 2 DO !« TO 1.

23o 2 CNT-B;257 3 DO WHILE NUMB '-•- CK -JCIJ),233 4 NW16-NUMB - K.

23? 4 CNT-CNT » 1.

260 4 END.2ol 2 CALL PRIN7CHAR..--0- CNT>.262 2 END.263 2 CALL PRINTCHARl '3- - NUMB;.264 i END PPINTJNUMBER.

END OF SCANNER PROCEDURES

'«.-.. 3VMB0L TABLE DECLARATIONS • • « -'

DECLARE

curisvm address. /-symbol eeimg accessed-svm60l based curssvm c13 bvte.3vne0ljaddr based cur*svm t!3 address,nextssvmjemtrv eased next*Svm address,hashjmask lit '2fh'.sjtvpe lit "i",displacement lit 12".

147

Page 300: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 301: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

266 1

257 2263 228? 1

273 1

271 2

272 a

273 i274 2

271 2

275 1

277 2273 2

27? 1

233 2

281 2

292 2

2ar 123J 22SS 2

285 I

297 2238 2

233 1

250 2

291 2

232 1

231 22?-» 2

2?* 1

296 2297 2

298 2

see 2

:<u 2

;02 1

263 226J 2301 2

OCCURS LITP«LENGTH LITfld*length LITLEVEL LITRELJID LITLOCATION LIT3TAPTJNAME LITFCBiADDR LIT

UNRESOLVED LITLABELSTVPE LITMULTSOCCURS LITGROUP LITNONSHUMER I C*L I

T

LITALPHA LITALPHAJNUM LITLITJSPACE LITLITWMJOTE LITLITIZERO LITNUMERIC*. I TERfiL LITNUMERIC LI'COMP LITA*ED LITA*N*ED LITNUMSED LIT

3 i

10',

SYMBOL TYPE LITERALS

-32-,128-

-9-.

•ie-.H-.

-12'.-13'.-16'.-21".-72-.-73-,'88'.

/• • * m SYMBOL TABLE ROUTINES « • - •,

SET.EAODRESS PROCEDUftE':AODR>.DECLARE AODR ADDRESS.

SVMSOLJAODR >' LOCAT I ON i -ADDR;END SETIADORESS.

GETJADDRESS PROCEDURE ADDRESS.RETURN SYMBGL*ADDR < LOCATION

>

t

END GETfAOORESS.

GETIFCBiAODR PROCEDURE ADDRESS,RETURN SYM60LJADDRv;FCB*ADDR>J

END GET*FCB*ADOR;

GETiTYPE PROCEDURE BYTE,RETURN SVMBGL'ISfTVPE).

END GET* TYPE,

SETtTVPE PROCEDURE i TYPE).DECLARE TYPE BYTE-SYMBOL C S*TYPE i-TVPE.

END SETJTYPE.

GETILENGTH PROCEDURE AODRESS.RETURN SYMBOL JAODR < FLDSLENGTH > .

END GETJLENGTH;

GETSLEVEL PROCEDURE 3VTE,RETURN SHR < SYMBOL i LEVEL > , 4) I

END GET*L£VEL.

GETIOECIMAL PROCEDURE BYTE,RETURN SYMBOL* LEVEL? and 0FH,

END GETJDECIMAL.

GET*P*LENGTH PROCEDURE BYTE.RETURN 3YMBGL*P*LENGTH>.END' GETJPJLENGTH,

BUILDJSYMBOL PROCEDURE <LEH>.DECLARE LEN BYTE. TEMP ADDRESS.TEMP-NEXTSSVM.IF <NEXT*SVM » SVnEGL'ILEN »LEH DISPLACEMENT j )

> MAXJMEMORY THEN CALL FATAL*ERROR'I ' ST ' }

.

CALL FILL CTEMP. 0. LEJU,END SUILD*SVMBOL.

AND*OUTJ0CCURS PROCEDURE TYPE*IN> BYTE;DECLARE TVPESIH BYTE,RETURN TYPE* IN AND 127.

END AND*OUT*OCCURS.

- PARSER DECLARATIONS -

148

Page 302: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 303: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

PSTACKSIZEVBLUESTATESTACkVALUE2VARCIDfSTACKIDJPTRMAXJEVTESUEiINDCOND-tTVPEHOLDJSECTIONHOLD*SEC*AODPSECT I ONfFLAGL*ADDRLJLENGTHLtTVPEL.IDECCON*LENGTHCOMPILINGSPMPMPP1NOLGGKCI- J. K3STATE

LIT Si

CPSTACkSIZE)<pstacksize><pstacksize>

<iee>^20.> ADC

BVTE.BASEDBYTEBVTE.ADDRESS.ADDRESS.BVTEADDRESS.ADDRESS.BVTE.BVTE,BVTE.BVTEBVTEBVTE,EVTE.EVTEBVTE.BVTE

.-» SHE OP PARSE STACKS-'ADDRESS. '- TEMP ''ALUES +/BVTE, .-- SAVED STATES •/

ADDRESS. .-- VALUE2 STACK-/BVTE, --TEMP CHAR STORE-

MAX* I NTJMEMINITIAL C > ,

INITIAL ca?

INITIALCTRUE>.INITIAL ^23S>.

INITIALvFALSE).— INDICIES FOR THE PARSER-/

INIT IAH STARTS 5,

CODE LITERALS

.-- THE CODE LITEPALS PRE BROKEN INTO GROUPS DEPENDINGON THE TOTAL LQ4GTH OP CODE PRODUCED POR THAT ACTION -

-'- LEriGTH ONE »/ADD LITSUB LITMUL LITDIV LITNEG LITSTP LITSTI LIT

,'- REGISTER ADDITION -//* REGISTER SUBTRACTION *//- REGTSTER I1ULTIPLICATI0N -//* REGISTER DIVISION '/,-« NOT OPERATOR »r/m STOP PROGRAM -^

/- STORE REGISTER 1 INTO REGISTER B •/

/" LENGTH TUO *'PNO LIT '8'. /- ROUND CONTENTS OP REGISTER 1

LENGTH THREE •/RET LIT '9',

CLS LIT 'IB'SEP LIT 11-

BRN LIT 12-OPN LIT '13 •

0P1 LIT '14-

0P2 LIT 'IS -

RGT LIT 'IS'RLT LIT 'XT=Ei LIT '13'

INV LIT •13

EOR LIT '20

RETURN #//" CLOSE -/• • SIZE ERROR •//- BRANCH *•/- OPEN FOR INPUT -//n OPEN FOR OUTPUT */r* OPEN POR 1-0 *•-'- REGISTER GREATER THAN -/.-'- REGISTER LESS THAN m,.'- REGISTER EQUAL ••/« INVALID FILE ACTION -r/' END OP FILE REACHED »/

.-'• LENGTH FOURACC LIT -21'.

DIS LIT -22'.

STD LIT -22'.

LSI LIT '24-.

'/

ACCEPT •/DISPLAV ••STOP AND DISPLAV ••LOAD COUNTER I MEDIATE

LENGTH FIVE */DEC LIT "23-

STO LIT -2S'STI LIT -27-

ST2 LIT -23st: LIT -S3'ST4 LIT '30'STI LIT -31-

/- DECREMENT AND 3RANCH IF ZERO *•/" STORE NUMERIC «v/• STORE SIGNED NUMERIC TRAILING -//• STORE SIGNED NUMERIC LEADING -.-'

•* STORE SEPARATE SIGN LEADING -/.'» STORE SEPARATE SIGN TRAILING */" STORE COMPUTATIONAL */

'- LENGTH SIX' '/LOD LITLD1 LITLD2 LITLDZ LITLD4 LITLOS LITLD6 LIT

LOAD NUMERIC LITERAL ••LOAD NUMERIC -.

LOAD SIGNED NUMERIC TRAILINGLOAD SIGNED NUMERIC LEADING -

LOAD SEPARATE SIGN TRAILING -

LOAD SEPARATE SIGN LEADING •<-

LOAD COMPUTATIONAL -.-

.'- LENGTH SEVEN ••PER LIT -39', .'- PERFORM -/CNU LIT -40-, /m COMPARE FOR UNSIGNED NUMERICCNS LIT -41-, /- COMPARE FOP SIGNED NUMERIC -'CAL LIT -42 . ,* COMPARE POR ALPHABETIC -,

149

Page 304: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 305: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

337 1

cos 2

33? 2

313 2

311 1

312 2313 2

314 1

311 2

IIS I

317 1318 2

313 2323 2

321 3

322323 3

324 2

321 2

32= 1

327 2323 2

32? 2

330 2

331 1

332 2

333 2

333 2

33? 2

340 2

341 2

342 1343 2

RUS LIT '43'. /» REWRITE SEQUENTIAL -/OLS LIT -44', ,"- DELETE SEQUENTIAL */RDF LIT '45", /« READ SEQUENTIAL */WTF LIT '46", .-'» WRITE SEQUENTIAL •/

RVL LIT 47', /* READ VARIABLE LENGTH */UVL LIT '43-, /-WRITE VARIABLE LENGTH -'

/* LENGTH NINE ••SCR LIT '49', /* SUBSCRIPT COMPUTATION *•

3GT LIT '50'

SLT LIT '51'

SEQ LIT -12"

MOV LIT '52'

/<* STRING GREATER THAN •//» STRING LESS THAN »//* STRING EQUAL ••/* MOVE */

'- LENGTH 10 -/RRS LIT '34'. /» READ RELATIVE SEQUENTIAL ••WRS LIT '35'. /-• WRITE RELATIVE SEQUENTIAL *i>

RRR LIT "36". •* READ RELATIVE RANDOM *•WRR LIT "37-, •* URITE RELATIVE RANDOM -/

RUR LIT '33'. /' REWRITE RELATIVE »•

DLR LIT "39'. /« DELETE RELATIVE •/

/» LENGTH ELEVEN <VMED LIT 63', /* MOVE EDITED s

i>* LENGTH THIRTEEN »/MNE LIT El', -* MOVE NUMERIC EDITED */

.-» VARIABLE LENGTH -/GDP LIT -62", /» GO DEPENDING ON *•

/» BUILD DIRECTING ONLV -/INT LIT -S3-, •* INITIALIZE STORAGE •/BST LIT 6-1'. /" BACK STUFF ADDRESS */TER LIT 'S3'. -"» TERMINATE BUILD *•SCO LIT 'So'; /» SET CODE START »•

, '. • * . PARSER ROUTINES •»•«»<DIGIT PROCEDURE tCHAR> BVTE.

DECLARE CHAR BVTE.RETURN <CHAR-:-'90 ANO ;CHAR3>"'3' >;

END DIGIT.

LETTER PROCEDURE BVTE,RETURN kCHAR>-'A"" > AND ^CHAR<»'Z' >j

END LETTER.

INVALID*TVPE PROCEDURE.CALL PPINTJERRORC'IT');

END INVALIDfTVPE.

SVTEWUT PROCEDURE COHEJBVTE i.

DECLARE QNEiBVTE BVTE.IF <OUTPUT#PTR:«OUTPUT*PTR 15 > GUTPUTJEND THENDO.

CALL WRITEJOUTPUT,; OUTPUT iBUFF'.'.

GUTPUT*PTR- GUTPUT-SBUrr,END)OUTPUT*CHAR»GNESBVTE.

END BVTEIOUT.

ADDPtOUT PROCEDUPE ;ADDR;,DECLARE ADDR ADDRESS,CALL BVTEfOUTCLOW^ADDP) .,

CALL BVTE*OUT-'HIGH C ADDR > : -

END ADDRiOUT.

INCJCOUNT PROCEDURE'XNT',,DECLARE CNT BVTE.Ir^NEXTSAVAILABLE -rJEXTJAVAILABLE * CNT>

>MAXJINTSMEM THEN CALL FATALJERRORC 'MO' 'J.

END INCJCOUNT,

ONEJADORiOPP PROCEDURE : CODE. ADDR )

.

DECLARE CODE BVTE. ADDR ADDRESS.CALL evTE*OUT.:CODE).CALL ADDP*GUT>.AODR.'.CALL INC*C0UNTC3>i

END ON£*ADDR*OPP.

NOTf IMPLIMENTED PROCED'URE,CALL PRINT JEBP.OR t'NI'ij

END NGTi IMPLIMENTED;

150

Page 306: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 307: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

248 2247 2

149 z2-0 2

SSI 22*2 2

353 2254 233S 3

35e 2

337 4

338 4

219 4

280 4

3S1 5282 I282 4

284 4

283 4

289 4

27a 5

sri 5271 8274 8

277 z276 4

377 2

273 2

279 2

28b 1

281 2232 2

232 2

234 1

231 2336 2

237 2

238 1

239 2

293 2

251 2292 2

292 1294 229J 2298 2

297 2

298 1

299 2490 2401 2402 2

•<02 1404 2407 2

407 2408 2409 2

410 1411 2412 2

412 2

411 2

418 2

417 2418 2

MATCH PROCEDURE ADDRESS..-» CHECKS AN IDENTIFIER TO 2EE IF IT IS III THE SYMBOLTABLE. IF IT IS PRESENT, CURJSVM IS SET FOR ACCESS,OTHERWISE THE POINTERS ARE SET FOR SflTRV*/DECLARE POINT R0DRE5S. COLLISION BASED POINT ADDRESS. < HOLD. I.'

IF 7ARCCO^>fiaX*ID*LEf4 THEN '.'ARC'' >=flAX*I DSLEN.HOLD-O.DO 1-1 TO VARCvOJ.

HOLD-HOLD-VARC ; I )

.

EiiorPOINT=HASHSTA6*ADDR * SHL^HGLD AND HA5HIMASK .. 13)

DO FOREVER.IF COLLISION"*} THENDO.

cuRisvn. coll I s

I

on-nexti svm,CALL eUILDfSVMB0L<VARCv'6^i.SYMBOL : PfLENGTH < -VARC < >

.

DO 1-1 TO VARC(0>.SYMBOLISTART*NAME->I J-VARCCI).

END.CALL SETiTVPEv UNRESOLVED.'. <"• UNRESOLVED LABEL "RETURN CUR*SVM.

END.ELSEDO.

CUR*SVN-COLL I S I ON.IF -:hold =getjpjlength»»varc<6:> thenDO,

I-1JDO WHILE SYMBOL. STARTtNAME - I >- VARC<I>.IF :! -I«1.>H0LD THEN RETURN.: CUR5SVM -COLLISION.'.

END.END.

END.POINT-COLLISION.

END.END MHTCHi

SETJVRLUE PROCEDURES NUMB),DECLARE NUMB AODRESS.VALUE<MP>-NUM£j

END SETJVALUE.'

SETJVALUE2. PROCEDURE SADDR).DECLARE ADDR ADDRESS.VALUE2 v MP > -ADDR;

END SETSVALUE2.

SUESCNT PROCEDURE EVTE2IF SSUB*IND "SUBJIND

SU6*IND"1.RETURN SUBSINDi

END SUB*CNT,

C00EJ6VTE PROCEDURE '.CODEDECLARE CODE BYTE,CALL BVTEiOUT.COOE.'.CALL INC-IC0UNTC1J.

END CODEiBVTE.

COOEtADORESS PROCEDURE .CODE.DECLARE CODE ADDRESS.CALL ADDR*OUT<CODE>.CALL INCiC0UNT.:2>;

END'CGDEIADDP.ESS.

INPUTtNUMEPIC PROCEDUP.E BVTE.DO CTR-1 TO VB8CO),

IF NOT DISIT<VSRC<CTRJ> THEN RETURN FALSE.END.RETURN TRUE.

END INPUTJNIJMERIC.

CONVERT* INTEGER PROCEDURE ADDRESS.ACTR»OiDO CTR-1 TO VARC':0>'

IF NOT DIGIT.rv'RRCSCTR.' . THEN CALL PP.INTJERROR( 'NN'AiCTR-SHLCACTR, 2 ,'»SHL' ACTR, 1> » VARC.CTR'. - '0

,

END.RETURN ACTP,

END CONVERT! INTEGER,

151

Page 308: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 309: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

11? 1

*2e 24 21 2422 2

423 2424 :

123 1

426 2427 2

423 2

42? 2

410 1

431 2

4:2 -1

;22 1

424 2

435 2426 2

441 1

-42 24-12 2444 2445 2446 244 e 244? 2453 2

451 2

152 1

453 2

458 245? 2460 2

461 z

462 2

4©-464 2465 2

466 2

467 2

463 246? 2479 2471 2

8ACH3TUFF PPOCEDURE CflD&l- «OD23iDECLARE ADD1. SOD23 BODRESSiCALL BVTEtOUTCBST;.CALL ADDRiOUTCADDi:/.CALL ADDK*0UTiAD02>.

END BAOCiSTUFF.

UNRESGLVEOISRANCH PROCEDURE.CRLL SETJVALUEiNEXTJAVAILABLE * J

CALL ONE*ADDRSOPP':BP-N. 0).CRLL SETJVALUE2CNEXTJAVA ILRBLE).

END UNRESOLVEDiBRRNCH;

BRCK*COHD PROCEDURE.CRLL BflCKSTUFrv"VftLUi<SP-l>. NEXTSAVAILABLE?

END BRCKiCONDi

SETJERRNOI PROCEDURE.CRLL SETIVRLUE<NEXT«RVflILRBL£).CRLL CGDEJADDR£S3.:0).

END 3ETJ6RANCH;

KEEPJVRLUES PROCEDURE.CRLL SETJVAL'JE i VRLLE C SR > ) J

CALL 5ETJVRLUE2'.VRLUE2':SP>END ^EEFIVRLUES.

S7DJRTTRIBUTE3 PROCEDURE ( TVPE >

.

DECLARE TVPE BVTE.CALL CODEfADDPESS':GETlrCE*flDDR).CRLL CODE!ADDRESS ^ GETJADDRESS ".

.

CRLL C0DEJADDRES3'.'G£7JL£NQTH.>;IF TVPE»G THEN RETURN.CURJSVM-SVM50L1ADDP >: PEL J 1 >

:

CALL C00E*AD0PESS^OET»ADDRESS>.CALL CODEIBVTECGETJLENGTH).

END STD*ATTR I BUTES.

REAOJUR I TE PROCEDURE : I NDEV. :•

;

DECLARE INDEX BVTE;

IF <CTR -GETJTVPEJ-1 THENDO.

CALL CCDEtevTECRDF-INDEX).CALL STDJATTRIBUTESCui.

END.ELSE IF CTF-2 THENDO.

CALL CCDE*6VTE>:RR3»INDE.X>.CRLL 3TDJATTRI=.UTES';i.'.

END;ELSE IF CTP-2 THENDO.

CALL CODE*BVTE:RRR»INOEX}.CRLL STDSATTRIBUTES':i.'.

EHDjELSE IF CTR-4 THENDO.

CRLL CODE J6VTE<RVL» INDEX.'.CRLL STD-SATTRIBUTESv'S;.

END.Ei_SE CRLL FRIN7*ERR0R< 'FT ' '.

END REAOJURITE.

AFITHHETICJTVPE PROCEDURE 3VTE..

Ir <<L«TVPE »flN&*OUT*OCCURSCL*TVPS> >2»«NUNeR ICILITERAL3RND LtTVPE'I-CONR ' THEN RETURN i_JT'r = E - NUHERICful

Cnu— ZN-AL \Z»" f'FE.

RETUPf. :.

END -V--;'ETIC*TYPE.

DEL»Fi*T PPCCEC' jPE' -'-AG-'.

0I2-ARE FLAG BYTEI- CTR-.OETjr.=E '«;

F "..AG "-E>. Z- COOg*S't~.*UftJ

152

Page 310: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 311: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

CALL ":**T7R loij . =.3

RETUKfi;END;I" >.C7P.»*j hND NOT PL5S THENELSE IF CTr<; • > -iiCj PLftu "nE/.

EL££ Co^_ ;(.vnLID*T'- = ECftLi. i~:*HTTRIEO~Ej' 0>.

COOEJBVTc DLS

4.-> 1 STTRIBUTES P».GCEDUR£j7-jC 2 CALL :CDE*ADDRE2S'._-iADDR -

331 2 Cni-L C0CE*EVTE-k.f«_ENu7H .

32-2 2 IALL CCwEic'T'TE- L*C'EC .

.

302 2 EHO STTRIEUTESi

!H i LGADSLfID ?ROCEDURE<S*PT?.ii

335 2 DECLARE SJPTR BVTE.306 2 IF -ASCTR » -nwJE^iipTR.. .• > NOM*Noi :ERICSLI ~J OR

•.ACTR - NUNERICJt-ITERAL. THEN337 I DO.

SCS Z LJAD0P-^ALUE2<3FTR ;,

3-?? 2 LiLENGTH-CGNJLENGTH,110 2 i_.JTVPE-AXCTP.i

311 I RETURNj313 2 END.313 2 if aactrolitjzero then514 1 DO.

313 : LfTVPE. LJAODF-HiCTR,316 2 LSLENGTH-1,317 3 RETURN.515 J END,313 2 CURi"SVM*'VALUE',S-*PTR>.326 I LiTVPE-GETJTVPE,321 2 LJuENGTH-GETJLENGTH.322 2 LiDEC-GETJDEClnAL.322 2 IFCL*fiDOP. »VFtLU£i'lSJPTS> ;«w then w>A0DP«'jE7*A0DRESS.323 2 END LOAD*LSID.

326 1 LOADJREG PROCEDURE ; REGJNO. PTR).327 2 DECLARE REGJNC PTR> BVTE,SIS 2 CfiUL LOBO*L*IDCPTR>i323 I CALL CGDEfevTECLOD-ARITHnETICJTVPE).37.0 2 CnU. ATTRIBUTES.321 2 CALL CODEiSVTE<REG»Nuj.37:2 2 END LGBDiREG.

3-2 i STOREtPEG PPGCEDUREv'PTR,;324 2 DECLARE PTR BYTE.S2S 2 CALL LOADiL-tlDCPTR).330 2 CALL CODEJEVTE^STO AS ITHnETIC-ITVPE -15

i

317 2 CAuL ATTRIBUTES.322 2 END STOPEJREG.

32? i ST0PE*CGN3TANT PROCEDURE ^u^P.EZS.340 2 IFv'MAXJINT^flEn "MAX* INTJMEn - VflRCC©J .-.'NEXTJAVAILABLE

THEN CALL FATALJERFORv 'MO '.

342 2 2ALL SVTS*OUTilriT>J343 2 CALL ADDfi*G'JT' MAXSINT*MEm

.

344 2 CALL AODRSCUT-'CONXLENGTH ' *VARCv&> j;

343 2 DO CTR » 1 TO CONJLENGTH.346 2 CALL SVTEiOUT':vARC'.CTRj^.347 2 END.345 2 RETURN nA.^JlrjTiMEM.343 2 END STOREICGNSTRNT,

333 1 NUriERICiLlT PROCEDURE BVTE.331 2 DECLARE Chap BVTE.332 2 DO CTP-1 TO VARC<3.'.332 2 IF NOT< DIGIT..CHA? : •VAftCvCTRj

>

OR •XHAR"'-'/ OR CHAR»'-'">OR >XHfiS»' 'v. THEN RETURN FmLSE.

333 2 END.336 2 RETURN TRUE.337 2 END NUMERICXLIT

S3* 1 ROUNDSSTORS PROCEDUPE333 2 IF /BLUS<SP>0« THEN360 2 DO.361 2 CALl. 20DEJEVTE'. Rf.2'.'

.

153

Page 312: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 313: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

552 Z CAi Cuutior"553 : END.554 2 CfiLL STOREi-REG^SP-555 I END R0UND.SSTGRE.

566 1 AOD5SUB PROCEDURE c INDEX/.557 2 OEClSRE HIDEX S'tTE.

565 2 CSLL LOSD-SREG^O. MPP1>,56? 2 IP ..'RLUECSP-IjOO THEN570 2 DC.171 2 CSLL LCSD.tREG<l. SP-2172 ; call eoo6*evTE<fl&o>j57": 2 CALL C0C'EIBVTE<S7I>.174 I END.171 2 CSLL LOSDiRECl. 3P-1>;576 2 CSLL CODEJBVTECSDD HIDE;177 2 CALL R0UHDJ3TGRE.373 2 END BDD1SUB.

575 1 MULT *D IV PROCEDURE : INDEX).583 2 DECLARE INDEX EVTE.LSI 2 CSLL LOflD*REG<0. MPP1J]SS2 2 CSLL LOSDfREGCl. SP-l/.552 2 CALL CODEJEVTE'.NUL - INDEX).554 2 CALL ROUNDiSTGRE,555 2 END MULT.JDIV.

CHSCKISUSSCRJPT PROCEDURE.CUR*SVM»VALUE<NP '.

IF GET*TVPg<fIULT*OCCURS THENDO.

CALL PRINTJERROR'. IS' 1,

RETURNJ. END.

IF INPUTJNUMEF.IC THENDOi

CALL 3ET*VALUE2<GE7*A0DRE33 CGET*LENGTH - CONVERT* I NTRETURN*

END)CUR*SVM»MATCH.IF <<CTR »GET*TVPEXNUrlERICj OR <CTP>COnP> THEN

CPfLL PRINTtEPRORv 'TE- ...

CALL ONEiflDDRIGPPtSCR. GETJAOORESS).CPlLL CGDEfBYTECSUBJCNT',.CPiLL CODE*BVTE<G£TJLENGTH).CALL 3ET»vflLUE2':SU3*IND>*

END CHECKiSUBSCRIPT,

LCRD*LA6EL PROCEDURE.CURjsym«value : rip >

.

IF , ASCTR «GET*ADDR£33>O0 THENCFtLL BACKfSTUFF ,A*CTR, VALU£2<MP) J.

CALL 3ET»HDDRE33','VflLUE2'.tlP • >

,

CSLL 3ETJTVPE-.LSeEL*TVPE>,IF -:SiCTR -GETJFCeiSODR.'OO THEN

CSLL BSCKJ3TUPP. SiCTR. MEXTIAVSILAELESYMBOL *ADDR C FCESADDR > »NEXT*AVA I LA6LE.CALL ONEiHDDRfOPP-:RET. O'J.

END LGADJLA6EL.

L0ADJSEC.ILA6EL PROCEDURE.A*C TR-VALUE •: HP >

.

CSLL SETJVSLJE-:H0LDi3ECTI0N).H0LD*3ECT I ON-SICTR.A*CTR*VALU£2CMP.;CSLL SETJVRLUE2 < HOLDJSECJADDR )

.

HOLOfSECJAODR » AICTR.CSLL LGADSLABEL.

END LOAD*SECILABEL.

625 1 LSeELJADDPIOFFSET PROCEDURE ' ADDR. HOLD, OFFSET•527 2 DECLARE ADDP AD0RE33.623 2 DECLARE .HOLD. OFFSET. CTR) BYTE.623 2 CURJSVM-ADDR;620 2 IFvCTF GETiTVPE)-LS6ELiTVPE THEN531 2 DO.

£32 2 IF HOLD THEN PETURN GETJADORESS.524 2 RETURN GET*FC&-fADDR.SiS 3 END J

636 2 IF CTROUNPE30LVED THEN CALL INVALIDtTYPE.£33 2 IF HOLD THEN

556 1

587 2

588 255 ? 2ssa 253-1 z

5S2 25?3 25>4 2

595 j

596 :

597 z

593 2

55? 2

600 2€01 2

iaz 2

633 2

634 2505 *

4-36 1607 :

601 260? £610 2611 I

611 7

612 2614 2

615 :

616 2

517 1

518 2

51? 7

620 2

621 2

622 2

622 2

624 2525 2

154

Page 314: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 315: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

62? 2 DO.648 2 A*CTR--GET*ADDPE3S.641 2 CALL SeT*S0C'R6SS<NEXT*ftVRILflBLS - OFFSET..642 2 RETURN A*CTR;543 3 END.544 2 A*CTR-GETtFCBJAODR.645 2 SVMB0LJA0DRCFCE.tHDDP''-NE.'-;TJAVAILH6LE - OFFSET.646 2 RETURN ASCTR.647 2 END LAEELJADDRiGFFSET.

646 I LABELJADDR PROCEDURE 'IRDOR, HOLD.' ADDRESS649 Z DECLARE ADDR ADDRESS.

HOLD BVTE.630 2 RETURN LABELJADDRiOFFSET <AODR, HOLD.631 2 END LA6ELJADDR;

632 1 CODEJFOR-tDISPLAV PROCEDURE rPOIf.

633 2 DECLARE POINT BVTE,634 2 CALL LOADiHIDiPOINT),633 2 CALL ONE.tADDR.rOPP CD IS. LJADDP;636 2 CALL CODE*BVTE<L-tLENGTH.>.637 2 END CODEiFORfDISPLAV.

633 1 AJAN.JTVPE PROCEDURE BVTE,639 2 RETURN ^L*TVPE-ALPHH.< OR vL*TVPE-ALPHA*NUn>,660 2 END HSANSTVPE.

661 1 NOT* INTEGER PROCEDURE662 2 RETURN L*0ECO8<SSI 2 END NGT*INTEGER;

576 2

571 2». 2 2

o73 2573 2575 2

£73 2

575 2

530 2

531 z

532 2

533 253* 255* 2537 2

533 2

533 z

SS9 z

5?1 2

532 255" 25?-i 2

5?5 2

NUMERIC*TvPE PROCEDURE BVTE,RETURN .L*TVPE>-NUnERIC*LITERAL;> AND <L*TVPEOC0nP '

,

END NUMERICiTVPE,

G£N*COHPAR£ PROCEDURE.DECLARE CHSTVPE, H*D6CJ BVTE,

<H*ADDR. HiLENGTH) ADDRESS.

CALL LOAD*LtID.:MP).L*TVPE-AND*OUT*OCCURS i LSTVPE :

.

IF C0NDSTVPE-3 THEN /- COMPARE FOR NUMERIC *i>

DO;IF ASAN*TVPE OR '.L*TVPE2-C0MP » THEN CALL INVALIDSTVPE.CALL SET SVALUE2 : NEXT *AVA I LAELE >

.

IF LSTVPE-NUMERIC THEN CALL CGDE*6VTE<CNU>.ELSE CALL C0DESBVTE^CN5>.CALL CODEtADORESS'iLSADDR).CALl. CODESADDRESS..LJLENGTH;.CALL SETJ3RANCH.

END.ELSE IF CCNDSTVPE-4 THENDO;

IF NUMERICSTYPE THEN CALL. INVALIDSTVPE,CALL SETJVALUE2..NEXTfAVAILABLE:*.CALL COOEIBVTE'XALi.CALL COOEJADDRESSCLSADDR:'.CALL C0DE*ADDRSS3>:L*LENGTH.vCALL 3ET*BRANCH.

END.ELSE DO,

IF NUMERICSTVPE THEN CTR=1,ELSE CTR-O,

697 2 H*TVPE"L*TVFE.693 2 H*DEC-L*DEC.699 2 h*ADDR»l.*ADC'R.700 3 KILENGTH-LSLENGTH,701 2 CALL LGADIL*ID<SP>.782 3 IF NUMEP I CSTVPE THEN CTR-CTR-1,704 C IF CTR-2 THEN -» NUMERIC COMPARE */701 I c.0.

706 4 CALL -OADSREG'.O. MP>.707 4 CALL 3ET*VALUE2vN£.\TSAVAILABL£-6>.705 4 CALL L0ADSREG..1. SP).789 4 CALL CODE*SVTEv SUB >

.

710 4 CALL COC'ESSVTE'.'RGT - COND*TVPE .

.

711 4 CALL SETSBRANCH;712 4 END.712 2 ELSE DO.

- Al.= HA NUNEF.'IC TOflFAFE -

155

Page 316: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 317: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

714 4 IF CH*DECOS3 OR ;H*TVPE»COMP"JOR (LlCECOe) OK CL*TVPE«COMPiOR .HJLENGTHOLiLENGTH- THEN CALL INVRLIO*TVPEj

716 4 CALL SET»VALUE2<NE>:T*AVAILABLEJ,717 4 CALL C0DESBVTS'CS0T*COMD*TYpe>J713 4 CALL CQD6»ADDRESS<H*rrODR:>;719 4 CALL CQDE*fiDC>RESS<L*HDDR>;726 4 CPU. CODEJADDRESSCHfLENGTH;,721 4 CALL SETJBRANCH;722 4 END;722 2 END.724 2 END GENiCOnPARE.

721 1 MOVESTVPE PROCEDURE BVTEi726 2 DECLARE

HOLDSTYPE BYTE.ALPHASNUflJMOVE LIT 9',

A.*N*ED*MOVE LIT '1'.

nuriER I ckiove LIT '2'.

NfEDSnOVE LIT •-',

727 2 LfTYPE»AND.S0UT*0CCUR3>:L*TYPE'.',723 2 IFk i'HOLD*TVPE -AND*GUT*GCCUR3^GET*TYPE:> ;»GROUP; OR <LJTVP£-GRGUP

THEN RETURN ALPHAJNUNSriOVE.720 2 IF HOLD-tTYPE -ALPHA THEN721 2 IF A*AN*TVPE OR <L*TVPE-AIED> OR ;HTVPE-A:«H*ED;

THEN PETURN ALPHAJNUrtxnOVE.732 2 IF HOLD*TYPE-ALPHA*NUM THEN724 2 DO.721 2 IF NGT»INTEG£R THEN CALL INVALIDITVPE.727 2 RETURN ALPHASNUf-UMOVE,728 2 END;

IF '-HOLDtTYPE^-NUNERIC:' AND CHOLDITVPE<-COnP? THENDO;

IF CLSTVPE-ALPHA) OR <LSTYPE>COHP) THEN CALL INVHLID*TVPEjRETURN NUMERICJMOVE*

END.IF HOLD*TYPE-ASN»ED THENDO.

IF NOTSINTEGER THEN CALL INVALIDiTVPE.RETURN ASNSEDSnOVE,

END;IF HOLD«TYPE-A*ED THEN

IF A*ANJTVPE OR ':L*TVPE2C0MP> THEN RETURN AJNJEDinOVE*IF HOLDSTVPE-NUMSED THEN

IF NUMERICJTVPE OR CL-tTYPE-ALPHAiNUrD THENRETURN N*SDSMOVEj

CALL INVALIDiTVPE,RETURN Oi

END MOve*TVPE;

760 1 0EN.W10VE PROCEDURE,761 2 DECLARE

LENGTH1 ADDRESS.ADDR1 ADDRESS.EXTRA ADDRESS.

"

762 2 ADDsAODiLEN PROCEDURE.763 2 CALL CODEJADORESSiADORl..,764 2 CALL CODEifiDDRESSCLiADDR^.763 2 CALL CGDEsADDRESS^LfLENGTH;

.

766 2 END ADOJADDJLEN.

767 2 CODEtFORIEDIT PROCEDURE;768 2 CALL ADD*ADD*LEN;763 2 CALL CODEJADORESSiGETJFCBiADDR ;

.

770 2 CALL CODEJADDRESSiLENGTHU,771 3 END CODEIFORJEDIT.

772 2 CALL L0AD5LJIDCnPPl>.772 2 CUR*SVM-VPLUECSP:>.774 2 IF >:ADDR1 -VALUE2CSP J J-0 THEN AODRl-GETtADDRESS;775 2 LENGTH1-GETJLENGTH;

777 2 DO CASE nOVEJTVPE.

/* ALPHA NUMERIC MOVE -/

773 2 DO.77? 4 IF LENGTHi;-L.*LENGTH THEN EXTRA-lENGTH1-l*LENGTH,7-31 4 ELSE DO.732 I EXTRA-6;732 5 L*LENGTH-LENGTH:L734 3 END.735 4 CALL CODESBVTECMOVV;

-~? 2740 Z

741 2

743 2744 z741 z746 2747 3

74? 3

710 :

731 2732 2754 273! 2736 2

737 2

733 2

735 2

156

Page 318: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 319: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

736 4 CALL. F"0DrADO*LEN.787 4 CBU- C0DE*fiO0ftES3CEXTRA>j733 4 END,

• * ALPHA NUMERIC EDITED *.-'

739 3 DO.750 4 CALL C0DEf8VTE;NED;.751 4 CBU. CODEJFGKiEDIT,"52 4 END.

."* NUMERIC MOVE *''

793 2 DO.794 4 CALL L0AD*REG;'2, MPP1).795 4 COLL 3T0RE*REG;3P:>.756 4 END.

/< NUMERIC EDITED MOVE */

797 3 DO.793 4 CALL CODE*BVTEvMNE>.799 4 CPU. CODEJF0R.IEDIT.eaa 4 call codejbvtE'Ljdec:'.801 4 CALL C0De«eVTE<6ET*OECII>lflL>;S02 4 END,382 3 END.304 2 END GE(J»MOVE.

SOS 1 CODEiGEN PROCEDURE; PRODUCTION).386 2 DECLARE PRODUCTION BVTE.387 2 IF PRINTJPROO THEN383 2 DO.335 3 CALL CRLF.31a 2 CALL PRINTCHARCPOUNDJ.311 3 CALL PRIHT*NUMBERCPROOUCTION>J312 3 END.

313 2 DO CASE PRODUCT I ONJ

"• PRODUCTIONS-/1

/» CASE NOT USED '/314 3

/» 1 <P-DIV> • PROCEDURE DIVISION <USING> <PROC-SCDv:-

313 2 DO,318 4 COMPILINO « FALSE.317 4 IF SECTIONSFLAG THEN CPU. LOADJSECtLASEL.319 4 END.

/• 2 :USING> - USING :IC-STRING>

S20 2 CALL NOT-tlnPLIMEHTEDj /» INTER PROG Com ••

.-- 3 S! •CEMPTv;.

321 3 i '- NO ACTION REQUIRED */

/• 4 <ID-STRING> > <ID>

322 3 ID*STfiCK<ID*PTft »a .'-VALUE;SP>./» 5 S! <ID-STRING3> <ID>

322 2 DO.324 4 IF;ID*PTR -IDPTR-l.i-20 THEN325 4 DO.328 5 CALL PRINTiERRORC ' ID" ).

327 5 ID*PTR-15;328 I END.329 4 id*stpck;idsptr>-vrlue;sp:'.833 4 END;

,•'» 5 •:pr0c-80dv> - ^paragraph}

331 3 ; /» no rction required -/

'» 7 s 1 <proc-eodv> ^paragraph;,

332 3 . .-'• no action required */

/• 3 <paragraph> - :id:- <sentenC6-l.1ST>

333 3 DO.

157

Page 320: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 321: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

334 4 IF 5ECTI0N*Fl.SG»e THEN seCTI0N*R.flG»2;335 4 call LOfio*useeu537 4 end.

.'» ? SI vIDO SECTION

313 I 00.

333 4 IF SeCTI0N*FUfl0Ol THEN343 4 DO.341 J IF SECTIONtFLAG-2 THEN CALL PRINTJERRGR^ PF ' >,

34; 3 SECTI0N*FLSG=1.344 5 .HGLDJSECTIOH-VRLUEiMP.'.343 3 H0L^*SEC*FIC'DP»VF<LUE2<MP>.346 5 END;347 4 ELSE CALL LOADfSEClLAaEL848 4 END.

/• 10 -ISENTENCE-L I ST> <SENTENCE> »

343 3 i /* NO RCTIOH REQUIRED *'

/» 10. S! •CSENTENCE-LISTV <SENTENCS3-

330 3 . .-'* NO ACTION REQUIRED »•

/• 12 <SENTENCE> = < I OPERATIVES »

331 3 . .'- NO ACTION REQUIRED -/

/- 13 S 1 ^CONDITIONAL^

332 3 ; /« NO ACTION REQUIRED •/

/« 14 \! ENTER <ID> C0PT-I03

333 3 CALL HOTJINPLIMENTED. .-'» LANGUAGE CHANGE '/

/- 13 < I MPERAT IVE3> - ACCEPT <SUBID> »

334 3 DO.333 4 CALL LOAO*L»IDCSP>.335 4 CALL ONEiADDRJOPPCACC. LJADOR),337 4 CALL CODEtevTE^LSLENGTH.i.838 4 END;

/- 15 S! <ARITHHETIO

339 3 . •* NO ACTION REQUIRED */

/' 17 S! CALL <LIO <USING>

860 3 CALL NOT* InPLInENTED. /• INTER PROG COnn -/

/* 18 S! CLOSE <ID>

361 3 CALL ONEJADDRJOPPCCLS. GETJFCSiAOOR )

.

/« 13 V <FILE-ACT>

662 3 . /* NO ACTION REQUIRED -/

/* 28 \: DISPLAV <LIT/ID> <0PT-LIT.ID>

363 3 DO.364 4 CALL CaDE«F0R*OISPLAV<NPPi;>.363 4 IF ''ALUE':3P>Oe THEN CALL CODE*FOR*DISPLAV< SP)

.

867 4 END.

.'•> 21 M EXIT CPROGRAn-ID>

363 3 ; /' NO ACTION REQUIRED *•

/• 22 S' GO <IDI'

363 3 CALL ONE*ADOR*OPP\£RN. LAeELJAODRi VALUE<3P). i.>a

/'» 23 S' GO :IC-STRING> DEPENDING CID>

370 3 DO.371 4 CALL CODE JSVTE' GDP >,

372 4 CALL CODE*BVTEi IDJPTR.'.373 4 CUR*SVN-VALU£-:SP5.374 4 CALL C0DEI6VTS.GETiLENGTH>.373 4 CALL C0DEiADDRE3S<GET*ADDP.£SS>.375 4 DO CTR-0 TO IDIPTP.377 3 CALL C0D£JADDRE3S'."LABEL»AD0RIGFFSET^ ID*STACIO- ID*PTR }. 1, 3..

373 3 END.

158

Page 322: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 323: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

373 4 END.

/* Z* 'n! MOVE CLIT/ID} TO 'CSUSICO ».

388 2 CALL GEMH10VE;

/* 2" S! open ':tvpe-actign> <:l;- *.

381 2 CALL GNE*ADDPSGPP<GPN - VALUE '. HPPl .- . GET*FC3-*A0DR .>.

/• 26 V PERFORM CIO <THRU> IFINIStO

832 3 DOj

is; 4 DECLARE '.ADDR2, ADDR2 ; ADDRESS.334 4 IF VALUE <SP-i.'»8 THEN ADDF2-LABELJA0D&SGFF3ET.: VALUE :nPPij . 0, Z>.

336 4 EI_SE ADDR2-LABELSADDR»GFFSET..'.ALUE'.3P-lJ. 8. 3J.

337 4 IF .:ADDR3 -VRLUE2':SP ' "•*> THEN hDDR2=nE>.t*AVAIlA6LE * 7.

383 4 ELSE CALL SACK'STUFF-: VALUE< SP J . NEXTiAvAILASLE • 7>.

338 4 CALL ONEfADDRSGPP* PER. LA6EL*ADDP' VALUE >:NPPiv. I' ,.

ail 4 CALL C0DE»ADDRES3^ADDR2^.332 4 CALL C0DEJAD0RES3CADDR3J.332 4 END.

.'» 27 S' <READ-ID>

334 2 CALL NOTJIrtPLIMENTEDi ,'• GRAMMAR ERROR '/

/* 23 V STOP CTEtfHINATE:- -

991 3 DO;356 4 IF /HLUE<SP>-8 THEN CALL CODE»BVTECSTP>.393 4 ELSE DO.333 I CALL GNE-IADDR*OPP'STD. VALU£2<SP>>;96fl S CALL C0DE*6VTE<C0N*LENGTH>,3B1 5 END,982 4 END;

/* 23 ^conditionals - ^arithmetic'.. <3 1 ze-error> »//• 29 :inperative> •/

902 5 CALL BflCKJCOND,

/" 28 V <FILE-ACT3> <INVALID> •-.IMPERATI V£3>

984 3 CPU. BACKJJC0NO;

/* 21 V <IF-N0NTERMINAL2- -XONDITIOfD :ACTI0N> EL./* 21 -CIMPERATI'-EC- -^

381 2 DO.

906 4 CALL BACXSTuFFi; VALUE >:riPPl.'. VALUE2': SP-2> J.

3B7 4 CHL4. BACKSTUFF.:VALUE<SP-2^. NEXTInvAI^ABLE J

.

388 4 END.

/• 22 S! crebd-id:' <spec:al> •; imperatives

383 2 CALL SACKSCONDi

22 •lARITHMETICD - ADD CL/IO <0PT-LXID> TO 'ISUBID} "/- 22 <R0UND> »/

91B 3 CALL ADD*SUS<8).

/* 34 S' DIVIDE <L.-ID> INTO •:3U8ID> ;R0UND'->

911 2 CALL rtU.T5DIV.lJ,

/- 25 S' MULTIPLV <L^'ID> 3V .3UB:D> O?0UND>

912 3 CfILL MULT*DIV<3>.

/* 36 V SUBTRACT <L- ID} :0PT-L^'ID> PROM -.

/* 26 csoeiD^ :round> -^

913 3 CALL ADDJ3U& CD;

'« 27 .;FILE-ACT2' - DELETE <JD2- -/

314 2 CALL DELJRUT : 6 >

.

y- 38 S' REURITE <ID>

911 3 CALL DEL-IRUT^l.',

y- 39 \' k-RITE <ID> :SPECIAL-ACT>

916 3 CALL READiURITE<l.'.

159

Page 324: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 325: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

s+ 40 <C0N0ITX0H> <LU/Xu> CHOT) XGNO-TVPE>

917 3 DO.913 4 IF IFSFLAG "HEN919 4 CO.SCO 3 IFtFLAG»NG7 IFiFLAG, •* RESET IFiFLAG ••

521 I CALL GGDEfBVTEiNEG;.912 3 END.923 4 CALL GENfCOMPARE.924 4 END.

/» 41 CCGND-TVPE3 - NUMERIC

923 3 CONDSTVPE-3.

.'• 42 V ALPHABETIC

926 3 C0ND*TVPE-4.

i>» 43 S! .CCOTIPAREC ;lit/id>

927 ; CALL KEEPIVALUES.

,'* 44 <NOT> • NOT

523 3 IF NOT IFJFLAG THEN929 3 CALL CODEfSVTEajEGi.933 3 ELSE IF*FLAG-NOT IFJFLAG. /- RESET IFJFLAG <•/

/<* 43 S! <EMPTY>

931 3 .-"- HO ACTION REQUIRED -/

/* 4S ^compared » greater

932 3 COND*TVPE-0;

/« 47 S' LESS

933 3 C3ND*TVPE-1.

/* 43 V EQUAL

934 3 CGNDJTVPE-2.

/« 49 <ROUND> » ROUNDED

931 3 GALL SETiVALUECl;;

/» 3B V <EnPTV>

935 3 /• NO ACTION REQUIRED «•

/- 31 -.-TERMINATED - CLITERALD

937 3 . /' NO ACTION REQUIRED •<•'

.'* 32 S! , RUN

333 3 , /' NO ACTION REQUIRED' - VALUE CSP) ALREADY 3ER0

/• 33 C3PECIAL3- - <INVALID>

939 3 . .-• NO ACTION REQUIRED -/

/* 34 V END

9443 3 DO.341 4 CALL 3ET*VALUE<2;.342 4 CALL CODE*BVTE<EOR..943 4 CALL SETJ8RANCH.344 4 END.

/* 33 <OPT-ID> - vSUEID:>

343 3 . /* VALUE AND VRLUE2 ALREADV SET ~/

/*> 36 \

'

9*5 3 , .-- VALUE ALREADV 2ER0 •/•'

•« 37 -ACTION:- - <IMFERATIVE>

9*7 3 CALL UNRESGLVEDJ6RANCH.

.-* 35 S! NEXT SENTENCE

160

Page 326: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 327: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

9"*8 3 CfiLL UNRES0LVED56RANCH.

/" 59 CTHRU> THRU CID>

349 3 CfiLL KEEWVBLUES;

.•'» 53 S!

358 2 . /* NO ACTION REQUIRED ••

.- 61 CFINIShO - <L/ID> TIMES

351 ; DO.952 4 CfiLL LGADfLtlDCNP:'.353 4 CALL ONEJAODRJCPP^LDI. LJADDR:'.354 4 CfiLL C0PE*evTS<t*L£HGTH5j355 4 CfiLL SET#VHLUE2<NEXT*RVAILflBLE>J95o 4 CfiLL GNESADORSOPP'. DEC. 3>,

357 4 CALL SET*VfiLUE<NEXTiAvfiILfi6L£.<.358 4 CALL C0DE*ADDRESS<3). END;

/» 62 S! UNTIL ^CONDITION}

363 3 CRLL KE£P*vfiLUES.

/* 52 S

!

361 3 . .'• WO fiCTION REQUIRED •/

/* 64 sINVALID> - INVBLID

962 3 DO,

352 4 CALL SETiVBLUECUi364 4 CfiLL C0DEJ8VTE'! INV>.955 4 CALL 5ET*6PfiNCH,356 4 END.

/- 55 <S I ZE-ERROR} . - SIZE ERROR

367 3 DO.968 4 CALL CODE*BVTE':SER>.963 4 CALL UNRESOLVED*BftANCH;970 4 END,

/- 66 -^SPECIAL-ACT} » <UHEN> ADVANCING ;HOU-MANV>

971 2 CALL NOTIIMPLIMENTEDj /- CARRAGE CONTROL •/

/- 67 S!

972 3 , /. NO ACTION REQUIRED '/

/• 63 CWHEIO - BEFORE

972 2 CALL r^OTJIMPLIMENTEDi '- CARRAGE CONTROL */

/* 63 V AFTER

374 3 CALL NOTIInPLIMENTEDi /» CARRfiGE CONTROL • .'

/• 73 <HOU-flANV> :: <INTEGER>

375 3 CALL NOT* INPLIMENTEDj -- CARRAGE CONTROL -/

/» 71 S' PAGE

975 3 CALL NGTflNPLItlEtlTED; /* CfiRRflGE CONTROL "/• 72 CTYPE-ACTION> :: INPUT

377 2 ; /» NO ACTION REQUIRED - VALUECSP) fiLREflDv ZERO •-

•* 73 S ' OUTPUT

973 3 CfiLL SETSVALUECIj,

,-••74 S 1 1-0

373 3 CALL 5ETIVALUE<2j<

" 75 ;subid> • ;subscript>

9s0 3 . /" value and value2 alreadv set m/

"6 S! -:id>

161

Page 328: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 329: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

9339*4935

/» NO ACTION REQUIRED »/

77 <ihteger> » •::npuT>

CALL SCT*VftLUE< CONVERT! INTEGER >.

73 <IK> - < INPUT}

CALL S6T*VHLUe<MflTCH>;IF GET*TVPE»UNR£SGLVSD THEN CAL- SET*VftLUE2-; NEXTJA7AILA8LE >

END.

333939990=91992>?3994991

1001 31002 *loo; 4100*4 4

1003 31003 4

1011 4

1012 41013 4

IF NUMERIOLIT THENDO.

CALL SETiVALUE;NUnERICJLITERAL>.CALL SETJVALUE2 i STGREJCCNSTANT )

.

EflDi

ELSE CALL SETIVALUECMATCH).ENDi

SO S! C3UBSCR I PT>

.'» NO ACTION REQUIRED »•

31 s ! ZERO

call set*value<littzero);

32 ^subscript;- - -:id> c <input> •

CALL CHECkiSUBSCRIPT.

33 <OPT-L/ID> - <L."'ID>

/- NO ACTION REQUIRED —-'

34 S ! <EHPTV>

/- VALUE ALREADY SET •/

31 <NN-LIT> - O.IT>

DO.CALL SETtvALUE'"ONINUMERICILIT>.CALL SETIVALUE2<ST0REiCGNSTfiNTij

ENDi

36 S! SPACE

CALL SETJVALUE<LIT»SPACE).

37 S! QUOTE

CALL SETSVALUE':LIT*QUOTE>.

63 -xiterao - CNN-LIT}

/» NO ACTION REQUIRED </

39 S! CINPtTO

DO.

IF NOT NUMERIC-SLIT THEN CALL INVALIDfTVPE,CALL SETJVALUECNUMERICILITERAL:'.CALL SETJVALUEl'. STORE ICONSTfiNT..,

ENDi

90 «•.! ZERO

CALL SETIVALUE'ILITIZERO).

91 <LIT/ID> - <U"ID>

,- tlO ACTION REQUIRED -/"

92 S! CNN-LI TV

/- HO ACTION REQUIRED •'

33 COPT-LIT/'tW - O-IT/ID}

-'» NO ACTION REQUIRED -'

162

Page 330: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 331: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

94 S ! CEMPTO

/» NO ACTION REOUIRED «/

91 CPRGGRAm-id;. :• -:ID>

CALL NOTJIMPLIMENTED. .— INTER PROG COMM

1023 2

1324 2

1B25 1

1025 2

1027 2

1023 I

102? 2

1030 2

1021 I

1632 2

1023 2

1024 I

1635 2

1037 1

1038 2

1023 2

1648 2

1041 2

1042 2

1042 2

1044 41041 4

1046 4

1047 4

1043 4

1849 2

1038 2

1831 1

1012 2

1032 2

1034 2

1033 2

1035 3

1033 2

103S 2

1056 2

1051 1

1062 2

1652 2

10.S4 210-53 2

1055 4

1057 4

1653 3

1070 31071 3

1072 4

1072 4

1074 ;

1073 2

1075 2

CLEAR THE STACK WHILE INCREMENTING

/* NO ACTION REQUIRED -/

/» 97 -:READ-ID} - READ <ID>

CALL REBOiURITECO);

/• 93 CIF-NONTERMINAl;- « IF

IFtFLAG - TRUE. /• SET IPiPLAG

END. /• END OF CASE STATEMENT */END CGDE*GEN.

GETIN1. PROCEDURE BVTE.RETURN INOEXICSTATE).

END GET INI,

GETIN2 PROCEDURE BVTE.RETURN INDE^CSTATE).

END GETIH2.

INCSP PROCEDURE,VALUE': SP »SP * 1J«8,VP.LUE2<SPJ"8lIF SP >- PSTACKSIZE THEN CALL FBTHL*ERPGR< 'SO' >.

END INCSPi

LOOKflHEBD PROCEDURE.IF NOLOOK THENDO;

CALL SCANNER.NOLOOK.FALSE,IF PRINTfTOKEN THENDO.

CALL CRLF.CALL PRINTtHunEERCTOKEfO.CALL PRINT-TCHARC- ->i

CALL PRINTfACOjn-END.

END.END LOOKAHEADi

NO*CONFLICT PROCEDURE <C3TATE; BVTE,DECLARE CCSTSTE, I, J. K1 BVTEiJ-INDEXliCSTATEi.K"J * INDEX2CCSTATEi - 1.

DO I "J TO K,

IF READKI^-TOKEN THEN RETURN TRUE.END.

RETURN FALSE.END NOiCONFLICT.

RECOVER PROCEDURE BVTE.DECLARE TSP BVTE, RSTATE BVTE.DO FOREVER.

TSP-SPjDO UHILE TSP O 233.

IF NOICONFLICT .'RSTATE "STBTESTACKCTSPM THENDO. /- STATE UILL READ "OKEN */

IF SPOTSP THEN SP " TSP - 1.

RETURN RSTATE.ENDlTSP - TSP - 1.

END.CALL SCANNER. /* TRV ANOTHER TOKEN ~S

END.END RECOVER.

PROGRAM EXECUTION STARTS ERE - - «/

18771073

/• INITIALIZATION "/

TOKEN-52. -* PRIME THE SCANNER WITH -PROCEDURE- -'

CALL M0VE'-'PASS1JT0P-PASS1*LEN, OUTPUTJFCB. PA5S1SLEN ;

.

/» THIS SETSOUTPUT FILE CONTROL BLOCKTOGGLES

163

Page 332: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 333: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

READ POINTERNEXT SVM6GL TftBLE POINTER

1079 1 OUTPUT-tEND-^GUTPUTiPTP « GUTPUTJ6UFF-1 ,fl28.

ioao 1 00 JHILE COMPILING;1081 2 IF STATE > MftXRMO THEN /- READ STATE -/

1082 2 DO;1033 3 Call incsp.1884 3 STATESTACK.SP- - 3TATE, /• SAVE CUPRENT STATE ~r

1083 3 CALL LOOKAHEAD.1036 3 I -GET INI,

ies7 2 J - I » GETIN2 - 1,

1088 z DO I-I TO J.

less 4 IF READl^I. - TOKEN THEN1098 4 DO.

/* COPV THE ACCUMULATOR IF IT IS AN INPUTSTRING- IF IT IS A RESERVED WORD IT DOESNOT NEED TO BE COPIED "

1091 5 IF CTQKEM»INPUT*5TR) OR * TOKEN-LITERAL; THEN1092 5 DO K-0 TO ACCUMO).1093 i, VARC C K ; -ACCUM < K

>

.

109* 6 END.1095 3 STATE-READ2<I^.1096 z NOLOOK-TRUE,1097 5 I -J.

1096 " END,ELSE

1099 4 IF I -J THEN1100 4 DO.1101 z CALL PRINTJERROR': 'NP'>.

llui z CALL PRINT>: ERROP-tNEARfl).1103 3 CALL PRINTJACCUM,1104 z IF ESTATE. "RECOVER. .'-0 THEN CGMP ILING-FALSE,1106 END,

Ere.1103 : END;

ELSE/- END OF READ STATE */

1109 2 IF S'TATEDMAXPNO THEN /» APPLV PRODUCTION STATE '/111B 2 00.1111 3 MP-SP - QETIN2,1112 2 MPP1-MP * 1,

1113 3 CALL COOE*GEN*:STATE - MAXPNO;.1114 2 SP-rlP.1111 3 I-GETINlj1116 3 J-STATESTACKCSP>;1117 3 DO WHILE <K -APPLVlCI/> O AND JOt1118 4 I-I 1.

1119 4 END;1120 3 IF <K.»APPLV2<n.'«a THEN COMPILING-FALSE.1122: 3 STATE-1C1123 : END,

ELSE1124 2 IF STATE<-MAXLNO THEN ,'«LOOKAHEAD STATE-'1121 2 DO,1126 3 I-GE TIN1.1127 3 CALL LOOKAHEAD.1128 3 DO UHILE :K -L00K1' I j><3-3 AND TOKEN OK,1129 4 I-I-l.1136 4 END.1131 : STATE-LOOKED.1132 : END,

ELSE1133 2 DO. /•PUSH STATES*/1134 3 CALL INCSP.1131 2 STATESTACK<SP '-GETIN2,1136 3 STATE-GETIN1.1137 3 END.1138 2 END. /<* OF UHILE COMPILING -/1139 1 CALL evTEtOUTCTER;.1140 1 DO 1JHILE OUTPUTJPTSO OUTPUTJSUFF.1141 2 CALL BVTEtOUT.TER).1142 2 END;1143 1 CALL CLO:SE.1144 1 CALL CRLF.1145 1 • CP.U- PRINTS EN0*0F5PARTJ2>,1146 1 CALL BOOT,1147 1 END.

MODULE I NFORHAT I ON

CODE AREA SICE

164

Page 334: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 335: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

ISI5-II PL-'M-SG V2. 1 COMPILATION OF MODULE DECODEOBJECT MODULE PLACED IN ?1 DECODE OBJCOMPILER INVOKES BV PLNSa Pi DECODE. PLM

JPAGELENGTHOO.DECODE DO.

? 2

10 2

11 2

12 113 214 2

11 2

16 1

1? 2

13 2

1? 2

28 111 2

22 2

23 2

24 2

2B 227 2

28 1

25 2

ca 2

21 2

22 2

22 4

24 4

/* THIS PROGRAM TAKES THE CODE OUTPUT FROM THE COBOL COMPILERAND CONVERTS IT INTO A READABLE OUTPUT TO FACILITATE DEBUGGING

/* « * 1G0H LOAD POINT '/

DECLARE

LIT LITERALLY LITERALLV.BOOT LIT •9'.

BDOS LIT -3',

FCB ADDRESS INITIAL CSCH),FCBJSVTE BASED FCB -.Li BYTE.I BVTE.ADDR ADDRESS INITIAL ^lOOH/CHAR EASED ADDR BYTE.ClfiDDR BASES ADDR ADDRESS.BUFFiEND LIT OFFH'.FILE* TYPE C*;- BYTE DATA C'C. I'. U'>,

M0N1. PROCEDURE .'F. A).

DECLARE F BYTE. A ADDRESS.L SO TO L /- PATCH TO JMP Z */

END M0N1.

M0N2. PROCEDURE ;F. A; BYTE,DECLARE F BYTE, A ADDRESS.

L GO TO L. /* * > PATCH TO " JMP 3 " - - *>/

RETURN Z.

END M0N2.

PRINTJCHAR PPOCETXJRE : CHAR j;

DECLARE CHAR BYTE;CALL M0N1 C 2. CHAR t .

EN£> PRINTJCHAR;

CRLF ; PROCEDURE.CALL PRINTJCHARC12;.,CALL PRINTICHARCIG); '

END CRLF.

P- PROCEDURE :ADD1>.DECLARE ADD! ADDRESS. C BASED ADD1 CI) BYTE,CALL CRLF.DO i»e TO i.

CALL PR3NT*CHBR<C<I>>)END;CALL PRINTJCHAR.:' '1,

END P.

GETICHAR. PROCEDURE BYTE.IF CADDP «ADDR 1^>BUFF*END THENDG,

IF M0N2C20. FCB^Oa THENDG.

CALL PC '. 'EMO'3 >l

CALL TIME':iO>l2S 4 L: 00 TO L /' PATCH TO "JMP 0008" - -

io 4 END.27 1 A0DR«80H.ZZ 2 END;29 2 ,

RETURN CHAR.40 2 END GETJCHAR.

41 1 DtCHAR PROCEDURE i OUTPUT J6YTE'.-

.

42 2 DECLARE OUTPUT-teVTE BYTE.43 2 IF 0UTPUT*8YTE21G THEN CALl pR INT JCHAR-: OUTPUT*BYTE * 2SHJ43 2 ELSE CALL PR INT*CHAR'0UTPUT*6VTE - 27H...

H 2 END DSCHAR.

47 1 D . PROCEDURE <: COUNT ',,

43 2 C'ECLARE: COUNT. J ADDRESS.43 2 DO J»l TO COUNT;

165

Page 336: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 337: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

CALL OSCHAR>.SHRmjET*CHAR,CALL DSCHARvCHAR AND OFH.-

CALL PRINT*CHARv j.

END.END D,

PR INTEREST PROCEDURE.DECLAREF2 LIT '?-.

<^4

P5= 5F7FSFiaFllF13GOPINTBSTTEF;cd

LITLITLITLITLITLITLITLIT-ITLIT-ITLITLITLIT

'32'•33'-49''14-00'51'•52'

ej55

C7 2

59 2~4 i

59 2"4 2

79 2

34 2

33 2

94 2

»9 2

104 2

109 2111 3

111 2121 2125 2129 3

131 2125 2

133 2

F2 THEN RETURN.F"2 THEN DO, CflLLF4 THEN DO.F3 THEN DO.F5 THEN DO,F7 THEN DO.F9 THEN 00.F18 THEN DO.Fll THEM DO.F12 THEN DO.

IF CHAR < GDP THEN DOlIF CHAR-GDP THEN DO,

CPlLL OCi>i CflLL DiSHLiCHflft. !)»!).IF CHAR-INT THEN DO, CALL 00}IF CHAR-B3T THEN DO. CflLL DC4)IF CHAft-TER THE7I DO. CALL PC. <

L GO TO L, y PATCH TO "JffPIF CHAR-SCO THEN DO. CflLL D<2>IF CHAR O OFFH THEN CALL P(. i

END PRINTJREST,

IF CHARIF CHARIF CHARIF CHARIF CHARIF CHARIF CHARIF CHARIF CHARIF CHAP

Oil;CALL DC2>CALL Ov2>CflLL Di4jCALL DCS)CALL D'. 5;. R

CflLL DCS;.CALL DC9J.CALL DiIOj.CALL 0C12).

RETURN,RETURN!RETURN;RETURN,RETURN,RETURN,RETURN.RETURN.

. RETURN,RETURN,

END.END,END.END.END.END.END.EI ID.

END.END.

RETURN, END.CALL D^CJADOR *RETURN, END.

END.'>.3" * » •/ END,RETURN, END,

XXX')>i

RETURN, END.

/» PROGRAM EXECUTION STARTS HERE *•

139 1 FCS-tBvTE-:C2;. FCSiBvTE<ai - a,

143 1 DO 1-3 TO 2.

141 2 FCB»BVTE< I»9)-FIL£*TVPEiI>.142 2 END.

IF M0N2-:i5« FCS>-;35 THEN DO. CflLL P< CZZ2L GO TO L ENC-.

/„ . • • PATCH TO "IMP BOOT

14a 1 » DO WHILE li

149 2 IF GETJCHAR O 55 THEN 00 CASE CHAR.151 3 .-» CASE a NOT USED •/152 Z CALL PC i ADO'>i.tsa 3 CALL P\ '."SUB','' i,

154 - CALL PC. C -MUL '.>;>

1SS C CALL p< c-Div-:oi155 Z CALL p< C -NEG'i^157 Z CAU- p< < 'STP'^^iIIS Z CALL PC C'STI'ii;1S9 z CALL PC C'RNC'JJ)150 z CflLL p< C" RET-; >.

151 z CALL p. :-CLS-.o,152 3 CflLL PC C •SER-.';,153 3 CflLL p< < BPN ' > >i

154 j CALL p.. i'OPN' ,);

151 z CALL PC. ( 0P1'^>.155 z CALL p.. i 0P2 •>>.

15T 3 CflLL p< ( - RGT •) ..

.

153 3 -ALL PC ' RLT-..,,153 2 CALL PC ; -reo-,,,170 3 CALL PC. : ' imv .»>,

i-i 3 CALL PC C -EOR')>,172 2 CALL Pi i 'ACC >.•;

173 Z CALL PC <• D I S ' / >

174 Z CALL p, < STD'-"),ITS Z CflLL PC C LDI- .'>.

175 z CALL PC i 'DEC' •;,

177 z CALL PC STO ' > >

166

Page 338: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 339: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

173 ; CALL Pi i-STl'))L?9 2 CALL P. CST2'))136 3 call Pi i-ST3",>1S1 : CfiLL Pi C'ST4'5)13; 2 CALL P< C'ST3'>5it: 2 CBLL PC. •:-L00".'>134 2 CALL Pi i LD1 ' ) >

1SS 2 CALL PC i L02'))133 2 CALL Pi i ' LOS • >

)

137 2 CfiLL PC. i LD4 ' ) J

133 2 CfiLL c • C'U>4' ))

13? 3 CfiLL Pi i ' L03 ' ) -•

130 2 CfiLL PC i 'PER').*

131 3 CBLL p< i'CNU' j >

is; 2 CfiLL Pi i'CNS'))1ST, 2 CBLL PC C CAL

'

1 )

l?t 2 CfiLL pi i-RUS- >>

131 3 CALL PC i OLS' >

)

ISi 2 CALL PC. C ' ROF ' J )

137 3 CfiLL PC. i -UTF>)133 3 CfiLL PC. C'PVL >>139 2 CfiLL PC. i-UVL')>tea 3 CfiLL PC. i SCR'))201 3 CALL Pi l SGT'))202 3 CALL PC. i SLT'))203 2 CALi- PI. i SEO-))204 3 CfiLL PC i MOV ' )

)

201 3 CALL Pi i RRS-))203 3 CfiLL Pi i-URS')/207 3 CBLL PI. i-RRR);20S 2 CALL PC l URR'),209 3 CfiLL ?i i ' RUR ' )

)

210 2 CfiLL PC. i ' DLR ' >

)

in 2 CfiLL p'^C -MED' >>

212 3 CALL Pi i - MNE ' ) )

212-

CfiLL PC i'GOP'))214 2 CALL Pi. t'HIT'))215 2 CfiLL Pi i -33T-J)213 3 CfiLL PI i ' TER ' )

>

217 3 CALL p< i SCO >>

213 3 EIIO, .-» OF CASE STAT219 2 CALL PRINTiREST,220 2 ENOi /* ENO Or 00 WHILE221 • EHO;

MODULE INFORMATION

COOE AREA SIZE - 0371HVARIABLE AREA SIZE > 0013HMAXIMUM STACK SIZE -» OOOEH213 L I TIES REAO

PROGRAM ERROR <S>

ENO OF PLXM-38 COMPILATION

167

Page 340: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 341: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

LIST OF REFERENCES

1. Craig, Allen S. MICRO-COBOL An Implementation of NavyStandard Hypo-Cobol for a Micro-processor basedComputer System.

2. Aho, A. V. and S. C. Johnson, LR Parsing, ComputingSurveys, Vol. 6 No . 2, June 1974.

3. Bauer, F. L. and J. Eickel, editors, Compiler ConstructionAn Advanced Course, Lecture notes is Computer Science,Springer-Verlag, New York 1976.

4. Digital Research, An Introduction to CP/M Features andFacilities, 1976.

5. Digital Research, CP/M Interface Guide, 1976.

6. Eubanks, Gordon E. Jr. A Microprocessor Implementationof Extended Basic, Masters Thesis, Naval PostgraduateSchool, December 1976.

7. Intel Corporation, 8008 and 8080 PL/M ProgrammingManual, 1975.

8. Intel Corporation, 8080 Simulator Software Package, 1974.

9. Knuth, Donald E. On the Translation of Languages fromLeft to Right, Information and Control Vol. 8, No. 6,1965.

10. Software Development Division, ADPE Selection Office,Department of the Navy, HYPO-COBOL, April 1975.

11. University of Toronto, Computer Systems Research GroupTechnical Report CSRG-2, "An Efficient LALR ParserGenerator," by W. R. Lalonge, April 1971.

12. Digital Research, Symbolic Instruction DebuggerUser's Guide, 1978.

168

Page 342: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 343: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

INITIAL DISTRIBUTION LIST

No. Copies

1. Defense Documentation CenterCameron StationAlexandria, Virginia 22314

2. Library, Code 0142Naval Postgraduate SchoolMonterey, California 93940

3. Department Chairman, Code 5 2

Department of Computer ScienceNaval Postgraduate SchoolMonterey, California 93940

4. Assoc. Professor G. A. Kildall, Code 52KdDepartment of Computer ScienceNaval Postgraduate SchoolMonterey, California 93940

5. Lt. M. S. Moranville, Code 52MsDepartment of Computer ScienceNaval Postgraduate SchoolMonterey, California 93940

6. ADPE Selection OfficeDepartment of the NavyWashington, D. C. 20376

7. P.R. Mylet8005 Kidd St.Alexandria, Va. 22309

169

Page 344: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet
Page 345: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

177913ThesisM998 My letc ' 1 MICRO-COBOL: a subset

of Navy standard HYPO-COBOL for micro-com-puters.

i

t|

/I

Thesis -w-rniM998 Mylet ' ' /913c.l MICRO-COBOL: a subset

of Navv standard HYPO-

COBOL for micro-com-puters.

Page 346: MICRO-COBOL : a subset of Navy standard HYPO-COBOL for ...micro-cobol asubsetof navystandardhypo-cobol formicro-computers phil«prussellmylet

thesM998

MICRO-COBOL

3 2768 00192609 „DUDLEY KNOX LIBRARY 6.7