MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS...

of 353 /353
Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL: an implementation of Navy standard HYPO-COBOL for a microprocessor-based computer system Craig, Alan Scott Monterey, California. Naval Postgraduate School http://hdl.handle.net/10945/18198

Embed Size (px)

Transcript of MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS...

Page 1: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Calhoun: The NPS Institutional Archive

Theses and Dissertations Thesis Collection

1977-03

MICRO-COBOL: an implementation of Navy

standard HYPO-COBOL for a microprocessor-based

computer system

Craig, Alan Scott

Monterey, California. Naval Postgraduate School

http://hdl.handle.net/10945/18198

Page 2: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

mm

Imawflft

• •-

MV'«'"./''''''.•

Page 3: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 4: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 5: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 6: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 7: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 8: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

NAVAL POSTGRADUATE SCHOOLMonterey, California

THESISMICRO-COBOL

AN IMPLEMENTATION OFNAVY STANDARD HYPO-COBOL

FOR A MICROPROCESSOR-BASED COMPUTER SYSTEM

by

Alan Scott Craig

March 1977

Thesis Advisor: Gary A. Kildall

Approved for public release; distribution unlimited.

T178074

Page 9: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 10: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

SECURITY CLASSIFICATION OF THIS PACE (Whmn Data Bntatad) DUDLEY KNDY ! meiBV

REPORT DOCUMENTATION PAGEI. REPORT NUMBER 2. GOVT ACCESSION NO

READ INSTRUCTIONSBEFORE COMPLETING FORM

3. RECIPIENT'S CATALOG NUMBER

4. TITLE (and Subtttf)

MICRO-COBOLan implementation of

Navy Standard Hypo-Cobolfor a microprocessor-based computer system

3. TYPE OF REPORT k PERIOD COVEREDMasters Thesis;March 1977

«. PERFORMING- ORG. REPORT NUMBER

7. AUTHOR^

Alan Scott Craig

I. CONTRACT OR GRANT NUMBERS.)

t. PERFORMING ORGANIZATION NAME AND ADDRESS

Naval Postgraduate SchoolMonterey, California 93940

»0. PROGRAM ELEMENT. PROJECT, TASKAREA 4 WORK UNIT NUMBERS

II. CONTROLLING OFFICE NAME AND AOORESS

Naval Postgraduate SchoolMonterey, California 93940

12. REPORT DATE

March 197713. NUMBER OF PAGES

170U. MONITORING AGENCY NAME * ADORESS<(/ dlttarant from Controlling OHIcT)

Naval Postgraduate SchoolMonterey, California 93940

IS. SECURITY CLASS, (ol thtt rdport)

Unclass i f ied

1 5a. DECLASSIFICATION/ DOWNGRADINGSCHEDULE

16. DISTRIBUTION STATEMENT (ol tnia Kaport)

Approved for public release; distribution unlimited

17. DISTRIBUTION STATEMENT (ol tha aaatract antarad In Block 20. II dlllarant /ran Report)

18. SUPPLEMENTARY NOTE5

IS. KEY WORDS (Continua on eawaraa aid* II nacaaaary mid Idantlfy by kloek ntmkar)

COBOL, compiler, formal grammar, microprocessor, microcomputer,LALR(l), HYPO-COBOL

20. ABSTRACT (Contlmf on rawaraa */*• II naeaaaaty and Identity by klmmk mamkar)

A compiler for ADPESO standard HYPO-COBOL has been imple-mented on a microcomputer. The implementation provides nucleuslevel constructs and file options from the ANSII COBOLpackage along with the PERFORM UNTIL construct from a higherlevel to give increased structural control. The language wasimplemented through a self-hosted compiler and run-time package

DO ,^:M7, 1473

(Page 1)

EDITION OF I NOV S> IS OBSOLETES/N OlOi-OM-6601 |

SECURITY CLASSIFICATION OF THIS PAOE (Whan Data Kntarad)

Page 11: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 12: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

JiiCuwiTy classification of this p»GEr*s.n n»i« Bntand-

DD Form 14731 Jan 73

'N 0102-014-6601 SECURITY CLASSIFICATION OF THIS PAGEr»T««" Data Enff<l)

Page 13: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 14: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Approved for public release; distribution unlimited

for

MICRO-COBOLan iuiDl?mentaMon of

Navv Standard HyDo-Cobola microprocessor-based comDuter system

by

Alan Scott C ra i qCaptain, United States Marine Corns

B.S.f Briaham Youna University/ May 1^71

Submitted in oartial fulfillment of thereau

i

rpmen t s for the deqre° of

MASTER OP SCTE^CF TM COMPUTE" SCIE"CF

f ron the

NAVAL POSTGRADUATE SCHOOLw a rch 1977

Page 15: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

A A/>-^

Page 16: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ABSTRACT

A compiler for ADPFSO standard riYPO-COBUl has been im-

plemented on a micrccomcuter. The implementation provides

nucleus level constructs and file options from the &TJSIT

COBOL package a 1 ono with the PERFORM UNTIL construct from a

higher level to aive increased structural control. The

language was implemented throuoh a self-hosteo c O

m

d i 1 e r an^i

run-time package on an b 6 microcomputer-oaseo system.

doth compiler and interpreter can n e executed in l^K bytes

o f use r s t oraae .

Page 17: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 18: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

CONTENTS

I. INTRODUCTION 7

A. HISTORY OF COBOL 7

tJ. MOTIVATIONS OF HYPU-CObOL 8

C. MICROCOMPUTERS 9

1 . Hardware Q

2. Software in

0. OBJECTIVES OF MICRO-COBOL 11

II. MICRO-COBOL MaCHIijE 13

a. GtNERAL INSCRIPTION 15

a. MtMORY ORGANIZATION lb

C. MACHiNL OPERATIONS lb

1. Format lb

2 . Arithmetic operations 1 o

3 . Branching 17

4. Moves 21

5. Input-outPu£ cN

0. Special instructions d&

III. MiCRO-COBOL IMPLEMENTATION 30

A. COMPILER IMPLEMENTATION 30

1. General method 50

£ . Control flow 31

3. Internal structures , 5?

<4 . Part one 53

5. Part two 41

Page 19: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 20: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

b. INTERPRETER IMPLEMENTATION 50

1. General structure 5

2

.

Code modules . 50

a. Arithmetic instructions....... 5 1

D. Branching.... 52

c. Input-outout operations 52

d. Moves 53

3. Limitations 5 'i

C. SUFTrtARE TOOLS 54

IV. CONCLUSIONS ^b

APPtNLUX A - MICRO-COBOL USERS MANUAL 58

PROGRAM. LISTINGS 115

LISI OF REFERENCES loB

INIIIAL OiSTRIbUTION LIST 170

Page 21: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 22: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

I. INTRODUCTION

A. HISIOKY OF COBOL

As indicated in the name* COoOL - COmmon dusiness

Oriented Language - was intended to be a common standard

comouter programm i nq 1 anguaae with consistent imolementa-

t ions on various machines. Backed heavily by t^e L/epartrrent

of Defense/ C d L has become a widely accepted 1 a n g u a o e for

data processing applications. Over the fifteen years of its

existance t h e lanauage has undergone several revisions ana

still continues to be ungraded and cnanoed ( 1 ] .

The evolution of COBOL has resulted in a large language

containing numerous capabilities* many of which are not ap-

propriate for a given machine nor desired ov a class of

users. hor this reason the COPuL language is broken a o v\ n

into modules which may be implemented at various levels.

The minimal standard COBOL/ as currently defined/ contains

only the lowest levels of three modules out of the possible

twelve modules which currently exist.

Page 23: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 24: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

B. MOTIVATIONS OF HYPO-COBOL

None of the existing standard sets of COBOL modules fit

the requirements of the Department of the Navy/ ana thus

HYPO-CObOL was develooed. Pather than taking one of the im-

plementation levels described in the standard/ anotner sub-

set of the complete instruction set was developed whicn in-

cludes only oarts of modules. HYPO-COBul was desianea to

impose minimal reauirements on a system for comciler sup-

oort. where possioler short constructs «ere used in tne

place of longer ones. Inhere multiple reserved words serve

the same function in COBOL/ tne shortest form was used.

There is no optional veroage in t^e lanquage/ ana there are

no duplicate constructs performino the same function.

Limits were placed on all statements that have a vari-

able input format sc that all statements have a fixeu max-

imum length. A here possible/ such constructs were removed

completely from the languaoe. In addition, user oefi r ed

names were limited to twelve characters to reduce svrrrol

table storaae requirements.

Rather than include the standard levels of imolementa-

t ion for all of the modules/ constructs «erp included only

as required. In addition to low level constructs/ the PER-

FORM UNTIL construct was included to allow better program

structure. Further justification tor the manner of subset-/

ting and a highly detailed description of eacm element of

the language is contained in the HYPO-CObOL Manual [10] .

Page 25: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 26: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

C. M1CRQC0MPUTFRS

Current technological advances in the desinn of in-

tegrated computer components have lead to tne proliferation

of single chip central processors known as microcomputers.

The number of chips produced and the varying capabilities of

each product make generalizations very difficult. Tne term

microcomputer* however/ is generally usea to describe a sys-

tem built around one of these processors. Such a svstem

would have memory, incut and output capaoilities/ and timinq

circuts as well as a central processor. One cnio systems

with all of these capabilities are currently becoming avail-

able.

1 . Mardwa re

The most sianificant factor in the proliferation of

m i c rocompu t e r-Dasea systems has t>eeo their cost. Keason a hlv

powerful central Drocessors can currently be ourcnasea for

less than twenty dollars* resulting in the apcearance of

manv new applications. Along with the low cost of tne cen-

tral processor have come low cost peripheral oevices that

are well suited to tne speeds ana capaoilities of the micro-

computers. In the case of traditional uspts of computers/

the low cost of microcomputer hardware has led to new uses

ana to distributed processor networks. Chanqes in the cost

and capabilities of microcomputers have oeen dramatic over

the last several years/ with more and more capaoilities be-

ing offered at lower prices.

Page 27: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 28: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

2 . Software

Software has lagged far oehind the developments in

hardware for microcomputers. Most of the currently avail-

able systems do not supoort high level languages at all/ and

where supported* the 1 anguaoes are often systems languages

rather than aoplications oriented languages. One of tne

restrictions imposed by many hioh level languages has been

the reguirement for c ross-como i 1 i ng on a more powerful

machine 173. In addition, some of the resident compilers

reguire large amounts of memory. Recent wor< on versions of

BASIC however, has led to quality resident compilers for

scientific tyoe calculations tol .

To allow the use of microprocessor systems in many

of the proposed applications/ lanauages need to De developed

that will run on microcomputers without placing unreasonable

demands on their capabilities and size. If the developments

in hardware continue at their present rate, software will

almost certainly continue to 1 aa behind. however/ current

compiler construction techniques do seem to maice it possible

to provide the reauired lanouages, at least on the current

types of hardware 13J.

10

Page 29: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 30: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0. OBJtCflVtS OF MICRO-COBOL

The major objective of this oroject was to implement

HYPO-COBOL on an 80t)0 m i c rocomDu t e r-based system. As steps

toward that objective/ the fol lowing underlying goals were

established: first* cefine HYPO-COBOL as an LAlK(i) qrammar

llc!J. Secono* construct a compiler based on a table-driven

parser for that LALR(l) gra^rrar. Third* implement an inter-

preter to run the intermediate lanquage instructions pro-

duced by the compiler.

rt h i 1 e it was recognized that tnere would be difficulties

in displaying the complete capabilities of the HYPO-COBOL

language on the equipment currently avai laole at the Naval

Postgraduate School* it was considered feasible to implement

a major portion of the subset with the current equipment and

software.

One of the justifications for this project was the

current standard policy of the Department of Defense to re-

quire all computers used in non-tactical environments tc Le

capaole of executing COBOL. In the case of the Department

of the Navy* the standard that would need to ne met for a

microcomputer-based svste^ is hYPO-COBUL.

Finally* it shoula be noted that tnere was no attempt to

add to the HYPO-COBOL definition. One area of investigation

was to test the feasibility of the subset. In defining tne

grammar* areas were found where additions could have been

made* and future users may require enhanced capaoilities to

t 1

Page 31: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 32: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

make the languaqe fit their requirements. Indications have

been made? in the following sections; of places where

changes seemed appropriate.

12

Page 33: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 34: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

II. MICRO-COBOL MACHINE

A. GtNhRAL DESCRIPTION

The following sections describe the MICRO-COBOL pseudo-

machine architecture in terms of allocated memory areas and

pseudo-machine operations. The pseudo machine was the tar-

get machine for the compiler and was implemented through a

proarammed interpretation. The ^ICRO-CObOL machine has been

given first* since all other system components can oe

uescriDed in terms of the taraet machine.

There were several ways to design the pseuoo machine.

The parser used produces operations in the oroer convenient

for a stack machine* and other applications have used a

simulation of a stack machine to interpret the output of the

compiler Ibl. The operations required for HVPu-COoOL did

not reauire the use of a stactc but could oe desioned as re-

latively independent operations. it would ce possiblp to

produce an interpreter tnat consisted of a set of

subroutines which would be called directly by machine level

operations on the t)0b0. The emitted code would then consist

of instructions to load parameters ana calls to th»

suoroutines. This second i d <=» a was rejected due to the lim-

ited time available for the production of tne project and

because the code generation would then oe very closely tied

to the exact implementation of the i n t e rp ref e r . It was de-

13

Page 35: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 36: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

cided to produce output coae for a pseudo macnine that

would be defined to have all of the needed operations as

basic instructions, the machine operators chosen contain all

of the information required to perform one complete action

required by the language.

The machine contains multiple parameter operators and a

program counter that addresses the next instruction to be

executed. Tnree reaisters are provided which hold eighteen

digit numoers used for aritnmetic operations along with a

suoscript stack that is used to compute subscript locations

along witn a set of flags that are used to pass branchinq

information from one instruction to another.

Addresses in the machine are representee by lb bit

values. Any memory address greater than 2 hexadecimal is

valid. Addresses less than 20 hexadecimal will be inter-

preted as having special siqnificance. For example/ au-

dresses one through eiaht are reserved for sucscriot stack

references. All other addresses in the machine are absolute

addresses .

The arithmetic registers allow for the 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. fthile the form of the representation is not

specified in the HrPU-CObOL document, it is necessary that

there oe no loss of precision for operations on numbers nav-

14

Page 37: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 38: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

i ny a full eiqnteen digits of significance.

There are two major types of numbers defined in the

machine. The first is numbers in the DISPLAY mode. Tnese

numbers are represented in memory in the standard informa-

tion exchanae code for the oerioherals. For m 1

c

rocomput e r s

,

the common reDresen t at" i on would be in ASCII characters.

Ihese numbers may have separate siqns indicated by "+" and

"-" or may have a "zone" indicator added/ denoting a nega-

tive sign. Hacked decimal format is also available with

numbers carried as seauential digit pairs storec in memory.

The sign is indicated in the riaht-most position.

The following flags exist in the machine and can be

checked by the i ns

t

rue t i ons for a true or false value:

BRANCH flag -- indicates if a Dranch is to be taken; EfvU OF

RECURD flag -- indicates that an enu of input condition has

ceen reached when an attempt was made to reau input/" OVER"

FLUa flag -- indicates the loss of information from a regis-

ter due to a numoer exceeding the available size? INVALID

flag -- indicates an invalid action in writinq to a direct

access storage device.

The following resources are reouired for a minimal im-

plementation of this machine: a system input device capable

o* receivina low volume input/ a system output" device capa-

ble of displaying low volume output/ and a direct access

storage device caoable of storing/ reading/ and writing

files and programs.

\b

Page 39: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 40: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

B. MEMORY ORGANIZATION

Memory is divided into three major sections: ( 1 J trie

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

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

of these sections is reauired. The first two areas assume

the ability to both read and write, but the thira only re-

quires tne ability to be read.

The data area contains variables defined by the uAfA

DIVISION statements, constants set in the WORKING STOkAGE

SEC I I ON , and all file control blocks and cuffers. These

elements will be manipulated by the machine in accordance

with tne code instructions.

C. MACHINE OPERATIONS

1 . Format

All of the machine operations consist of an opera-

tion number followed oy a list of parameters. The sections

that follow descrioe the various instructions, list the re-

quired parameters, and descrioe the actions taken oy tne

machine in executinq eacn instruction. As each instruction

is fetched from memory, the oroqram counter automatically

increments by one.

2. Arithmetic operations

There are five arithmetic instructions which act

only on the registers. In all cases, the result is placed

lb

Page 41: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 42: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

in register two. Operations are allowed to Destroy the in-

put values during the process of creatine, a result. There-

fore» a number loaded into a register will not be available

for a subsequent operation.

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

and regi s t e r one

.

Parameters: no parameters are reauired.

SUB: (subtract). Subtract register one from register

zero

.

Parameters: no parameters are required.

MUL: (multiply). Multiply register zero Dv register

one

.

Parameters: no parameters are reauired.

D

i

V : (divide). Divide register zero Dv fne value in

register one. The remainder is not retained.

Parameters: no parameters are required

KNO: (round). rtound reqister t „ o to the last signi-

ficant decimal place.

Parameters: no parameters are required.

5 . b ranc h i ng

All of the branchinq instructions are accomplished

Dy changing the value of the proaram counter. Some are ab-

solute branches and some test for condition flaqs that are

set by the other instructions. branches may also test the

1 7

Page 43: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 44: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

state of the reqisters or perform direct comparisons on

memory fields.

Several instructions use the same conditional

Branching conventions. First/ the branch flag is checked

for its current setting. If it is true* tnen a oranch is

made by changing the orogram counter to the value of the

<branch address>. Tne branch flag is tnen set to false. if

the flag was originally false* the program counter is incre-

mented to the next secuential instruction.

ti W N : (branch to an address). Load the program

counter with the <bra r, ch aadress>.

Parameters: <branch aadress>

The next three instructions share a common format.

The memory field addressed by the < n e m o r y address-> is

checKed for the <aadress length>* ana if all the characters

match the test concition* then the branch flag is comple-

mented. A conditional branch is taken after the test.

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

dress>

CAL: (compare alohabetic). Compare a memory field

for alphabetic characters.

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

numeric characters allowing for a sign character.

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

numeric characters only.

Page 45: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 46: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

DtC: (decrement a count and brancn if zero). Decre-

ment the value of the <address counter> bv one, and if the

result is zero the proaram counter is set to the address

given. If the result is not zero* then the Drogram counter

is incremented by four. If the result is zero before decre-

menting, the branch is taken.

Parameters: <address counter> <branch address*

tOP: (branch on end of records flaaj. If the ena-

of-records t 1 aq is true, it is set to false and the program

counter is set to the <branch adoress>. If false, the pro-

gram counter is incremented bv two.

Parameters: <branch adress>

GUP: (oo to - ceoendinq on). The memory location ad-

dressed by the < n u ^ b e r aoress> is read for the numcer of

bytes indicated oy tne <memory length>. This numoer indi-

cates which of the <branch addresses> is to he used. The

first parameter is a bound on the numoer of brancn ad-

dresses. If the number is witnin the ranae, the Drogram

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

value causes the proaram counter to be advanced to the next

sequential instruction.

Parameters: <bouna number - byte> < memory lenoth> <memory

address> <branch addr-l> <branch addr-^> ... <cranch ador-n>

I N V : (branch if invalid-file-action flag true). If

the i n va I 1 d-f i 1 e-ac t i on f 1 aa is true, tnen it is set to

false, and the nrogram counter is set to the branch a d -

19

Page 47: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 48: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

dress. If it is false/ tHe program counter is incremented

Dy two.

Parameters: <branch address>

PtR: (Derform). The code address oointed to by tne

<change adaress> is loaded with the value of the <retum aa-

dress>. 1 h e o r o g r a m counter is then set to the <branch a d -

dress> .

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

dress>

RtT: (return). If the value of the <oranch adaress>

is not zero* then the program counter is set to its value*

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

dress> is zero* the proaram counter is incrempnted by two.

Parameters: <oranch address>

Rtu: (register eaual). This instruction checks for a

zero value in reaister two. If it is zero, tne branch flag

is complemented. A conditional Drench is ta<en.

Parameters: <branch aodress>

RGT: (register greater tnan). register two is

checked for a negative sign. If oresent* the oranch flag is

complemented. A conaitional branch is taken.

Parameters: <pranch address>

R L T : (reaister l^ss •nan). Reaister two is checked

for a positive sign* and if present* the branch flag is com-

olemented. A conditional branch is ta*en.

20

Page 49: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 50: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Parameters: <branch address>

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

true* then the DrognaT counter is set to the branch adaress*

and the overflow flag is set to false. If it is false* then

the program counter is incremented by two.

Parameters: <branch aadress>

Ihe next three instructions all perform the same

function and have the same aeneral format. Ihev compare Uo

strings ana perform a conditional branch. If the test con-

dition is true* the branch flag is complemented prior to

taking the conditional branch.

Parameters: <strina addr-l> <strina aodr-2> <lenath - aa-

aress> <branch address>

SfcQ: (strings eaual). Comoare two string for egual

charac ters.

SGT: (string greater than). Compare sfrina one for

greater than string two.

SLT: (string less than). Compare string one for less

than string two.

4. Moves

The machine supports a variety of move operations

for various formats and tyoes of aata. It aoes not suoport-

direct moves of numeric data from one memory field to anoth-

er. Instead/ all of the numeric m oves qo through the regis-

21

Page 51: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 52: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ters. f h i s greatly reduced the number of instructions since

all of the numeric tvpes need to be suDported by moves into

and out of the reqisters for arithmetic operations.

The next seven instructions all perform the same

function. They load a register with a numeric value and

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

memory at the <numoer address>. All seven cause the program

counter to be incremented bv five. Their common ror^at is

given below.

Parameters: <number address> <byte length> <byte o e c i m a 1

count> <byte register to load>

LUD: (load a numeric literal). Note t^at the decimal

point indicator is not set in this instruction format. Tne

literal will have an actual decimal point in it if re-

qu i red.

LD1: (load a numeric field).

LL)2: (load a numeric field with an internal trailing

s i gn ) .

LU3: (load a numeric fielo with an internal leauina

s i gn

)

L D 4 : (load a numeric field with a separate leaaino

si gn J .

L D 5 : (load a numeric field « i t h a spparat^ trailina

sign) .

2i

Page 53: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 54: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

L D 6 : (load a packed numeric field).

MhD: (move into a alphanumeric eaited field). The

edit mask is loadeo into t K e <to address> to set uo the

move* and then the <from address> information is loadea. The

program counter is incremented by ten.

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

<edit mask address> <edit mask length>

MNt: Uove into a numeric eai tea field). First the

edit mask is loaded into the receiving field/ ana then tne

information is loaded. Any decimal point al ian^ent required

will be performed. if truncation of sianificant digits is a

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

counter is incremented by twelve.

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

move> <eoit mask address> <address mask length> <nyte to de-

cimal count> <ovte from decimal count>

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

field given by the <to adoress> is filled o y the from f 1 p I ri

for the <move lenat^> and then filled with blanks in the

following positions for the <fill count>.

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

length> <address fill count>

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

register two are store a into reaister zero and the decimal

count and sign are indicators set.

Parameters: none.

25

Page 55: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 56: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

The store instructions are grouped in the same order

as the load instructions. "eqister two is stored into

memory at the indicated location. Any alignment is per-

formed/ and if a non-zero leading digit is truncated oy the

operation, the overflow flag is set. All five of the store

instructions cause the orooram counter to be incremented bv

four. Ihe format for these instructions is as follows.

Parameters: <address to store into> <byte length> <bvte de-

cimal count >

STU: (store into a numeric field).

311: (store into a numeric Held with an internal

trailing s i on )

.

S

1

2 : (store into a numeric field with an internal

leading sign).

S13: (store into a numeric field with a separate

t rai 1 i ng s i qn ) .

314: (store into a numeric field with a separate

I eadi ng sign).

315: (store into a packed numeric *ield).

5 . Input -out out

The following instructions perform input and output

operations. The recuired operations are specified in tne

HYPU-CObOL manual* but t- n e exact/ definitions of file formats

and access methods p>re not defined. Files in this machine

?4

Page 57: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 58: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

are defined as having the following criaracteristics: they

are either seauential or random, ana* in general/ files

created in one mode are not required to oe 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 charcter

string that delimits a variable length recora.

ACC: (accent). head 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 reac>

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 adoress> on the svstem output device

for the indicated length. The Drogram counter is increment-

ed by t h ree

.

Parameters: <memorv address> <byte l^nath>

There are three open instructions with the same for-

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

bloc* referenced will be opened for the moae indicated. The

program counter is incremented by two.

Parameters: <fcb address>

2b

Page 59: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 60: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

OPN: (open a file for input).

0P1: (open a file for output).

0H2: (open a file for both input ana output). lhis

is only valid for files on a random access device.

The following file actions all share the same for-

mat, tach performs a file action on the file referencea bv

the file control block. The record to be acted uoon is

given by the <recorc aartress>. The proaram counter is in-

C remen t ed oy s i x

.

Parameters: <fco adaress> <record aadress> <recora lenath -

address>

DLS: (delete a record from a sequential fileJ. Re-

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

is reauirea to be ooen in the input-output mode.

Hl)F : (read a sequential file). "ead the next record

into the memory area.

AlF: (write a recorq to a sequential file). Append a

new record to the file.

RVL: (read a variable lengtn record).

UVL: (write a variable lenoth recora).

RwS: (rewrite sequential). The rewrite operation

writes a record from memory to the file* overlaying the last

record tnat was read from the device. The file must be open

2o

Page 61: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 62: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

in the input-output moae.

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> ana a

<relative length>. The memory fielo 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 the record count on the file start ina with one. After

the file action, the crogram counter is incremented oy

nine.

Parameters: <fco adaress> <record aodress> <record l*»noth -

address> <relative address> <relative lenath - b y t e > .

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

dressed by the relative record nun-oer.

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

relative to the record number.

RRS: (read rancom sequential). Read the next seouen-

tial 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). »»rite a record into

the area indicated by the memory reference.

wRS: (write random seauential). write t n e next

sequential record to a random file. The relative record

?7

Page 63: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 64: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

number is returned.

b . Special instructions

The remaininq instructions perform special functions

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

previous grouos.

NUT: (nepitive test). Negate the value of the d r a n c h

f 1 aq.

Parameters: no parameters are recuirea.

LDI: (load a cede address direct). Loao the <code

address> with the number indicated by the <memory address>.

Parameters: <code aaoress> <memory aaaress> <lenath - byte>

SCR: (calculate a subscript). Load the subscript

stack with the value indicated from memory. The aadrpss

loaded into the stac< is the <initial address> plus an

offset. Multiplying the < f i e 1 d lenqth> by the n u m d e r in tne

<memory reference> qives the offset value.

Parameters: < i n i t i a 1 adaress> <field 1 e n q t h > <memory refer-

ence> <memory lenath> <stac l< level >

SID: (stop with display). DisDlay the indicated in-

formation and then stop.

Parameters: <memory address> <length - Dyte>

SIP: (stop), terminate the actions of the machine.

Parameters: no parameters are required.

28

Page 65: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 66: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

The following instructions are used in sett inq up

the machine environment and cannot be used in the normal ex-

ecution of the machine.

BST: (backstuf f ) • Resolve a reference to a label.

Labels may oe referenced prior to their definition* reauir-

ing. a chain of resolution addresses to be maintained in the

code. The latest location to oe resolved is maintained in

the symbol table and a pointer at that location indicates

the next previous change. A zero pointer indicates no nrior

occurrences of the label. The code address referenced cv

<change address> is examined and if it contains zero, it is

loaded with the <new addr«»ss>. I* it is not zero, then tne

contents are saved/ and the process is repeated with the

saved value as the change address after loading the <new ad-

dress> .

Parameters: <change address> <new aodress>

INT: (initialize memory). Load memory with the < i n -

put string> for the given length at the <me", ory address>.

Parameters: <memory address> <address length> <inout

st n nq>

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

gram count e r

.

Parameters: <start address>

TtR: (terminate). Terminate the initialization pro-

cess and start executina code.

Parameters: no parameters are reduired.

29

Page 67: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 68: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

III. MICRO-COBOL IMPLEMENTATION

A. COMPILER IMPLEMENTATION

1 . Gene ra 1 met Hoc

Ihe LALR parser-table construction programs used

here are based on the work of Anutn 19J . His work defines

two methoos of testing a grammar to see if it is LRfO. One

of these methods leads to the creation of a set of tholes

that can be used to arive the parse actions of a compiler.

Ahile difficult to implement in the form aiven by Knuth, tne

method has been developed in usable form for subsets of the

grammars that are LR(k). References 2 and 3 contain de-

tailed discussions of the methods currently available. The

algorithm used to ceveloo the tables for the ^iCRO-COBuL

comDiler was develooed by ft, Lalonae fl2J.

The compiler was designed to reao the source

language statements from a diskette or other mass storage

device* extract the needed information for the symbol table*

and write the output code bac< onto the diskette al Iin one

pass of the source program. The grammar was initially de-

fined for the entire language* but the size constraints

placed on the implementation reouireo smaller tables. Tne

grammar was then defined in two parts «hicn run in succes-

sion. Ihe major method of oassina information from the

3U

Page 69: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 70: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

first part to the second is Dv olacina the information in

t he symbo I table.

The outout code from the compiler consists of the

operations that have oeen previously defined. Tney were

designed as an intermediate lanquage that would be executed

by the interpreter described in section B. The vast differ-

ences between the operations available for the target com-

puter and the ODerations necessary to support COBOL made

this approach easier than BOBO machine code.

2. . Con t ro 1 flow

The comoiler has been designed so that the operation

of the two oarts woulo be transparent to the user. >*hen tie

first part is loaded it orings in with its code a reader

program which loads the second file automatically. Prior to

calling the reader program, the first part writes any pend-

ing code to the disk and loads all togoles to a common area

ready to be read by the second part.

Internal lv> the control of the two parts is identi-

cal. The parser is called after initialization and runs un-

til it either finishes its task or reaches an unrecoverable

error state. The major subroutines in the compiler ar* the

scanner and the production case statement. Both are con-

trolled in their actions by the parser.

31

Page 71: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 72: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

3. Internal structures

The major internal structure is the svmbol table.

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

the descriptions of the various symbols in the program. As

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 tne identifier

aqainst a hash table that points to the first entry in tne

symbol table with that hash code. A chain of collision ad-

dresses is maintained in the symbol table wnich lin<s en-

tries which have the same hash value.

All of the items in the symool table contain tne

following information: a collision fields a tyoe field/ tne

length of the identifier, ana the address of the item. If

an item in the symbol table is a data field/ tne followinq

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/ ano the ad-

dress of the edit field/ if rpquired. If the item is a file

name then the following additional information is included:

the file record length/ tne file control block andress/ and

the optional symbol table location of the relative record

pointer. If the item is a label* then the only additional

information is the location of the return instruction a*" tne

end of the paraoraph or section.

32

Page 73: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 74: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

In addition to the symbol table* two stacks are used

for storing information: the level stack ana the identifier

stack. In both cases* they are used to hold pointers to en-

tries in the symbol table. The identifier stac< is used to

collect multiple occurrences in such statements as the GO TO

DEPENDING statement. The level stack is used to hold in-

formation about the various levels that make up a record

desc ript ion.

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 Dv the parser* nart one

has a value stack and Dart two has t * o different value

stacks that operate in parallel with the parser state

stack. The use of these stacks is descrit-ed below.

4. Part one

The first part of the compiler is orimarilv con-

cerned with buildinq the symbol taple that will oe used oy

the second oart. The actions corresponding to each oarse

step are explained in the sections tnat follow. In eacn

case* the grammar rule that is beinq applied is given* and

an explanation of *hat program actions take place for t K at

step has been includeo. In aescribina 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 neeos to be retained and at what

33

Page 75: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 76: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

point in the parse it can be determined. », here 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 explana-

tion is given. Questions reqardinq the actual manipulation

of information should be resolved by consulting the pro-

grams .

1 <orogram> ::= <io-div> <e-aiv> <a-aiv> PROCEUURF

Reading the wora PROCEDURE terminates the first part

of the comp i 1 e r

.

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

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

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

4 ! <emoty>

5 <date> ::= DATE-v\RlTTEw . <comment> .

6 ! <empt y

>

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

8 ! <emoty>

9 <comment> ::= <inout>

10 { <comment> <input>

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

<scr-obj> <i-o>

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

UBJECT-CUMPUTER . <comment> .

13 <debug> ::= DEBUGGING MODE

Set a scanner to gale so that aebug lines will be

read

.

14 ! <emoty>

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

34

Page 77: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 78: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<fi 1e— control -1 ist> <ic>

16 1 <empty>

17 <f

i

le-control-1 ist> ::= <

f

i 1 e-cont ro

1

-ent ry>

18 ! < f i 1 e-con t ro 1 - 1 i s t > < f i 1 e-cont ro I -en t r

y

19 <f n e-cont ro

I

-ent ry> ::= SELECT <io> <at t ri bute- H st> .

At this point all of the information about the file

has been collected ana the t /oe of the file can oe

determined. File attributes are checked for compati-

bility and entered in the symbol table.

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

21 ! <at t r

i

but e- 1 i st > <one attric>

di <one-attrib> ::= ORGANIZATION <orq-tyoe>

23 ! AtCtSS <acc-tyoe> <relative>

2a ! ASSIGN <inout>

A file conrol bloc* is built for the file using an INT

opera t or .

25 <orq-tyoe> ::= SEQUENTIAL

No information needs to be stored since the default

file organization is sequential.

26 J RELATIVE

The relative attribute is saved for production 19.

27 <acc-tyoe> ::= SEQUENTIAL

This is the def au 1 t .

28 ! PANQOM

The random access mode needs to oe saved tor produc-

tion 19.

29 <relative> ::= RELATIVE <io>

The pointer to the identifier will be retained by the

3b

Page 79: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 80: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

current symbol pointer, so this production only saves

a flaq on the stack indicating that the production did

occur .

30 ! <en"pty>

31 <ic> ::= I-0-C0NTR0L . <same-list>

32 ! <empty>

33 <same-list> ::= <same-e 1 emen t

>

34 J <same-list> <same-e 1 emen t

>

35 <same-el ement > ::= SA^E <id-strino> .

36 <id-strina> ::= <id>

37 l<ia-strinq><id>

38 <d-div> ::= DATA DIVISION . <

f

i 1 e-sec t i on> <*ork> <lin<>

39 <f i

1

e-sect i on> ::= FILE SECTION . <file-iist>

Actions will differ in production 6a oecencina uoon

whether this croduction Has been comoleted. A flag

needs to be set to indicate completion of the file

sec t i on

.

40 ! <empty>

The flag, indicated in oroouction 3 Q , is set.

41 <file-list> ::= < f i 1 e-e

1

ement >

42 ! <file-list> < f i 1 e-e 1 einen t >

43 <files> ::= FD <ic> < f i

1

e-cont ro 1 > . < reco rd-desc r i p t i on>

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 <f i

1

e-cont rol > ::= <file-list>

45J <empty>

36

Page 81: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 82: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

46 <fi1e-list> ::= <f i

1

e-el ement

>

47 ! <file-list> <f 1 1 e-el ement >

48 <fi le-element> ::= BLOCK <integer> RtCuRDS

49 ! RECORD <rec-count>

The record lengtn can be saved for comparison with tne

calculated length from the nicture clauses.

50 ! LABEL RECORDS STANDARD

51 ! LABEL RECORDS OMITTED

5? ! VALUE OF <id-strinq>

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

54 J <inteaer> TO <integer>

The TO ootion is tne only indication tnat the file

will oe variable length. The maximum length must De

savea .

55 <work> ::= .mORK I NG-ST OR AuE SECTION . < record-desc r i ot i on>

56 ! <emot y >

57 <lmk> ::= LINKAGE SECTION . < record-desc r i ot i on>

5* ! <empty>

59 < reco rd-desc r i p t

i

on> ::= < 1 eve I -en t ry

>

60 ! < rec

o

rd-desc r

i

d t i on> < 1 eve 1 -en t r v>

b\ < 1 eve I -en

t

ry> ::= <integer> <aata-id> <redefines>

<data-type> .

The level entry needs to be loaded into t^e level

stack. The level stack is used to keep trac< of the

nesting of fielo definitions in a record. At this

time there ™ay be no information about tne length of

the item being oefined/ ano its attributes may aepenl

entirely uoon its constituent fields. If there is a

37

Page 83: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 84: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

pending literal* the stack level to which it applies

is saved .

6 2 <data-id> : : - <id>

63 ! FILLER

An entry is built in the symool table to recora infor-

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

plicitly in a proqra-n because it has no name/ but its

attributes will need to be storea as part of the total

record .

Q a <redefines> ::= REDEFINES <id>

The reaefines option aives new attricutes to a previ-

ously defined record area . (he symbol table Dointer

to the area being reaefinea is saved so that informa-

tion can be transferee from one entry to the other.

In addition to the information saved relative to tne

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 stac*. If this is

true/ then all information for the item on the too of

the stack has been saved ana the stac* can oe re-

auced

.

65 ! <emot y

>

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 orior to production 3V or

40 (the end of the file area) f it is an i mo I i ed rede-

36

Page 85: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 86: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

finition of the previous 01 level. In the workinq

storage section, it indicates the star*" of a new

record .

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

67 ! <emoty>

68 <prop-list> ::= <oat a-e 1 emen t

>

o9 ; <prop-list> <dat a-e 1 emen t

>

70 <data-e1 ement> ::= PIC <input>

The <inout> a t this point is tne character string chat

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

tracted information is stored in the symcol tacle.

71 ! USAGE Cu^P

F h e field is defined to be a o a c k e d numeric fielc:.

12 \ USAGE DISPLAY

the DISPLAY format is the default* and tnus no special

action occurs .

73 ! SIGN LEADING <seoarate>

This oroduction indicates the presence of a sign in a

numeric field. The sion will be in a leauina Posi-

tion. If the <seoarate> indicator is true* then trie

length will be one longer t K an the picture clause* and

the type will oe changed.

7a ! SIGN TRAILING <sepa rat e>

lhe same information required by oroduction 73 ^ust be

recorded* but in this case the sign is trailing rather

than 1 ead i ng .

75 ! 0CCUR6 <inteqer>

The type must be set to indicate multiple occurrences*

39

Page 87: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 88: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

76

77

79

80

ana the number of occurrences saved for comouting the

space defined bv this field.

! SYNC <direction>

Syncronization with a natural boundary is not required

by this mac hine.

! VALUE <1 i teral >

The field being defined will be assiqneo an initial

value determined by the value o * the literal through

the use of an i !W ocerator. This is only valid in the

WORKING-STORAGE SECTION.

78 <direction> :: = LEFT

; KibHr

J <emot y

>

81 <seoarate> ::= SEPARATE

The separate sign indicator is set on.

82 ! <empty>

83 <1 i tera 1 > : : = <i nput >

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

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

in a value assignment.

! <1 i t>

This literal is a quoted string.

! 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

literal constant is beinq saved is all tnat is re-

quired. The literal value can be reconstructed

8a

85

40

Page 89: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 90: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

later.

86 ! SPACE

67 J QUOTE

88 <inteqer> ::= <inout>

[he input strinc is converted to an integer value for

later internal use.

89 <i d> : : = < i nput >

The input strinc is the name of an identifier and is

checked aqinst tne symbol taDle. 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 aaoea

ana the address of that entry is saved.

5. Part two

The second part includes all of the PROCEDURE DIVI-

SION, and is the Dart where coae aeneration takes place. As

in the case of the first cart* there was no intent to show

how various pieces of information were retrieved Out onlv

what information was used in producing the output coae.

1 <o-oiv> ::= PROCEDURE DIVISION <using> .

<proc-oody> END .

This production indicates termination of the compila-

tion. If the program has sections* then it will ce

necessary to terminate the last section with a K E 1

instruction. The code will be ended oy tne output of

a TER ooe rat ion.

2. <usina> ::= USING <id-strina>

41

Page 91: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 92: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

3 ! <empty>

4 <io-strinq> ::= <id>

fhe identifier stack is cleared and the syrrool table

address of the identifier is loaded into the first

stack location.

5 |<id-strina><id>

The identifier stack is incremented and the symbol

taole pointer stacked.

6 <Droc-body> ::= <caraqraph>

7 ! <oroc-Oody> <Daraoraph>

8 <paraqraph> ::= <id> . < sen t enc e-1 i s t

>

The startinq ano endinq address of the paragraph are

entered into the sy^Dol taole. A return is emitted as

the last instruction in the paragraph (RET U). /.hen

the label is resolved/ it may be necessary to prcouce

a biST operation to resolve previous references to the

label

.

9 J <io> SECTION .

The startinq address for the section is saveo. if it

is not the first section, then the previous section

endinq address is loaded and a return (RET Oj is cut-

put. As in production 8 » a BST may be produced.

10 <sen t ence- 1 i s t > ::= <sentence>

11 i <sen t ence- 1 i s t > <sentence> .

12 <sentence> ::= <imperative>

13 !<conditional>

iu ; ENTER <id> <opt-ia>

Ihis construct is not implemented. An ENTpR allocs

42

Page 93: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 94: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

statements from another language to inserted in the

source code.

15 <i mperat i ve> ::= ACCEPT <subid>

ACC <address> <length>

16 ! <a r i t hmet i c >

17 ! CALL < 1 i t > <us i na>

This is not implementea.

18 ! CLOSE <id>

CLS <file control blocc adaress>

19 ! <f i I e-act >

20 \ DISPLAY <Ht/id> <opt-lit/io>

The aisplay ooerator is produced for the first literal

or identifier (DIS <adaress> <lenath>). If t^e second

value exists* the same code is also oroducea for it.

2\ ! ExIT <Drogram-ia>

RtT

22 ! GO <id>

BKN <address>

2 3 | GO <id-string> DEPENDING <id>

UUP is outoutf followed ov a numoer of parameters:

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

length of the depending idert i f ier> <the aoorpss of

the decendino identifier> <the address of each iden-

tifier in the stack>.

24 ! ^UVt <lit-id> TU <subio>

The types of the two fields determine the move that is

generated. Numeric moves go throuah register t*c us-

ing a load and a store. Non-numeric ^oves depend ucon

43

Page 95: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 96: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

the result field and may be either MOV/ M t D or M N E

.

Since all of t •"> e s e instructions have lonq parameter

1 istSr they have not been listed in detail.

25 ! OPEN <t ype-ac t

i

on> <io>

This produces either P N , P 1 , or P 2 depenoino uoon

the <t ype-ac t

i

cn> . Each of these is followea cy a

file control block address.

26 ! PERFORM <id> <thru> <finish>

The PER operation is Generated followed oy tne < o r a n c h

address> <tne address of the return statement to oe

set> and <the next instruction aooress>.

27 !<read-id>

28 ! STOP <f ermi nat e>

If there is a terminate message* then SPD is produced

followed ov <messaae adoress> <messaae length>. Oth-

erwise STP is emitted.

2R <cona i t i ona 1 > : t = <arithmetic> <size-error> <imoerative>

A BST operator is output to comDlete the branch around

the imperative from production b 5

.

30 ! <file-act> <invalia> <imperative>

A BST operator is output to complete the oranch f ron

produc t i on 64

.

31 ; IF <condition> <action> ELSE <imperative>

Iwo bST operators are required. Tne first fills in

the branch to the ELSE action. Ihe second completes

the oranch around the < i mpe rat i ve> .

32 J <reaa-id> <special> <

i

moerat i ve>

A bST is oroduced to complete the branch around tne

44

Page 97: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 98: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

< i mper at i ve>.

33 <Arithmetic> ::= ADD <l/id> <opt-l/id> TO < s ub i d > <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 numoer involved/ and in eacn case the standard

parameters will be produced. This oarse step will in-

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

itted for the first number into reqsfer zero. if

there is a second number, then a load into register

o^e will oe produced for it/ followed by an ADD and a

S T I . Next a loaa into reaister one will be generated

for the result numoer. Then an ADD instruction will

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

H N operator will be oroduced prior to the store.

3^ J DiVIDt <l/ia> INTO <subia> <round>

The first number is loaded into register zero. The

second ooerana is loadea into register ono. A njy

operator is oroauced/ followed bv a RND onerator crior

to the store/ if reauireo.

35 ! MULTIPLY <l/ia> BY <subid> <rouno>

The multiply is the same as the divide except that a

MUL i s orcducea .

36 ! SUBTRACT <l/ia> <0Dt-l/id> FRUM

<suoia> <round>

Subtaction generates the same coae as the ADD except

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

'IS

Page 99: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 100: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

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

Either a DLS or a DLR will be produced along witn fne

required parameters.

38 ! REWRITE <id>

Either a R W S or a Rh'R is emitted/ followed by parame-

ters.

39 ! WRITE <id> <specia1-act>

There are four possible write instructions: »<TH, W V L

*

wRS, and WRR.

4 <conaition> ::= < 1 i t / i d > <not> <cond-tyr>e>

One of the compare instructions is oroduced. Ihey are

CflL, CNS, CNU, RGT, RLT, REU, SbT, 3LT, and SEQ. T*o

load instructions and a SUb will also be emitted if

one of the reqister comparisons is reauired.

41 <cond-type> ::= NUMERIC

42 ! ALPHABETIC

43 I <compare> <lit/id>

a a < n o t > : : = NOT

NEG

45 1 <emntv>

46 <compare> ::= GREATER

47 ! LF3S

48 ! EQUAL

49 <WOUNU> ::= ROUNDED

50 ! <empty>

51 <terminate> ::= <Hteral>

52 J RUN

53 <special> ::= <invalid>

4o

Page 101: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 102: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

5a i END

An ERO operator is Droaucea followed by a zero. The

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

stuffed with a brancn 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 oroduction 32.

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

56 ! <empty>

57 <action> ::= <imperativ°>

BKN

58 ! NEXT SENTENCE

BRN

59 <t hru> : : = THPu < i a>

oO ! <empty>

61 <finish> ::= <]/\i> TIMES

LUI <address> <length> DEC

6? ! UNTIL <condition>

b3 ! <emo t y

>

64 <invalid> ::= INVALID

iNV

65 <size-error> ::= SIZE ERROR

SER

t>6 <special-act> ::= <when> ADVA fy LING <how-many>

67 i <empt y

>

68 <when> ::= BEFORE

o9 J AFTER

70 < how-man y >;: = <inteaer>

47

Page 103: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 104: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

71 ! PAGE

12 <type-action> ::= INPUT

73 ! OUTPUT

7a ! I-G

75 <subid> ::= <subscript>

76 ! <id>

77 <integer> ::= <inout>

The value of the incut string is saved as an internal

number. •

78 <i d> 11- <i nput >

The identifier is checked aqinst the symbol table* if

it is not oresent* it is entered as an unresolved la-

oe 1 .

79 <l/ia> : : = < i nput >

The input value may be a numeric literal. If so* i f

is placed in the constant area with an INI ocerana.

If it is not a numeric literal* then it must op an

identifier, and it is located in the s y t- p o 1 taole.

80 ! <suosc r i d t >

81 ! ZERO

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

If the identifier was defined with a USING option,

then the incut strina is checked to see if it is a

number or an identifier. If it is an i den t i f i e r ,~ t Hen

an SCR operator is produced.

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

8a J <empty>

65 <nn- lit> ::= <lit>

as

Page 105: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 106: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

The literal string is placed into the constant- area

using an INT operator.

86 ! SPACE

87 ! QUOTE

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

89 I <input>

The input value must be a numeric literal to be valid

and is loaded into the constant area using an INT.

90 ! ZERO

91 <lit/io> ::= <l/io>

9<? ! <nn-lif>

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

9U ! <empt/>

95 <orogram-ia> ::= <id>

96 ! <emct />

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

There are four reaa ooerat ions: R u F , ??VL> R K S * and

RhR.

The output code file is the only oroauct of tne com-

piler that is retained. All of the needed information ^as

been extracted from the symbol table/ <^na it is not required

Dy the interpreter. Code *ill be generated for all proarams

including those that contain errors ana can oe examined

through the use of the decoae program. This program

translates the output file into a listing of code operators

followed by the parameters.

a9

Page 107: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 108: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

B. INTERPRETER IMPLEMENTATION

1. General structure

The format tnat has been presented for tne output

code determines the aeneral form of the interpreter. If it

had not been possible to transform the instructions from tne

compiler into a set of call-like commands* it woula haye

been necessary to implement a stack in the interpreter. in

general* the interpreter contains a large "case statement"

which decoaes each ooerat ion and either calls suoroutinps to

perform the required actions or acts airectly on the run-

time environment to control the actions of tne interpreter.

All communication between instructions is done throuan com-

mon areas in the nrogram where information can be stored for

later use

.

The design of the intProreter has been modularized

in an attemot to allow easy transition to other hand^are

configurations and operating systems. It desired* anv sec-

tion of the instructions could be implemented in assembly

language modules or could oe passed to the operating system

for action. Tne entire system has been coded in PL/ V for

consistency* ease of development* and maximum portaoilitv

17] .

d . Coae modul es

The following sections explain the interpreter oy

noting the specific manner in which the machine instructions

SO

Page 109: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 110: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

defined in section II-C have been imolemented. The divi-

sions are the same as those in section II-C.

a. Arithmetic instructions

Since the machine was defined as having o n 1 v one

set of arithmetic registers* it was necessary to convert all

numeric inout to one form. The packed decimal format was

chosen as the format that would be used in the registers.

This conversion process slows down the arithmetic operations

slightly* but the reduction of the interpreter memory size

was considered more important.

All of tne arithmetic ooerat ions take place in a

set of three work areas or registers. Each of tnese areas

is ten bytes long and can contain an eionteen digit number

with one fill character on eacn end. The extra space facil-

itates cnecking for overflow and also maxes roundina opera-

tions easier. Tne lanauage ^ooes not support the COMPUTE

verb* so no storage of intermediate results is required f r 3 r

one instruction to another.

All of tne arithmetic instructions use tne

packed decimal feature of the «0"0 as a basis for their ac-

tions. Each of the instructions depends on the oasic opera-

tion of addina two registers: subtraction is accomplished

using nines complement arithmetic* multiplication is uone

through a shift ana add algorithm, and division oy a snift

and subtract method.

SI

Page 111: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 112: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

If the amount of computations reauired by a

given application mane it necessary to speed up tnese in-

structions* thev coulo be replaced by a package in assembly

language. Extending tne arammar to include the CO'PUTt verb

would reguire changes in the compiler to allow for temporary

locations* but it coula be included.

D . Branc h i ng

Ihe operation of the interpreter is controlled

by a orogram counter that points to the next operation to oe

performed. All branching is done by changing tne normal

sequent i al order of execution of instructions. In addition

to acting directly on the program counter, branching in-

structions use the oranch flag to aetermine «hen chances

should be made. All of the addresses that ooint to coop are

absolute addresses and can oe loaded directlv into the pro-

gram count er.

c. Input -out put operations

All of the inout and output ooeraticns use tne

CP/M interface capabilities 15] . The program expects to see

the files in the form that the C P /M editor would have creat-

ed tnem. fhe physical records on tne disk are assumed to be

126 bytes in length and have all logical records ending with

a carriage-rpturn and a line-feed sequence. There is only

one type of file under CP/M, so all restrictions on mixing

mooes of files are removed for fixed lenqth files. Files

created in one program as sequent ial can be accessed as ran-

52

Page 113: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 114: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

dom files in another crogram. Variable lenqth files cannot

be accessed in a ranaom fashion because there is no way to

compute the starting address of each record.

where possible* the interface routines have Deen

localized in the proqrams to simplify transportation to

another operat iny environment. Items relating to file con-

trol blocks* dis* record lengths* ana other system parame-

ters have been established as literals in the programs*

rather than enterea as numbers/ so that changes will not

have to oe made throughout the code.

a. Moves

As noted previously* the machine lacks numeric

moves. Ihere were two major reasons fcr leavina out |, ne

various moves of numeric data. The first was that the aaded

moves would have required more program space* ana the second

was to simplify the coaino ana checking of the program.

Since all of the numeric tyoes are supoorted with register

load and store operations* any move can be accomp 1 i snea by a

load into register twc ana a storp into the result fiela.

Alpha-numeric moves are supported as direct

moves from memory t o memory. if speed is reguired for a

numeric move* the fields concerned can be redefined as

alpha-numeric and the memory move used. however* tnis type

of move will only work on two numbers that have exactly the

same representation in tne computer.

53

Page 115: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 116: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Edited moves also are from memory to memory, but

they involve several additional steps. The edit mas< is

loaded into the result field before any characters are load-

ed, and each character in both the receivinq field and tne

sending field is examined to determine what action should oe

taken in addition to a move.

3 . Limitations

The MICRU-CObCL implementation did not lend itself

to support of the interorogram Communications Module. Tnere

was no capability in the operatinc system to dump the memory

image onto the disk or to restore it. It would be possible

to implement such a supervisor call* or a one way call could

perhaps be implemented from one proqram to anotner without

the posibility of a return to the calling proaram. If re-

quired Dy an apDlication where modification of tne operat inq

system was not practical, a small overlay program could ce

written as an independent function to oe loaded with tne in-

terpreter. If large systems ^re to De run on microcomputers

with minimal memory, some tyoe of interproaram communica-

tions would greatly facilitate th^ir desian.

C. SOFTWARE TOOLS

As in any software development, one of tne things that

was most imoortant tc tne success of this project was tne

software support for tne development effort. This svstem

was developed on the i 6 / b 7 ratner than on the 6080. Using

5a

Page 117: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 118: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

the Intel I N T E R P p r o d r a m [81 ana the CP/M simulator

developed by at the Naval Postgraduate School till, if was

possible to both compile programs on CP/C^S ana run the gen-

erated coae. This facility removed the necessity of tran-

sporting code from the 3o0 to the 808U for testing and

greatly improved the d roduc t i v i t y .

Using the simulator did not result in exactly the same

product as would have been developed it the project had been

done entirely on the PO^U. It was not possiole to load a

program on tne simulator without destroying the core imagp

currently in the simulator. In particular/ the first part

of the compiler could not leave the symbol table for the

second part if the second part was loaded oy a normal load.

This problem was resolved Dy writina a set of small proorams

that read in the seauence of compiler components from simu-

lated memory image files. These orograms nave been included

in tnis document so that/ if future work is done/ the simu-

lator could be used aoain.

S5

Page 119: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 120: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

IV. CONCLUSIONS

This project demonstrates the feasibility of aopl yinq

modern compiler construction techniques to the implementa-

tion of a language developed prior to the work on formal

grammars. iV<ot only is it possible to construct a compiler

for HYPO-CGRUl usinq an LAlR(I) parser, but the resultino

programs are h 1 q h 1 y compact. This allows the implementation

of the compiler on smaller machines and increases the number

of t a rge t systems.

Only a limited number of proorams have t^een written us-

ing the compiler, ana no attempt has been maae to train oth-

ers in its use. However/ adapting to the sucset snoulo not

be a major Droolem for a programmer experienced in writino

standard COBOL. There have been no extensive timing tests

of the system, out current indications are tnat ooth tne

compiler and interpreter operate at an acceptable rate.

fhere are several areas tnat could be enhanced in this

implementation of HYPO-COBOL. One of these areas is the in-

terprogram communication module. Due to the limitations on

core size usually imposed bv microcomputer systems, it- would

be very helpful to be able to compile a set of programs that

could be used together as a single module. Several ideas

were presented in the cody of this paper which indicate how

the interorogram communication module could oe developed.

5b

Page 121: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 122: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Ihe GIVING option for arithmetic statements could De

addeu to the arammar. This option would improve comptation-

al programs/ and could be supported without change to the

existing interpreter. As discussed previously/ the COMPUTE

verb could be added if desired/ but it would reouire greater

changes both to the grammar and to the interpreter.

Programmers that have used COBOL in a standard imple-

mentation will find the appearance of trie WuRKluG-SlOHAuE

SEC I ION guite different due to the lac* of the 7 7 level. No

restriction was placec on the size of the level numbers oth-

er than they must be less than 255. This allows for the

standard practice of level skipping. In addition/ it would

not be dificult to make the 77 level perform in a normal

manner. Inere is no difference in the wav that the language

considers an 01 level and a 77 level item, but the comData-

bility with common usaae would De very heloful to a COBOL

p rog ramme r

.

It is hoped that the results o * this project are in a

form that will allow others to use the compiler as a wor*inq

system. it is recognized that many undiscovered problems

will plague the initial users/ but every effort has been

made to describe what the system should do and to isolate

the functions within the interpreter to facilitate changes.

57

Page 123: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 124: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

APPENDIX A - MICRO-COBOL USERS MANUAL

Ihis manual is written to explain the imol imentat ion of

HYPU-COBUL done at the Naval Postgraduate School for the In-

tel 8 8 U microcomputer runnina with C P / M (Control Proqram /

Microcomputer). It is not intended that this manual ta<e

the place of the HYPO-COBOL specification out that it supoly

information on the manner in wnich this i mp 1 i men t a t i on was

done. Ihere is no attempt to teach COBOL; however, someone

who has a working knowledge of the language should be able

to produce programs from the information contained in t^is

manua 1 .

This manual contains a brief overview of the justifica-

tion for HYPO-COBOL and the organization of this imolimenta-

tion. It contains a brief explanation of each of the con-

structs availaole in the language ana shows samples of their

use. It explains the interactions between the various parts

of the compiler and interpreter and how they interface * i t h

the operating system. It also includes a list of references

that might be useful to someone who wished to modify the

comp i 1 er

.

One of the major goals of this document is to explain

how the operating system used effects the operation of the

compiler. It is recognized that if the 1 mp 1 1 men t a t i on is to

be useful it will neeo to be modified to run on otner conf l-

58

Page 125: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 126: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

gurations of hardware and on other operating systems. Where

it was possioler the interaction with the operating environ-

ment was insulated from the other parts of the orogram, but

in the case of the file structure certain assumDtions nad to

be made that could recuire mod i f

i

cat i on

.

59

Page 127: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 128: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ACKNOWLEDGEMENT

Any organization interested in reproducing the COBOLreport and specifications in whole or in Dartr using ideasfrom this report as the basis for an instruction manual orfor any other purpose* is free to do so. However, al I suchorganizations are requested to reproduce the following ack-nowledgment paragraphs in their entirety as part of the pre-face to any such publication. Anv organization using a

short passage from this document* such as in a cook review*is requested to mention "COBOL" in acknowledgement of tnesource* but need not cuote the acknowledgement.

COBOL is an industry language and is not tneproperty of any company or group of companies*or of any organization or group of organisa-tions. No warranty* expressea or implied* is

made by any contrioutor or hy the CODaSYL Pro-gramming Language Committee as to the accuracyand functioning of the programming system andlanguage. Moreover* no responsibility is as-sumed bv anv contrioutor* or py the committee*in connection therewith.

The authors and copyright holders ofmaterial used herein

the copyrighted

PL0W-MAT1C (trademark of Sperry Rand Corora-t ion) , programming for the Uni vac ( R ) I and Ii*Data Automation Systems copyrighted 19 5 8* 1959*by Sperry Rand Corporation; IBM comercial Trans-lator Form No. F 26-6013* cooyrignted 1959 o y

IBM; FACT* DSI 21 A52b0-?760 * cooynahted 19ou ovMinneapol is-Honeywel I .

have specifically authorized the use of this material in

whole or in part* in the COBOL specifications. Such author-ization extends to the reproduction and use of COBOL specif-ications in proaramming manuals or similar publications.

60

Page 129: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 130: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

CONTENTS

I, HYPU-LOBUL OVERVIEW 64

II. ORGANIZATION OF THE IMPLEMENTATION 66

III. MiCKO-CObOL ELE^tNTS o8

IDENTIFICATION DIVISION Format 70

ENVIRONMENT DIVISION Format 71

<f i le-control-ent ry> 7 2

DATA DIVISION Format 7 '4

<comment> 7ft

<data-descript i on-ent ry> Format II

PRGLEDOKE DIVISION Format 19

<sen

t

ence> tiO

< i moer a t ive-statement> ol

<cond i t ional -statement s> 62

ACCtPI o3

ADD bu

CALL ttS

CLOSE eo

61

Page 131: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 132: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

DELETE 67

DISPLAY b8

DIVIDfc 69

ENTER 9

EXII 91

GO 92

IF 93

MOVE 9U

MULIlPLY 95

OPEN 9b

PEKf-UKM 97

REAU 9P

REAKllE 99

STOP 100

SUdlRACl 101

«VRI IE 102

<condi t ion> 1 3

Sudsc r i Dt i nq 1 O'-i

IV. COMPILER IOOGLES 105

62

Page 133: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 134: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

V. RUN TIME CONVENTIONS 106

VI. FILE INFRACTIONS WITH CP/M 107

ERROR MESSAGES 109

LIS I OK REFERENCES 1 1 'J

63

Page 135: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 136: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

I. HYPO-COBOL OVERVIEW

In order to oroviae a standard CObOL subset that could

be implemented on a small comouter system, the Department

of the Navy has defined HYPO-CQBUL. This definition is in-

tended to give the minimum subset of the CU8UL language that

would oe useable as a working product. fhis subset does not

agree with the lowest l^vel of CUHuL as defined by the C -

DASYL group and in some cases includes only a portion o * one

of the CUBOL levels as defined in the current stanuar'ls. it

is defined to include a portion of the NULLtUS and coth

SEQUENTIAL 1-0 and RELATIVE 1-0. A small portion of the DE-

BUG module was included along with some IN [ERPROuP AM COMMUN-

ICAliUN instructions.

rtnere possible, short forms were included rather than

long forms, and if two forms existed for tne same instruc-

tion, only one was included. For example, the snortened PIC

is used rather than the full word P I C T u P t . Also GO is not

followed by the oDtional word 10. This does allow the de-

finition to De a orcper suoset of the standard COBUL, but,

at the same timm, reduces the impact of the wordiness of

COBUL on a small system.

As an exception to the general rule, PEKFuRM uMIIL was

included from level <? of the NUCLEUS in order to provide an

additional control structure to support structured program-

64

Page 137: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 138: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ming techniaues. Further information on HYPu-CObOL can be

found in reference t>

.

6b

Page 139: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 140: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

II. ORGANIZATION OF THE I MPL I MFNT AT I OlM

Ihe compiler is aesiqned to run on an 80PU system in an

interactive mode through the use of a teletype or console.

It requires at least l^k of RAM .memory and a mass storage

device for reading and writing. [he compiler is composed

of two parts or passes/ each of which reads a portion of fne

input file. Pass one reads the input program ana ouilas the

symbol table. At the end of the OAFA DIVISION/ pass one is

overlayed dv oass two whicn uses the symbol taole to nrnjuce

the coae. The output code is written as it is produced to

minimize the use of internal storage.

Ihe first program of the interpreter builos t ne core

image of the code ana performs such functions as bacK-

stuffing addresses. This first orogram loads the second

program in and relenguishes control to the run time environ-

ment. Ihe interpreter is controlled by a larae case state-

ment that aecoaes the instructions and performs the required

actions.

As a tool for debuqginq the compiler a seperate orogram

was created that will read the output coae and translate the

operations b a c k into the mnemonics that are useu in the

second oass of tne compiler. 1 n i s "decoae" program has been

included with the other programs in oroer that anyone wish-

ing to make chances to the output code or to the actions of

60

Page 141: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 142: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

the interpreter can use this tool

67

Page 143: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 144: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

III. M1CR0-C0BUL ELEMENTS

This section contains a descriot ion of each element in

the language and shows simple examples of its use. The fol-

lowing conventions are used in explaining the formats: Ele-

ments inclosed in orc<en braces < > are themselves complete

entities and are described elsewhere in the manual. Ele-

ments inclosea in stacKS of traces { > are choices/ one of

the elements which is be used. Elements inclosea in b r a c < -

ets I ] are oot iona' . All elements in caDital letters are

reserved woras and must be soelled exactly.

User names are indicated as lower case. These names

have been restricted to Id characters in length. There are

no restrictions in the comoiler on wnat characters mav be in

a user name. Some restrictions ao need to be made to assure

that they are not ta<en as literal numbers when usei in t n e

DATA DIVISION. For example a record could be jetineu in the

DATA DIVISION with the na^e 1334, but the command HOVE l?i>4

TO RECURU1 would result in the movement of the literal

number not the data stored. The HfPO-LOtfOL description re-

quires that each na^e start with a letter. Ihis restriction

was not implemented because it violates common Drogramminq

prac t i ces .

Ihe incut to the compiler does not need to conform to

stanaard COBOL format. Freeform inout will be acceDteo as

66

Page 145: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 146: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

the default condition. If desired/ sequence numoers can De

entered in the first six positions of each line. however* a

togqle neeas to be set t- o cause the compiler to icnore those

1 i nes

.

69

Page 147: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 148: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

IDENTIFICATION DIVISION

ELEMENT

:

IDENTIFICATION DIVISION Format

FOkMA I

:

IDENTIF ICAT ION DIVISION.

PKO(iRAM-ID. <corrment>.

IAUIHOR. <comment>.]

I D A I E - WRITTEN. <co:nment>.l

iSELuRITr. <connrrent > . 1

DESLR1PI IUN:

This division provides information for pronram i a e n -

tification for tHe reader. The order of the lines is

f i xea

.

examples:

IDENTIFICATION DIVISION

PROGRAM-ID. SAMPLE.

AUTHOR. A S CRAIG.

70

Page 149: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 150: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

tNVlR8NMtNT DIVISION

ELEMENT:

ENVIRONMENT DIVISION Format

FORMA I :

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

SUUKCE-CQMPUTER. <comment> TDEdUOGING MODE] .

ObJtCT-COMPUTFk. <comment>.

[INPUT-OUTPUT SECTION.

FlLh-CONTROL.

< f i 1 e-c on t ro 1 -en t r y > ...

ti-U-CONTROL.

SAME file-name-1 file-name-^ lfile-name-3J

(file-name-^] ( f i I e-name-Sl . ] ]

DESCRIPI ION:

Ihis division oetermines the external nature of a

file. In the case of C P / M all of the files used can

be accessed either seauentially or* randomly except fc

variable length files which are senuent lal only. The

debugging mode is also set by this section.

71

Page 151: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 152: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<f i le-control-entry>

tLEMhNf :

< f i le-control-entry>

FORMAT :

1 .

StLtCT f i 1 e-name

ASSIGN i mp 1 en-en t o r-n ame

[ORGANIZATION SEQUENTIAL]

IACCESS SEQUENTIAL! .

d.

SELtC T f i 1 e-name

ASSIGN implementor-name

ORGANIZATION RELATIVE

IACCESS (SEQUENTIAL [RELATIVE dat a-nameJ }

]

{RANDOM RELATIVE data-name >

UESLRIRI ION:

The f i

1

e-con t ro 1 -en t ry defines the tyne of file that

the proaram expects to see. There is no difference on

the diskette, out the type of reads and writes t^at

are performed will differ. For C P / M the lmolementor

name needs to conform to the normal specifications.

Page 153: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 154: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

examples:

SELECT CARDS

ASSIGN CARD.FIL.

StLECT RANDOM-PILE

ASSIGN A. RAN

ORGANIZATION RELATIVE

ACCESS RANDOM RELATIVE RAfJD-FLAb

76

Page 155: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 156: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

DATA DIVISION

ELEMENT :

L)ATA DIVISION Format

FORMAT :

DATA DIVISION.

[FlLfc SECTION.

[FD f i 1 e-name

IbLOC* inteqer-1 RECORDS]

IRECORD [integer-^ TO] integer-i]

[LAdEL RECOkD {STANDARD}]{OMITTED >

LVALUE OF imolementor-name-l literal

[implen'entor-name-? literal-?]

l<record-desc n ct

i

on-ent ry>] ...] ...

-1

.. J

[wORKING-SFORAbE SECTION.

l<record-descrict i on-ent ry>] .. 1

[LlNt\AGE SECTION.

l<record-descript i on-ent ry > ] . . ]

DESLRIPI IUN:

This is the section that describes how the data is

structured. There are no major differences from stan-

dard COBOL exceot for the followinq: 1. Label

records make no sense on the diskette so no entry is

74

Page 157: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 158: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

required. 2. The VALUE OF clause likewise has no

meaning tor C P / ^ . 3 . The linkage section nas not Deen

1 mp I i men t ed

.

If a record is given two lengtns as in KF.COHD 12 10

128, the file is taken to oe variacle length and can

only be accesseo in the sequential mode. bee the sec-

tion on files for more information.

75

Page 159: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 160: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<C ommen t >

ELEMENT

:

<commen t >

FORMA I :

any string of characters

oestKiPi ION:

A comment is a string of characters. it may include

anything other than a oeriod followed by a Dlan* or ^

reserved word* either of wnich terminate the string.

Comments may he empty if desired/ out the terminator

is still reouired ov thp program.

EXAMPLtb:

this is a comment

anotheroneal I runtogether

O08Ub 16K

7o

Page 161: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 162: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<data-descript lon-ent ry>

ELEMENT:

<data-'Jescripficn-entry> Format

FOKMAI :

level-number {data-name)(FILLER >

(KtUEFINES data-name]

[PIL charac t e r-s t r 1 n^l

(USAGE {COMP M{DISPLA f >

[SIGN {LEADING} ISEPARATtJ)(TRAILING)

[UCCURS integerl

[SYNC [LEFT J]

[RIGHT]

[VALUE literal].

DESLR1PJ IUN:

This statement aescribes the soeci He attributes of

the data. Since the 8U80 is a byte machine? tr>ere was

no meaninq to the SYiJC clause* and thus it has not

been i mp I i men t eo

.

77

Page 163: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 164: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

examples:

01 CARD-RECORD.

Od PART PIC X(5).

02 NEXT-PART PIC 99V99 USAGE COMP.

02 FILLER.

05 NUMB PIC S9f3)VQ SIGN LEADING SEPARATE

03 LONG-NUMB 9(15).

05 STRING REDEFINES LONG-NUMB PLC X(15).

02 ARRAY PIC 99 OCCURS 100.

76

Page 165: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 166: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

PROCEDURE DIVISION

ELEMENT:

PROCEDURE DIVISION Format

FORMAI :

1 .

PROCEDURE DIVISION [USING namel Iname^J

section-name SECTION.

Ipa raa raph -name . <sentence> L<sentence>

LnameS] ]

. ] ... J

d.

PKOCEDORE DIVISION [uSINb namel lname2J ... InarreSj ]

pa ragraph -name . <sentence> [<sentence> ...J ...

DESCRiP! IUN:

As is indicated* if t^e proaram is to contain sec

tionSf then tne first paraarapH must oe in a section

The OSINO ootion is part of the interprogram con. muni

cation module ana nas not been impiimented.

79

Page 167: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 168: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<sen t ence>

ELEMENT

:

<sen t ence>

FORMA I

:

< i mpe rat i ve-statement>

<conai t i ona 1 -statement>

LNThK verb

uEbLRiPl IU.%:

All sentences otner than E rj T E R fall in one of the two

main categories. ENTER is part of the 1 n t

e

rorog nam

communication module.

BO

Page 169: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 170: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<imDerative-staten*ent>

ELEMENT:

< i mpe rat i ve-stateiient>

FORMAT:

The following verbs are always imperatives:

ACCEPT

CALL

CLOSE

DISPLAY

EXI I

GU

MUVt

OPEN

PERrORM

SIOP

The following may De imperatives:

arithmetic veros without the SIZE E^kOk statement

and DELETE/ rt R I T t , and REWRITE without the INVALID notion

81

Page 171: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 172: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<conai tional -statements>

ELEMENT:

<cond i t ional -statements>

FORMAT

:

If-

RhAIJ

arithmetic veros with the SIZE E k R R statement

and DELETE, ^RITE, and REWRITE with the 1NVALIU ootion

P2

Page 173: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 174: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ACCEPT

ELt^EiMT:

ACCtPT

FORMAT :

ACCtPT <ident i

f

ier>

DE SCRIP I I UN:

This statement reads up to 12. characters from t^e con

sole. The usage of the item must De DISPLAY.

EXAMPLtS:

ACCEPT IMMAGE

ACCEPT NUWC9,)

fli

Page 175: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 176: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

AuO

ELEMENT:

AUD

FORMA I

:

AUD { i dent i f i er > f { i oen t i f i e r- 1 > J 10 identifier-2{literal > { 1

i

teral }

IROUNDEDI (SI^E FRROR < i rrpera t i ve-s t a t em<=>n t > ]*

DESLRIPI IUN

This instruction aarts either one or two numbers to a

third with the result Demg placed in t H e last loca-

tion.

EXAMPLES:

AUD 10 TU NlJfoBl

AUu X Y TO Z RuUIjDEO.

ADD 100 TO NU^bEK SUE ERRGP GO ERR0R-L0C

fla

Page 177: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 178: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

CALL

ELEMENT:

CALL

FORMA F :

CALL literal [USING namel [na"ie?J ... lname5J )

DESLRIPI IUN:

CALL is not i*nplimented

85

Page 179: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 180: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

CL05F

tLEMtlMT :

CLOSE

F K M A T :

CLQbt f i 1 e-name

DEbCKiPI iUN:

Files must be closed if thev have oeen written. nci»-

ever; the norTal roqui rement to close an input tile

prior to tne enc of DPocessina does not exist.

tXAMPLEb:

CLOSE FILE1

CLOSE RAfMDFILE

flb

Page 181: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 182: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

DELETE

ELEMENT:

DtLtTE

FORMA r

:

DELETE record-name FIN VALID <imcerative-statement>J

DESLR1PI 1UN:

This statement reaui res the record name/ rot the file

name as in the standard form of the statement. Since

t-here is no deletion mark in C P /

M

, tnis woula normal lv

result in the record still beino readable. It is>

therefore* filled with zeroes to indicate that it has

been removed .

EXAMPLES:

DELETE REC0RD1

87

Page 183: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 184: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

DISPLAY

ELEMENT:

DISPLAY

FORMA I :

DISPLAY {identifier} [ { i dent i f 1 e r- 1 >

J

{literal } { 1 i teral }

DESLP1PI I UN:

This aisolays the contents of an iaent i f ler or

ai splays a literal C"> the console. Usage rrust oe

DISPLAY. The maximum length of the (ii spl av is 12 posi-

tions.

EXAMPLES:

DISPLAY MESSAGE-1

DlSPLAf MESSAGE-i 10

DISPLAY 'THIS MUST BE THE tMD'

86

Page 185: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 186: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

DIVIDE

ELEMENT:

DIVIDE

KOHMAl :

DIVIDE {identifier} into i denf i f i e r- 1 [ROUNDED]{ 1 i teral }

ISIZE EHPO" < i rperat i ve-s t at errent >J

DE5LW1PI 1UN:

lhe result of the division is scored in iaentifier-1?

any remainder is lost.

tXAMPLtS:

DIVIDE NU^B INTO STOKE

DiVlDE 2b INTO PESulT

89

Page 187: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 188: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ENTER

ELEMENT:

ENltK

FURmai :

ENTER language-naiie [routine-name!

DESCRIPI I UN:

Ihis construct is not i mo H men tea

<?0

Page 189: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 190: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

tXIT

EltMENT:

EXI I

FORMAI :

EXI I [PROGRAM]

DESCRiPl IUN:

The EXIT command causes no action cv the interpreter

out allows for an empty paraqraon for the construction

of a common return ooint. The optional PROGRAM state-

ment is not i mp 1

i

men t eo as it is Dart of the interpro-

qram communication nodule.

EXAMPLES:

RETOPN.

EXIT

91

Page 191: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 192: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

bO

ELEMENT:

GU

FORMAI :

1.

GU d rocedu re-name

d.

GU orocedure-l (procedure-21 ... procedure-20

U t P £ N u T .^J G i uent i f ier

DESLR1PI IUU:

The go command causes an unconai t ional brancn to the

routine specified. The second form causes a forward

branch deoendina on the value of tne contents of the

identifier. The identifier must ce a numeric integer

value. There can oe no more than ^0 Drocedure names.

EXAMPLES:

GU KEAu-CARD.

GU KEA01 REAU2 READ3 DEPENDING REAu-iNUEX

92

Page 193: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 194: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

IF

ELEMENT:

Ih

FORMAI :

IE <condition> UmDerative > ELSE imperative-?{NEXT SENTENCE}

UE3UPIP I iUN:

This is the standard COBOL IF- statement. Note that

there is no nesting of IF statements allowed since the

Ih statement is d conditional.

examples:

Ih A GREATER B A00 A TO C ELSE GO ERROH-ONE.

It- A NOT NUMERIC NEXT SENTENCE ELSE rtOvE ZERO 10 A

93

Page 195: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 196: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

MOVE

LLEMtNT:

MUVt

FORMAI :

MUVt {identif ier-1} TO iaentif ier-^{literal >

OESLrUPl IUim:

The standard list of allowable ^oves applies to tMs

action. As a space savina feature of tnis i mp I i ment a-

tion, all numeric moves go through the accumulators.

This makes numeric moves slower than a 1 pha-nume r 1

c

moves/ and where oossiole thev s n o u 1 a be avoided. Any

move that involves picture clauses that are exactly

the same can be accomplished as an aloha-numeric mcve

if the elements are reaefined as aiona-numeric* also

all group moves are alpha-numeric.

EXAMPLtb:

MUVt SPACE TU PWINT-LIHE

MUVt A (10) TU B(PTK).

94

Page 197: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 198: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

MULTIPLY

ELEMENT

:

MULI 1PLY

F0RMA1 :

MULIIPLY {identifier} bY identifier-*? IRUUNDLDJ{literal >

ISIZE ERRuR < i nnperat i ve-st at ement >1

DESCR1PI ION:

The multiply routine roouires enough space to calcu-

late the result with the full number of decimal digits

prior to moving the result into identifier-?. Ihis

means that a number with 5 places after the decimal

multiplied by a number with o places after the decimal

will generate a number with 11 aecimal places which

would overflow if there were more than 7 diaits t.efore

the dec i ma 1 place.

EXAMPLES

MULlIPLr X BY Y.

MULI1PLY A BY 6(7) SIZE E»ROR UO OvFkFlOa

9S

Page 199: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 200: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

OPEN

ELEMENT:

OPEN

FORMA I :

OPEN {INPUT f i lP-narre >

{OUTPUT f i 1 e-name>{ 1-0 til e-narne >

OEoLPIP I IUN:

These three types of opens have the exact san-e effect

on the diskette. However/ they do a 1 1 c « tor internal

checkino of the otner file actions. h o r example* a

write to a file set onen as input will cause a fatal

error.

EXAMPLES:

OHEN INPUT CARDS.

OPEN OUTPUT KEPOkT-FILE

<?o

Page 201: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 202: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

PERFORM

ELEMENT:

PtRrURM

FORMA I :

1 .

d.

i.

PtRrURM procedure-name (THRU Drcceaure-name-cM

PtRhORM procedure-name (THRU proc eau re-name-d

{ 1 dent ifierj TIMES{ i nt eqe p }

P t R h U R M Drocerture-name (THRU orocedure-name-c!]

UNTIL <condition>

DESLRlPl IUN:

All three options are supported. branching may be ei-

ther forward or bdc<ward> and the procedures called

may have oerforT statements in them as long as toe end

points do not coincide or overlap.

EXAMPLES:

PtRrURM OPEN-ROUTINE.

PtRrURM TOTALS ThPu END-REPORT.

PtRFORM SUM 10 TIMES.

PtRrURM SKIP-LINE UNTIL PG-CNT GREATER 60

97

Page 203: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 204: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

READ

ELEMENT

:

REAL)

FORMA I

:

1.

REAL) file-name INVALID <imperative-statement>

^.

R h A I) file-name END <imperativp-st3tement>

DESLR1P I IUN:

The invalid conoition is only applicable to tiles in a

random mode. All sequential files must have an F nD

st dtement .

examples:

REAL) CARDS END GO END-OF-FILE

.

RtAU RANDOM-FILE INVALID MOVE SPACES To REL-i

96

Page 205: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 206: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Pt WRITE

ELEMtNT :

RtWKlTE

F0RMA1

RtWKlTfc file-name [INVALID <

i

mpera t i ve>)

DESLRlP I I UN:

R t »» W i T t is only valid for f i 1 p s that are open in fne

I-U m o a e . The INVALID clause is only valia for random

files. This statement results in the current record

oeing written o a c k into the place that it was just

read from. Note that this requires a file name not a

record na^e .

EXAMPLES:

RESPITE CARDS.

RtflKlTE RA.mD-1 INVAIO PERFORM EPkOR-CHECk

99

Page 207: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 208: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

bTuP

ELEMENT:

S I OH

FOPMAI :

SI OP {RUN }

{literal!

DESLPlPl 1UN:

This statement ends the running of the 1 n t e rr re t p r .

It a literal is sceci f iea» then the literal is

displayed on the console prior to terminat inn ot t h

e

program .

EXAMPLES:

SIOP RON.

SI OP 1 .

SI OP "INVALID FINISH"

100

Page 209: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 210: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

SUBTRACT

ELEMENT:

SU6IRACT

FOKMAI :

SUrilRACT { i dent i f

i

er-1 } [

i

dent i f l

e

r-2] FROM identifier-3{ 1 i teral -1 > (li teral -2 1

IROUNDED] tcSIZE EkROR <*i mpe ra t i ve-s t at emen t >1

DESLRlR I IUN:

Identitier-3 is decremented by the value of

ident i tier/1 j teral one/ a n o » if sceci f ieo>

i den t i f i e r/ 1 i t e ra 1 two. The results are stored Dack

in identifier-^. Rounding and si^e error options are

avai laole if desired.

EXAMPLES:

SUblRACT 10 FRU^ SUBU2).

5UBIKACT A B FROM C ROUNDED

101

Page 211: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 212: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

WRITE

ELEMENT :

WRI I E

FORMA I :

1.

/vKllE file-name [{BEFORE} ADVANCING {INTEGER}]{AFTER > {PAGE >

d.

•<HH I IE file-name INVALID <imrerative-statement>

DESLRIP I ION:

There is no printer on the 80flu system here/ so tne

ADVANCING option is not imolimenteo. The INVALID oo-

tion only aoplies to random files.

EXAMPLES:

AKllE OUT-FILE.

rtKllE RAND-FlLt INVALID PERFORM ERKOR-RECOV

102

Page 213: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 214: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

<Cond i t

i

on>

ELEMENT:

<Cond i t i on>

FOHMAf :

KtLAllUwAL CONDITION:

{ident i f ier-1 > [NOT! {GpeatEk} {identifier-?/(literal-l) {LESS > {literal-? >

{EQUAL }

LLASS CONDITION:

identifier [NOT] {NUMERIC >

(ALPHABETIC)

DESCR1PI IUN:

It is not valia tc compare two literals. The class

condition N U M t R I C will allow for a siqn if the iaen-

tifier is signea numeric.

EXAMPLES:

A NUT LESS 10.

LINE GREATER "C".

NUMttl NOT NUMERIC

103

Page 215: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 216: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Subscripting

LLtMENT

:

Sudsc r i pt i ng

F0HMA1 :

data-name (subscript)

DESLH1PI iUN:

Any item definec witn an OCCURS many be referenced cy

a subscript. The sucscript may be a literal integer,

or it may be a data item that has open specifieo as jp

integer. If the subscript is signed, the sign must oe

positive at the time of its use.

tXAMPLtS:

At 10)

I ILM(SUB)

10U

Page 217: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 218: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

IV. COMPILER TOGGLES

Ihere are four t c g a 1 e s in the compiler. They are en-

tered on the first line of the program as a dollar sign fol-

lowed by the qiven letter. In each case the toggle reverses

the aef aul t value.

$L -- list the input coae on the screen as the crogram

is compiled. Default is on. Error messages will be diffi-

cult to understand if this toagle is turned o f f > but if the

interface device is a teletyoe* it ">ay be aesirea in certain

si t ua t ions.

$3 - - seauence numbers are in the first six oositions

of each record. Default is off.

$P -- list productions as tney occur. default is off.

SI -- list tokens from the scanner. Default is off.

10b

Page 219: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 220: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

V. RUM TIME CONVENTIONS

Ihi s section explains how to run the compiler on the

current system. The compiler expects to see a file with a

type of CdL as the inout file. In general f the input is

free form. If the input includes line numoers then the com-

piler must he notifiea by setting tne appropriate toggle.

Ihe compiler is started by t y p i n a COBOL <file-name>. i". here

the file name is the system name of the input file. There

is no interaction required to start the second part of tne

compiler. The output tile will have the same file name as

the input file/ ana will be given a file tyoe of CIN. Any

previous cooies of the file will be erased.

Ihe interpreter is started bv typing CBLIimT < f i 1 e -

name>. Ihe first program is a loaoer, ana it will aisplay

"LOAD FINISHED" to indicate successful completion. Tne

run-time packaae will be brought in by the Duila procram,

and execution should continue without inter upt ion.

106

Page 221: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 222: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

VI. FILE INTERACTIONS WITH CP/M

The file structure that is expected by the program im-

poses some restrictions on the system. References 2 and 3

contain detailed information on the facilities of C P / M , and

should be consul tea for details. The information that has

oeen included in this section is intended to explain wnere

limitations exist ana how the proaram interacts with the

system.

All tiles in CP/V are on a random access device/ and

there is no w a v tor 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 lenath records. Tne restrictions of the

ASSIGN statement do orevent a file from being open for ooth

random and sequential actions during one orogram.

tacn logical record is terminated by a carriage return

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

this is the only end mar* that exists. This convention was

addopted to allow the various programs which are used in

CP/m to work with the files. Mies created by the editor/

for example/ will generally be variable lengtn files. This

convention does remove the capability of reading variable

lenath f i les in a random mode.

107

Page 223: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 224: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

All of the physical records are assumed to oe l^H bytes

in length, and the crogram supplies buffer space for these

records in addition to the logical records. Looical records

may De of any desireo length.

108

Page 225: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 226: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ERROR MESSAGES

COMPILER f-ATAL MESSAGES

tiH Bad read -- disk error/ no corrective action can oe

taken in the program.

CL Close error -- unaole to close tne output tile.

MA Make error - - could not create tne output file.

MO Memory overflow -- the code and constants generated

will not fit in the alloted memory soace.

OP Ooen error -- can not ooen the input file/ or no such

file oresent .

ST Symbol table overflow -- symbol table is too large for

the allocated soace.

/<<R /» r i t e error - - aistc error* could not * r i t e a coae

record to the disk.

COMPILER WARNINGS

EL Extra levels -- only 10 levels are allowed.

109

Page 227: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 228: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

FT File tyoe -- the data element used in a rean or write

statement is not a file name.

IA Invalia access -- the specified ootions are not an al-

lowable combination.

ID Identifier stack overflow - - more than 2 items in a

bU 10 — DEPENDING statement.

IS Invalia suDscrict -- an item was suoscrioteo but it

was not defined Dy an OCCUKS.

iT Invalid type - - the field types oo not match for this

stat emen t

.

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

item that is part of a group item previously assigned

a value.

NF No tile assigned -- there was no StlhCT clause for

this f 1 1 e . .

N I Not implimented - - a oroduction was used tnat is not

i mp I i men t ed

.

N N Non-numeric -- an invalid character was founo in a

nume r i c string.

1 10

Page 229: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 230: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

NP No production - - no production exists for the cuurrent

parser configuration; error recovery will automatical-

ly occur.

NV Numeric value -- a numeric value was assigned to a

non-numeric item.

PC Picture clause -- an invalid character or set of char-

acters exists in the oicture clause.

PF Paragraph first -- a section heaaer was produced after

a paragraoh header, whicn is not in a section.

HI Kedefine nesting -- a redefinition was made for an

item which is part of a redefined ite^.

R2 Kedefine length -- the length of the redefinition item

was greater than the item that it reaefinea.

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

identifier due to an invalid character.

SG Sign error -- either a siqn 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 fiela aetined.

1 1 1

Page 231: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 232: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

TE Type error -- the type of a subscript inaex is not in-

teger numeric.

vE value error -- a value statement was assigned to an

item in the file section.

INTtKHRtTtR FATAL ERRORS

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

put file.

ME Make error -- the system was unaole to make an input

file on the ais^.

NF i jo file -- an inout file could not be ooeneo.

W I write to input -- a write was attempted to an inout

file.

INTtRPRtTtR WARNING MESSAGES

EM hnd mark -- a record that was read did not have a car-

riage return or a line feed in the exoectea location.

GD Go to depending -- the value of the oepenaing indica-

tor was greater than the number of available oranch

1 12

Page 233: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 234: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

addresses .

1C Invalid character -- an invalid character was loaded

into an outout field during an edited move. For exaw-

ple> a numeric character into an alphabet ic-only

field.

SI Sign Invalid - - the sign is not a "+" or a"-"

1 13

Page 235: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 236: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

LIST OF REFERENCES

1. Craig> A . S. MICRO-COBOL an implementation of NavyStandard HYPO-COBOL for a m i

c

roprocessor-basea com-puter system, Masters Thesis, Naval PostgraduateSchool , March 1977 .

2 . Digital Research, An Introduction to CP/M Features andFac i 1 i t i es, 1976

3. Digital Research, C P / M Interface Guide, 1 9 7 o .

4. Intel Corporation, 8008 and 80*0 PL/v Progromminq Manu 1

al, 1975.

5. Intel Corperation, 8080 Simulator Software Packaae,1W4.

6 . Software Development Division, ADPE Selection Office,Department of the Navy, HYPO-CbBOL, Aoril 1^75.

7. Strutynski, K a t h r y n B. Information on the CP/M Inter-face Simulator, internally aistrioutea technicalnote.

1 14

Page 237: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 238: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C001OC002OG0030C0C4OCO05000060C0C70CO0800009C00100C011OCO 120C013000140C01500016O0O170C0180CC19CC0200C0210C022CC022CC0240C025CC0260C0270C0280CC290CO30000310C03200033C003400035000360CC37000380C039CC0400C0410G0h2000430C044CC0450C0460C04 70004600049CC050000510C05200053CC05400055000560C0570C058CC0590C060CC061000620C06300064C00650C0660C0670C068CC0690C0700C0710C0720C0730007400075000760CO7700076CC079CCCfaC0C0810C0020C0830C064OC0850C066CCC670C0880CC89CC090OCOVl0C0920C0930CC94OC0950C0^6OC0970C0980C099CC1000C1010C1C200103

, 0C1040C1050C106OC1070C1C8

/*

tOOH: /*

/*

CCECU COMPILER - PART 1

LCAC POINT */

GLOBAL CECLARATIONS AND LITERALS

*/

*/

CFCLAPE LIT LITERALLY 'LITERALLY';DECLARE

eoos LITKAXSVEMCRY L ITINITIALIPOS LITRCRSLENGTh LITPASSLSLEN LITBLCT LITCR LITLF LITCUOTE LITFCUNC LITTRLE LITFALSE LITFCREVER LIT

•5H', /* ENTRY TC OPERATING SYSTEM•3100H', /* TOP OF USEABLE MEMORY• 2C00H'

,

• 2C00H'

,

•255' ,

•46',

'0',

• 13' ,

• 10',•22H'

,

•23H'

,

' l» t

'0' ,

•WHILE TRUE';

DECLARE MAXRNO LITEPALLY '104',/=* "AX READ COUNT */MAXLNC LITERALLY '129',/s MAX LOCK COUNT */MAXPNG LITERALLY '145*,/* "ax PUSH COUNT */MAXSNO LITERALLY •234',/* MAX STATE CCLNT */STARTS LITERALLY '!•;/* START STATE */

SYSTEM */

DECLA

CECL,

DECL

DECU

DECL

RE /SCI CATA (0,57, 48, 56, 32, 8 ,2 5, 59, 2, 16, 17, 22, 29, 5, 34, 44, 9, 19, 32, 37, 6, 33, 3, 14, 15,1 3, 20, 32, 28, 4y, 32,it 1,1, 1 ,1,1,1 , 10,1 ,39, 1 , L, 1, 3c, 40, 4 9, 3 6,3 9, 1,1 ,38, 46, 1, 7, 50, 1,32. 1,32, 32, 45, 1, 32, 1,32, 1,32, 47, 37,

4

, 5, 12, 12, 21, 22, 27,1, 60,1, 23, 2<,, 55, 30, 51);L0CK1 CATAIO, 3, 0, 25, 0,9, 19, 0,t2, 0,42,0, 1,0, 52,0,

4 ,0, 54, 0,40, 0,35, ho, 60, 0,1, 0,32, 0,1, 0,1,0, 11, 0,cO,0) ;

APPLY1 CATA (0,0, 0,0, 0,0, 9, 10, 12, 14, 19, CO, 0,0,0,0, C , 0,0, 97, 0,27, 0,0, 0,69, 0,91, 92, 0,0, 9 1,92, 0,0,0,3,1C4,0,0,0,0,0,:5,0,0,34,0,0,23,30,30,29,0,21,40

30,31 ,33,322,230 ,229,105.14,1542,146,16,,193,23,206,63,40,59133,54, 134,09, 142 ,18,101,102,2

31,62,33,724, 179,1783,133,128,6,222, 199,

,4, 24,48,29,341 i 1 o, 52. 75,77,05,109,0,42 ,441, 175,219,20,25,38,363,54,54I ,62,67,1,1,1,2,1,1,11,2,2,22, 2, 2., 2, 88 ,89 ,

j-,0, 0, 1

1,4,0,0

,24,3b,, ?3 ,

79,024,2,<-6,12,20,20.33,,!>'.>,

) ;

1, 1,,1,1,2,2,2,796,9,0,2,1 ,0

f , 13,137, 24,54 , 55 ,

1,83,34,24,14d ,50,01,177,22 ,223 3,39,55,56,

1,1,1,,1,1,1,2 ,1,1,2,2,49,101,,o,:,i,0,0,0

3,53,11 ,32,32,39U42, 38,36,43,1,23,24,53,52 ,41,26,32,54,40, 1 ,1

41, 0,35, CI, 0,47,0,7,O,22,C,32,C

0,101,0,0,100,0C, 13, 17,0, 102,52,56,87,93,94

9,61,66,27,234,232.231 ,223 ,1738,4, 50, 20, 12, 1825 ,53, 1C6, 1556,2^4,62,52,206);,135,69,71,1364 ,1U4, 184,91 , 139CO, 103,202,104

6,76, 117,75, 156,94, 1 21 ,74. 125129,127,205,20565,220, 116,37

4,24,109,4,15,1624,16, j3, 39, 4056, 57, 56, 60, 615, S7,Qd,e9,9C,92,3 ,5 ,3, 10, 12, 1452,185 , 149,225,1,2,3,2,4,4,5,5,23 ,23 , 24 , 24,2539,39,39,39,42;6

,

jo , 56 , 56

,

do

1,1,1,1,1.1,1.1,1,1.1.1,1,1,1,1,1,2,1 ,1, 1 ,5,5 ,1, 2 . J, 2, 2 ,2,2,2, 22.9,3,0,3,0,3,0,2,0,1,5,3,0,0,1,1,1, 1,1,2,2,1,1

/* END CF TABLES »/CECLARE

/* JOINT CECLARATIONSTHESE ITEMS ARE DECLARED TOGETHER IN THIS SECTIONIN ORCER TC FACILITATE THEIR BEING SAVED FCR1FE SECCND PARI CF THE COMPILER.*/

CL'TPUTSFCo (23) BYTECEBUGGING BYTEPRJNTSFROC BYTEPP1NTJTCKEN EYTEL1STJINPUT BYTESEatNUI* BYTENEXISSYM ADDRESS,POINTER ACUKnSSNEXTtA VAI LAeLE ATOPESSMAXSINTIME* ADORcSSF ILEtSECSENC BYTEFKEFiSlCRAOE ACURESS

INITI AL(0,

INITIAL (FALSE),INITI AL1FAL SE)

,

INIT I AL(FALSE),INITIAL (FALSE,,INITIAL (FALSE) ,

INITIAL ( 10CH)

,

INITIAL (2002HI,INITIAL ( 32 OOH),INITIAL (FALSE) ,

INITIAL (2500HI,

', 'CIN' ,0,0,0, 0)

,

/* I C eUFFERS ANC GLOBALS */INSACCR ADCRESS INITIAL (5CH),INP'JTtFCB BASED INAOOR 133) BYTE,CLTPIJT1FTR ACCRESS,CLTPLTJEUFF (12d) BYTE,CLTPUTUNC ACUKESS,CUTPUTHFAP BASEC OUTPUTSPIP BYTE;

115

Page 239: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 240: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C109C01 10OClll001120C1130C1 1400115001160C1 170C1 1800119CC1200C12100122OC1230C12400125OC) 26OC127001280C129CC130O013100132001330C1340013500136CC137001380C139CC140OClll0C1420CU300144OC145001460C1470C148CC1490C150CC15 1

OC1520C1530C1 540C1550C156001570C1580C159CC1600C1610C1620016300164001650C16600167CC16800169CCi700C1710C172OC173OC17400175OC176001770C176CC179CC180001810C182001830C184OC18500186O0U70C188CC1£9CC190001910C1S20C1930C1940C19500196CC1970C1S8CC199CC200002010C2020C20300204002050C206OC207002C8CC2C9CC2 10002110C212002 13002 140C2150C2160021700218

MCM: PROCCCLPE ( F , A 1

;

CECLAPE F BYTE, A ACORESS;GC TC eccs;

END MCN'l;

MCN2: PROCE0L3E (F,A> BYTE;CECLARE F BYTE, A ADDRESS)GC TC BCCS;

END *CN2;

PRINTCHAR: PRCCECUP.f (CHAR);CECLARE Cf-AR QYTE;CALL MCM (2, CHAP);

END PRINtO«F;

CRLF: PRCCECURE;CALL PRINTCHAR(CR) ;

CALL PP INTCt-AR (LF) ;

ENO CRLF;

PRINT: PROCECUPE (A);CECLARE A ADDf.ESS;CALL MCM (S,A)

;

END PRINT;

PRINT JERRCR: PROCEDURE (CODE);CECLARE CCCE ADDRESS;CALL CRLF ;

CALL PR 1NTCFAP(HIGH(CPDE) ) ;

CALL PP INTCHAR (LCW(CODE) I ;

ENO FRINTiERPCP;

FATALiERRGF: FFCCEPU RE ( REASON )

;

DECLARE REASCN ADDRESS;CALL PP INT JERPOR (REASON) ;

CALL TICE ( 1C);CO TC BCCT

;

END FATALJEPRCP;

OPEN: PROCECURS;IF M0N2 (15i IN$ACCR) = 255 THEN CALL FATAL $ ERROR (• OP • J ;

ENC CFEN;

MCRE1INFUT: FPCCECURE BYTE;/ READS THE 1NPLT FILE AND RETURNS TRUE IF A P.ECCRDWAS RtAC. FALSE IMPLIES END OF FILE */

CECLARE CCM BYTE;IF (DCNT:=MCN2(20,.INPUTSFCB) )>1 THEN CALL FAT AL $ ERR CR (

' 9R ' )

RETURN NOT (CCNT) ;

END NCPESINFLT;

PAKE: PROCECUPE;/* DELETES ANY EXISTING COPY CF THE OUTPUT FILE

ANC CREATES A NSW COPY*/CALL MCM ( 19,.CUTPUT*«-cs) ;

IF MON2122 ..CUTPLT JFCS)=255 THEN CALL c A T AL SERIOR ( ' M A •) ;

ENO MAKE;

WRI TE50UTPLT : PROCEDURE:/* WRITES CLT A BUFFER «/CALL MCM < 26. .OLTPUT$BUF c

) ; /* SET DMA *

/

IF M0N2(21 ,.CUTPUT$FCB)O0 THEN CALL FA T A L SERROR ( ' WR ) ;

CALL MCM(2fc,80H); /* RESET DMA »/END WRI (ESCLTPL1 I

MCVE: PR0CECURE (SOURCE, DESTINATION, COUNT);/* MOVES FCR THE NUMBER OF BYTES SPECIFIEC BY COUNT */CECLARE ( SCLT.CE, DESTINATION) ADDRESS,(SJ6YTE EASCC SOURCE. DSbYTE BASED OES T I NAT ICN , COUNT) BYTE;DC WHILE (CCUNT :=CCUNT - 1) <> 255;

DJ3YTE=S$3YTE ;

SCLRCE=SOURCE +1;DESTINATION - DESTINATION + 1;

END;END hCVE;

FILL: PROCECL'REUDDR, CHAR, COUNT) ;

/* MOVES CHAR INTO AODR FOR COUNT BYTES */CECLARE ADCP ADDRESS,(CHAP , CCUNT ,C?ST BASED ADOR ) BYTE;DC WHILE (CCUNT: =CCL'NT -1)<>255;

OtST=CHAR ;

ACCP=ACDR + l;END:

END FILL;

/ * * *CECLARE

LITERALINPUTtSTRPERIODINVALID

' * SCAMPER LITS *

LIT '15'

,

LIT • 32'

,

L II • 1' ,

LIT '0';

*/

*//* » * « » SCANNER TABLES * * »DECLARE TOKEN«TAf-LE CATA

/* CONTAINS THE TOKEN NUMBER ONE LESS THAN THE FIRST RESERVED WORDFCR EACH LENGTH CF WORD */(0,0, 1,4, 5, 15, 22, 32, 30, 44, 47, 49, 51, 55, 56, 57),

TABLE DATA! 'FC'DF' .'TO* ,'PIC* , 'CGMP' ,

'

DATA' ,'FILE'f'LEFT'.'MCfjfc', 'SAME', 'SIGN ',' SYNC • , • ZERO • r 'BLOC K«,' CUOTE' , • RK.HT' , • SPACE' ,

' USAGE ',' VALUE ' , 'ACCESS ' , 'J- Hit, 'AUTHOR' , 'FILL'". ?' , ' OCCURS* , 'KANCO-M' . • J-.ECCR C • , • SE L ECT '

t • DISPLAYS 'LEADINGS ' LINKAGE ' , "OM I TTED« ,• RECORDS'

,'SECTICN ,

,, CIVlSICN', , RELATIVE , ,'SECU'-ITY', , SCPARATE ,

,, STANDARO'

, 'TRAILING ' , ' DEBUGGING' , ' fRUCEDUkfi' , 'P.EDEK INES",

'

PROGRAM- If ,

'

SfOUrNT IAL* • 'SNV IkUNMENT • , ' l-U-CONTROL', ' DA U-wR Illfl,' , 'F ILE-CGNTRCL' , • INPUT-OUTPUT' , 'ORGAN UAT ION'

,

LABEL 1

'ASSIGN'

116

Page 241: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 242: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C219002200C2210C2220C22300224002250C2260C227002280C229CC2300C2310C2320C233CC2340C235002360C237002330C239CC240002410C2420C24300244002450C2460C2470C2480C249CC2500C2510C2520C2530C2540C25500256CC25700258C0259CC2600C2610C2620C2t30C26400265002660C2670C2660C269OC2700C2710C2720C2730C274002750C276002770C2760C279OC2800C2610C2820C283002840C2650C2860C2670C288C0289CC29C0C2910C2920C2930C2S40C2S50C2960C2970C2S8CC2S9CC3000C3010C302003030C3C4003050C3060C3C70C3C80C3C9CC31000311003120C3130C314003 15003160C3170C3180C3190C320OC3210032200323CC3240C32500326OC3270C328

, 'CONFICURATICN' , • IDENTIFICATION' , 'OBJECT-CCMPUTER, • SCURCE-CC^PUTER' , 'WORKING-STORAGE' >

i

OFFSET (16) ACCRESS/* NUMBER CF BYTES TO INDEX INTO THE TABLE FOR EACH LENGTH */INITIAL (0,0,0,6,9,45,80, 128,170,218,245,265,

287,335,346,362),

WORCSCOUNT CATA/* NUMaER CF WQRCS OF EACH SIZE */(CO, 3, 1,9, 7, 8, 6, 6, 3, 2, 2, 4, 1,1, 3),

PAXSLEN LIT • 16' .

ACDiSNC DATA (PROCEDURE •),LCCKEO BYTE INITIAL (0),FOLD BYTE,

ADDRESSEUFFERJENO INITIAL (100H),NEXT BASED POINTER BYTE,IN3UFF LIT •80H' ,

CHAR ' BYTE,ACCL'PSLENG LIT •50' ,

ACCUM BYTE,P 1ACCUM <ACCUM$LENG) BYTE,CI5PLAY BYTE INITIAL (0),C ISPLAYSREST ( 73) BYTE,1CKEN BYTE; /RETURNED FROM SCANNER */

/»***# PROCEDURES USED 3Y THE SCANNER * * * */

BUFFERSEND THEN

NEXTKHAR: FRCCFCURC- BYTE;IF LCCKEC TFENC ^ *

LCCKEC=FALSE;RSTLRN (CHAR:=HOLD)

;

FND;IF (PCINTEP:=POINTER + 1)CC;

IF NCT MCRSi INPUT THENDC;

BLFFER$ENO=.MEMORY!PCINTER=.ADOSEND ;

ENC;ELSE FCINTFR=INBUFF;

END;RETURN (ChAR:=NEXT) ;

END NEXlSCFiR ;

C-ETSCFAR: FFCCECLRE;/* THIS PROCEDURE IS CALLED WHEN A NEW CHAR IS NEEDED WITHOUTThe DIRECT RETURN OF THE CHARACTER*/CFAR=NEXT$CFAP. ;

END CETICHAR;

DISPLAYSLINE: PROCEDURE:IF NOT LISTJINPUT THEN RETURN;DISPLAYIDI SPLAY + 1) = • $• ;

CALL PR1NTI.DI SPLAYSREST) ;

CISPLAY=0;END D1SPLAYJLINF ;

LCADSDISPLAY: FRCCEDLRE;IF DISPLAY < 72 THEN

DI SPLAY (DISPLAY:=DISPLAY + I) = CHAR;CALL GETSCFAR;

END LCACSDISPLAY ;

PLT: PROCEDURE;IF ACCLN < ACCUfMLENG THENACCUM( ACCLf :=ACCUM+1)=CHAR;CALL LCADSDISPLAY;

END PUT;

EATSL INE : FROCEOLRE;CC WHILE CFAROCR;

CALL LCADSDISPLAY;END;

END EATSLINE;

0ETSNCS3LANK: PROCEDURE;DECLARE (N,I) BYTE;CC FOREVER;

IF CHAR = ' ' THEN CALL L OADSDI SPLAY

;

ELSEIF CHAR=CR THENCC;

CALL DISPLAYSLINE;IF SEOiNUM THEN N=0; ELSE N=2;CC I = 1 TO N;

CALL LCADSDISPLAY;ENO;IT CHARELSEIF CHAR

DC;

ENO;ENC;ELSERE1LRN;

ENO; /* ENO OF OC FOREVER «/ENO CETINClf LANK;

SPACE: FRCCEDUPE eYTE:RETLRN ICFAF=' •) OR (CHAR=CR)

END SPACE;

•*• THEN CALL EATSLINE;

' :« THEN

IP NOT DEBUGGING THEN CALL EATSLINE;ELSE CALL LOADSDISPLAY;

117

Page 243: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 244: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

CC329 1

00330 200331 20C332 20C333 20C334 2OC335 20C336 200337 3

OC338";

0C339 2CC340 2

0C341 200342 1

0C343 1

00344 2

0C345 20C346 1

0C347 1

0C348 20C349 2CC350 20C35 1

?

00352 3

0C353 40C354 40C355 30C356 a

OC357 2C0358 1

0C35S 1

00360 I

0C361 20C362 20C363 20C364 20C365 30G366 30C367 a

0C3*e 4C0369 3CC370 ?

CC371 2

00372 200373 200374 20C375 30C376 •a

0C377 20C378 2CC37S 1

CC38C 1

00381 200382 200383 200384 ?0C3e5 200386 20G387 20C388 2

C0389 2C0390 1

0C391 1

0C392 20C3S3 20C394 2CC395 20C2S6 2

0C397 20C358 30C3SS 3CC400 20C401 20C402 30C403 30C4 04 20C4C5 1

0C406 1004C7 1

0C4C8 1

0C409 2CC410 ?

0C4U 200412 3

0C413 300414 a

00415 30C416 30C417 40C418 30C4 19 2CC420 1

0C421 1

0C422 1

00423 20C424 20C425 2CC426 1

00427 1

0C428 20C429 20C43C 2004 31 300432 30C433 400434 400425 30C436 a

00437 20C438 2

DELIMITER: PPCCEDURE BYTE;/* CHECKS FOR A PFRIOU FOLLOWED BY A SPACE CR CR*/IF CHAR <> •.• THEN RETURN FALSE;HCLL) = NExT$CHAR;LGCKEC=TRUE ;

IF SPACE THENcc;

CH«R = •.»;

RETURN TRUE;ENO;CHAR=« .•;RETURN FALSE;

END CELIMITER;

ENDKFSTOKEN: PROCEDURE BYTE;RETURN SPACE CR DELIMITED;

END EN£$CF$TCKEN;

GETHITERAL: PROCEDURE BYTE;CALL LCAC$CISPLAY;CC FOREVER;

IF CHAP = QUOTE THENDC;

CALL LCADJDISPLAY;RETURN LITERAL;

ENC;CALL PUT;

END;END C-ETILITERAL;

LCCKtLP: PRCCECLRE BYTE;CECLARE FCIM ADDRESS.(HERE fcASEC PC INT, I ) BYTE;

MATCH: FFOCEOURE BYTE;DECLARE J BYTE;DC J = 1 TO ACCUM;

IF HERFU - 1) <> ACCUfMJ) THEN RETURN FALiE;ENC;RETURN TRUE;

END MATCH;

POINT-CFFSEKACCUM)*- .TABLE;CC 1=1 TG WCROtCGUNT(ACCUM);

IF MATCH THEIJ RETURN I;PC1NT = PCINT + ACCUM;

. END;RET CRN FALSE;

END LCCKSUF;

P.ESEP VEDll-CFD: PROCEDURE BYTE;/» RETURNS THF TOKEN NUMBER OF A RESERVED WORD IF THE CONTENTS O c

THE ACCUMULATOR IS A RESERVED WCRO, OTHERWISE RETURNS ZER.0 </CECLARE VALLE 3YTE;CECLARE NUMB BYTE;

IF ACCLM > MAX$LEN THEN RF.TUR;J 0;IF (NLM6:=T0KEN$TABLE< ACC'JM) ) =0 THEN RETURN 0;IF ( VALUE:=LOCKSUP 1=0 THd.N RETURN 0;RETURN (NUMB + VALUE) ;

ENC RESERVECiWCRC;

GETiTCKEN: FPOCECURE BYTE;ACCOM=0 ;

CALL GET«.NC$EL4.VK;IF CHAP=OLCTE THEN RETURN GETJLITERAL;IF CELIMITER THEN

• CC;CALL PLT;RETURN PF.RICC;

END;CC FOREVER;

CALL PUT;IF ENCSCFSTCKEN THEN RETURN INPUTSSTR;

END; /» CF CC FOREVER = /END CETSTCKEN;

SCANNER: PPCCECLPE;CECLARE CHECK BYTE:CC FCREVEP;

IF(TCKEN:=GET$TOKEN) = INPUTtSTR THENIF (CHECK:=3ES3RVE0$WURD) <> THEN TOKEN=CHECK;

IF TCKEN <> THEN RETURN;CALL FRINTSERRCR ('SE');DC WHILE NOT ENO J OF tTOKON ;

CALL GETSCHAR;ENC;

END;END SCANNER;

PPINTSACCLM: PRCCEDURE;t CCUM( ACCUM+ 1) = ' i '

;

CALL PF INT t .RSACC'JM) ;

ENO PRINTSACCLM;

PRINTSNUMBEP: F F CCEIl.'R E ( NUMB) ;

CECLARE (NL«E, I ,CNT,K) 6YTE, J DATA ( 1 00 , 1 ) ;

CC 1=0 TO l;cm = c;dc while numb >= (k:=j(i));

numb=numo - k;CNT^CNT + l;

ENC;CALL FRINTCHAKC 0» t CNT);

END;C«LL PP INTTHAM • 0' NUMB);

END frintjnlmber;

118

Page 245: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 246: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C439CC4400C4410C44200443004440C4450C44600447004480C4490C45000451004520C45300454004550C4560C4570C456004590C4600C4610C462004630C4640C4650C4660C4670C4680C46900470004 710C4720C47300474CC47 500476004770C4780C479C04800C48100482CC483004840C465004660C4e70C488CC4C9CC4900C4910C4920C493CC4940C495004960C4S70C4980049900500005010C502OC5030C5C40C505005060C5C70C5C80C5G9CC510005110C5120C5130C514005150C5160C517005180C519CC5200C5210C52200523OC5240C5250C526005270C528C0529CC5300C531005320C5330C5340C5350C536005370C53800539CC5400C5410C5420C5430C5440C545005*600547nrs4«

INITJSCANNEP: PROCEDURE:/* INITIALIZE FOR INPUT - OUTPUT OPERATIONS */CALL MCVE (.'CBL', INSADOR + 9, 3);CALL FILUIKSADUR + 12,0,5);CALL CPEN;CALL MCVEilMDCR , . OUTPUTS FC3 ,9 );0UTPUT$&NC=(CUTPUT$PTR:=.0UTPLT$3UFF - 1) + 128;CALL -MAKE ;

CALL GEIlChAR; /* PRIME THE SCANNER »/CO WHILE Ct-AR = $• ;

IF NEXTCHAR = 'L' THEN L I S T S !NPUT= NOT LISTSINPUT;ELSE IF CHAR =«S« THEN SECSNUM= NOT SECSNUM;ELSE IF CH4R = 'P' THEN PRIWTSPROO = NOT PR I N'T i FRCD;ELSE IF CHAR = «T' THEN PRINTJTOK.EN = NOT PR INT 1TCKEN

:

CALL CETSCHAR;CALL GET$N0$6LANK;

END;ENO IN1TJSCANNER ;

/*

/* * * i

DECLARE

CUR1SYMSYMBCLSYMBCLSAODRNEXTiSYMSENTP.YHASHiPTRDISPLACEMENTt-ASHIMASKSilVfcCCCUPSACCP2PiLENGTHS1LENGTHLE VElLCCAT IONP E L $ I

C

STAPTSNAMEM A X J I C t L E N

/» *

ENO OF SCANNER PROCEDURES »/

SYMBOL TABLE DECLARATIONS * * * */

ADORESS, /*SYMBOL BEING ACCESSEC*/BASED CURSSYM BYTE,BASED CURSSYM ADDRESS,BASED NEXTSSYM ADDRESS,ADDRESS,LIT '12',LIT •3FH'

,

LIT •2',LIT '11* ,

LIT '4',LIT •3',L IT '3',LIT 10' ,

LIT •2',LIT '5',LIT '11', /*1 LESS*/LIT • 12' r

* * TYPE LITERALS *»«*****/DECLARESFQLENTIAL LITPANCCM LITSEGSFELATIVE LITVARIAELClL :NG LITGFCUF LITCCMP LIT

/» * »

'2',•3»,'4'

,6«,

•21»!

SYMBOL TABLE ROUTINES */

IMTJSYMBCL: PROCEDURE;CALL FILL (Ff.EESSTCRAGE.O, 130) ;

/* INITIALIZE HASH TABLE ANO FIRST COLLISION FIELD */NEXTSSYf=FPEESST0RAGE+128;NEXTtSYf $ENTPY=0;

END IMTJSYMeOL;

GETtPtLENCh: PROCEDURE BYTE;RETURN SYMeCLIPSLENGTH) ;

END CETSPSLENGTh;

SETJACDRESS: F FOCEDUR E ( AODR ) ;

DECLARE ACCP ACCRESS;SYMBOL i£DCR(LOCATION)=ADOR;

ENO SETSAOCRESS;

GETiAODRESS: PRCCEDURE ADORESS;RETURN SYMeCLSADDR(LOCATION) ;

END GETSADCFESS;

GETITYPE: PROCEDURE BYTE;RETURN SYMBOL! SSTYPfc) ;

END GETSTYPE;

SETJTYPE: PFOCEOUF:

= ( TYPE)

;

CECLAPE TYPE BYTE;SYMBOL ( SSI YPE) =TYPE;

END setstype;

OPSTYPE: PPCCECLPE(TYPE) ;

CECLAPE TYPE BYTE;SYMBOL ( S$7YPfc)=TYPE OR GETSTYPE;

END CRSTYPe

;

C-ETSLEVEL: FPCCECURF oyTE;RETURN SHRISYMBOLI LEVEL) ,4)

;

END GET JLEVEL ;

SETiLEVEL: PPOCECURE ILVLJ;CECLAPE LVL BYTE;SYMBOL UEVEL)=SHL(LVL, 4) OR SYMBOL ( L EV CL ) ;

END SETSLEVSL;

GETSDECIMAL: PRCCEDURE BYTE;RETURN SYMECL(LEVtL) AND OFH;

END GETSCECIMAL;

SET1CECIMAL : PROCEDURE (DEC);CECLAPE CfC BYTE;SYMBOL (LEVEL) = CEC OR SYMBOL I LE VEL ) ;

FKO SFTSTFClMAt:

119

Page 247: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 248: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C54S 1

0C550 1 SF.TSJILENGTP: PROCEDURE (HOWSLONG) ;

0C551 2 CECLAPE P-CWJLUNG AODRESS;00552 2 SYMBOL JADCP ( SiLENGTH) = HCWtLONGJ00553 2 ENO JET t S $L ENGTP ;

00554 10C555 1 GETtSJLENGTP: FPCCEDURE ADDRESS;00556 2 RETURN SYMeCL J.ADCR ( SSL ENGTH )

;

0C557 2 ENO CETSS JLENGTh;0C558 1

CC559 10C560 1 SETSADDP2: FPCCEDURE (ACOR):0C561 2 CECLARE ACCR ADDRESS;0C562 2 SYMBCLSACCR < A C CR 2 ) =ACDR

;

0C563 2 END SETJADCP2;0C564 1

0C565 1 GETSACCR2: PROCEDURE AODRESS;00566 2 RETURN S Y*eC LI AD DP. I A00R2 ) ;

0C567 2 ENO CETSADCR2;0C568 1

0C569 1 SETJCCCL'RS: PROCEDURE ( CCCUR)

;

CC570 2 CECLAPE OCCUR 3YTE ;

OC571 2 JYM60L(CCCLRS)=CCCUR:0C572 2 ENO SETSCCCLRS;0C573 1

0C574 1 GETSCCCURS: PROCEDURE BYTE;0C575 2 RETURN JYNeCL (OCCURS);0C576 2 END C-ET$GCCLSS ;

0C577 1

00578 1 /* * * PARSER DECLARATIONS * * * */CG579 1 CECLARECC560 L INT LIT '63', /* CODE FOR INITIALIZE */C05CI 1 SCO LIT '66', /* CODE FOR SET CCDE START */OC582 1 PJTACKSIZE LIT <30', /* SIZE OF PARSE STACKS*/0C5E3 1 STMfcJTACK (PSTACKSIZE) BYTE, /* SAVED STATES »/00584 1 VALLE (PSTACKSIZE) ADORESS, /* TEM° VALUES */0C5E5 1 VARC 151) 3YTE, /*TEMP CHAR STORE*/00566 I ICSSTACK (10) ADDRESS INITIAL (0),C0587 1 ICiSTACKSPTR BYTE INITIAL(O),0C568 1 HCLCJLIT BYTE,0C5eS 1 RESTlHOLOtLlT (ACCUMSLENG) BYTE,CC590 1 hCLCiSYM ADDRESS,0C591 1 PtfiOINGILl TER AL BYTE I N I T I A L ( F ALSE ) ,

0C592 1 PENC1NGJLIT1ID AODRESS,0C5S3 1 REOEF 3YTE INITIAL (FALSE),0C594 1 Rf-OEFiONE ADDRESS,0C595 1 RECEFSTfcO ACDRESS,0C596 I TEMFSPGLD ADDRESS,0C597 1 TEMPlThO ADDRESS.0C598 1 CCMFILING BYTE lNI T I AL ( TRUE )

,

0C599 1 SP BYTE INITIAL (255),CC6C0 1 MP BYTE,0C601 1 MPP1 BYTE,0C602 1 NCLCCK BYTE INI T I AL

(

TRUE )

,

0C603 1 U.J.K) BYTE, /*INDICIES FOR THE PARSER*/0C604 1 STATE BYTE IN I T I AL ( ST ARTS ) ;

0C605 1

00606 1 /« * * * PARSER ROUTINES **»**/0C6C7 1

0C608 1 BYTEJCUT: PPOC ECLR E ( CN5 SB YTE )

;

00609 2 /* THIS PRCCEOURE WRITES ONE BYTE OF OUTPUT ONTO THE DISKCC610 2 IF REQLIREC THE OUTPUT 3UFFER IS DUMPED TO THE DISK */00611 2 CECLARE CNEJBYTE BYTE;0C612 2 IF (OUTPUT JPTR:=CUTPUT$PTR l)> OUTPUTtENC THENCC613 2 CC;00614 2 CALL hk ITE tCUTPUT

;

00615 3 0LTPLT1PTR=.0UTPUT$3UFF;0C616 3 ENO;0C617 2 CUTPUTKPAR = CNE$BYTE;0C618 2 END BYTEJCLI;0C619 1

00o20 1 STRINCICUT: FPCCEDURE ( ADDR, COUNT )

;

OC621 2 DECLARE ( ACCR, I , CCUN T) AODRESS, (CHAR 8ASEC ADOR) BYTE;

0C622 2 CC 1=1 1C CCUNT;0C623 2 CALL t3YTi$0UT ( CHAR) ;

0C624 3 ACCR=ACDR+l;0C625 3 END:0C626 2 END STRlNGSCLiT;0C627 1

0C628 1 ACCRJCUT! F PCC ECUR E ( ADCR )

;

0C629 2 CECLARE ACCR ADDRESS;CC630 2 CALL E Y T F SCL T ( LOl* ( AODR ) ) j

00631 2 CALL BY1E$CUT(HI6H(ADDR) )

;

0C632 2 ENC ACCRSCLV.0C633 100634 1 FILLSSTRING: FPCCEDURE ( COUNT , CHAR )

;

0C635 2 CECLARE ( I .COUNT ) AODRESS, CHAR 8YTE;0C636 2 CC 1=1 TO CCUNT;0C637 2 CALL e YTE SOUT ( CHAR 1

;

0C638 3 END;0C639 2 ENC FILLSSTFINC;CC640 1

00641 1 STARTUNIT IALIZE: PROC EDUR E ( AOOR ,CNT ) ;

00642 2 CECLARE (ACCR.CNT) U>0R5SS;0C643 2 CALL B Y 1

E

CLT ( I NT )

;

0C644 2 CALL ACCP i CL T ( AOCP.l ;

0C645 2 CALL AC C

P

i CUT ( CN T )

;

0C646 2 ENO S TAR Ti IM T I AL I ZE

;

0C647 1

00648 1 ELUCISYMBCL : PROCEDURE (LEN)

;

0C649 2 CECLAFE LEN PYTE, TEMP AODRESS;CC650 2 TEMP=NEX1 S5YM ;

00651 2 IF (NEXTiSYM:= .SYMBOL ( LEN : =L£N + IS PL ACEMENT ))

00652 2 > NAXi^EHCRY THEN CALL F AT AL $ c KROR (' ST ' )

;

0C653 2 CALL FILL ( 7 LMP , C

,

LEN ) ;

00654 2 ENO eUILOS JYKBLL ;

120

Page 249: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 250: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C655 1

0C656 1 MATCH0C657 2 /* CHECKS AN .IDENTIFIER TO SEE IF IT IS IN THE SYMBOL00658 2 TABLE. IF IT IS PRESENT, CURSSYM IS SET FCR ACCESS.0C659 2 CTFERKISE A NEW ENTRY IS MADE AND THE PRINT NAME0C660 2 IS E.NTERED. ALL NAM = S ARE TRUNCATED TO MAX$ID$LEN*/00661 2 CECLARE (POINT, COLLISION BASED POl^T) ADDRESS.0C662 2 (HCLDtU BYTE;0C663 2 IF VAROMAXJIDJLEN0C664 2 THEN VARC = MAX$ID$LEN;0C665 2 /* IRLNCATE IF REQUIRED */0C666 2 FOLD = Cj

CC 1=1 TO VAPC; /* CALCULATE HASH COOE */00667 20C668 2 HGLO = FCLD + VARC( I 1 ;

00669 2 END:CC670 2 PCINT=FREESSTORAGE + SHL((H0LD AND HASHiMA SK ) , 1 )

;

0C671 2 CC FOREVER;00672 2 IF COLLISIONS THEN0C673 2 oc;00674 ~-x CLRSSYM,CCLLISICN=NEXTSSYM;

CALL BUILD$SYrt80L(VAPC);00675 400676 4 /* L-CAU PRINT NAME */00677 4 SYMBOL! Pi LENGTH) =VARC;C0678 4 CO I- = 1 TO VARC ;

0C679 4 SYMBCL(START$NAME + I)=VARC(I);C0680 5 ENO;0C681 4 RETURN CURSSYM;0C682 4 ENC;0C683 3 ELSE00684 -a DC;00665 a CLRiSYM=CCLLI SIGN;0C686 4 IF (HOLO:=GcTtP$LENGTHI=VARC THEN00667 4 CC;0C688 4 l=i;0068? 5 DO WHILE SYMBOL! STARTSNAME + 1)= VARCtll:CC690 5 IF II:=I + U>HOLO THEN RETURN ( CUR $ S YM : = COLL I S I ON)0C691 t END;0C692 5 ENC;0C693 4 ENC;0C694 3 pcint=ccllisicn;0C695 3 enc;0C6S6 2 ENO natch;0C697 1

0C698 1 ALLCC0C699 2 /* THIS ROLTINE CONTROLS THE ALLOCATION CF SPACECC700 2 IN THE MEMORY OF THE INTERPRETER. »/C 7 I 2

0C702 2 CECLARE (HOLCBYTESSREQ) ADDRESS;0C703 2 FCLC=NEXT$AVAILAELE ;

00704 2 IF CIEXTSAVAILABLE :=NEXT$AVAI LABLE f BY T ES $REO ) >M AX t IN T JMEM00705 2 Tt-EN CALL FATALSERROR( 'MO' ) ;

0C7C6 2 RETURN FCLC;0C7C7 2 END ALLCCA1E;CC7C8 1

CC709 1 SETIR0C710 2 CECLARE (C1.D,NC-W} ADDRESS;

IF <RECEF:=NCT RECEF) ThEN00711 20C712 2 cc;0C713 2 RECEFJCNE=CLD;0C714 3 REC£FJThG=NEW;0C715 "3 END;0C716 2 ELSE CALL PRINTSERRCRl 'Rl ' )

;

0C717 2 ENO SETSRECEF;CC718 1

0C719 1 SETJCOC720 2 CUR$3YM = ICJSTACK.( I C$ST ACK. t PTR ) ;

0C721 2 END SETSCliRJSYf ;

0C722 1

0C723 1 STACK0C724 2 CALL SET JCLRISYM;0C725 2 RETURN CET1LEVEL;0C726 2 END jtackslevel;0C727 1

CC728 1 LCACS0C729 2 CECLARE HCLC ACCPcSS;OC73C 20C731 2 LCAC$PECEF$ACOR: PROCEDURE;00722 3 Clp$sym=oeoef£:ne;OC733 3 HCLD=GET$AOOkESS:0C734 3 END LCACiRECfcFSACCS;0C735 20C736 2 IF IDJSTACKOO THEN00737 2 DC:OC728 2 IF VALLEISP-2) =0 THEN0C729 a DC;0C740 3 CALL SET1CIJRSSYM;0C741 4 HCLD=GsT*SSLFNGTH GETSADDRESS;0C742 4 ENC ;

0C743 3 ELSE CALL L CAC SR5DEF SACDR :

00744 3 IF ( ICJSTACKSPTF : =1 0$ STACKSPTR* 1 ) >9 THEN0C745 3 CC;0C746 3 CALL PR!NTSSPROR< 'EL' ) ;

0C747 4 IDtSTACK$PTR=9;CC748CC749

4 ENC;a END;

0C750 2 ELSE FCLD=NEXT$AVAIL4BLE;00751 2 IOSSTACM ICtSTACK$PTR)=VALUE(MPPU ;

0C752 2 CALL S=T JCLRtSYM;0C753 2 CALL SETSACCPcSS(HOLO) ;

0C754 2 ENC LCAOtLEVEL:0C755 1

121

Page 251: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 252: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C756 1

00757 2

0C758 20C759 2CC76C 20C761 20C762 3OC76300764

Q

400765 40C766 400767 4C0768 5C0769 5

0C770 5

0C771 50C772 4

0C773 A0C774 as

00775 20C776 20C777 2C0778 20C779 2CC780 20C7&1 30C782 3OC783 30C764 30C7E5 20C786 20C787 2

0C788 a

C0789 a

0C790 30C79L 40C792 40C7S3 30C794 20C795 20C796 200797 3CC793 30C799 30C800 a

oceoi 30C8O2 30C803 a

0C804 30C8C5 a

00806 30C8C7 40C808 4

CC809 30C810 ^

CC811 30C812 3CC813 30C814 4CC815 3CC816 "3

0Cbl7 a

0C818 4

CC819 4CC820 30C821 30C622 40C823 400824 30C825 a

0C826 3CC627 q

0C828 a

CC829 4CC830 40C831 4

0C632 50C833 c

00824 40C835 40CE36 300837 30C838 3C0839 3CC640 s

CC84L 30C842 a

00843 20C844 20C845 1

CC846 10C847 2CC84 8 2CC849 2CC850 20C651 20C652 20C653 20CE54 a

CC855 2CC856 20C657 2

0C858 2CC859 2CC860 1

REDEFlURiVALUE: PROCEDURE;CECLARE l-CIC ADDRESS,

<CEC ,K,J,SIGN) BYTE;IF REDEF THENCC;

IF RECEF$TWC=CURSSYM THENcc;

HCLP=GET$SiLEN3TH;CLF,SSY^ = REDeFSONSiIF H0LOGETSS1LENGTH THENCC;

CALL PRINT$EPR3R( 'R2* );HCL0=GETiS$LENGTH;CURiSY*=REOEF$CNE;CA1L SETSSSLENGTH(HOLO) ;

END;PECEF=FALSE;

ENC; '

END;ELSE IF PENOINGSLITERAL=0 THEN RETURN;IF PENC IKC JLIT$ I CO I DSSTACK IPTR THEN RETURN;CALL START J INI TI A L I ZE < GST

S

ADDRESS , HOL C := G ET SSiLENGTH );IF PENCIN£JLITERAL>2 THENtC;

IF PENDING$LIT£PAL=3 THEM CHA^'O 1;

ELSE IF PENDING1L1TERAL=4 THEN CHAR=' ';ELSE CHAR=CUCTE;CALL FILLSSTRINGIHCLD,CHAR) ;

ENC;ELSE IF PENCINGtLlTERAL = 2 THENCC;

IF FClC <= HCLDSLIT THENCALL STRING$OUT(.RcST$HCLD$LIT,FCLC);

ELSE CC;CALL STR1NG$0UT< . REST SHOLCSL I T

,

HCLDiL I T )

;

CALL FILL$STRING(HCLD - (HOLOiLlT + 1),' •);ENC;

ENO;ELSE DC;

/* THE NUMBER HANDELER */DECLARE (DEC.PINUSSS IGN, I , J , L I

T

SCEC , ML ENGTH

,

NUMSBEFORE ,NUM$AFTER , TYPE) BYTE, ZONE LIT ' 10H'

;

IF( (TYPE:=GETJTYPE)<16 » CR (TYPE>20) THENCALL PRINT$EPROR I 'NV ) ;

N*LENGT>=GET$S$L ENGTH;CEC=CE1S0EC IKAL:MINUSJSIGN=FALSE;IF REST JHGLCSL IT=«-' THENDC;

KINUS1SIGN=TRUE;J-l;

END;ELSE IF R=ST$H0LDSLIT='+' THEM J=l;ELSE J=C;L I1$CEC = 0;CC 1=1 TO HOLCSLIT;

IF hOLDSLITI I ) = • . • THEN LIT*0EC=I;ENC;IF L1T1CEC=0 THENCC!

NUM$3EFCRE=RESTSHOLDSLIT-J;NUPSAFTER=0;

ENC;ELSE CC;

NLM3EFCRE=LITSDEC -J-l!NUK$AFTtR=PEST$HCLD$L IT - LlTSDEC;

ENC;IF (I:=N$LENGTh - DEC XNUM S8EF0R E THEN

CALL PRU.TiEPROR( ' SL • ) ;

IF I>NUM$BSFORE THENDC;

I = I-NUf SBEFORE ;

IF MINUSSSIGN THENcc;

1=1-1;CALL BYTE$OUTC0' + ZONE);

END;CALL FILL$STRING( I

, '0' )

;

ENC;FLSE IF MINUSJSIGN THEN R ESTSHOL CSL I T < J ) =R = S T $F C LD $L I T < J

)

+Z0NE ;

CALL STRING$OUT(.R=ST$HCLOJLIT J, NUMS.8EF0RE ) ;

IF NUCSAFTEk > DEC THEN .* JM SAFTER = CEC;CALL STRING$OUT( .RESTShOL JSLIT + LIT$CEC, NUKtAFTER);IF (I: = CEC - NUM1AFTERJO0 THEM

CALL FILLSSTRINGd , '0' I ;

END;FENCING5LITERAL=0;

END REDEF$CR$\/f LUE ;

RE0LCE$STACK i FfiCCEDUP.E;CECLARE HCLCJLENGTH AOORESS;CALL SETSCLRISYM;CALL RECEF!CRJVALUE;HOLCJL ENGTH =C£TS St LENGTH;IF GETS1YPE > 128 THENCC;

H0LDUENGTH=H0L0$LEN1GTH * GET$OCCURS;END;IDiSTACK JPTR=in$STACKtPT^ - 1;CALL ScTSCLRSSYrt ;

CALL SETlSUENGThlGETtSlLENGTH hOL DSL ENGTH) ;

CALL SETH YPEIGRCUP) ;

ENC PECUCESSTACK;

122

Page 253: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 254: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C861 1 ENCiCFSRECGPO: PROCEDURE;00862 2 DC WHILE I C 1ST ACK f PTR <>3;CC863 2 CALL RECUCE SS T AC K

;

0C864 3 END;OC865 2 CALL SSTICLPSSYM;CC866 2 CALL RECE F 1CRSVA LUE ;

CC867 2 10fSTACK=C;0C866 2 7E«P$HCLD = ALLOCATE (TEMP$TWC:=G£T$StLENGTH) ;

CC869 2 END END$3F 1RECCRD ;

CC870 1

CC671 1 CCNVEPTSINTECEF: PROCEOURE;0C872 2 CECLARE INTEGER ADDRESS;CC873 2 INTEGER*0;CC874 2 CC I = I TC VASC;00875 2 INTEGEP=SHL( I NTEGER , 3) +SHL

(

INTEGER , 1 )+(VARC( I )-«0' I ;

CCC76 3 ENC;OC677 2 VALUE( SF) ^INTEGER;CC878 2 END CCNVER T 1 I NT EGER ;

CC679 1

CC880 1 CRSVALUE: PFOCECLRE I PTR , ATTRI B ) ;

CCb81 2 DECLARE PTR BYTE, ATTRIB ADDRESS;00882 2 VALUc< PTP)=VALUE (PTR) OR ATTRIB;0C883 2 END CR1VALLE;CC884 1

CC665 1 8LILC$FC9: FPCCECURE;0C886 2 CECLARE TEfF ADDRESS:0C887 2 .CECLARE BUFFEP. til) 3YTE, (CHAR, I, J) BYTE;00888 2 CALL F I LL I . EUFF £ R , • Sill!fCPfiQ "?

J 1=0"CC890 2 DC WHUE (J < 11) AND (K VARC ) ;

CC8S1 2 IF (CFAR: = VARC(I :=I+l )) = • .• THEN J = 8;CC892 3 ELSEDC;0C893 3 eLCF£R(J)=CHAR;0C894 4 J=J+l;0C895 4 ENC;CC696 3 END;CC897 2 CALL SE

T

JACCR2 ( TEMP : = ALLOCATE ( 164) ) ;

0C898 2 CALL ST A RT i IM T I AL I ZE < T EMP , 16 ) ;

CC699 2 CALL BYTE$CLT(0);C0900 2 CALL S TR I N C JC'jT ( . EUFP ER , 1 1 1 ;

0C901 2 CALL f ILL$STFING(4,0) ;

CC902 2 CALL C? 1 VALLE ( SP-1 , 1 )

;

OC903 2 END ELilLOSFCB;CC904 1CC9C5 1 SETSSIGNi PFCCE CURE ( NUMB) ;

CC906 2 CECLARE NUfB BYTE;00907 2 IF GETtTYPE=17 TH*:N CALL SET $TYP E ( VALUE ( SP ) + NUMB);CC908 2 ELSE CALL PR INT

S

ERRCR ( ' SG' ) ;

0C909 2 IF VALUt(SP)<>0 THEN CALL Se T $ S SLENG TH( G E T $ S tL ENG7H 1);CC910 2 ENO setssign;CC911 1

0C912 1 PICJANALI2EP: FRCCEDURE;0C913 2 CECLARE /* WORK AREAS AND VARIABLES */CC914 2 FLAG BYTE,CC915 2 FIRST BYTE,CC916 2 COLNT ACCRESS,0C917 2 ELFFER (31) BYTE,0C918 2 SAVE EYTE,CC919 2 RE?ITITICNS ADDRESS,CC920 2 J BYTE,0C921 2 CECSCCLNT BYT^,0C922 2 CFAR eYTE

,

0C923 2 I BYTE,CC924 2 TEMP ACDRESS,CC925 2 TY^E BYTE,0C926 2CC927 2 /* * * KASKS * * */0C928 2 ALPHA LIT '0'

,

00929 2 AUDIT LIT '2',

CC930 2 AtN LIT '4',

0C931 2 EC I T LIT '3',CC932 2 NL'M LIT ' 16 !

,

0C933 2 NLM$EDIT LIT •32*,CC934 2 EEC LIT '64'

,

0C935 2 SIGN LIT '128',0C936 200937 2 NUMSMASK LIT '101011113',00938 2 NLf'iEUSMASK LIT 'L00001J19',0C939 2 SJNUMSMASK LIT • 0010 1 1 1 1

3• ,

0C940 2 AiE*MASK LIT • 1 1 1 1 1 IGO'3 ' ,

0C941 2 AtNSMASK LIT •111010103',0C942 2 MNJEiHASK LIT '111000006',CC943 2CC944 2 /» TYPES */CC945 2 NETYPE LIT '80',CC946 2 NTYPE LIT '16',0C947 2 SNTYPE LIT '17',0C948 2 AIYPE LIT '8«,0C949 2 AETYPF LIT '72' ,

C0950 2 ANTYPE LIT '9',0C951 2 ANETYPE LIT '73' ;

CCS52 20C953 2 INCJCC1LNT: PROCf CURE < SWi tch > ;

0C954 3 DECLARE SWITCH 3YT-;CC955 3 FLAG=FLAG CR SWITCH;CC956 3 IF <CCUNT:=COU.\T + L) < 31 THEN BUFFER (COUNT ) = CHAR;0C957 3 END INCfCCLNT;0C958 2CC959 2 CFECK: FRCCEOURE (MASK) BYTE;CC960 3 /* Tl IS ROUTINE CHECKS A MASK AGINST THECC961 3 FLAG BYTE AND RETURNS TRUE ID THE FLAG0C962 3 HAC NC BITS IN COMMON WITH THE MASK */CC943 3 DECLARE MASK &VTE;CC964 3 RETURN NOT < (FLAG AND MACK) <> 0)5CC965 3 END CHECK;CC964 2

123

Page 255: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 256: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C967 200968 3CC969 •a

CC970 3

0C971 3CC972 3CC973 200974 2CC975 200976 7.

0C977 2

CC978 2CCS79 2CC980 2CC981 3

0C982 3CC983 2

0C9E4 2

0C965 20C986 2

CC987 3

00968 3C0989 3CC990 3CC991 3

0C992 30C993 3

0C994 3CC995 30C996 3CC997 30C998 30C999 3C1000 a

01001 301002 401003 401004 3010C5 301006 301007 i

010C8 401009 4C1010 4010 11 3

01012 -}

01013 a

01014 4

01015 401016 401017 501018 5C1019 401020 401021 401022 501023 401024 ?

01025 301026 401C27 401028 301029 5

C1030 201031 201032 201033 201034 301035 201036 201037 21038 2

C1039 2C1040 201041 201042 201043 201044 a

01045 3C1046 301047 3

01048 301049 a

01050 401051 401052 401053 3010E4 ^

01055 201056 1

01057 1

01058 201059 2ClOtO 201061 201062 301063 3

01064 301065 201066 2010o7 201068 301069 2

01070 3

01071 301072 401073 401074 a

01075 201C76 2

PICiALLCCATE: PROCEDURE! AMT) ADORESS;DECLARE AMT ACORESS;IF (MXSINTSMEf«:=MAX$INT$MEf< - AMT) < NEXT $A VA UAeLE

TFfcN CALL FATALSERROR I ' MO ) ;

RETURN NAXJINTtMEM;END PICJALLCCATE ;

/* PROCEDURE EXECUTION STARTS HERE */

C CUNT, FLAG , CEC $CCUNT = ;

/* CHECK FCR EXCESSIVE LENGTH «/IF VARC > 30 THENco;

CALL f PINTSERRCRl * PC ' 1

;

RETURN ;

FNO:/* SET FLAG 8ITS AND COUNT LENGTH */I =l:CC WHILE K = VARC;

IF (CHAR : = VARC(I ) )=' A« THEN CALL I NC SCCUNT ( A LPI- A ) ;

ELSE IF CHAR =«8' THEN CALL I NC iCOUN T

(

ASEDI T ) ;

ELSE IF CHAP ='9' THEN CALL I NC SCOUNT < NUM )

;

ELSE IF CHAR ='X< THEN CALL I NC SCCUN7 ( ASN) ;

ELSE IF (CHARTS') AMD (COUNT=0) THENFLAG=FLAG CR SIGN;

ELSE IF (CHAR = 'V'l AND ( DEC SC CUNT= ) THENCECICCUNT=CCUNT;

ELSE IF(CHAR=«/'J OR <CHAR='0») THEN CALL I NIC JCCUNT ( E D I T )

ELSE IF(CHAR='Z") OR (ChAR='t*J OR (CHAR='««) OR<CHAR=«+«) OR <CHAR=«-«) OR (CHAR='$'I THENCALL INCSCOUNT(NUMSEOIT) ;

ELSE IF (CHAR='.') AND ( OECiCOUNT = 1 THENDC;

CALL INCSCOUNT(MUMJEDIT) ;

CEC*CCLNT=CCUNT;ENC;ELSE IF {<CFAR = 'C') AND ( VARC ( I 1 ) = ' R • ) ) OR

UCHAR^'O') A.JO (V4RC 11 + 1)=' B' » ) THEN00;

CALL INC$CGUNT(NUM$EDIT) ;

CFAR=VARC( I :=I+L )

;

CALL INCSCOUNTINUMSEDIT) tENC;ELSE IF (CHAR=«(') ANO (C0UNTO01 THENcc;

SAVE = VARC(I-U ;

FEPITI TICNS=0;CC KH1LE(CHAR:=VARC( I : = I+l) JO • ) •

;

REPniTI0MS = SHL(REPITITIONS,3) +SHLIREPITI TICNS, 1) +<CHAR -'0');

ENC;CFAk=SAVE;CC J=l TO P.EPITITIONS-l;

CALL INCSCOUNT(O) ;

ENC;ENC;ELSE CC;

CALL PRINT$EF.ROR< 'PC ) ;

FETURN ;

ENC;1=1+1

;

ENC; /* ENC CF DC WHILE !<= VARC *//» AT THS FCINT THE TYPE CAN BE DETERMINED «/IF NOT ChECMNUf SECIT) THENcc;

IF CFSCMNUM$ED$MASK) THEN TYPE=NETYPE;ENC;ELSE IF CFECK<NU*SMASK) THEN TYPE'NTYPEjELSE IF CFECKl SNUMSfASK) THEN T YPE= S$NS T YPE ;

ELSE IF CFECK(NOT( ALPl-A) ) ThEN TYPE=ATYPE;ELSE IF CFECM ASESMASK) THEN Type =AETYPE;ELSE IF CFECM ASNSMASK) THEN TYP?=ANTYPE;ELSE IF CHECKl A$N$Ei.1ASK) TFcN T YP E= AN ET Y PE ;

IF TYPE = THEN CALL PR I NT JERRCR I • PC ' ) ;

ELSE CC ;

IF RECEF THEN CUR$SYM=RECEF$TWO;FLSE CLRSSYM = HOLDtSYM;CALL SETITYPE <TYP£) ;

CALL SETJSLENGTHICOUNT + GETSSS L ENGTh ) ;

IF (TYPE ANO 64) <> THENDC;

CALL SETSAD0R2(TEfJ P: = PIC$AL LOCATE (COUNT ) ) ;

CALL STARTS! NITIALIZEt TEMP, COUNT):CALL STRINGSOUT I

.

BUFFER 1, COUNT);ENC;IF DECiCOUNTOC THEN CALL SETiDEC I r*AL (COUNT-DEC ICCUNT ) ;

END;END F 1CJANALIZER ;

SETSFILEtATTRIP. : PROCEDURE;DECLARE TEPP ADDPES3, TYPE BYTE!IF CURSSYPOVALUE (MPP1 ) THENCC;

TEfT =CLR$3YM;CLR$SYN--VALUE(MPP1) ;

SYfCCL JAOCR(RcLilD) =TEMP;ENC;IF NCT (TE^P:=VALUE(SP-l ) ) THEN CALL PRINTIfcRROR CNF');ELSE cc;

IF T E NF = 1 TFEN TY PF = SFCUENT I AL

;

FLSE IF TEMP=15 THEN TYPE=RANDOM;TLSE IF TcMP=9 THEN T YPE = SEOiRE LAT I VE

;

ELSE DC;CALL FPINT$ERROR( ' IA« ) ;

TYP5=l;ENC;ENC:

CALL SET tTYPE (TYPE) ;

END SET1F1 Lfc $A1 .RIB;

124

Page 257: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 258: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

010770107801079010800108101C8201063010640106501C8601067010880108901090010910109201093010940109501096010970109801C99C11000110101102011030110401105011C6011C7011C801109C111C0111101112Oil 130111401115onu0111701118CI I 19C1120011210112201123011240112501126011270112801129ClliO011310113201133011340113501136011370112801129011401141

011420114301144011450114601147011480U49C115001151011520115301154011550115c01157011580115901160011610116201U301164011650116601167011680116901170011710117201173011740117501176011770117601179C1180011810118201183011840118501166

LCACSLITERAL: PROCEDURE;CECLARE I e\TE;IF PENCINGJLITERAL <> THEN CALL PRINTSERROR CLE 1 );ELSE CC I = TO VARC;

HCLDJLITd )=VARC(I) ;

end:end l cads literal;

check jfcruevel : frqcecureldeclare newslcvel byte;hold isyk, cur $syh=value (mp-1)

j

call set$level(newslevel:=value(mp-2) 1;if ne*1level=1 thenCO;

IF ICSSTACKOO THENCC;

IF NOT FILE$SEC$6ND THENCC

'

CALL SET$REDEF< IOtSTACK , VALUE ( MP- 1 ) 1 ;

VALUE<MP)=1; /» SET REOEFINE FLAG */END;CALL ENDSOFSRECCRD;

ENO;ENO;ELSE CC WHILE STACKSLEVEL >=

CALL REDUCESSTACK;EMC;

END ChECKSFCSUEVEL;

NEWSLEVEL ;

CCCESGEN: FFOCECLRE (PRODUCTION) ;

CECLARC PFCCLCTIGN BYTE;IF PRINUPPCC THENcc;

CALL CPLF;CALL FRINTCHAR(PGUHD) ;

CALL FR INT$NUMBER(PRODUCT ION)

;

END;

CC CASE PFCCUCTICN;

/* PRODLCTIO.NS*//* CASE NOT USED

/*

/*/*

/*

/*

/*

/*

/*

/*

/*

/*/*

/*-

/*

/*

/*

/*/*

/*

/*

/*/*

/->

/*

/*

/*

/*

/*

/*

//*

/*

/*

1 <CPCGRAM>CCMPIL ING= FALSE;

2 <IL-OIV> :

2

:= <ID-OIV> <E-D!V> <C-DIV> PROCEDURE

= IDENTIFICATION DIVISICN . PRCGRAP-ID<COMM£NT> . <AUTH> <CATE> <SEC>

/=> NC ACTICN REQUIRED */3 <ALTH> ::= AUTHOR . <CGMMENT> ./* NC ACTICN REQUIRED */4 <EMPTY>/* NC ACTICN REQUIRED */5 <CATc> ::= DATE-WRITTEN . <COMMENT> ./ NC ACTICN RECUIP.ED */6 <EKPTY>/* NO ACTICN REQUIRED */7 <SEC> ::= SECURITY . <COMMENT> .

/* NC ACTICN REQUIRED */8 <EMPTY>/* NC ACTICN REQUIRED */9 <CCMML; NT> : := <I NPUT>/* NC ACTICN REQUIRED »/

10 • <COMMENT> <INPUT>/* NC ACTION REQUIRED */

11 <E-OIV> ::= ENVIRONMENT DIVISICN . CON c IGUR AT I ON11 SECTION . <SRC-CEJ> <I-0>

; /* NC ACTICN REQUIRED */12 <SRC-OEJ> ::= SOURCE-COMPUTER . <CGMMENT> <CEBUG>12 OBJECT-COMPUTER . <CGMMENT> .

; /« NO ACTICN REQUIRED */13 <CEeuG> : := DEBUGGING MODE

LEBUGGING=TRU£; /* SETS a scanner TOGGLE */14 <EMPTY>

; /* NO ACTICN REQUIRED */15 <I-0> ::= INPUT-OUTPUT SECTION . FILE-CONTRCL .

15 <FILE-CCNTROL-LIST> <IC>/* NC ACTICN REQUIRED */

16 <EMPTY>/* NC ACTICN REQUIRED */

17 <FI LE-CCNTROL-LIST>/* NC ACTICN REQUIRED */

1818

; /* NO ACTICN REQUIRED */19 <F 1L£-CCNTRCL-ENTRY>

CALL SETIFILFSATTR IB;20 <A1TRIBUTE-LIST> ::=

; /* NC ACTICN REQUIRED */21

VALUE (KF) = VALUE (SP) OR VALUE(MP-);22 <CNE-ATTRI8> ::= ORGANISATION <ORC-TYPE>

VALUE(yFl=VALUE( SP) ;

23 ACCESS <ACC-TYPE> <RELATIVE>VALUEIf F) = VALUE.( MPP1 ) OR VALUE(SP);

24 ASSIGN <INPUT>CALL BLILC1FCB;

25 <CRG-TYFE> ::= SEQUENTIAL; /* NC ACTION REQUIRED - DEPAUlT */

26 RELATIVE-CALL OR 1VALLECSP ,4) ;

27 <aCC-TYPE> ::= SEQUENTIAL; /* NC ACTION REQUIRED - DEFAULT */

28 RANDOMCALL CSJVALLE(SP,2) J

29 <RELATIVfe> : : = RELATIVE <ID>CALL 0P!VAIL'E< VP ,8) ;

:= <FI LE-CCNTROL-ENTRY>

<FILE-CCNTROL-LIST><FI LE-C0NTROL-ENTRY>

::= SELECT <!D> <ATTR I 8UTE-L I ST>

<ONE-ATTRIB>

<ATTRIBUTE-LIST> <0NE-ATTR1B>

*/

*/

*/*/

*/

*/

*/

*/

*/

*/

»/

*/

*/»/

*/»/

*/

*/

*//*/

»/

*/*/

«/

*/

"/

*/

*/

*/

*/

*/

*/

*/

*/

125

Page 259: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 260: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

011870118801189C 115001191011920119301194011950119601197011980119901200012010120201203012040120501206012070120801209C1210012110121201213012140121501216012170121801219C1220012210122201223012240122501226012270122801229C1230012210123201233012340123501226012270123801239C1240012410124201243012440124501246012470124801249C1250012510125201253012540125501256012570125801259012600126101262012630126401265012660126701268012690127C012710127201273012740127501276012770127801279C1280C1281012820128301284012850128601287012e801289012900129101292012931294

0129501296

/*

/*

/*

/*

/*

/*

/*

/*/*

/*

/*

/*

/*

/*/*

30 <EMPTY>/ MO ACTICN REQUIRED - DEFAULT #/31 <IC> ::= I-0-CONTROL . <SAME-LIST>

32

33

34

35

36

37

<EMPTY>

<SAME-LIST> ::= <SAfE-ELE MENT>

<SAME-ELEMENT>

<IC-STRING> ::=

<C-OI V>

<SAME-LIST> <SAME-ELEMENT>

: := SAME <IO-STRING> .

<ID>

<ID-STRING> <ID>

38 <C-OIV> ::= DATA DIVTSIGN38 <LIflK>

; /* NC ACTICN REQUIRED */39 <FILE-SECT1QN> :: = FILE SECTION

FILEJSECiENC = TRUE;40 <EMPTY>

FILE$SEC$ENC=TRUE;41 <FILE-LIST> ::= <FILES>

; /* NC ACTICN REQUIRED */42 <FIL£-LIST> <FILES>

; /* NC ACTICN REQUIRED */43 <FILES> ::= FD <ID> <F I LE-C CNTROL>43 <KECORD-DESCRIPTION>

<FILE-SECTIONx <WCRK>

<FILE-LIST>

/*

/*

/*

/*

/*

/*

/*

/*

/*

/*

/*/*

/*

/*

/*

/»/*

/*/*

cc;

END:

CALL ENCSOFJRECORD:CCPSSYP =VALUE(*PP1) ;

CALL £ETiADCRESS(T:MP$HCLO) ;

CALL SET$S$LE/JGTH(TEMPiTv.C) ;

44 <F1 LE-CCNTP.GL> : : = <FILE-LIST>/* NO ACTICN REQUIRED #/

45 <EMPTY>/* NC ACTICN REQUIRED */

46 <F1LE-LIST> ::= <F I LE-ELEM5NT>/* NC ACTICN REQUIRED "/

47 <FILE-LIST> <FILE-ELEH£NT>/* NC ACTICN R^OUIRED */

48 <FUE-ELPMSNT> ::= 3LCCK <INTEGER> RECORDS/* NO ACTION REQUIRED - FILES NEVER 6LCCKED *

/

49 RECORD <REC-CCUNT>CALL Sei$SLENGTH(VALUE( SP) )

;

50 LABEL RECORDS STANDARD/* NC ACTICN REQUIRED */

51 LABEL RECOPCS CHITTED/=» NC ACTICN REQUIRED */

52 VALUE OF <ID-STRING>/* NC ACTICN REQUIRED */

53 <PEC-COUNT> ::= <INTEGER>/* NC ACTICN REQUIRED - VALUE (SP J CC-P.PECT */

54 <INTEGER> TO <INTEGER>CC;value(mp) = \,alu5( spi ; /* variable length »/call set$ttfe(4) ; /* set tc variable */end;

55 <wcrk> ::= working-storage secticn .

55 <record-oescr1ption>; /* nc acticn required */

56 <?«PTY>; /* NC ACTICN REQUIRED */

57 <LINK> ::= LINKAGE SECTION . <R ECCRD-DES CR I FT ION>CALL Ph INTIEkROR ( 'NI* ) I /* INTER PROG COMM */

58 <EMPTY>; /» NO ACTICN REQUIRED »/

59 <FEC0RD-D5SCRIPTI0N> ::= <LE VEL-ENTRY>; /* NC ACTICN REQUIRED */

60 <RECORO-OESCRIPTICN>60 <LEVEL-£NTRY>

; /* NC ACTICN REQUIRED */61 <LEVEL-ENTRY> : : = <INTEGER> <DATA-ID> <RELEFINES>61 <DATA-TYPE> .

/*

I*

/*

/*

/*

/*

/*

/*

CALL LCADSLEVEL;IF PENCINGSLI TERALOO THEN PEND IMG $L IT $ ID= I D $ST ACKSPTR ;

't2 <CATA-IC> ::= <IC>/* NC ACTICN REQUIRED */

63 FILLER

CLPtSYf, VALUE(SP)=NSXT$SYM;CALL BLILDJEYMBOHO) ;

64 <PEDEFINES> : := REDEFINES < I D>

CALL SET$RECEF( VALUE! SP),VALUE(SP-2>>;VALUE(^PI=l; /* SCT REDEFINE FLAG CN */CALL CFECKiFCRtLEVEL ;

CC;

END:

cc;

END;

CC;

END;65 <EfPTY>

CALL CFECKlFTRSLEVEL;66 <CA7A-TYPE> ::= <PROP-LIST>/* NO ACTICN REQUIRED */

67 <£MPTY>/* NC ACTICN REQUIRED */

68 <FRCP-LIST> ::= <DAT4-cLEMENT>/ NC ACTICN REQUIRED »/69 <PKOP-LIST> <DATA-ELEMENT>/* NC ACTICN REQUIRED */

70 <CaTA-kLEMcNT> : := PIC <INPUT>ALL P ICSANALI Zfck

;

71 USAGE COMPCALL SET$T^PE(CO«P>;

72 USAGF 01 SPLAY; / NC ACTION REQUIRED - DEFAULT #/

+ /

*/

*/

*/

*/

*/

*/

*/

*/»/

»/

*/

*/

*/

*/*/

»/

*/

»/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/<=/

*/

*/

*/

»/

/*/

*/

*/

*/

*/

*/

126

Page 261: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 262: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

012970129801299C1300013011202

013030130.4012050130601307013C801309C131001311013120131301314013150131601317013180131901320013210132201323013240132501326013270132801329C1320013310132201233013340133501336013370132801329C1340013410134201343013440134501246013470134801349C13500135113 52

01353013540135501356013570135801359C1360013610136201363013640136501366013670136801369C13700137101372013730137401375013760137701378C1379C1380013810138201383013840136501386013870133801389C1390013910139201393013940139501396013970139801399014C0014 01014020140301404

/*

/*

/*

CAL

CAL

cc;

ENO;

cc;

73I SE74

L SE75

CACA

76/77

IFDC:

T$SJGN< 13) ;

T1SIGNU7) ;

SIGN LEADING <SEPARATE>

SIGN TRAILING <SEPARATE>

OCCURS <1NTEGER>

LL CR$TYPE( 1281

;

LL SET$OCCURS(VAL'JE(SP> ) ;

NO ACTION REQUIREDSYNC <DIRECTICN>BYTE MACHINE */

VALUE <LITERAL>

NCT FILEtSECSENO THEN

END;ENC;

CALL PP1NTSERR0R( 'VE' )

;

FENDING$LITERAL=0;

/*

/*

/*

/*

/*

/*

/*

/*

/*

/*

/*

/*

VAL

CC;

END!

CC:

END;

PEN

PEN

FEN

CAL

VAL

78/79/*

80/*

81LE(S82/83

CAPE

'84

CAPE

'85CINC£6

DING87

DING88

L CC89

UE(S

<CIRECTICN> ::= LEFTNO ACTICN KEQUIRtO */

RIGhTNC ACTICN REQUIRED */

<EHPTY>NC ACTICN REQUIRED */<SEPA*ATE> ::= SEPARATE

F) = 2;<EMPTY>

NO ACTICN REQUIRED */<LITERAL> ::= <INPUT>

LL LCADSL ITEP.AL;NC ING*LITERAL = 1

;

<LIT>

LL LCADSL ITERAL;NCINGiLITERAL=2;

iL I1EPAL=3;

1LMEPAL = 4 ;

ZERC

SPACE

QUOTE

= <INPUT>JLnEFAL = 5:

<!NTEGER> ::

NVEFTSINTEGfc?;<IC> : : = <I\'PUT>

P)=KATCH; /- STORE SYMBOL TABLE FCINTERS */

»/

*/

/

*/

*/

»/

»/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

ENC; /* ENC OF CASE STATEMENT */END CCCEtGEN;

GETIM: PRCCECLRE BYTE;PETLRN INDtXKSTATEJ;

END CETIN1 ;

GETIf.2: PRCCECLRE BYTE;FETU?N lNa£X2(STATE) ;

END GETIN2;

INCSF: PROCECURE;SF=sp + l;IF SP >= PSTACKSIZE THEN CALL F ATA L$ ERROR (' SG' )

;

VALLE(SF)=C; /* CLEAR VALUE" STACK */END 1NCSP;

LCCKAFEAO: FRCCECURE;IF NCLCCK HENCC;

CALL SCANNER;NCLCCMFALSE;IF PRINTSTOKEN THEN

CC;CALL CPLF;CALL PRINTSNUMBEMTOKEN) ;

CALL PRINTSCHAR( ' • )

;

CALL PPINTSACCUM;ENC;

END;END LCCKAHEAC;

NCSCCNFLIC7: PPCCEOURE (CSTATE) BYTE;CECLARE (CSIATE , I , J ,K) BYTE;J=INCEX1(CSTATE) ;

K=J + INDE>2<CSV ATE) - 1;CC I=J K k;

IF REfCK I ) =TCKEN THEN RETURN TRUE;END;

RETLFN FALSE;END NCJCCNFL1CT;

RECCVFR: PRCCECLRE BYTE;CECLARE (1SF, RSTATE) BYTE;cc fgrever:

T S P = S F ;

CO VHILE TSP <> 255;IF NOtCCNFLICT(RSTATE:=STATESTACK(TSP) ) THENCC; /» STATE WILL READ TOKEN »/

IF SCOTSP THEN SP = TSP - 1;RETURN RSTATE;

END;ISP = TSP - l;

ENC;CALL SCANNER; /« TRY ANOTHER TOKEN /

END:END RECOVER;

127

Page 263: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 264: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0140501406014070140801409C1410014110141201413014140141501416014170141801419C1420014210142201423014240142501426014270142801429C14300143101432014330143401435014 3601437014381439

014400144101442014430144401445014460144701448014 49C14500145101452014530145401455014560145701458014590146001461014620146314 64

014650146601467C14680146901470014710147201473014 740147501476014770147801479C14800148101482014830148401485014e6014870148801489C14900149101492014930149401495014960149 70149801499C1500015011502

ENCJPASS: FFOCECLRE;/* THIS PRCCeLURE stores THE INFORMATION REQUIRED BY PASS2IN LOCATIONS AdOVE THE SYM8CL TASLE. THE FOLLOWINGINFORMATION IS STCREC:

0LTPL.7 FILE CONTROL BLCCKCCCPILER TOGGLESI NFC T EUFFER POINTER

THE OUTFIT ELFFER IS ALSO FILLEO SO THE CURRENT RECORD IS WRITTEN.»/

CALL BYTEICLT(SCC) ;

CALL ACCRICLT(NEXT$AVAILABLE) ;

CC WHILE CLTFUT$PTRO.CUTPUT$BUFF;CALL EYTtSQUT (OFFH) ;

ENO;

CALL MCVEI .OUTPUT $FCB , MAX JMEMCPY-PASSISL EN, PASS 1$LEN J;CO TO V/»Xi*EMORY;

ENC ENCSPASS;

/* PROGRAM EXECUTION STARTS HERE * */

CALL MCVEI IM HAL*POS,fAX$MEMCRY,RCRtLENGTH) ;

CALL INITJSCANNER;CALL l.MTSSYMeCL;

PARSER * »/

CC WFI

ILif :

c;

COMPILING;TATE <= PAXRNO THEN /» READ STATE */

/* SAVE CURRENT STATE »/

THEN

CALL 1KCSP;STMF.STACK( SP) = STATE;CALL LCCKAHEAC;I =G£T IM;J = I + GETIN2 - l;CC 1=1 TC J;

IF REACH I) = TOKEN THENcc

:

/* COPY THE ACCUMULATOR IF IT IS AN INPUTSTRING. IF IT IS A RESCRVEC WCRC IT DOESNCT NEED TO BE COPIED. </

IF (TOKEN=INPUTSSTR) OR ( TCKEN = Ll TER A L )

DO K=0 TC ACCUM;VARC(K) =ACCUM(KJ ;

END;STATE=REA02(I);nolock=true

;

i=j;END;ELSEIF I=J THENcc;

CALL PR1NTSERF CR ( 'NP' )

;

CALL PRINT!.' ERRCR NEAR $);CALL PRINTSACC'JM;IF (STATE:=*ECOVER)=0 THEN CCMP IL I NG= FALSE ;

END;ENC; •

/* ENC OF READ STATE */NOLSF STATE>MAXFNQ THENC;

/* APPLY PRCOUCTICN STATE */

KP = SP - GETIN2!MFFl^P + 1 ;

C*LL CCClSGENISTATE - MAXFNO);SP = MF ;

I=CE7IM;J«STAUSTACK(SP) I

DO WFILE (K:=APPLYK I I) <> AND JOK;1=1 + l;

ENC:IF (K :=APPLY2( I > ( = THEN COMP I

L

ING=FALSE ;

ST£TE=K;NOLSEF STATE< = MXLNC THENc;=G

/LOGKAHEAC STATE*/

END;Ct LLCALLCALLECF

:K3/

Cfi

F =

Ml

TIM;CALL LCCKAHEAC;OC WHILE (K : = LOOK1( I ) )<>0 AND TOKEN OK;

1=1+1;ENC;

£=LCCK2(I) ;

/*PUSH STATES*/CALL INCSP;STA7ESTACK( SPJ =GETIN2;ST* TE=0ETIN1;

CF WHILE COf-PILING */F ;

NT(.' ENC CF PART 1 i> ) ;

iPiSS;

128

Page 265: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 266: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00C01COC02COC0300C04COC050OCC600C0700008C0C09COOIOOOOllC0012000130001400015C0C16C0017CCC18C0C19C0C200002 1

00022C0C230002400025C00260OC27C002800029C0030000310C0320003300034C0C350OC3600037C0C38C0C39C0040C004100042C0C4300 04 4C0C4 5000460004 7C0048C0C49C0C5000C5100C52C0C5300054C0C550OC5600057C0058C0C59C0C600OC6100C620OC6300C64000650OC660006700068C0C69C00700OC7 1

00C720007300C74C0C75C0C7600C770OC78C0C79coceo0OC310CC820OC83000840CC85C0C860CCE7C0C88C0C89CCC900OC9 1

0CC920CC93000940CC95C0C960CCS7CCC98CCC99C0100001010010200103CO 104C0105

/*

10CH; /CCeCL COMPILER - PART 2

LOAC POINT */

CLCeAl DECLARATIONS AND LITERALS

*/

*/

CECLAPE LIT LITERALLY 'LITERALLCECLAPE

6CQS LIT «5HASHSTAeiACCR LIT '2

PASSPAXSPASSeccTCRLFCLCTPCLNTPLEPALSFCRE

DECLARE

ISLtNMEPCRY1$TCP

CECLAPE,53,,47,,6C,,57,,57,.APE,16,,C);ARE

CECL/

CECL.

E

EVcRPAXPAXPAXPAXSTAREA51.3, 1

54,59,59,LOG0,1

rno liLNC LIFNO i I

SNO LISTS LICI CAT59,47,,29,221, 14,15C,7 ,14 7,61,Kl CAT,14,C,

LILILILILILILILILILILI

TERATERATERATERATERAA(0,27,2.47,1,7,6,1,9,47A(0,54,0

TTTTTTTTTTTLLYLLYLLYLLYLLY62,5S , 3556, 1

9,501.5,,24,47,

C

,54,

43

3

I

1

221

W'83' ,/106

•121'218• i '

;

,o, S

,36,,55,.5,88,130,0),39,0,0,54,0

/* ENTRY TO OPERATING SYSTEP »/H«, /* ADDRESS OF THE 3CTTQM GF

THE TABLES FROM PAPT1 */

H«,H«,

CECL

DECL

, : ,o,46,,79,,24,

DECLARE,26,,1"<3,169, 12,, 10,,21,ARE,47,,61 ,

ARE,178,157,96,,158,196, 141

DECLARE,1 16, 1 16,62,, 1 16,28,, 171,12,,28,,43,,1CC

CECLARE,1,1,1 ,1,2,2,6C,,2 ,2,C,0,11 ;

/*CECLARE

/» V

/* TCRCUTHE*/COTPcteuPR INPR IN'

LIST:ec$NEXTPCINNEXTPAX!

APPL3,0,CO,82, J

66,6REAC39,4,211,16734, 1

12,80,0)LOCKlit ,

119APPL,15C,155176,,92,,196

he,23,11666,6.11341 ,4, 16612, I

29,24*. , 4

,1CCINOE,5,1,1.1,2,i61 ,64,21.2

Yl CA27, C,2,5,6,107,C,C2 CAT0,32

.

,2C6 ,

,162,7,19,4,17,

2 CAT46 , 1964 ,12Y2 CA,12 2,,149,136,1159,1,19 6,, ic,XI CA3 2,22,44,47,67,,12C,3,45,,215,2, 12,9,29,4,45,,1C1,X2 CA,1,1,,1,1 ,

,2 , t

4,66 .

,5,4,,0,C

,0,3 ,33,0)

;

A ( , 4 3 , 6 . 7 , 1 ,

202,2C6,206,202C8,207,210,20163,16,5, 182 ,220,22,25,29,3018, 19 ,20,22,25

H",500

6200100«,3*.

2H J

3H«

HILE TRUE' ;

* PAX READ COUNT *//* MAX LOOK COUNT *//•» PAX PUSH CGUNT »//=» PAX STATE CCLNT */START STATE */

3,15,19,21 ,23,25,30,31,40,41,43,44,48,52,27, 47, 1,28,58,10,34, -,5, 33, 12, 2 7, 2 8, 35, 3629, ',2, 26, 13, 32, 49, 51, 63, 17, 4, 37, 27, 3 8, 473, 15, 19, 21, 23, 25, 3 0,40, 4 1,43, 44, 48, 52, 535,19,20,21,23,25,30,40,41,43,44,46,52,53

2, 0,39, 0,1, 14,0,47, 0,29, 42, 0,2, 0,26,0,7,0,54,0,U,0,l,14,C,l,0,5 0,0,4 7,0,24,C,9,47

0,0,79,0,0,83,0,13,63,70,76,81,0,0,2,63,0,0,G,0,0,0,0,0,7 1,0,0,0,0,C,C5.S.9,15,1620, 23, 25, 26, 28, 29, jO, 31, 35, 26, 42, 46, 77, 7o56, 3, 5, 8, 9, 15, 16, 30, 46, 0,54,0,22,0,0, 17

12,84,17, 19,20,22,25,26,29,3 0,31,32,34,3 57, bo, 2 02, 36, 122, 85. 1/9, 195. 193, 194, 1363, 1 30, 23, 192, 198, 87, 3, 37, 4,1 90, 1?9, 23, 16302, 27, 86, 41, 170, 2, 13, 1 6 5, 8, 175, 135,6,10, 31, 22, 34, 35, 36, 39, 40, 185, 9, 15, 121. 132, 6

,29, 30, 31, 22, 34, 35,36,39,40, 199, 42, 11, 199

A(0,7,49C, 12TA(0134,70,191,444,9196,102,TA(0,1165,2867,674,147,41,2,12,130,345,4ic:

,

TA(01,2,1 ,5,2,2,6,1,4,5,0,0,

14,1,1121, 12,0,1105,25,64,911,1219o ,

14.8),1,1,26,,28,7 ,6816,29,212,4,2, 13J, 346,4o1C6,,1,11 ,5,5,182 ,2,0,0,1,1 ,

0,0,

U,2,237,1164o , Ho,69, 70,1,3.57, 124,4,6,6,, 13, 13,34,35,46,47106, IC.20, 1,1,1,1,.2,18,2,3,2,1,0,1,2,2,0,0,0,0,

2, 116, 116, 23, 116, 116, 28, 20, 31, 74. 116,116, 45, 1 16, 116, 23, 116, 116, llo, 116, 28, 43, 22,48, 49, 5 1,1 lo,52,51, 54 , 55,23, 60, 61, 26, 62,71, 23, 23, 74, 72, 74, 92, 9^,94,95, 96, 97, 116,7, 9, 12, 14, 17, 19, 21, 2 3, 25, 2d, 30, 32, 24, 36124, 177, 18 3, 181, 2 C5, 2 05, 184, 171, 171, 17 1

7, 7,=), 9, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12,13, 19, 19, 19, 19, 22, 22, 22, 25, 27, 27, 27, 28, 35, 36, 36, 37, 37, 38, 33, 39, 39, 39, hO, 42, 43,47, 5^,55, 80, SO, £0,88, 96, 96, 96, 99, 98, 1007,10 7, 103)

;

1, 1, 5, 1,L, 2, I, I, 18, 1,1, 1,5, 1, 3, I, 1,6, 1,11,2, 2, 2, 1,1, 2, 1,1, 2, 1,1, 5, 2, 1,1, 2, 1,2, 1,11,1,1,1.1.19,1,2,2,1,13,1,20,2,2,2,2,3,22, 2, 2, J, 14, 24, 38, 46, 47, 49, 51, 54, 56, 52, 592,2,1,2,0,0,2,1,0,2,1,0,2,1,1,3,3,2,2,0,10, 1, 0,0,0,C, 0,0, CO, 0,0, CO, 0,0,1, l,C,l,l0,0, 0,0, 0,0, 3,0,0,0,3,0, CO, CO, 0,0, 0,0,0

ND CF TAeLES */

CINT CECLARATICNS */H<: FCLLChING ITEPS ARE OECLARED TOGETHER IN THISP IN OFCEP. TO FACILITATE THEIR 3EING PASSED FRCPFIRST PART OF THE COMPILER.

UT1FCG (33) BYTE,GGINC BYTE,TJPRCD BYTE,TtTCKEN BYTE,IINFLT eYTE,NL'P BYTE,$SYP AODRESS,TER ALCF5SS, /» POINTS TO THE NEXT BYTE TC BE REAC /SAVAILASLE AOCRESS,INTiPEP ADDRESS,

/* I EUFFEPS ANC GL08ALS */IfvSACCP ACCPESS INITIAL (5CH),INPUTFCP BASEO INADDR (33) BYTE,CLTPLTiELFF (128) BYTE,COTFUTtPTR ADDRESS,CLTPUTIFNO ADDRESS,CLiTPUTlCHAR BASED OUTPUTSPTR 9YTE;

129

Page 267: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 268: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

U01U600107C01C8CO109C0110001110011200112G0114C0115C011600117C0118consC0120ooi;i001220012300124001250012600127C0128C0129CC1300013100132C0133C013400135001360013700138C0139CO 140C0141001420014300 1440O145001460014700148C0149C0150CC151C0152001530015400155C0156C0157C0158C0159C016000161001620016300164001650016600167C0168CO 169C0170C017100172C0173C0174C0175C017600177C0178consCC18000181CC1820C183C01840C185001860C167C0188(0189CC1900C191CC192CC1930C194CC195CC1960C1970C198CC19900200C0201002020020300204002050020600207C020800^09C0210

/* GLOBAL CCLNTERS */DECLARE

CTP eYTE.AJCTR ACCRESS,eASE ACCRE5S ,

eJEYTE EASEC EASE BYTE,ejADCR BASEC EASE ADDRESS;

MCM : PRCCECLRE (p.A) ;

A ADDRESS;DECLARE F BYTE,gc tc eccs;

END KCNl;

MCN2: PROCECLRE <F,A) BYTE;CECLARE F E*TE, A ADDRESS;GC TC BCCS;

END MCN2;

PRINTCFAR: FPOCECLRE (CHAR);CECLARE Ct-tfi BYTE;CALL MCM (2, CHAR);

ENC PFINTCHAP;

CRLF: FROCECLPE;CALL PR INTCFAP(CR) ;

CALL PRINTCHAR(LF) ;

ENC CRLF;

PRINT: PRCCECURF. (A);DECLARE A ACCRESS;CALL "CM (9, A) ;

ENC PPINT;

PRINTiERROR : PfiCCCCURE (CODE);CECLARE CCCc ADDRESS;CALL CRLF;CALL poiNTCMR(HlGMCnOE) ) ;

CALL PP INTCFAR(LCV,(CCDE) ) ;

END PR INTSERFCR ;

FATAH ERROR: P FCCECUR E ( RE ASC.N ) ;

CECLARE REASCN ADDRESS;CALL PR INTSERPCRI CEASCN) !

CALL TIfEllC);GC TO 9CCT

:

ENC FATALIERPCP;

CLCSE: FRCCECURE;IF MCN2 < 16, .CUTPUTSFCB) = 255 THEN CALL F AT A L 1 ERROR { «CC • ) ;

ENC CLCSE;

PGRE11NPLT: FRCCECURE BYTE;/* READS TFF INPUT FILE AND RETURNS TRUE IF A RF.COPD

«AS REAC. FALSE IfPH'ES E'JD OF FILE */CECLARE CCM BYTE;IF < CCNT:=PCN2( 20

,

-INPUTSFC8) )>1 THEN CALL F ATA L $ E RRC ?(

* BR ' )

RETURN NCT(CCNT);ENC WCRcIINCLT;

LOCATION*/

FILL: PPOCECLRE < A DOR

,

CHAR, COUNT) ;

/* "OVES ChtP I'JTC AGOR FOR COUNT BYTES */CECLARE ACCR ADDRESS,(CFAR,CCLNT .CEST BASEDDC VsHILE (CCLNT:=CCUNT

DE ST = CFAR;AOCP=ACCR 1;

ENC;fill;

ADDR) PYTE;-1)<>255;

END

/»CECLARE

L ITERALIt.FUTSSTPPERICCR P A P, I NL PAR ININVALID

LITLITLITLITLITLIT

SCANNER LIT!

•28' ,

•47',

•3«,•2«,•0'

;

*/

»//» * * * SCANNER TABLES * * *DECLAPE TOKEM'Aei.E DATA

/* CONTAINS THE TCKEN NUMBER ONE LESS THAN THE FIRST RESERVED WCRCFCR EACH LENGTH C F WORD *

/

ICO, 3, J, 12, 28, 40 ,47, 55, 59, 62),

130

Page 269: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 270: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

UUill TABLE CATA( «eY» t »C0» t • IF' i'TO' , 'AOO' , 'END' , • I-C*00212 t »NOT«, •RUN* f «CALL* .* ELSE 1 •« EXIT" , • FROM' ,

• INTO" f ' LESS* t

«

00213 ,' NEXT', 'OPEN 1 , 'PAGc', 'READ', 'SIZE', 'STOP' 'THRU' , 'ZERO','AFTEF','CLCSE','ENTFR', 'EQUAL' , 'ERR PS' , • INPUT' , 'CLOTE'0O214

00215 , « TI-ES' , 'UNTIL' , 'USING' , 'WRITE' , 'ACCEPT' , 'BEFORE' , 'OCLEC0216 , 'CI VIDE ', 'CUT PUT ','CISPLAY', 'GREATER'00217 , • INVALIC , 'NOMEP IC« , 'PERFORM', 'RE WRITE', • RCUNDED' , 'SECT

,'CIVISICN','MULTIPLY','SENTENCE','SueTRACT','ADVANClNG'•CEPENQING',' PROCEDURE'

,

'ALPHABETIC I,C021800219C0220 OFF SET (11) 4CC3ESS IMTIAL00221 /* NUMBER CF BYTES TO INDEX INTC THE TABLE FCR EACH LEN00222 (0,0, 0,8, 23, 63, 14 2, 173, 229, 26 1,288),00223C0224 WOPDi00225 /« NUMBER CF WORDS OF EACH SIZE */00226 (CO, 4, 5,15, 12, 5, 8, 4, 3,1),C0227C0228C0229 MX$ID$LEN LIT '12',C0230 NAXSLEN LIT '10',00231 ACCSENC CATA ('END. •),C0232 LCCKED BYTE INITIAL (0) ,

00233 HCLC BYTE,EtFFERSEND ADCRcSS INITIAL (100H),00234

00235 NEXT BASEO POINTER BYTE,C0236 INEUFF LIT '80H',00237 CFAR BYTE INITIALC '),00238 ACCUM BYTE,C0239 PIACCL'M (30) BYTE,C0240 DISPLAY BYTE INITIAL (0),00241 CISPLAYJPEST (73) 8YTE,00242 TCKEN BYTE; /^RETURNED FRCM SCANNER */C02430024400245 /* PROCECURES USED BY THE SCANNER */0024600 24 7 NEXT J

C0248 2 IF LOCKEC THENCG249 2 cc;C0250 2 . LCCKEC=FALSE ;

00251 3 RETLPN (CHAR:=HCLD)

;

00252 3 ENC;00253 2 IF (POINTER: = F0INTER +• I) >= BUFFERSENC THENC0254 2 DO;00255 2 IF NCT NCRESINPUT THENC0256 3 CO;00257 3 ELFFER$ENC=. MEMORY;C0258 4 FCINTEP = .ACO$E.JD;C0259 4 ENC;C0260 3 ELSE FC INTER = INEUFF;00261 3 ENC;00262 2 RETURN (CFAP :=NEXT)

;

C0263 2 END NEXTSCHAP;00264 1

CC265 1 GETSC00266 2 /* THIS FRCCFCURE IS CALLED WHEN A NEW CHAR IS NEECEO WI00267 2 TFE DIRECT FETURN CF THE CHARACTER*/CC268 2 CFAR=NEX1 JCFAR;C0269 2 ENC GETSCHAR ;

00270 1

00271 1 CIS 'LAYiLINE: FRCCEDURE;C0272 2 IF NOT LIS11INPUT THEN RETURN;C0273 2 CI SPLAY(C1 SFLAY 1 ) = ' J' ;

00274 2 CALL =>RirvT( .CISPLAYSREST) ;

00275 2 CI SPLAY = C;C0276 2 ENO DISPLAYUINE ;

C0277 1

C0278 1 LCADJC0279 2 IF DISPLAY<T2 THENC0280 2 01 SFLAY (CI SPLAY: = CISPLAY + 1)=CHAR;00281 2 CALL GEUCFAR;0C282 2 ENC LCAOJDI SFLAY ;

00283 1

00284 1 PIT : FPOCECLRE ;

00285 2 IF ACCUM < 2C THEN00286 2 ACCUMUCCLf- : = ACCUM*1 )=CHAR;00287 2 CALL LCALiCISFLAY ;

C028e 2 ENC PLT;C0289 1

CC290 1 EAT1L0C291 2 CC WHILE cfapocr;0C292 2 CALL LCACtDISPLAY;CC293 3 ENC;CC294 2 ENC EATtLINE I

CC295 1

0C296 1 GETSN0C297 2 CECLARE (N,I) BYTE;CC296 2 CC fcpever;CC299 2 IF CHAR = • ' THEN CALL LOAOSDI SPL AY

;

(0300 3 ELSE00201 3 IF CHAR=CR THEN00202 3 OC;C0303 3 OLL 01 SPLAYSL INE;C0304 4 IF SEQ1NUM THEN N=8; ELSE N=2;00305 4 CC 1 = 1 TC N;00306 4 CALL LCADSDISPLAY;C0307 5 Ere;

IF CHAR = '*' THEN CALL EATSLINE;C0308 4C020<: 4 ENC;C0310 3 ELSE00311 3 IF CHAR = »:• THENC0212 3 CC ;

00213 3 IF NOT CE3UGGING THEN CALL EATSLINE;00314 4 ELSE00215 4 CALL LOADtOISPLAY;00216 4 ENC;C0217 3 ELSEC0316 3 RE HPN ;

C0319 3 END; /* ENC CF DC FQPEVER */ro^?n 2 FNC CF TiNClP( n»:

131

Page 271: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 272: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00322C0323C0324001-2500326C032VC0328C0329(0*3000331C033200333C0334003350O336C0337C0338(033*5C03400034 1

C034200343C034400345C0346003470034800349C0350CO 3 5 1

00352C03530035400355C035600357C0353C0359C036CC03610036200363C0364C03650036600367C0363C036SC037 J

0C3710037200373C0374C037500376CC377C0378C0379C0380CC3810038200383C0364C03850038600387C0ie8CC3C-9(C3900C391CC3920C393CC394CC395CC396CC397C0398C0J<?9C04C00C401C04C2C0403C04C4004C500406C04C7C0408C04C9C0410CO* 1

1

004120041300414C0415C041600417C0416C041SC0420004210042?0042300424C04250042600427C0428CC429(0430C0431C04320043300434C0435

SPACE: PROCECU°E eYTE;PETURN ICHAP=' •) CS (CHAR=CR);

ENC SPACE;

LEFTtFARIN: FRCCECURE eYTE

;

return char = ' ( • ;

enc leftjpabin;

richtjparin: prcceoure 8yte;peturn char = ' ) •

;

enc p1ghtipafin;

delimiters ffoceclre byte;/* checks fcr a period followed ey a space cr cr*/if char o >.' then return false;hcld=nexi$cfar;LCCi«>ED = TRUE ;

IF SPACE THENoc;

CHAP x •••;RETLFN TRUE;

ENC;CFAR=» .

;

p.etlrn false;end delimiter;

enoscfitoken : ffccedure byte;return space cr delimiter cr lsfttparin or rightsparin;

enc enc$gf$tcken ;

getjliteral: prcceoure byte;cc forever;

if next$chap= cuote then return literal;CALL PLT;

END;END CET$LITERAL ;

LCCKILDE(H

MA

EN

P: PRCCECLCLARE PCINERE BASEC

PE BYTE;T ADDRESS,FCINT.I) BYTE;

TCH: FFCCECEClAREDO J= 1

IFENC;RETLFN TRUE;

C MATCH;

CURE eYTE;J BYTE;

TC ACCUM;FERE (J - 1) <> ACCUM(J) THEN RETURN FALSE;

ENRE

END LC

RESERV/»7HCECEIFCC

ENRE

END RE

GETJTCACCAIFIFCC

INT=CFFSEI1=1 TC WC

IF VAKPOINT =

D;TURN F/>LSECKIUP ;

ECJtiQRC: F

RETURNS 1

E ACCLMULACLARE VALLCLARE NUfeACCUM <=

(ACCUMI + .TABLE;FCSCCUNK ACCUM) ;

H THEN RC T URN !

;

FCINT + ACCUM;

SCCEDLRE BYTE;HE TCKEN NUMBER OF A R5SEPVED WORD IF THE CCNTENTS CFTCR IS A RESERVED WCRD, GTHcRWlSE RETURNS £E=vO =»/

E BYTE;EYTE;

"AXiLEN THEN

IF (NLf'e: = TCKENSTA3LE<ACCUM) )<>0 THENCC ;

IF

ENENC CE

ELENC;

D;TURN NLME;SERVECJWCF

KEN: FPCCECUM=C:LL GETJNC1CHAR=CLCIDELIMI Iff

CALL PLRE1LRN

c;LEFT1FAR i

(VALUE:=LOCK$UP) <> THENNUMB=NUMB «• VALUE;

SE NUM6=0;

C ;

CLRE eYTE;

ELAf.K :

E THEN RETURN GSTiLITERAL;THEN

FERIOC;

N THEN

CALL FLT;RETL9N LFARIN;

C;RICHTJPARIN THEN

/*

CALL PLRETLFN

C;FOREVER ;

CALL FLIF ENCS

C; /* CF CTSTCKEN ;

ENC CF

SCANNE

T ;

F PAR IN;

1 ;

SCANNER: PRCCECLIF (TCKEN : = Ct

IF (CTFENC SCANNER;

CFSTOKEN THEN RETURN INPUTSSTR;C FOREVER */

SCANNER ROUTINES */

P EXEC */

RE:TSTCKENI = INPUTSSTR THEN:=KESERVE0tWOK0) <> THEN TOKEN=CTR;

PRINT1ACCUM: FPCCFCURE;ACCL'M( ACCUM-U ) = '$•;CALL PR INT( .P IACCUMI

ENC FF INTSACCUM ;

132

Page 273: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 274: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0043700438C0439C044000441004420O44300444C0445004460044700446C0449C04500045100452004530045400455C045600457C0458C0459C046000461C0462004630C464CC46500466C0467C0468C0469C047CC0471C04720047300474004750047600477C04780047900460004*1C0462CC4G300484C048500486004E7C0488C0469C0490CC4910C492CC493CC494CC4950C4960049 7CC498CC499C050000501C05020O5O30C504C050500506C05070050600509C051CC0511CC51200513005 14C051500516005170C518C0519C0520005210052200523C0524CC525005260052700528CC529C053000531C0532005330053400535005360053700538C0539C054000541005420054300544

PR INT1NUMBEF: FFCCEDURE(NUMB) ;

CECLAREINUME ,1 ,CNT,K) BYTE, J DATA ( 100, 10 ) ;

CC 1=0 TC l;CNT=CjDC kHllE NUMe >= (K:=J(I>);

M.NB=NUMd - K;CM=CNT + l;

ENC;CALL FFINTCHARl'O' + CNT);

ENC;CALL PRIMCMRI'O" + NUMB);

END PRINTJM.KBEP 5

/*

END OF SCANNER PRCCEDURES */

CECLARE

CURJSYMSYNBCLSYM&CL SADDRNE>T!SYM$ENTPYHASH* V ASKSSTYPEDISPLACEMENTCCCOFSPtLENGTHFLCSLENGTHLEVELREUKLCCATICNSTARTiNAMEFCESACCR

SYMBOL TABLE DECLARATIONS * * * */

ACDPESS, /*SYM60L BEING ACCESSEC*/BASED CURSSYM BYTE,BASED CURSSYM ACDRESS,BASED NEXTSSYM ADCRESS,LIT '3FH',LITLITli r

LITLITLITLITLITLITLI f

12'11'

'3',

'3','10'5«

,

'2 ',

'11' /*1 LESS*/

/ » » * t * * * SYMBOL TYPE LITERALS * V

LNPESCLVEDLAEELiTYPEMLLTf CCCURSGRCUPNCNSNLMERICSl ITALFHAALFHASNUMLI 1SSPACELITSCLCTELI TiZERONO PER IC1LITE C ALNUMERICCCMPA$EDASNSECNUKSEC

LITLITLITLITLITLITLITLITLITLITLITLITLITLITLITLIT

SYM30L TABLE ROUTINES

•255•32'• 123•6' ,

'7«i

•8',

•9',

1 10'11 •

• 12'. 15 ,

• 16''21'•72'i 73 i

•80'

*//* * *

SETSACCRESS: PF CCECUF E ( ACDR )

;

CECLARE ACCR ACCFESS;SYMBOL$ACDR(LLCATICN)=ADDR;

END SETiACCRESS;

GETSACCRESS: PPCCEDURE AD0RE5S;PETLRN SYMBCLJAUCP (LOCATION) ;

END CETSADCPESS;

GET$FCe$ACDS: FPCCEDURE ADCRESS;RETURN SYMeCLSAOCRIFCBSADDR) ;

ENC GETlFCEiACCF ;

GETSTNFE: PRCCECLRF BYTE;RETURN SYM8CL (SITYPE )

;

END GETilYPE;

SETSTYFF: PFCCE CLRE (

T

YPE )

;

CECLARE TYPE EYTE;SYMBOL ( S1IYFE )=TYPE;

END SETSTYP:;

GETSLENGTH: FPCCEDURE ADDRESS;RETURN SYPeCLlACCRtFLDiLENGTH);

ENC CETtLENGTH;

GETSLEVEL: crcCECLPE BYTE:RETURN SPR( SYMBOL (I.EVFL) ,4) ;

ENC get$l=vel;

GETJCECIMAL: PPCCEDURE BYTE;RETURN SYI- 8CL (LEVEL ) AND OFH;

ENC GETiOECIVAL;

GE T$PtLENGTh: PPCCEDURE BYTE;RETURN SYM8CL(F JLENGTh )

;

END CETSPSLENGU ;

BI.ILCJSYMBCL: FFCCECUPE ( LEN) ;

CtCLAfcE LfN BYTE, TEPP ADDRESS;1FMP=NE >1« S If ;

IF (NfcXTiSYJ- :=.SYMP,CL(LEN:^LEfl DISPLACEMENT))> FAXtvEMCRY THPN CALL F AT AL $E RROR (

• S T • ) ;

CALL FILL ( TEMP, , LEN)

;

ENC ei 1LDISYKBCL ;

133

Page 275: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 276: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00545005460054700548(0549C055000551005520C55300554CC555005560055700558(0559(0560005610056200563C056400565C0566C0567(0568(0569(057000571005720057300574005750057600577CC57B(0579(0580C058100682005830C584C06850058600587C0588(05890059000591COf.920C5930C5940C5950C5960C59700598C0599(060000601006020060300604CC605C0606C0607C0608CC609(061C00611006 12006130061400615C0616C06 1700618C06 19C0620C062100622C062300624C062500626C062700628C0629(063000631006320063300*3400635C06360063700*3800639(064000641006420064300644C064500646C064700648CC649(C650C0651C0t5200653

1 AND$CLT$CCCL'RS: PROCEDURE (TYPESIN) BYTE;2 CECLARE TYPE1IN BYTE;2 RETURN TYPE1IN ANO 127;2 ENC ANOJCUTiCCCLPS;

/» * *

CECLAREPSTACKSIZEVALUESTATESTACKVALUE2VAPCIOSSTACKID1PTRMAXS8YTESUBSINOCCND1T YPEHCLDlSECTICNhCLDJSEC$4CCRSECTICNSFLACLSAOCRLJLENCTHLJTYPEL$CECCCMLENGTHCCKPIL INGSPMPMFF1NOLCCK( I ,J,K)51ATE

PARSER OECLARATICNS * */

LIT(FSTAC(FSTAC(PSTAC

(

(20)eYTE,BASEDeYTEBYTE ,

ACCRESACCRESBYTEACCRESACCRfcSEYTE,EYTE,EYTE,eYTEBYTEBYTE,EYTE,eYTEeYTE,BYTE

•30*, /* SIZE OF PARSE STACKS*/KSIZE) ADCRESS, /* TEMP VALUES */KSIZE) BYTE, /* SAVED STATES */KSIZE) ADCRESS, /* VALUE2 STACK*/100) BYTE, /*TEMP CHAR STCRE*/

AOORESS,

MAX$INT$KEMINITIAL (0),

INITIAL (0) ,

BYTE,

INITIAL(TRUE) ,

INITIAL (255),

INITIAL(FALSE) ,

/'INCICIES FORINITIAL(STARTS) ,

THE PARSER*/

/******** CCDE LITERALS * * * * * » » » $ */

/* THE CCDE LITERALS ARE 3RCKEN INTO GROUPS DEPENDINGCN Tf-E TCTAL LENGTH OF CCDE FROCUCEO FOR THAT ACTICN /

/* LENGTH CNE */ATC LIT «l« f /* REGISTER ADDITION */SUB LIT '2', /* REGISTER SUB T

R

AC T I CN */VUL LIT '3', /* REGISTER MULTIPLICATION */DIV LIT '4', /* REGISTER DIVISION */NEG LIT '5', /* NOT CPERATOR */STP LIT «6', /* STOP PROGRAM */STI LIT '7', /* STCRE REGISTER 1 INTO REGISTER */

/* LENGTH TkC */RNO LIT '8', /* ROUNC CONTENTS GF REGISTER I */

/* LENGTH THREE */RET LIT «9', /* RETURN */CLS L IT « 1CS /* CLOSfSEP LIT • 11' , /* SIZEBRN LIT '12', /* eRANCCFN LIT ' 13' , /* OPENCP1 LIT ' 14*

,

/* OPENCP2 LIT '15', /* CPENRGT LIT 'U«, /* P.EGi:PLT LIT '17', /* REGi:PEC LIT 1Q ' , /* REGI !

INV LIT '19', /* I.NVAlEQR LIT '2C , /* END (

ACCDISSTDLDI

CECSTOSTIST2ST3ST4ST5

LODLDILD2LD3LD4LD5LD6

PEPCNUCNSCALRWSDLSRCFWTFRVLWVL

SCPSGTSLTSECMCV

/* LENGTHLIT '21'LIT •22'LIT «22'LIT «24«

/« LENGTHLITL I T

LITLITLITLITLIT

'25•24 '

27', 2 o •

•29'•3C•31'

/* LENGTHLITLITLITL ITL ITLITLIT

32'33'34«'35'36'

1 37 •

i 3e .

/* LENGTHLITLITLITLITLITLITLITl nLITLIT

'39'4C '

'41''42»

'44 '

'45''46''47''48 «

/* LENGTHLITLITLITLITLIT

' 4S '

>5C51'52'5 3'

/* CLOSE *//* SIZE ERROR *//* BRANCH *//* OPEN FOR INPUT *//* CPEN FOR OUTPUT *//* CPEN FOR 1-0 *//* REGISTER GREATER THAN *//* REGISTER LESS THAN • //* REGISTER ECUAL *//* INVALID FILE ACTION *//* END CF FILE REACHED */

FCLR *//* ACCEPT *//* DISPLAY *//* STOP AND DISPLAY *//* LOAO COUNTER IMEOIATE */

FIVE *//* DECREMENT ANO BRANCH IF ZERO *//* STORE NUMERIC *//* STORE SIGNED NUMERIC TRAILING «//* STC=E SIGNED VUMSRIC LEACING *//* STCRE SEPARATE SIGN LEACING *//* STCRE SEPARATE SIGN TRAILING *//-> STCRE COMPUTATIONAL */

SIX *//* LOAD NUMERIC LITERAL *//* LOAD NUMERIC *//* LOAO SIGNED NUMERIC TRAILING *//* LOAO SIGNEO NUMERIC LEACING *//* LCAO SEPARATE SIGN TRAILING *//* LCAD SEPARATE SIGN LEADING *//* LCAD COMPUTATIONAL */

SEVEN *//* PERFORM *//* COMPARE FOR UNSIGNED NUMERIC *//* CCMPAPE FOR SIGNED NUMERIC '//* COMPARE FOR ALPHABETIC *//* REWRITE SEQUENTIAL *//* OELETE SEQUENTIAL *//* REAO SEQUENTIAL *//* WRITE SECUENTIAL *//* READ VARIABLE LENGTH *//* WRITE VARIABLE LENGTH */

NINE «//*/*/*/*/*

SUBSCRIPT COMPUTATION */STRING GREATER THAN */STRING LESS THAN */STRING ECUAL */fCVE */

134

Page 277: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 278: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00654 1 /* LENGTH 10 »/00655 I RR5 LIT »54«, /* READ RELATIVE SEQUENTIAL */C0656 I »fR « LIT '55', /* WRITE RELATIVE SEQUENTIAL */COc57 1 RPF LIT 'St*, /* READ RELATIVE RANDOM </00658 1 WPP LIT '57», /* WRITE RELATIVE RANDOM «/C0659 1 «WR LIT 'Se*, /* REWRITE RELATIVE */C0660 1 DLR LIT '59', /* DELETE RELATIVE */00661 I

00662 1 / LENGTH ELEVEN »/00663 1 MED LIT '6C, /* fCVE EDITED «/00664 1

00665 1 /* LENGTH THIRTEEN */00566 1 MNE LIT '61', /* MOVE NUMERIC EDITED */C0667 1

C0668 1 /* VARIABLE LENGTH /C0669 1 GDF LIT '62', /* GO DEPENDING ON »/CC670 1

00c71 1 / BUILC DIFECTING CNLY */00672 1 INT LIT '63', /* INITIALIZE STORAGE =»/

00673 1 BST LIT «64', /* BACK STUFF ADORESS */00674 1 TER LIT '65', /* TERMINATE BUILD */C0o75 1 SCO LIT '66'; /* SET CCD6 START »/00676 1

C0677 1 /* * * * PARSER ROUTINES *****/C0i78 1

00579 1 DIGIT: PRCCECL'RE (CHAP) BYTE;00680 2 DECLARE CHAR BYTE;CC681 2 RETURN (CHAR<='9'J AND (CHAR>='0*);C0682 2 ENC CICIT;C0e83 1

00684 1 LE7TEF: PPCCECLFE BYTE;00605 2 RETURN (CHAP>='A'l AND <CHAR<='Z');00686 2 ENC LETTER;C0687 1

0C68B I

C0o89 1 INVALICSTYFE : FFCCEDUPE;00690 2 CALL P F I N T 5 E F RCR ( • I T ' ) ;

0C591 2 ENC INVALID JTYFE ;

0C692 1

00693 1 BYTESCLT: P FCC

E

CLR E( C NE SBYTE )

;

CC694 2 CECLARE CNEieYTE BYTE;00J95 2 IF (0UTPLTJFTR:=0L7PUT$PTR 1) > OUTPUTJENC THEN0C696 2 CC;CC697 2 CALL h R I TF SCUTPUT (. OUTPUTS BUFF )

;

0C698 3 0LTFUTJPTF = .CUTPUT1BUFF ;

CCi99 3 END;C0700 2 CLT?UTiCHAF=CNESBYTE ;

00701 2 ENC eYTESOUT;C0702 1

00703 1 ACCRJCLT: PRCCECLRE (AOCR);C0704 2 CECLARE ACCF ADDRESS;C0705 2 CALL BYT E J CL T (LOW

(

ACCR ) )

J

00706 2 CALL BY7ESCL T (HI GH (AOCRj);O07C7 2 ENC ACCRiCUT;C0708 1

CC709 1 INCJCCLNT: F FOC E CLF.E ( CM > ;

C0710 2 DECLARE CNT BYTE;C0711 2 If (NEXTSAVA UABLE : =NEXT$ AV A 1 1. AOL E + CNT)00712 2 >MAXiIMiMEM THEN CALL H ATAL tE RRCR ( ' ^C ' ) ;

00713 2 ENC INC$CCLNT;C0714 1

C0715 1

CO 1 16 1

00717 1 CNESACCRiOPP: PFCCEDURE( CODE , ADCR ) ;

C0716 2 DECLARE CCCE EYTE, AOOR ADDRESS;C0719 2 CALL BY T E $ CL T (COC E ) ;

C072C 2 CALL ACC FSCLT ( ACCF ) ;

00721 2 CALL [NC5CCLNT (3) ;

C0722 2 ENC CNES AODR JCPF ;

00722 1

0C724 1 NCT J 1HPLIPENTEC : PROCEDURE;C0725 2 CALL PR1NTJEPR0R («NI«);C0726 2 ENC NC T$ I NPL I f ENT EO

;

00727 1

CC728 1 MATCH: PROCECURE ACDP.ESS;C0729 2 /* CHECKS AN IDENTIFIER TO SEE IF IT IS IN THE SYMBOLC0730 2 TABLE. IF IT IS PRESENT, CURtSYM IS SET FCR ACCESS,00731 2 OTHERWISE THE POINTERS ARE SET FOR ENTRY*/C0732 2 CECLARE ( PC I NT ,COLL I SI CU BASED POINT) AOORESS, (HOLD, I) BYTE;00733 2 IF VARONAXi ICJLEN ThENC0734 2 VAFC = MMID*LEN;00735 2 FCLD=0;00736 2 CC 1=1 TC VAFC;00737 2 HOLC = HCLD +VARC( I ) ;

CC738 3 ENC;C0739 2 PGINT=HASHSTA6$ADDR + SHLUHCLD AND H ASHtM A SK ) , 1 )

5

00740 2 CC FOREVER;00741 2 IF CCLLISICN=C THEN00742 3 00;00743 3 CLPSSY* ,CCLL1SI0N=NFXT$SYM;C0744 4 CALL BU I LDSSYM80L

(

VARC )

;

C0745 4 SYfBCH P$LENGTH)=VARC ;

C0746 4 DC 1=1 TC VARC;00747 4 SYM30L(START*NAME + I )=VARC( I ) ;

C0748 5 ENC;C0749 4 CALL SE T 1TY PE ( UNRE SCL VEC ) ; /* UNRESOLVED LABEL */C0750 4 RETURN CURSSYM;00751 4 ENC;CO 7 52 3 ELSE00753 3 DO;00754 3 CLP*SYM=CCLLISION;00755 4 IF (HOLD:=GET$P$LENGTH)=VARC THENC0756 4 CC;C0757 4 1=1;C0758 5 DO WHILE SYMBOL < STARTSNAME 11= VARC ( I ) ;

C0759 5 IF ( I: = I + l*>HCLD ThEN RETURN (CURSSYM

:

=CGLL I S I CN ) ;

C0760 6 END;C0761 5 ENC;00762 4 END;00763 3 PC1M=CCLLIS1CN;00764 3 FNC;CC765 2 ENC MTCH;

135

Page 279: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 280: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0C767 1C0768 2CO 769 2C0770 2OC771 I

00772 I

C0773 200774 200775 200776 1

00777 I

C0778 100779 2CC78C 2

C0781 200782 200783 1

CC784 100735 1C0786 200737 2C0788 2C0789 2CC790 1

0C791 1

0C792 10C793 2CC794 2

CG795 200796 2

0C797 1CC798 1

CC799 I

0C300 200801 2C0S02 3CCS03 20OEJ4 2C0605 1

coeo6 100607 I

C0EC8 2

coec9 2

C0810 2oo an 3C0812 3C0813 2ooei4 2ooeis 1

C0616 100817 1C0E18 2C0819 2C0320 200621 200322 2CC82? 1

C0S24 100625 1

00826 200627 2C0628 2C0829 2

C0830 1

00331 1C0832 100 333 200834 2C0635 1

C0836 1

0C637 1

CO 63 8 2C0639 2C0840 200341 I

0C842 1C0343 1

0C844 2C0345 2

00d46 200647 1C0S48 1

C0849 1

00650 200651 200852 200653 200854 2

00855 2

C0G56 2C0657 2coess 2(0659 I

C0660 1

C0861 1

00862 2C0663 2

C0664 200665 2

C0e66 200667 3C0868 3

(0869 2(0670 200671 200672 30C673 3

C0A74 2C0675 200676 200677 3rn(7(i *

SETS^ALUE: FFCCECURE(NUMB) ;

DECLARE NUKE ACCRESS;VALUE(KF )=M.fe;

ENC SETSVALOE;

SET$VALUE2: P FCCEDURE ( AODR I

;

CECLARE ACCR AOCRESS;VALLE2(f F)=ACCR;

ENC SETSVALLE2;

SLESCNT: PRCCECIPE 8YTE;IF (SUB$INC:«SUB$-INO 1)>8 THEN

SUBJINC=l;RETURN SLBJIND;

END <C8$CNT;

CCCEtEYTE: PPCCECURE (COCEJ;CFCIARE CODE EYTE

;

CALL 3YTE$CLT(C0Dt) ;

CALL INCJCCLNTU) ;

ENC CCCEseYTE;

COCEIAOCRFSS : PRCCEOLPE (CODE)CECLARE CCCE ACDRESS;CALL ADCF$CIT(CQCE) ;

CALL INCJCCUM(2I ;

ENC CCCESAOCRESS ;

INPIKNUMERIC: FRCCEELRE 8YTE;CC CTR=1 TC VAPC;

IF NOT CIGIT<VARC(CTR) )

ENC;FETURN TRUE;

END INFUTSNUf EF IC

;

THEN RETURN FALSE;

CCNVEPTSINTEGER: PRCCEDURE AODRESS;ACTR=0;CC CTR=1 TC VARC;

IF NOT C I I

T

(VARC(CTR) ) THEN CALL PR I NT SERROR <• NN • )

A$C1R=SHL(ACTR,3)+SHL< ACTR, I) + VARCICTR) - 'C;ENC;RETURN ACTR;

ENC CCNVERTJINTECER;

BACKSTLFF: FROCECLRE (AC01,ADD2);CECLARE (ACC1.ACC2) ADORESS;CALL BY1EJCL"! (EST ) 5

CALL ACCFICLT(ADCI) ;

CALL ADCFSCLT (A0C2) ;

ENC BACKSSUFF;

UNRESOLVEDleRANCH : P°CCEOURE;CALL SET1VALIE(NEXT$AVAILA3LECALL CNElACCRSCPP(eRN.O) ;

CALL SET5VALLF2 < NE XT$AV AI

L

ABLE )

ENC LNRESCLVECURANCh;

1)

BACKtCCNC: FFGCECLR6;CALL BACKSTLFF( VALUE (SP-l J , NEXT SAVA IL A3L E ) ;

ENC eACKSCCNC;

SETSERANCH: FRCCECURE;CALL SET!VALLE ( NEXT SAVA I L A8L E ) ;

CALL COCESACCPESS(O) ;

END EETSERANCh;

KEEPSVALUES: PPCCEDURE;CALL SET1VALLE(VALUE(SP) ) ;

CALL SE7JVALLE2( VALUE2(SP) )

ENC KEEPSVALLES:

READSWPITE: FPCC ECURE ( INCEX)

;

CECLARE INCEX BYTE;

IF (CTR :=CETtTYPE)=l THENDC;

CALL CCCE SBYTEfRDF+INOEXCALL STANOARCSATTRIBUTES

END;ELSECC ;

ENC;ELSECC ;

) ;

(0);

>

;

(l);

IF CTP=2 THEN

CALL CCCEtBYTE (ORS+I NOEXCALL STANDARCSATTRI8UTES

IF CTR=2 THEN

CALL CrCEtBYTE(RRR+INDEX) ;

CALL STANCARDSATTRIBUTES( 1)

;

136

Page 281: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 282: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

C0E79 2CC880 200881 2O0t'82 30OR83 300E84 2coees 2CCfc86 1

00£87 1

ccese I

00889 2CC890 2CC891 2CC692 20C693 2C089A 1CC895 1C0E96 1

OCf97 20CE98 2(CE99 2

CG900 20J9O1 300902 3C0903 300904 3CC905 2C0<06 200907 2C0<08 2C0<09 2CC C

. IC 1

009 11 1

CC912 1

00'13 2C0< 14 2C0915 2CCV16 200917 I

C0918 1CC919 I(0920 200921 2CO 92 2 2C0923 2

00924 2C0925 2CC926 30C927 3C0928 3

C0929 3

CG920 200931 200932 2C0933 30C934 3C0935 300936 200937 2

C0938 2C0939 2

C0940 2

C0941 2C0942 1

C0<43 1

CC944 1

C0945 2

CC946 200947 2C0948 2

C0949 2C0950 20C951 1

0C952 1CC953 100954 200955 200956 200957 2CC958 2CC959 1

CC960 1

CC961 1

CC962 2

00963 200964 200965 2CC966 200967 2C0968 2CC969 3CC97C 2C0971 200972 I

0C973 1

00974 1C0975 2CC976 200977 200978 3C0979 3CC980 7

0C981 2C0982 2CC983 1

CC984 I

0C985 1CC986 20C987 2C0988 2CC939 3CCS90 3

CC991 2009^2 2

ELSE IF CTR = 4 THENCC;

CALL CCCE$3YTE(RVL+INDEXI ;

CALL STAN0APCSATTRI6JT=S(0» ;

ENO;ELSE CALL P R INT SE PRCR ( • FT • ) ;

ENC REACSV.RITE;

ARITHMETICtTYPE : PROCEDURE BYTE;IF ( (Li TYPE :=ANOICUT$OCCURS(LJTYPEI I > =NUMER ICSL I T E R A L

)

CR (L$1YPE< = CC^P) THEN RETURN LSTYPE - NUMERIC SL IT ERAL ;

CALL 1NVAL ICiTYPE ;

RETURN C;ENO ARITHPET1CMYPE;

DELtRVT: PPCCECL RE < FL AG )

;

CECLARE f-LAC BYTE:IF (CTR:=CETSTYPfc)=3 THENCC;

IF FLAG THEN CALL COOEiB YTE ( RWRI

;

ELSE CALL CODE S3YTE(0l.R ) ;

CALL STANDARDSATTRIBUTESd ) ;

RETLPN ;

END:IF (CTR = 2) ANC (NOT FLAG) THEN CALL CODE i E YT E ( OLS J ;

ELSE IF (CTR<>4) AND FLAG THEN CALL CGCE $b YTE ( RWS ) ;

ELSE CALL I N V ALI

D

i T YPE ;

CALL STANDAPCJATTRIBUTESO) ;

END CELSRhT;

ATTP.IELTES: FPCCECURE;CALL CCCElACCFESS (LJADCR) ;

CALL CCC:$EYTE<LiLENGTH) ;

CALL CCC6SEYTE(L$CEC);END ATTRI8L1ES;

LOAOSLJID: FRCCECL.RE ( S$PTR ) ;

CECLARE StFTP BYTE;IF((ASC7P:=VAlUS(StPTR)KN0NJ\UNERIC$LIT) OR

(ACIR^NLPER ICSLITERAL) THENDC ;

L$ACDF=VALUE2( SPTRJ ;

LiLENG7h=CCMLENGTH;LS^YPt^AJCTR;RETLPN ;

ENC;IF A$CTR<=L ITiZERC THEN

LtTYPE ,L$ACDR = AiCTR;L$LENGTF=1 ;

RETLPN ;

ENC;CLR$SY^ = \,ALLE(S JPTR) ;

LITYPE^GETSTYFE;LJLENGTh«GST 5LENGTH;liCEOCEIJCECIMALSIF(LSACCR:=VALUE2(S1PTR) )=0 THEN L$ADCR=GET $ ACDRE S S

;

ENC LCADIL1IC;

LOACJPEG: PPCCE CLRE ( FEG$NO,PTR ) ;

CECLARE (P.EGINO.PTR) BYTE;CALL LCACSLi IC(PTR) ;

CALL CCCEieYTElLCC+ARITHMET ICJTYPE) ;

CALL AT f= lei TES ;

CALL CCDE$eYTE(REGiNC) ;

ENC LCADiREG;

STCRESREG: PFCCECURE ( FTR 1

;

CECLARE FTR EYTE;CALL LCACJL J lC(PTR) ;

CALL CCCEteYlE(STC + AR I THMET !C I T YP E -I);CALL AT7P1EL1ES;

ENO skresreg;

STCRESCGNSTANT: FROCECURE ADDRESS;IF (MAX5 !NT$f>E^:=MAX$INT$ME,« - V ARC XNEXT $ A v A IL ABL E

THEN CALL F A T AL SERROR ( • MC • )

5

CALL BYTEtCLT(INT) ;

CALL ACCFiCLKK AX1INTSMEM) ;

CALL ACCFlCLT(CCNSLENGTri:=VARG) ;

DC CTR = 1 TC CCNSLENGTH;CALL BYTEiGLT (VARC(CTR) ) ;

ENC;PE TURN CAX1 INTtMEf ;

ENC STCRESCCNSTANT;

NUNERICSLIT: PPCCECURE BYTE;CtCLAPF CHAR eYTE;CC CTR=1 TC VAPC;

IF NOT ( DIGI T(CHAR: =VARC(CTR) )

CP (CHAR='- ,1 OR (CHAR='+')

CR (CHAR='.')) THEN RETURN FALSE;ENC,RETURN TPLE;

END NUHERICSLIT;

FCUNCSSTCRE: PFCCEOUPE;IF VALUEISF )<>0 THENcc

;

CALL CCCE$BYTE(RND) ;

CALL CCCESBYTE(LSOEC) ;

ENC;CALL STCFEIPEG(SP-I) ;

END RCLNOSSTCPE ;

137

Page 283: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 284: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

' 0C994 1

0CS95 1

CCS96 2CC997 20OS98 2CC999 2C1C00 2OlCOl 301C02 301CO3 301C04 2

01C05 2• C1C06 201007 2

cicoa 1

C1C09 1

C1010 101011 201012 201013 201C14 201CL5 201016 201017 1

C1C18 1

C1C19 1

01C20 2

01021 2C1022 201C23 2C1C24 i

C1C25 3

01C26 201C27 201C28 2C1C29 3C1C20 3

01021 2

01032 201C33 201G34 201025 201026 2010j7 2C1C38 2C1C29 1C1C40 101C41 1

01042 201043 2

01044 2C1045 2

01046 2C1C47 201048 2C1049 2C1C50 2C1C51 201C52 1C1C53 1

01C54 1

C1C55 201C56 201057 201058 2C1C59 2C1C60 201C61 201C62 201C63 1

01C64 1

01065 1

01C66 201C67 2C1C68 2C1C69 2C1C70 201C71 201C72 301C73 3

01C74 2C1C75 2

C1C76 201077 201078 3C1C79 3C1C80 3

01C81 201C82 201C83 2C1C84 2oices I

C1C86 I

01C87 1C1C88 2C1C89 2(1C90 2C1C91 201C92 201C93 1

01C94 1

C1C95 1

01C96 201C97 2_ClC9e 1

ADCJSUB: PRCCECLPE (INDEX);CECLARE INCEX BYTE;

CALL LCAt JFEC(0,MPP1 ) :

IF VALUE(SF-2)<>0 ThENCC;

CALL LCAOSREGU ,SP-3) ;

CALL CCCEJBYTE1 ADO)

;

CALL CCCE$BYTE(ST1 I

;

ENC:CALLCALLCALL

ENC ACCtSUB

LCiCJSEC tl.SP-CCCEfEYTEUDCRCLNDiSTCRE;

1);+ INDEX)

MULTSCIV: PPCCECLRE(INDEX) ;

CECLARE INCEX BYTE;CALL LCACfrEC (0.MPP1 )

;

CALL LCACIPEC(1,5P-1) ;

CALL CCCE$eYTE(fUL + INDEX)CALL RCLNDJSTGRE;

ENC fLLTJCIV;

CFECKi SU3SCR1FT : F°OCEOURE;CLRSSYN=VALLE(MP) ;

IF GETSTYPE<NULT$CCCURS THENcc;

CALL PF INTSERRGRCIS' ) ;

RETLPN;ENO;IF 1NPLT JNLCERIC THENCC;

CALL SETSVALUE2(GETSA0CRESSRETLPN;

ENC;ClPiSYM^ATCI-:IF ( <CTR: = CE7tTYPEKN>JMFRIC ) OR (CTR>COMP) THEN

CALL FR !NT$ERRCR< »TE" ) i

CALL CNS5ACCP 10PPI SCR, GETS ADCRESS);CALL CCCE?eYTE( suescwT)

;

CALL CCCE JEYTEIOflTSLFNCTH) ;

CALL SET1VALLE2I SUBSINO) ;

ENC CFECKSSLESCPIPT;

L0ADJLA8EL: FFCCECURE;CLRSSY M =\ALLE (MP) ;

IF ( A$CTS:=f;ET*AOCRESS)<>0 THENCALL 2ACK1STUFF(A£CTR,VALUE2<MP) );

CALL SET1ACCRESS( VALUE2(MP| I

;

CALL SETJTYFE(LABELSTYPE) ;

IF (A1CTP :=C£TSFC8$ACDR)O0 THENCALL BACKISTUFFIAJCTP. ,NEXT$AVAILABLE):

SYMBOL SACCR(FCBSACCR)=NEXTSAVAILA6Lc:CALL CNEJACC? iOPP <RET,0) ;

ENC LCACSLAEEL;

LOADtSECSLAGEL : FPCCECURE;A$CTR=VALLE IfPI;CALL SET1VALLE I HO L D$ SECT I ON ) ;

HCLDSSECTlCMAiCTR;A !CTS=VALUE2 (MPI ;

CALL SET!VALLE2(HCLC$SECSADDR) ;

FCLDtSECiACCP = AiCTR;CALL LCACSLAEEL;

ENC LCAD$StC!LAEEL;

LABEL! AD DR: FPCCECURE <aCDR,HOLD)ACDRESStCECLARE ACCP ACCRESS;CECLARE (-CLC BYTE;CURSSYM=ACCF ;

IF(CTR:=CET!TYPE)=LA8ELSTYPE THENCO;

IF FCLC THEN RETURN GETSADDRESS;RETURN CETiFCBJAODR;

END;IF CTROLNRESCLVEC THEN CALL I NVAL I D$ TYPE ;

IF HOLC THENCC;

A$C1R=CET$ADCRESS;CALL SET JADORESSlNEXTtAVAlLAELE + 1);RETLRN ASCTR;

ENC;A$CTR=GETSFCEf ADCR:SYM60LSALCR (FCBJA0DR)=NFXT$AVAIl.A6LE + 1;RETURN ASCTP;

END LAeELtACCRj

CODEJFCPSC! SPLAY : PPOCEOURE (PCINT);CECLARE FCINT BYTE;CALL LCACtL! IC(FCINT) ;

CALL CNcSACCP tCPP( CIS, LtAOCR) ;

CALL CCCajeYlE(LiLENGTH);ENC CCCEiFCRJC I SPLAY;

ASANtTYFE: FPCCECURE BYTE;RETURN (Lt TYPE = ALPHA ) OR ( LSTY PE = AL PHA$NUM ) ;

ENC A1ANSTYFE;

(GETSLENGTH * C CNV ER T$ INTEGER ))

:

138

Page 285: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 286: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

ticssCllOO0110101102C110301104C1105C110601 10701 108C1109C111001111011120111301114011150111601 117CI 118C1119C11200112101122011230112401125011260112 7

C1123CI 1290113001131C1132011330113*0113501136C1137CI 13301139CI 140011410114201 14301 144C114501 14601147C 1 1 4 8CI 149CI 150CI 151C115201153011540115501 15601157C1158C1159CI 16001161011620116301164C1165CI 166C1167C1168C1169C1170011710117201173C1174011750117601177CI 178C1I79C118001181CI 1820118301184011850118601 18701188C1189CU9001191C1192CI 19301194011950119601 197C1198C1199C1200C1201

N011INTEGEP: PRCCECURE BYTESRETURN LJOECOO;

END nctsinteger;

NUMERICSTYFE : PROCEDURE BYTE;RETURN IL$TYFE>=NUMERIC) ANO ( L ST YPE<=COMP )

;

END NLMERICS1YPE;

GENSCCMPARE: PRCCECURE:CECLARE (HS1YPE ,H$CEC> BYTE,

(HJACCP .FSLENGTH) ADDRESS;

CALLLS1YIF CCO;

LCACSLJIC(MP) ;

PE=AND$CLTSOCCURS(LSTYPE) ;

GN0J1YFE=3 THEN /* COMPARE FCR NUMERIC */

ENCiELSECC ;

ENC;ELSE

IF AJANSTYPE OR ( LSTY PE >COMP ) THEN CALL I NVA L IDS TYPEIF LSTYFE=NUMERIC THEN CALL COOE S8YT E ( CNU )

;

ELSE CALL CCDE $BYTE< CNS )

;

CALL CCCESACCRESS(LSADDR) ;

CALL CCCESADCRESS(LSLENGTH) ;

CALL SETSERANCH;

IF CCNCJTYPE=4 THEN

IF NLfEPlCSTYPE THEN CALL INVAL I OSTYP E

;

CALL CCCESBYTE(CAL) ;

CALL CCCESJOCRESS(LSAODR) ;

CALL CCCE SA0CRESS1LSLENGTF) ;

CALL ScTSdRANCH;

DO;IFELSHJTH$CHSAH$LCALIFIFDO;

NUfERICSTYPE THEN CTR=1;E CTP=0;YPE=L1TYPE ;

EC=LICEC;ccr=lsacdr ;

Engtf=l$length;L LCACSLSICK S=) ;

NUNERICSTYPE THEN CTR=CTR+l;CTR=2 ThEN /* NUMERIC COMPARE */

ENC:ELSI

ENC:

CALL LOAC$REG(0,MP) ;

CALL LCACSREGd, SP) ;

CALL CCCES8YTE< SUB) ;

CALL CCDEiBYTEfRGT +CALL SETSERANCH;

cc;/*IF

C0NDSTYPE1 ;

ALPHA NUMERIC COMPARE */(HSDECOO) OR (HSTYPE=COMP)

OR (LSOECOO) CR ( LS TY PE = CC'<P )

OR (H$L ENGTHOLILENGTH) THEN CALLCALL CODESBYTEt SGT+CONOSTYPE) ;

CALL CCCE$ADDRESS<hSACCPI ;

CALL COCESAOORSSS(LSADDR) ;

CALL C0DE$AODRESS(H$LENGTH) ;

INVAL IT.STYPE

ENC;ENC CENSCOMPiFE;

MCVES1YPE: PPOCECURE EYTE;CECLAREFCLDSTYFE EYTE,4LFHAJNLMMCVE LITA1KSEDSMCVE LITNLMERICSf-OVE LITMEDJMCVE LIT

'0'

• 2'• 3'

LJTYPEIF ( (HC

TIF HOL

I

IF HOLcc;

I

RENCjIF (HOCC ;

I

RENC;IF HOLcc;

I

RENC;IF HOL

I

IF HCL1

CALL 1

RETURNEND MCVEST

=ANC$CLT$OCCURS(L$TYPE);LCJTYFE:=ANCSCUT$CCCURS<GET$TYPE) )=GRCUP) OR ( L 1

T

YPE=GPOUP )

FEN BETLRN AL PHA SNUMSMCVE ;

D11YFE=«LPFA THENF ASANSTYPE CR I L ST Y P E = A $ED ) OR < L ST YPE = A SNSED )

TFEN RETURN 4L PHA SNUM t MOVE

;

OJlYPE=ALPHASNbM THEN

F NOTJINTEGER THEN CALL INVAL ID STYPE ;

ETLPN ALPHASNUMSMOVE;

LCJTYPE>=NUMERIC) AND ( HOLD $TYPE<=C0MP ) THEN

F <L$TYPE = ALPHAI OR ( L S TY FE>COMP > TFEN CALL INVH ID S T YPE ;

ETLRN NUMER 1CJM0VE;

C1TYPE=ASN$EC THEN

F NOTETLRN

D11YPF ASflDJTYFF NUM

RNVAL I

C;YPE;

SINTEGER THEN CALL I NVAL I

D

STYPE ;

ASNSECSMCVE;

f=ASED THENNSTYPE OR <LSTYPE>CCMP) THEN RETURN ASNSEDSMCV!E=NUM«ED THENERICSTYPE OR (L ST YP E = ALPHA JNUM ) TFENETUPN NSECSMOVE;CJTYPE;

139

Page 287: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 288: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

01202012030120401205C120601207C1208C1209C121001211C12120121301214012150121601217C1218C1219C122001221012220122301224C1225C12260122701228C1229C12300123101232C1233C1234012350123601237C1238C1239(124001241012420124301244012450124601247C1248C1249C1250012510125201253C125401255012560125701258C125SC12600126101262012630126401265012660126701268C1269C127001271012720127301274012750127601277C1278C1279C128C01281C1282C1283C128401285C12860128701288C1289C12900129101292012930129401295C129601297C129801299C1300

GENSMCVE:PRCCECLRE;CECLARELENGTH ADCRESS,*CCRl ACCRESS,EMRA ACCRESS;

ACCSACDSLEN: PROCEDURE:CALL CCCE$AD0RESS(ADDR1) ;

CALL CCCE$ADCRESS{L$ADDRI ;

CALL CCCEJAOCRESSd JLENGTI-);ENC AOClACCILcN;

CCDEIFCRJECIT: PRCCEDURE;CALL ACCSADOiLSN:CALL CCCESADCRESSIGETSFCBSAOOR) ;

CALL CCCEiAODRESSUENGTI-l J;ENC CCDSIFCRIEDIT ;

CALL LCACtLJ IC(MPPl ) ;

CLRSSYM=\ALLE(SP> ;

IF < A0DR1:=VALUE2<SP))=0 THEN ACCR 1=GZT SACCPESS i

LENGTH1=CET1LENGTH;

CC CASE MCVEJTYPE;

/* ALFFA NUMERIC MOVE */

OG;

EN

/*

00

EN

/*

CC

EN

/*

CO

ENENC;

END OENSMOV

IF LENGTH1>L$LEMGTH THEN EXTR A=L ENGTH1-L SL E NGTH

;

ELSE 00;EXTRA=0;L$LENGTH=LENGTHl;

END;CALL CGDESBYTFIMOV);CALL AOCSADOSLEN;CALL COCEiAODRSSS(EXTRA);

C;

ALPFA NUMERIC EOITED */

CALL CCOE$BYTE(MED) ;

CALL CCDEfFCRSEDIT ;

c;

NUMERIC MCVE */

CALL LCA0$REG(2,MPPl) ;

CALL STCRE$REG(SPI ;

C;

NUMERIC EDITEO MOVE */

CALL CCCEtBYTEIMNE) ;

CALL CCCESFCRJEOIT;CALL CCCE$8YTE( L SCEC) !

CALL CCCE$BYTE(GET$OECIMAL) ;

COCESCEN: PRCCECUPE ( PRODUCT ION)

;

CECLARE FRCCLCTICN BYTE;IF PRIM1PPCC TFENCC;

CALL CPLF;CALL PRINTCHAR(PCUNO) ;

CALL FRINTSNUMBERIPRCOUCTICN) ;

ENC;

CC CASE FRCCLCTICN;

/* PROCUCTICNS*//* CASE C NCT USED */

/* 1 <P-DIV> ::= PROCEDURE DIVISION <USING> . <FRCC-BOOY>

CC;COMPILING = FALSE;IF SECTICNSFLAG THEN CALL LO AD$S EC $L Ae EL

;

END;

/* 2 <US1NG> ::= USING <IO-STRING>

CALL NCTJ IMFLIMENTEC; /* INTER PP.GG COMM, »/

/* 3 <EMPTY>

; /* NO ACTICN RECUIREO * /

/» 4 <IC-STRING> ::= <I0>

*/

*/

*/

*/

140

Page 289: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 290: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

C1302 3 /* 5 <IO-STRING> <I0> */01303 3C1304 3 CC ;

01305 3 IF(ID$FTR:=ICPTR*1)=20 THEN01306 4 DC;01307 4 CALL PRINTJERRORC ID* 1 ;

C1308 5 ICJPTR=19;C1309 5 ENC;C1310 4 ID1STACK(ID«PTR| = VALUE{ SP) ;

01311 4 ENO;C1312 301313 3 /* 6 <FRCC-EO0Y> : := <PARAGRAPH> */CI 314 30121= 3 ; /* NO ACTICN RECUIREO «/01316 301317 3 /* 7 <PRCC-BOOY> <PARAGPAPH> */C1318 3C1319 3 ; /* NO ACTICN RECUIRED */C1320 301221 3 /* 8 <PARAGRAPH> ::= <1C> . <SENTENCE-L IST> */01222 301323 3 CC ;

01324 3 IF $ECTICN$FLAG=0 THEN SECT I0N$FLAG=2 ;

01325 4 CALL LCACSLAeELJC1326 4 ENO;C1227 301228 3 /* 9 <ID> SECTION . */C1329 3C1330 3 CC ;

01331 3 IF SECTICNJFLAGOl THENCL222 4 DC;01233 4 IF SECTIGN$FLAG = 2 THEN CALL PR I NT JERROR ( ' PF ' ) ;

01234 5 SECTI0N$FLAG=1 ;

01335 5 HCLCiSECTICN=VALUE<MP);01236 5 FCLC$SEC$ACDR=VALUE2(MP) ;

01337 5 END;C1338 4 ELSE CALL LCAD JSEC $LABEL ;

(1229 4 ENC;C1240 301341 3 /* 10 <SENTENCE-LIST> ::= <SENTENCE> . »/01242 301343 3 ; /* NO ACTION RECUIRED »/C1344 301245 3 /* 11 <SENTENCE-LIST> <SENTENCE> . */01346 301347 3 ; /* NO ACTICN RECUIRED * /

C1348 301349 3 /* 12 <SENTENCE> ::= <

I

MPERAT I VE> «/C1350 3C1251 3 ; /* NO ACTICN RECUIRED */C1252 301253 3 /* 13 <CCNOITICNAL> */01354 3C1255 3 ; /* NO ACTICN RECUIRED */C1356 301357 3 /* 14 ENTER <ID> <0PT-IC> *

/

C1258 3C1359 3 CALL NCT1 It- PL IMENTED ; /* LANGUAGE CHANGE */C1360 301261 3 /* 15 <IfPERAT! Vc> ::= ACCEPT <SU8ID> */01362 3C1263 3 CC;01264 3 CALL LC AC SL t I C ( SP ) ;

01265 4 CALL CNE $ ADOR iCPP < ACC , L JAOCR ) ;

01266 4 CALL C

C

CESBYT E ( L*L ENGTH ) ;

01367 4 ENO;C1268 201269 3 /* 16 <ARITHMETIC> */C137C 301271 3 ; /* NO ACTICN RECUIRED */01372 301273 3' /* 17 CALL <LIT> <USING> »/C1374 301375 3 CALL NOT $ 1 fF L I fENTEC; /* INTER PROG COMM »/01376 301377 3 /* 18 CLOSE <I0> */C1378 3C1379 3 CALL CNE JACCR tOPP

(

CLS , GET$FC3$ADDR )

;

C1380 301281 3 /* 19 <FILE-ACT> */01282 301383 3 ; /* NO ACTICN RECUIRED */C13e4 301285 3 /* 20 OISPLAY <LIT/IO> <0PT-LIT/IC> */C1286 3C13E7 3 CC;C13e8 3 CALL CCDE$F0R$DISPLAY(MPP1) ;

C1389 4 !F VALUEISPIOO THEN CALL CODE iFCRSOI SPLAY( SP )

;

C1390 4 END;C1391 301392 3 /< 21 EXIT <PROGRAM-IC> */C1393 301294 3 ; / NO ACTICN RECUIRED */01395 301396 3 /* 22 GO <ID> */01397 301398 3 CALL CNE £ACDR 10PP ( BRN

,

LABELS ADDR ( VALUE ( SP ), I ))

;

ft 399 -\

141

Page 291: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 292: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

C140CC1401014020K030140401405014C601407C1408C1409C141001411014120141301414014150141601417C1418C1419C142C0142101422014230142401425014260142731428C1429C143001421C1432014330143401435014360143701438C1439C1440014410144201443C144401445C1446C1447CI 44 6C144901450C145101452C14530145401455C1456C1457C1458C1459C146001461014620146301464014650146601467C146SC1469C147C0147101472C1473C14740147501476C1477C147801479C1480C148101482C148301484C146501486Ci4e701468C1469C14900149101492C149301494C149501496C1497C1498C149901S0C01501C15020150301504015050150601507015C8015C9f 1

cI a

/* 23

CC;

GC <IO-STRING> DEPENDING <IC> */

CALL CCCE$BYTc(GDP);CALL CCCE$BYTE< IDSPTR) ;

CUR$SYf=VALUE< SP1

;

CALL CCCEiBYTE(GET SLENGTH) :

CALL CCCESAODRESS(GETSADORESS);OC CTP=C TO ICSPTR;

CALL C0UE$AD0RESS(LA8EL$A0DR< IOtSTACKi IDJPTRJ.ll);ENC;

MOVE <LIT/ID> TO <SUBID>

ENC;

/* 24

CALL CEMMCVE;

/* 25 OPEN <7YPE-ACTICN> <10>

CALL CNElACCRiCPPCCPN + VALUE(MPPl), GET SFCStAOCR ) ;

/* 26 PERFORM <I0> <THRU> <F1NISH>

cc;DECLARE (ACCR2,AO0R3) ADDRESS;IF VALUE(SP-l) =0 THEN AD0R2 = L A3EL *AOOR (VALUE ( MP P 1 ) ,0 )

;

ELSE ACCR2=LA8ELiADDR( VALUE (SP-1 ) ,0)

;

IF <ACCR3:=VALUE2( SP) ) =C THEN AD0P3=NE*TSA VA I

L

ABLE + 7;ELSE CALL 8ACKSTUFF ( VALUE ( SP 1

,

NEXTSAVA ILABLE + 7);CALL CNEJADOP. $CPP(PE*,LA8EL$AD0MVALUE(MPP1),1));CALL CCCE$ADCPESS(AC0R2) ;

CALL CCCE$ADCRESS(AQ0R3I ;

*/

END;

/* 27

CALL NCTJ IfFLIMENTED;

/* 28

CC ;

<READ-IC>

/* GRAMMAR ERROR */

STOP <TERMINATE>

ENC;

IF VALLE(SP)=0 THEN CALL CODC S3YTE ( STP I ;

ELSE CALL CNE$ACDR$OPP( STD, VALUEISP ) )

;

2929

<CCNDITICNAL>

CALL BACKSCCNC;

/* 30

CALL P.ACKJCCND;

/* 3131

<A"UTHMETIC> <SIZc-ERROR><IMPERATIVE>

<FILE-ACT> <INVALIO> <I"PERATIVE>

IF <CCNCITICN> <ACTION> ELSE<IMPERATIVE>

CC;CALL eACKSTUFFt VALUE (MPP1) , VALUE 2 ( SP-2 ) 1 ;

CALL EACKSTUFF* VALUE ( SP-21 .NEXTiAVAILAfcLE);ENC;

/* 32

CALL BACKSCCND;

/» 3333

<ARITHMETIC>

CALL ADCISUE(O);

/* 34

CALL MLLTSCIVdl;

/* 35

CALL MULTJOIV(O);

/*I*

3636

<PEAO-ID> <SPEC1AL> <IMPERATIVE>

= «DD <L/ID> <CPT-L/ID> TZ <SL9ID><RCUND>

DIVIDE <L/IC> INTC <SU3IC> <RCUNC>

MULTIPLY <L/ID> eY <SU3ID> <RCUNC>

SUBTRACT <L/IO> <CPT-L/IC> FRCM<SUBIO> <ROUND>

CALL ACCtSLE (1)

;

/* 37 <FUE-ACT>

CALL CELJRWT(O);

/* 38

CALL CEL1PWK1);

/* 39

CALL REAC$V>RITE(1 ) ;

/* 40 <CCNDITICN>

CALL GENJCCfFARE;

/• 41 <CCNC-TYPE> ::= NUMERIC

CCND$TYFE=3 ;

/* 42 ALPHABETIC

CCNCJTYPE=4 i

/* 43 <CCMPARE> <LIT/IC>

CAIl. KFEC$VALUES:

= DELETE <ID>

REWRITE <ID>

WRITE <ID> <SPECIAL-ACT>

:= <L I T/IO> <NOT> <CCNC-TYP£>

*/

*/

*/

»/*/

»/

*/

*/*/

*/

<•/

*/

*/

*/

*/

142

Page 293: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 294: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

C1511C151201513

1 S 1

A

C1515015160151701518C1S19C152C0152101522C1523C152401525CI 1

. 260152701526C1529C153001531CI 5 320153301534C1535015360153701538CI 529C1540C1541C 1 5 '• 2C1543C154401545015460154701548C1549C155001551C155201553C1554C1555015560155701556C1559C1560C156101562C1563C156401565C15660156701568C1569C157C01571015720157301574C1575015760157701578C1579C158001561015C201563C158401565015860156701588CI 589C1590CI 59 I

C15920159301594C1595015960159701598C1599CUCCC160101602C160301604C16C5CU06C 16C7C1608C1609(U10Cltll016120U13C161401£1501616CI 617f. 1 f 1 fl

/* 44 <NCT> : := NCT

CALL C0CE$et7E(NEG) ;

/* 45 <EKPTY>

; / NO ACTICN RECUIRED */

/» 46 <CCMPARE> ::= GREATER

CCNC$TYFE=0;

/* 47

CCND$TYP£=1;

/» 48

CCN0JTYFE=2 i

/* 49 <PCUND>

CALL SETSVALUEd) ;

/* 50 <EMPTY>

; /* NO ACTICN RECUIRED */

51 <TERP1NATE> ::= <LITERAL>

/* NC ACTICN RECUIRED */

52 RUN

/» NO ACTION RECUIRED - VALUE(SP) ALRcACY ZERO */

53 <SFECIAL> ::= <INVALIO>

/* NC ACTICN RECUIRED */

54 END

LESS

EQUAL

RCUNDED

/*

/*

/*

/*

CCCALL SET$VALUE(2> ;

CALL CCCcS IiYTE(EOR) ;

CALL SETSBRANCH;END;

/* 55 <CFT-ID> ::= <SUBIC>

; /* VALLE AND VALUE2 ALREADY SET */

/* 56

; /* VALLE ALnEACY ZERO */

/* 57 <ACTICN> ::= <IMPERATIVE>

CALL LNRESCLVECScRANCH;

/* 58 NEXT SENTENCE

CALL UNRESCLVL-OSERANCH;

/* 59 <THRL> ::= THRU <I0>

CALL KEEF1VALLES;

/* 60

/* NO ACTICN RECUIRED */

/» 61 <FIMSH> ::= <L/ID> TIMES

*/

*/

»/

*/

*/

*/

*/

*/

*/

*/

*/

*/

/

*/

*/

*/

*/

*/

CC:CALL LCACSLS IO("P|

;

CALL CNEIADORSCPPI LDI ,L iADCR) ;

CALL CCCcSBYTc (LSL ENGTH) ;

CALL SET$VALLE2( ,ic/TiAV» ILA6LE);CALL CNE$iDDR$GPP(DEC ,0)

;

CALL CCCESAUC'ESSIO) ;

CALL SETiVALUE(.\EXTSAVAlLA6LE) ;

ENC;

/* 62

CALL KEEFiVALUES;

/* 63

; . /* NO ACTICN RECUIRED */

/* 64 <INVALID> ::= INVALID

CC;

UNTIL <CONDITION>

ENC;

/* 65

cc;

CALL SETSVALUEI 1) ;

CALL CCDcieYTEl INV);CALL SETieRANCH;

<SIZE-ERROR> = SIZE ERROR

*/

*/

*/

*/

END;

CALL CCCEtBYTE t SPR1

:

CALL LNKESCLVEDS2RANCH;

143

Page 295: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 296: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

C1619 3 /* 66 <SPECIAl-ACT> ::= <WHEN> ADVANCING <HOW-MANY> */C1620 301621 3 CALL NCT$ IfFLIMENTEO; /* CARRAGE CCNTRCL */01622 301623 3 /* 67 */01624 301625 3 ; /* NO ACTICN REQUIRED »/C1626 3C1627 3 /* 68 <khEN> ::= BEFORE */C1628 301629 3 CALL NOT! If-FL IMENTED ; /» CARRAGE CCNTRCL */01630 301631 3 /* 69 AFTER */01632 301633 3 CALL NCT J IfPL IMENTED ; /* CARRAGE CCNTROL */01634 3CU35 3 /< 70 <HCW-MANY> ::= <INTEGER> */01636 301637 3 CALL NOT! INFL1MENTEC ; /* CARRAGE CCNTRCL »/01630 301639 3 /* 71 PAGE /C1640 301641 3 CALL NCTI If PLIMENTEO ; /* CARRAGE CCNTRCL */01642 301643 3 /* 72 <TYPE-ACTICN> ::= INPUT */01644 301645 3 ; /* NO ACTICN REQUIRED - VALUE(SP) ALREACY ZERO */CI 646 3C1647 3 /* 73 CUTPUT <=/

01648 3C164<; 3 CALL SETJVALUE(l);C1650 3C1651 3 /* 74 I-C */01652 301653 3 CALL SE 1 1 V ALLE ( 2 )

;

01654 301655 3 /* 75 <SGBID> ::= <SUBSCRIPT> */01656 3C1657 3 ; /* VALLE ANC VALUE2 ALREADY SET */01658 301659 3 /* 76 <ID> */C1660 301661 3 ; /* NO ACTICN REQUIRED */0166,? 3C1663 3 /* 77 <1NTEGER> ::= <INPUT> */C 1 6 6 4 301665 3 CALL SE 1 ! V ALLE (CC N V EST $ I NT EGER ) ;

01660 3C1667 3 /» 78 <IC> ::= <INPUT> */CI 66.3 3C166'i 3 CC ;

C1670 3 CALL SET $V ALUE ( MA TCH I ;

01671 4 IF GETSTYPE=UNRESOLVEO THEN CALL SET S

V

ALUE2 t N EX T $ A V AI L A BL E >

;

C1672 4 ENC;C1673 3C1674 3 /* 79 <L/ID> ::= <INPUT> */C1675 3C1676 3 CC;C1677 3 IF NUMERICSLIT THEN01678 4 DC;C167<5 4 CALL SE T $ V ALUE I NUNEP I C $L I TE P AL ) ;

C1680 5 CALL SE T

$

VALUE2 (

S

TCP E SCCNST ANT )

;

01681 5 ENC;01682 4 ELSE CALL SET JVALUE ( MATCH )

;

C1683 4 ENC;01684 3C1685 3 /* 80 <SUBSCRIPT> */01686 3C1687 3 ; /* NO ACTICN REGUIREO »/C1688 3C1689 3 /* 81 ZERO */C1690 301691 3 CALL S E T 1 VA LUE ( L I T SZERO )

;

C1692 301693 3 /» 82 <SL8SCRIPT> ::= <IC> ( <INPUT> ) */C1694 301695 3 CALL CHEC

K

i SUESCR I PT

;

C1696 3C1697 3 /* 83 <GFT-L/ID> ::= <L/ID> */C1698 3C1699 3 ; /* NO ACTICN REQUIRED »/C1700 3C1701 3 /* 84 <EMFTY> */01702 301703 3 ; /* VALLE ALREACY SET */01704 301705 3 /* 85 <NN-LIT> ::= <LIT> */01706 3017C7 3 CC;C1708 3 CALL SET SVALUE ( NONSNUMER IC SL IT )

;

C1709 4 CALL SET$VALUE21ST0RE$CCNSTANT);C171C 4 ENC;01711 301712 3 /* 86 SPACE - */01713 301714 3 CALL SET i VA LIE (L I

T

t SPACE )

;

C1715 3CI 716 3 /» 87 QUOTE */01717 3C1718 3 CALL SET 1 VALUE! L I T S0UC7E )

;

CI 719 3C1720 3 /* 88 <LITERAL> ::= <NN-L1T> */01721 301722 3 ; /* NO ACTION RECUIRED */01723 3

144

Page 297: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 298: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

C1724C17250172601727C1728C1729C1730C1731C17320173301734017350173601737C1738C1729C174CC17410174?017430174401745C174601747C1740C1749C1750017 5 1

01752C175301754C1755C175601757C1758017590176C01761CI 76201763C1764C1765C1766C1767C1768C1769C17700177101772C177301774017750177601777C1778C1779C1700017810170201783017d4017d5C17d6017d7CI 738C1789C1790017910179201793C1794CI 79 5C17961797

01798C1799C1800

1 6 I

C1802C180301604C18050180601607C1808018O9C181001811018120181301814C1815C181601817CI 8 18C1819£18^0

/*

/*

/*

/*

/*

89 <INPUT>

CC i

IF NOT NUMEPJCUIT THEN CALL 1 MV AL I C $T YPE ;

CALL SET$VALUE(NUMERICJLITERALI ;

CALL SETSVALUE21STORESCCNSTANT) ;

END;

90 ZERO

CALL SET1VALUE<LIT$ZER0);

91 <LIT/ID> : := <L/ID>

; /» NO ACTION RECUIRED */

92 <NN-LIT>

; /* NO ACTICN RECUIRED »/

93 <CF7-LIT/I0> ::= <LIT/ID>

; /* NO ACTICN RECUIRED */

94 <EMPTY>

/* NO ACTICN RECUIRED */

' 95 <FFCGRAM-IC> : : = <IC>

CALL NCTU*PLI,MENTED; /* INTER PROG COMM */

S6; /» NO ACTICN RECUIRED */

97 <PEAC-ID> ::= READ <IC>

CALL REACSWRITE (0) ;

*/

*/

*/

*/

*/

*/

*/

*/

*/

/* CLEAR THE STACK WHILE INCREMENTING */

ENC; /* ENO OF CASE STATEMENT */ENG CCCESGEN;

GETIM : PROCEDURE SYTE;RETURN INDEXKSTATE) ;

ENC CETINl;

GETIN2 : FRCCECLPE BYTE;RETURN INDEX2 (STATE ) ;

ENC CETIN2;

INCSP: PRCCECURE;VALUe( SF :=SF 1 J =0

;

VALUE2(SF) =C;IF SP >= PSTACKSIZE THEN CALL FATAL ScRROP (' SC ) ;

ENC INCSP;

LCCKAFEAC: PROCEDURE;IF NCLCCK THENCC ;

CALL SCANNER;NCLCCK=FALSE;IF FRINTJTOKEN TnENDC;

CALL CRLF;CALL PR INTSNUM3ER (TCKEN) ;

CALL PR INT JCriAR( • > ) ;

CALL PklNTSACCUM;ENC;

ENC;END LCCKAHE4C;

NCICCNFLICT: PRCCECURE (CSTATE) BYTE;DECLARE (CSTATE, I , J, K) 3YTE:J= JNDEX1 (CSTATEi ;

K=J + INCEX2(CSTATE) - 1

;

CC I=J TC K;IF REAC1U ) = TCKEN THEN RETURN TRUE;

ENC;RETURN FALSE;ENC NCJCCNFLICT;

RECOVER: PRCCECURE 3YTE;CECLARF ISP eYTE, RSTATE BYTE;CC FOREVER;

TSF=SP;' CO WHILE TSP <> 255;

IF NOtCCNr'LICKRSTATF : = ST AT EST ACK ( T SP ) I THENCC; /* STATE WILL REAO TOKEN "

/

IF SPOTS? THEN SP = TSP - I;RSTURN RSTATE;

ENC;TSf = TSP - 1;

enc;call scanner; /* try another token «/

ENC;ENC RECOVER;

145

Page 299: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 300: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

01821C1822C162301824C18250182601827C1828(1829C18J0C1831C1832C18J301834C18350183601637C183801839C1640cie4i0184201643C1844C1645C184601647C184801849C1850018510185201853C1854C1855C1656016 5 7C1858(1859C18600186101662C186301664016650186601667C1868C1869C18700187101672C167301874C16750187601677C1878C1879C1880C1881C1882C188301684C188501886C1687C188801689C189001691C189201893C1694C18950169601697C1898(1899(1900C1901C1902019030190401905C1906019C70190801909C 1 9 1

/* PROGRAM EXECUTION STARTS HERE * * */

/» INITIALIZATION */

TCKEN=62CALL MCV/ T

*/OUTPLUc

/*

00 WHILEIF SCC;

; /* PRIMS THE SCANNER WITH -PROCECURE- */E(PASS11T0P-PASS1SLEN, .OUTPUT SFCB .PASS 1 JLbNI ;

HIS SETSOUTFUT FILE CCNTRCL BLOCKTOGGLESREAC PCINTERNEXl SYMBOL TABLE POINTER

ND= (CUT PLTSPT R: = . CUT PUT $euFF-l 1 + 128;

»**»* PARSER * * * *

CCNFILING;TATE <=• KAXRNG THEN

*/

/* READ STATE */

/* SAVE CURRENT STATE */CALL INCSP;STATESTACKI SP) = STATE;CALL LCCKA»-EAD;I = GETIM;J = I GETIN2 - l;DO 1=1 TC J;

IF READK I) = TOKEN THENDC;/» COPY THE ACCUMULATOR IF IT IS AN INPUTSTRING. IF IT IS A RESERVED wORC IT DOESNOT NEEO TC BE CCIEO. */

IF (TOKEN= INPUTSSTRJ OR ( TOK EN=L I T £ R AL ) THENDO K=0 TC accum;

VARC (K) =ACCUM(K) ;

END;state=read2< i 1

;

nol0ck=true

;

i = j;END;ELSEIF I=J THENCC;

CALL PRINTSERRCR t • NP • )

;

CALL PRINT!. • E&^OR NEAR $');CALL PRINTSACCUM;IF (STATE:=RECOVER)=0 THEN CCMP I LI NG = F ALSE

;

END;ENC;

/* ENC OF READ STATE */ENC;ELSEIF STATE>MAXFNO THENCC;

/* APPLY PRODUCTION STATE */

MP = SP - GETIN2;MPP1=MP 1;CALL CCCESGEM STATE - MAXPNO);SP = MP ;

I=GETIM ;

J=STATESTACK(SP);00 WHILE (K: =APPLY1 < I I I <> AND JOK;

1=1 « 1

;

ENC;IF <K:=APPLY2( I I 1=0 THEN CCMPI L I NG=F ALSE

;

STATE=K;END;ELSEIF STATE<=MAXLNO THENCC;I=OE

/*LCPKAHEAC STATE*/

STATENC;EL <ECC;

END;END; /*CALL EYTDC WHILE

CALLENC;CALL CLCCALL CRLCALL FRIGO TC ecEOF

TIM;CALL LCCKAHEAD;DO WHILE (K: = L0CK1(I I )<>0 AND TOKEN OK;

1=1+1;ENC;

E=LCCK2(I);

/PUSH STATES*/CALL INCSP;STMESTACK<SP)=GETIN2;STATE^GETINl ;

OF WHILE COMPILING */E1CLT (TER I ;

CLTFUTJPTRO. OUTPUTS BUFF;BYTEiCLT(TER) ;

SE;F ;

NT( . 'ENC CF PART 2OT;

$• );

146

Page 301: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 302: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0000200C030OC04C0CO5C0006OOC070OCC8C0C09C0C1000011C0C12C0C1300014C0C15C0C16C0C17C0C18C0C19C0C2CC0C21C0C2200C230OC24C0C25CCC26C0C2700C28C0C29C00300003100C32C0C33C0C3A00C35C0C3£0OC37C00380OC39COCAOC0C41000420OC43C0C440OC45C0C4600CA7CCC48C0C49CCC5000C51CCC52C0C530OC540OC5500C5600C57C0C58CCC550CC60C0C61C0C620OCt30OC640CC65C0C66C0C67C0C68C0C69C0C700CC71COC720CC7300C74CCC75C0C76C0C77CCC78C0C79CCC80CCC810CC82CCC830CC8ACCC05CCC860CC87cocsaC0C89CCC9C0C091CCC92CCC930CC940CC95CCC96C0C97CCC98CCC99C0100C0101CC102C0103C0104C0105COlOf00107C0108C0109C0110

/*

10CH:

/*

CECLARE

LITBOGSBCCTCSLFTRUEFALSEFOFEVER

CC80L INTERPRETER */

/* LCJAC FCINT »/

GLC8AI CECLARATICNS ANO LITERALS */

LITERALLYLITLITLITLITLITLITLIT

'LITERALLY' ,

'5H'•0',•13','10',»l'f•0',WHILE

/* ENTRY TO OPERATING SYSTEM */

TRUE'

;

/» UTILITY VARIABLES */

CECLAPE

INCcXASCTRCTRBASE8SBYTEBtACCRHCLDHJBYTEH t A C C R

eYTE,ACCRESS ,

EYTE,ACCRESS,EASEC BASEEASFC BASEACCRESS,EASED HOLDEASED HCLC

BYTE,ADDRESS,

BYTE,AODRESS,

/* CCDE POINTERS */

COOEtSTARTPPCCRACSCCUNTEPCJPYTECSAOCR

/**»**

'2000H'LIT* p p o c c c

BASED PRCGPAMtCCUNTERBASED PROGRAMIC'JUNTER

BYTE,ACCRESS;

GLOBAL INPUT AND OUTPUT ROUTINES *****/

CECLAPECUFRENTfFCB ACCRESS,STAPTJCFFSET LIT '36'

PCM : PRCCECLRE (F,A) ;

CECLARE F EYTE, A ACCRESS;gc tc eccs;

END fCNl ;

MCN2: FROCtClRE (F.A)BYTE;CECLARE F OYTfc, A ACCRESS;GC TC ECCS;

END f'CN2;

PRINTJCHAR: PRCCECLRE ICFAR);CECLARE CFAF BYTE;CALL MCN1 ( l ,CFAR ) ;

END PRINTJCHAR;

CRLF: PRCCECLRE;CALL PR INT KFAP. ICR) ;

CALL PPINTKFAR(LF);ENC CRLF;

PRINT: PROCECURE (A);CECLARE A ACCRESS;CALL CRLF;C3LL MCMIS.A);

END PRINT;

REAC: PRCCECLRE <M ;

CECLARE I ACCFESS;CALL MCN 1 ( 1C,A) ;

END READ;

PRINTJERRCP: PRCCcCURE (CCDE);CECLARE CCCE ADDRESS;CALL CRLF;CALL FO INT JCFARIHIGH(CODE) ) ;

CALL PR INT!CFAR(LLWlCODE) ) ;

END PR INTtERROR ;

FATAL1ERR0R : PF CCEDUR E t CCDE ) ;

CECLARE CCCE AODRESS;CALL PR INTSCPRCR1C0CE) ;

CALL TIVEdC);/» DEBUGCC TC BCCT;DEBUG */

ENC FATAL$ERPOR ;

OPEN: PRCCECLRE <ALCR) BYTE;DECLARE ACCR ADCRESS;RETURN KN2 ( 15, AOCR J ;

ENC CFEN;

CLCSE: PRCCECLRE (ACDR);CECLARF ACCR ADCRESS:IF M0N2 I 16 ,ACCK)OC THEN CALL F AT AL tE PROR ( ' CL ' I

ENC CLCSE;

147

Page 303: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 304: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

UOlll 1

00112 1 DELETE: PROCEDURE;C0U3 2 CALL MCM(lS,CURR£NT$fCB> ;

001 1-4 2 ENC CELETE?00115 100116 100117 1 MAKE: PROCECIRE (AOCP)?00118 2 CECLARE ACCR ADDRESS;C0119 2 IF K0N2 (22, ADCR)O0 THEN CALL F ATAL tERROR ( « I" E « ) ;

CC120 2 ENC MAKE;00121 1C0122 100123 1 SETtCN/: FRCCECLRE;C0124 2 CALL MCM(26,CURRENT$FCS + START SOFFSET I

;

C0125 2 ENC SETSCMA;C0126 1

00127 1

C0128 1 CISK1REAC: FPCCECURE eYTE;CC129 2 RETURN ,"-CN2 (20 , CUPR ENT SFCB ) ;

C0130 2 END CISKSREAC;00131 1

00132 1

C0133 1 OISKtWRITE: FPCCECURE BYTE;00134 2 RETURN MCN2 (2 1

,

CURRENT tFCB )

;

00135 2 ENC ClSKSfcRITE ;

C0136 1

00137 I

00138 1 /**$»**»»** UTILITY PROCEDURES ***********«**/C0139 1

CC14C I

00141 1 CECLARE0C142 1 SLESCRIPT (8) ADDRESS;C0143 1

00144 1

00145 I PES: PRCC ECLP E

(

t CCR ) ACCPFSS:00146 2 /=> THIS FPCCECURE RESOLVES THE ACCRESS OF A SUBSCRIPTED00147 2 ICENTIF1EP CP A LITERAL CONSTANT */C0148 2C0149 2 CECLARE ACCR ADDRESS;C0150 2 IF ACDR > 32 THEN RETURN ADDR;00151 2 IF AOCR < 9 THEN RETURN SU BSC R 1 PT ( ADDR ) ;

00152 2 DC CASE ACCR -9;C0153 2 RETL'f-N .'O';00154 3 SETLRN .' ';C0155 3 PETLPN .'

;

00156 3 ENC;C0157 2 RETURN C;C0158 2 ENC RES;C0159 1

CC160 I

00161 1 MOVE: PRGCEDLRE(FPCM, DESTINATION, COUNT)?00162 2 CECLARE ( F P C M , CES T I N AT I CfJ . COUNT ) ACCRESS,00163 2 IF eASEC FRCf, D BASED DEST1NATICN) bYTE;00164 2 DC WHILE (

C

CLNT : =CCUNT - 1) <> OFFFFH?C0165 2 0=F;00166 3 FRCf^FFCM + 1 ;

00167 3 DESTINATION=GESTINATICN + I;C0163 3 END;CC169 2 END CCVE;CO 170 1

00171 1

00172 1 FILL: PROCECLRE (CEST I NAT ION, CO JNT

,

CHAP >

;

00173 2 CECLARE (CE ST INAT I ON .COUNT ) ACCRESS,00174 200175 2 (CHAR,C EASEC DESTINATION) BYT^?00176 2 DC WhILE <CCLNT:=CCUNT - DO OFFFFH?00177 2 C = Ct-AP;C0178 3 DEST 1 NAT IC N = CEST I NAT I ON + 1;C0179 3 ENC;CC180 2 ENC FILL;00181 1

C C 1 8 2 1

00183 1 CCNVEPTSTOSHEX: PROCEDURE ( POI NT ER , CCUNT ) ADDRESS;00184 2 CECLARE fCINTE?. ACORESS, CCUNT BYTE?CC185 2 A1CTR=0;C0ie6 2 EASE=PCINTEP;00107 2 CC CTR = TC CCUNT;C0188 2 A$CTR = SI-L(A$CTR,3) + SHL<A$CTR,1) + BJEYTE(CTR) - '0';C0189 3 ENC;CC190 2 RETURN A1CTR;CC191 2 ENC CCNVERT IK JHEX;0C192 1

CC193 1

0C194 1 /»»*****» CODE CCNTRCL PROCEDURES *«***»»**/CC195 1

CC196 1 CECLARE00197 1

C0198 1 ERANCH1FLAG BYTE 1 N I T I AL ( TRUE ) i

CC199 1

C0200 1 INCtFTR: PROCECLRE (CCUNT);00201 2 CECLARE CCUNT BYTE;00202 2 PRCCRAM JCClNTER=PROGRAM$COUNTER + COUNT;00203 2 END INCSPTP;C0204 IC0205 1CC206 1 GETSCFKCCE: PPCCECJPE BYTE;C0207 2 CTR=C$EYTE;CO 20 8 2 CALL INC1PTRU);C0209 2 RETURN CTR;CO^IO 2 END CET1CP1CCCE;00211 1

148

Page 305: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 306: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00212 1

00213 I

00214 200215 200216 200217 2C0218 2C0219 3C0220 300221 200222 2C0223 1

00224 I

00225 1

00226 200227 200228 2C0229 2C0230 1

00231 1

00232 1

00233 I

00234 1

C0235 1

00236 1

00237 2C0238 2C023S 2C0240 2C0241 300242 300243 200244 2C0245 100246 1C0247 1

C0248 2C0249 2C0250 2C0251 2

C0252 100252 I00254 1

00255 200256 200257 2C0258 1C0259 1

C0260 1

00261 200262 200263 200264 1

00265 1

00266 1C0267 200268 2C0269 2C0270 1

C0271 100272 100273 200274 200275 ?00276 a

00277 a

C0278 4C0279 4C0280 30C261 20C282 200263 10C284 1

00285 100286 20C267 200288 2CC289 3CC290 300291 30C292 4CC293 40C294 3CC2S5 20C296 20C297 1

CC298 I

CC299 1

£0300 200301 200202 200303 3C0304 300305 400306 4CO 307 3C03C3 2C03C9 2COZ-10 100311 1

CONDITIONAL 1ERANCH: P ROC HOUR E< CCUNT ) ;

/* THIS FPCCECURE CONTROLS BRANCHING INSTRUCTIONS */CECLARE CCUNT eYTE;IE NCT ePANCKJFLAG THENCC ;

BRANCH$FLAG=TRUE;PRGGRAf$CGUNTER=C$ADOR (CCUNT) ;

ENC;ELSE CALL INCJPTR (SHL(CCUNT, lJ + 2) ;

ENC CCN0ITICNAL1ERANCI-;

INCPEMENT<CR1ER/NCH: PRGCEOURE ( MARK )

;

DECLARE MARK eYTE;IE MARK 1FEN CALL INC$PTR(2);ELSE PRCGRAMJCOUNTER=C$ADOR;

ENC INCREMEMSCFIEPANCH;

/4*«44***4* *CCMPARIS0NS »***»*********/

CHARtCCMPARE : PRCCECURE BYTE;eASE=C$JCCR;HCLC=CSACCR ( 1 ) ;

DC A$CTR=l TC CSACDR(2) - 1;IF eiGYTE(AiCTR) > HS 8 YTE < AJCTP. ) THEN RETURN 0;IF e*eYTE<A$CTR) < H$6YT£(A$CT!<) THEN RETURN 1;

ENC;RETURN 2;

ENC CFAR$CC*FAFE ;

STPING5CCMPAPE: FRCC ECURE( PI VOT )

;

CECLAPE FIVCT BYTE;IF CHARSCCMFAREOPI VOT THEN BR 4NC h$FL AG=NC T ERANCHIFLAG:CALL CCNGM I C NAL t ER ANCH (3 i ;

END STRING$CCMPARE ;

NUMERIC: PFCCECLRE(CHAR) BYTE;CECLARE CFAP BYTE?RETURN (CHAR >='0'1 AND (CHAR <='9');

ENC NLMERIC;

LETTER: PROCECUPE (CH A R ) BYTE;CECLARE CHAR EYTE;RETURN (CHAR > = 'A') AND (CHAR < = «Z , 1;

END LETTER;

SIGN: FROCFCLRE (Cl-AR) BYTE;DECLARE CHAR eYTE;RETUPN <ChAR=<+') CR (CHAR=«-');

END SIGN;

CCMP$NLM$UNSIC-NEC: PRCCECURE;8ASE=C$ACDR ;

CC A$CTR=0 TC C$ACCR(2)-l;IF NCT NUMERIC(BiBYfc(A$CTR) ) THENDC",

ERANCH$FLAG=NOT BRANCHSFLAG;RETLRN;

ENC;ENC;CALL CCNCIT ICNAL$BRANCH(2 )

;

ENC CCMPSNUM1LNS IGNED ;

CCMPJNUMJSIGN: FBCCEDURc;eASE=CSACCR;CC AJCTP=0 TC C$ADCR(2)-l:

IF NCT (NLMERIC(CTR:=3$9YTE(A$CTR )

)

CR SIGN(CTRJ) THEN00;

ERANCH$FLAG=NCT BRANCH$FLAG;RETURN;

ENC;ENC;CALL CCfvCI T ICNALSBRANCHI2) ;

ENC CCMPSNUM JSIGN ;

CCMPSALPH* : PRCCECURE;9ASE=C$ACCR;CC AiCTR=0 TC C$A00R(2)-l;

IF NOT LETTER(BiBYTElAJCTR) ) THENDC;

ERANCH$FLAG=NOT 9RANCHSFLAG;RETURN;

ENC;ENC;CALL CCNCIT ICNAL$ePANCH(2) ;

ENC CCMFtALPFA ;

149

Page 307: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 308: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

0021200313C0214003150031600317C021800219C0320C0321002220022300324C02250O2260C327C0328C0329C033000331C02320033300334C02350033600337C0338C0239CC340C0341C0242C0242C03440034500346C0347C0348C0349C035C00251C02520025300354CC3550035600357C0358C0259C0360002610026200363C0364003650036600267C0268C0269C03700037100272C0373C0274002750037600377C0278C0379C02800C381C038200383002P40C2850038600387CC288CC389CC390C039100392C03930C294CC295

/* * 4 ***** * *NUMER!C OPERATIONS **********/CECLARE

(ROR1.R2) (10)<SIGNC,SIGN1,S ICN2)<CEC$Pio,DECJPTl,DEC$PT21CVERFLCh BYTE,PSFTR BYTE,SWITCH BYTE,SIGNIFJNO BYTE,ZEPOJFESULT BYTE,ZONE LITPOSITIVE LITNEC I TI V£ LIT

BYTE, /* REGISTERS */BYTE,BYTE,

10H'l'l0' ;

CHECK JFCRSSICN : PFCCE CUR E ( CHAR ) BYTESCECLARE Ct-AF BYTE;IF NLMERIC (CHAR) THEN RETURN POSITIVE;IF NLMER !C (CHAP - ZONE) THEN RETURN NEGIT1VE;CALL PR INT«EPPCR( ' SI ' ) ;

RETURN FCSITIVE;END CHECKSFCFiSIGN;

STCPE! IMMEDIATE : PROCEDURE;CC CTR=C TC 9;

R0(CTR)=F2(CTR) ;

END;CECiPTO = CEC 3FT2;SJGN0=£IGN2

;

ENC STCRESINf-EC IATE;

GNESLEFT: PPCCECLRE;CECLiRE FLAG PYTE;IF ( (FLAC:=SFP(eseYTE,4) )=0I OR (FLAG=9) THENDC ;

OC CTF = C TC! 8;8$EYTE( CTR ) = SHL(B$BYTE(CTR ) ,4) OR SHR ( B $8 YT E ( CTR + 11,4);

ENC;B$EUE (9)=SHL(B$3YTE(9) ,4) Ofi FLAG;

ENC;ELSE CVEFFLCW=TRUE;

END CNEiLSFT;

CN'EJRIGHT: FFCCECURE;CTR=10;CC INCEX=1 TC 9:

CTR=CTP-l;B$3YTE(C7R)=SHR(B$BYTE(CTR) ,4) OR SHL (BJ6YTE ( CTR-1 ) , 4 )

;

ENC;e JBYTS=SFP (EJEYTE ,4) ;

ENC fNESRIGHI;

SHIFT1RIGHT: P FCC EOURE ( COUNT )

;

CECLARE CCLNT BYTE;CC CTR=l TC CCLNT:

CALL CNESRIGHT;ENO;

ENC SFIFTIRIGHT;

SFIFTUEFT: FPCCECLRE (CCUNT);CECLARE COLNi BYTE;CVERFLCh=FALSE;CC CTR=1 TC CCUNT ;

CALL cnesleft;IF CVEPFLCr, THEN RETURN;

END!ENC SFlFTiLEfT;

ALLIGN: PROCEOURE;eASE=.RC;IF DECSPfO > C£C$PT1 THEN CALL SH I FT J P IGHT

(

CECtPTO-CE C $PT 1 ) ;

ELSE CALL SHFT$LEFT(DECtPTl-CEC$PTOI ;

ENC ALLIGN;

150

Page 309: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 310: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00296 10C397 1 AOC$RC: PROCE CLPE < SECCNC , OEST):C0298 2 CECLARE (SECCNC, CEST] ADDRESS, (CY,A,B,I) BYTE;CC399 2 HCLD = SECCNC;C0400 2 EASE = CESI;00401 2 0=0;00402 2 CTR=9;00403 2 CC IN0EX=1 TC 10;00404 2 A=«C(CTP1;C0405 3 e=H18YTE(CTR J;C0406 3 I=CEC(A<CY);00407 3 CY=CAPFY;C04C8 3 I = CEC (1 + Bl ;

C0409 3 CY=(CY CR CARRY» AND 1;C0410 3 8J8YTE <CTR)=I ;

C041

1

3 CTR=CTR-1;C0412 3 ENC;00413 2 IF CY THEN00414 2 CC ;

00415 2 CTR=9;00416 3 00 INDEX = 1 70 10;C0417 3 I=P2(C7R);C0118 4 I =CE C( I+CY);C0419 4 CY=CARRY AND 1;C0420 4 P2(C7R)=l;00421 4 CIMCYR-l;C0422 4 ENC;00423 2 ENC;00424 2 ENC ACCSRO;C0425 1

C0426 1 .00427 1 CCf-PLIfCNT: FFCCECUR E ( NUf 3 )

;

C0428 2 CECLARE NUMB BYTE;C0429 2 CC CASE NL'fE;CC430 2 HCIC=.PC;C0431 3 HOLC=.Fl;00432 3 HCLC=.R2;C0433 3 ENC;00434 2 IF SIGNJC(MPP) THEN SIGNO(NUMB) = NEGITIVE;00435 2 ELSE S I C-NJC < NLMB ) = POSITIVE;C0436 2 CC CTR=C TC 9;00'.37 2 HIBYTE(CTR)=99H - HSBYTEICTR);C0436 3 ENC;C0439 2 ENC CCVPLIMENT;CC440 1

00441 100442 1 CHECKSRESLLT : PPCCEOURE;00442 2 IF SF C'.(S2,4 )=9 THEN CALL COPPL I PENT ( 2 ) ;

00444 2 IF SHS(R2,4)O0 THEN GVERFL C «=TRUS ;

00445 2 ENC CHECKJPESLLT ;

C0446 1

00447 1

CC446 1 CHECK1SIGN: FPCCECURE;00449 2 IF SIGNO ANC SIGN1 THENC0450 2 CC;00451 2 SIGN2=FCS1TI VE

;

00452 3 SETLPN;00453 3 ENC;00454 2 SIGN2=NECIT IVE;00455 2 IF NCT SICNC AND NOT SIGN1 THEN RETURN;00456 2 IF SIGNO THEN CALL CC VPL

I

MENT ( I )

;

00457 2 ELSE CALL CC (-PL I MENT (C J ;

C0458 2 ENC CHECKSSIGN;CC459 1

C046C 1

00461 1 LEACINGSZERCES: FRCCEDURE <ADDR) BYTE;00462 2 CECLARE CCLM BYTE, ADCR ADDRESS;00463 2 CCLNT=0;00464 2 EASE=ACCP;00465 2 CC CTS=C TC 9;C0466 2 IF (BieYTE(CTP) AND OFOH) <> THEN RETURN COUNT;00467 3 CCLM=CCUNT 1;C0468 3 IF (CJEYTEICTR) AND OFH) <> THEN RETURN COUNT;C0469 3 CCLNT=CCLNT + 1;C0470 3 ENO;00471 2 RETURN CCLNT;00472 2 ENC LE AD IMG $ I ER C E S

;

C0473 1

00474 1

C0475 1 CHECKJCECIf Al : FPCCECURE;C0476 2 IF DEC$P 12 <>

(

CTR : =CS 8 YT E ( 3 I ) THENC0477 2 CC ;

C0476 2 6ASE=.P2;C0479 3 IF CECSFT2 > CTR THEN CALL SH I FT !R

I

GHT ( CEC $P T 2-C TR ) ;

C0480 3 ELSE CALL SH I F T$L EFT ( CTR-OEC JPT2 )

;

00481 3 END;004e2 2 IF LEADINCJ2EROES(.R2) < 19 - C$BYTE<2) THEN OVERFLCW = TRUE;0C483 2 ENC CF ECK$C EC 1 PA L ;

C0484 1

C0485 1

CC486 1 ACC: FPCCECURE;GC.87 2 GVERFLCW = FALSE;CC488 2 CALL ALLIGN ;

C0489 2 CALL CHECK i S IC-N;CC490 2 CALL AOC KC ( . P 1 , . R 2 )

;

00491 2 CALL CHECKJRESULT ;

0C492 2 ENC ACC;CC493 1

0C494 1

00495 1 ACDISEPIES: FF CC E CURE ( CCUNT J ;

CC496 2 CECLAPE (I, CCLNT) BYTE;CC497 2 CC 1=1 TC CCLNT;00496 2 CALL A CC SRO( . P2 , . R2 ) ;

CC499 3 ENC;C0500 2 ENC ACCSSERIES;

151

Page 311: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 312: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00 = 02CC50300504C0505005060050700508C0509C05100051100512C0513005140051500516005170C518C0519C052000521C05220052300524C0525C052600527C0528C0529C0530C0531005320053300534C0535005360053700538C0539C054C00541C05420054300544C0545005460054700548C0549C055000551005520055300554005550055600557C0558C0559C056000561C05620056300564C05650056600567C0568(0569C05700057100572C057300574C0575005760057700578C0579C05800058100582CC5830C58400585005860058700588£0589CC590005910C5920C5930C594C05950C5960C5970C598CC599C060000£0l_C0602

SETSMLLTSCIV: FRCCECURE;CVERFLCI* = FAISE;IF (SIGNC ANC SIGM) OR

INC1 SICNO ANC NOT SIGM) THEN S I GN2= PCSIT I VE

;

ELSE SICN2=NEGITI VE;CALL FILL< .R2,10,0) ;

ENC SETSfULUCIV;

R1SGPEATER: FRCCECURE eYTE;CECLARE 1 eYTE;CC CTR = C TC 9;

IF Fl (CTR)X I :=99H-R0(CTR) ) THEN RETURN TRUE;IF RKCTRXI THEN RETURN FALSE;

ENC;RETURN TRUE;

END RUGREA7ER;

MULTIPLY: PRCC ECLFE ( VALUE )

5

CFCLARE VALUE BYTE;IF VALL'cOO THEN CALL ADDS S E P IE S < VALUE ) *,

eA SE = .RC;CALL CNE1LEFT;

ENO NLLTIPLY;

CIVICE: FROCECLPE;CECLARE II ,J,K,LZ0,L21) 3YTE;CALL SETifLLl JCIV;IF(L 20 :=LEACiNGS2ERCES<eASE:=.R0))<>

<L2l:=LEACINC$2ERCfc$l .Rl> I THENCC;

IF L20L21 THENCO;

CALL SHIFTILEFTJ I :=L20-L21)

;

CEC$PT0=OEC$PTO + I;ENC;ELSE CC;

CALL SHIFTJRIGHTf I:=L21-L20);CFC$PT0=CECPT0 -I

;

ENC;ENC;CECPT2= 20 - L21 CECPTO - CECPT1;CALL CCI'FLIfEM(O) ;

00 1=L21 TC IS;J = C;OC fcHILE R1SGREATER;

CALL AOCSROl -Rl, .Rl)

;

J=J+l;ENC;K=SFR( 1,1);IF I THEN R2(K)=R2(K) CRELSE P2(K)=R2(K) CR SHL(J,4);

ENC!ENC CIWDE;

LCAPS/SCHAR : PRCCECURE(CHAR) ;

CECLARE CHAR PYTF ;

IF (SWITCH :=NCT SWITCH) THENBSEYTf (RtPTR )=BI6YTt ( °.$PTR) OR SFL(CHAR

ELSE 3$3*7E(R$PTR:=R$PTR-1)=CHAR - 30H;ENO LCACSAJCHAR;

LOACSNLMBERS: PFCCEOUR E ( ADDR ,CNT ) ;

CECLARE ACCP ADCRESS. (I,CNT)3YTE;HCLC=RES(ACCR);CTR=CNT;CO INCEX = 1 TO CNT;

CTR=CTR-l;CALL LCA0$A$CHAR(H$BYTE1CTR) )

;

END;CALL INCSPTR(5);

ENC lcacjnuveers ;

SETSLCAD: PRCCETLPE (S1GNSIN);CECLARE S1GMIN BYTE;CC CASE (CIR:=C$BYTE(4) );

eASE=.RC;BASE-. Pi!eASE=.R2;

ENO;CECSPTOKTR )=C$BYTE(3)

;

SIGN0(C7R )=S1GNSIN;CALL FILL (EASE, 10,0) ;

R$PTR = 9 ;

SWITCH=FACSE;ENO SEIJLCAC;

LOACtNUMERI C : FPCCEOURE;CALL SET1LCACI 1 ) ;

CALL L0AC$NtfBEPS(C$ADDR,C»BYTE(2));ENC LCADSNUf ERIC;

30H.4)

152

Page 313: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 314: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00603CC60400605cotoeC060700608C0609C0610C0611006120061300614C061500616C061700618C0619(0620006210062200623C0624C062500626C0627C0628C0629C06300063100632C063300634(063500636C0637C063800639C0640C0641G064200643C064400645(0646C0647C064800649(06500065100652C0653C06540C6550C656C0657C0658C0659(0660006610O662006630066400665C0666C06670066800669(067C0C6710067200673C0674C0675(0676006770067800679(C68C006810C6820C663C0684C068500686(C687CC688C0689(C690C06910C6920C693(0694(C695CC69600697C0698C0699(07000070100702(070300704C0705C0706(0707(0708C07C9C0710.00711

L0A0SNUI«$LIT: FPCCECUPE:CECLARE(LITSSUE,FLAG) BYTE;

OARSS1CN: PROCEDURE;imSIZE = LlT$SIZE - i;HCLC =KLD l;

ENO CHARSS ICN;

LITSSI ZE = C JEVTE ( 2 ) ;

HCLC=Csaccp ;

if h$by7e='-« thenCC;

CALL CFARSSICN;CALL SETSLCAC(NEGITIVE) ;

ENC;ELSE DC;

IF MBYTE*'* 1 THEN CALL CHAR$SIGN;CALL SETSLOAD(PCSITIVE) ;

ENC:FLAG=0;CTR=LIT JSIZE;DC INDEX=1 TC LITJSIZE;

C1BsCip-l;IF MBYTEtCTR ) = '. • THEN F LAG=L I T SS I Z E - (CTR*1)ELSE CALL LO ACS ASCHAR { h$BY TE (CTR ) )

;

ENC;CECSPTC((SBYTE(4) >= FLAG;CALL INC J F T P (5 )

;

ENC LCACSNLfSL IT;

STCF.EJCNE: FPCCECURE;IF (SViITCF : = NCT SwITCH) THEN

3S3YTE=SFR(HieYTE,4) OR '3';ELSE CC;

HQLC =KLC-1;esEYTE=<F$BYTE AND OFHJ CR '0';

ENC:EA SE=3ASE-1 ;

ENC STCRESCNE;

STCRE JASJCHAP: FPCCECURE (CCUNT ) ;

CECLARE CCLNT BYTE;S V* I 1CH = r/!LSc ;

HrLD=.R2 + 9;CC CTR=1 TC CCUNT;

CALL STCRESCNE;ENC;

END STCR5SASSCMR;

SETSHNE: PPCCECLPE <AC~P>;CECLARE ACCR ADCRESSiIF NCT SIGN2 THENCG;

BASE=ACCR;BSBYTc=8S6YTE CR ZONE;

ENC;CALL INC IP TP (4);

ENC SETSZONE;

SEISSIGNSSEP: PPCCEDURE (ADDR);CECLARE ACCR ACCRE5S;eASE=ACCP:IF SICN2 Tt-EN BSBYTE^* 1

;

ELSE BSBYTE-'-';CALL INCJPTP (4)

;

ENC SETtSIGMSEF ;

STCPESNUMEF IC : FRCCECURE;CALL CHECKSCECI KAL;e«SE = CJACi:R CSBYTE(2> -I!CALL STCFESiS JCHAR (CSbYTEI 2)) ;

ENC STCRE JNLyEP. IC;

/**«**««** INPUT-OUTPUT ACTIONS *******«»»**/CECLAPE

FLAG!EXTENRFCSNPTPSCBUFFSVflPSETERM1ENCSCINVALRANCCCLFRf.FCBSBFee SABLFFSPLFF1P.UFFSBUFFSccNseCCNSbCCN1 I

CFFSETTSGFFSETCFFSETLENGTHNCNATGRFSRECCRCICNSFILENTSFLAGYTEf CRFTkENOTASTBYTEUFFYTENPUT

LITLI T

LITLITLI T

LI'TLIT6YTEBYTEBYTEBYTEBASf1

.

BASEADCPAODRACCRBASEADCPBASEADCR

'33',1 12* ,

'32' ,

17«,'128V'CR'

•1AH'

,

C Cc cESSCSSESS

BCSS

cESS

UPPENTSFCBURRENTSFC3

BYTF,ADCRESS,

UFFSPTR BYTE,INITIAL (OOH),

CNSBUFF BYTE,INITIAL (82H);

153

Page 315: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 316: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

UO lid 1

C0713 I

C0714 2C0715 2C0716 2OC717 2C0718 2C0719 2CO720 200721 200722 1

C0723 1

00724 1

00725 2C0726 200727 2C0728 2C0729 3C0730 2C0731 2C0732 1

00733 1

CC734 1

C0735 2C0736 2C0737 2CC738 2C0739 1

C0740 1

0C741 100742 200743 200744 2

C0745 1C0746 1

0C747 I00748 2C0749 2C0750 200751 2C0752 200753 200754 2C0755 2C0756 2C0757 2C07 56 2C0759 2C0760 1

0C761 I

00762 100763 200764 200765 2C0766 200767 2C0768 2C0769 3C0770 400771 4C0772 3C0773 300774 3C0775 4C0776 400777 4C0778 3

CC779 3

C0780 300781 40C782 4CC783 3C0784 2C0765 2

00786 200787 2C0788 1

C0789 1

CC79C I

0C79L 20C792 2CC793 10C794 1

0C795 1

CC796 2

0C797 2C0798 1

CC799 1

CC80C 1coeoi 200802 2C0803 2C0E04 200805 200(06 200607 1

C0808 1

C0E09 1

C0810 2C0811 2OOf 12 200813 200814 2C0815 2C0816 1

ACCEPT: PRCCECLRE;CALL CRLF;CALL PR INTSCHAR(3FH) ;

CALL CPLF;CALL FI LL<CCMlNPUT,(CONSBYTE:=C$BYTE (2) ) , • 'J;CALL REAC (CCNSBUFF) ;

CALL HCVE(CCNiINPLT,RES<C$AOCRJ,CON$BYTE);CALL INCIPTPU);

ENC ACCEPT;

OISPLAY: ppcceclpe;EASE=C*ACCR ;

CALL CPLF;CC CTR = TC C$8YTE(2) - 1;

CALL FFINTSCHAR(B$BYTE (CTRJ )

;

END;CALL INCJPTP(3>;

ENC CISPLAY;

SETJFILESTYFE : F PCCEOURE (TYPE) ;

CECLARE TYPE eYTE ;

eA SE=CJACCR ;

e$eYTE(FLAG$CFFSETJ=TYPE;ENO SETSFILEITVFE;

GET JFILE1TYFE : FPCCEDURE BYTE;eASE=CSACCR ;

RETURN eiSYTE (

F

LAGSCFF SET )

;

END C-ET$F1LE$TYFE;

SETlliC: PRCCECLRE;END$CFJFECCSC,INVALID=FALSE ;

IF C£ACCF=CLPRENT$FCE TFEN RETURN;/* STORE CURRENT PCINTERS ANO SET INTERNAL hRITE MARK */BASE=CURPEMSFC3;FCSSADCR(PTPSCFFSET)=BUFFSPTR;FCeiBYTc(FLAGSOFFSETI=CURRENT$FLAG;/* LCAC NEk VALUES */eLFFlcNC=<BLFFiSTART:=(CURRENTiFCb:=C$ADCR)+STARTSCFFSET)

BLFFILENGTh;CURRENT $FL*G=FCB*eYTE(FLAG*CFFSET);eCFF$3TR=FCeSACCRlPTRS0FFSET);

ENC SETS1JC;

CPEN1FILE: PRCCECUP.E ( TYPE ) ;

CECLARE TYPE BYTE:CALL SETJF I LEiTYPM TYPE) ;

CTR=0PEMCLRRENTSFCB:=CSA0DR)5DC CASE 1YFE-1;

/* INFLT </CO:

IF CTR = 255 THEN CALL PR INT % ERROR (' NF )

;

FCejAODR(PTR$OFFSET)=CURRENTfFCG+100H;ENC;/* CLTFLT */CO;

CALL CELETE;CALL ^AKE (CtAOOR) ;

FCB$ADCR(PTRSOFFSET)=CURR£NTJFCe+STARTtOFFSET-lENC;/* I-C */DC;

IF CTR=255 THEN CALL F ATAL $ ERROR (' NF •)

;

FCE JADDK(PTRSGFFSET ) =C URR ENT $FC8 + 100H;ENC;

END;CLRRENT$FCB=C; /* FORCE A PARAMETER LOAD »/CALL SET1I JC ;

CALL INCJPTR(2);ENC CPENSFILE;

V.RITESMARK: FRCCECURE eYTE;RETURN RCL (CURRENTJFLAG, 1 )

;

ENC V.RITESPAFK;

SETShR ITEfMAPK: FRCCEDURE;CURRENT JFLAG=CUFRENT$FLAG OR 80H;

ENC SETthRITESPARK;

V.RITEJFECORC: FRCCEDURE;IF NOT SS-F t CLRRENTSFLAG, 1 ) THEN CALL F AT AL i ERROR( ' W I • ) ;

CALL SET1CNA;CLRRENT$FLAF=CURRENT$FLAG AND JFH;IF (CTR :=UI

<

KJWRITE ) =0 THEN RETURN;1NVAUIC=TRUE ;

ENC WP ITESPECCPC;

REAOSRECORC: FRCCECURE;CALL SE TICCA;IF WRITESCAFK THEM CALL W? I TE SR EC CRD

;

IF (CTR :=D ISKtREAD) =0 THEN RETURN;IF CTR=1 TI-EN ENO$OF$RECORD = TRUE;ELSE INVAL IC=TRUE ;

ENO READJRECCRC;

154

Page 317: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 318: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

30617 1

00818 1 READ*C0819 2 IF ( eUFF!PTR:=BUFF$PTR + 1) >= BUFFENC THENC0820 2 CC;00621 2 CALL PEAOSRECCRD;00822 3 IF ENCJCFSPECORC THEN RETURN TERMINATOR;00823 3 BUFF$PTR=6UFF$ START;00624 3 ENC;coe25 2 RETURN ELFFIEYTE;00626 2 END READ$8YU;00627 1

C0628 1

00829 1 WRITEC0830 2 CECLARE CHAR BYTE

;

00631 2 IF (BUFFJP7R :=BUFFIPTR+1) >= BUFFtENO THEN00632 2 CO;C0833 2 CALL WPITEtPECORO;00634 3 buff$ptr=buff$start;C0635 3 END;00636 2 CALL SETSWRITESMARK;301=37 2 ELFF$8Y1E=CFAP;C0638 2 ENC WR ITESSY1E;(0839 1

(0640 1

0C841 1 hRITEC0842 2 CALL WP MESEYTE(CP) ;

00643 2 CALL WP 11E$EYTE(LF) ;

CO 84 4 2 END WR ITElENCJf AFK!C0645 1

C0646 100647 1 READ*u064B 2 IF READteYTEOCR THEN CALL PR I NT SERsOP ( • EM • ) ;

C0649 2 IF REAOiEYTEOLF THEN CALL PR I NTSEP.RG R ( ' EM • ) ;

CC650 2 END RE ACtENClMAFK ;

C0E51 1

C0652 1

CC653 I READSC0654 2 CALL SETIIK;C0655 2 B*SE=»CSACCR(1);00656 2 CC A$CTT< = TC C1A00R(2)-1 ;

00657 2 IF (CTR : = (BSBYTE< ASCTR) :=REAC$6YTE) ) = VARtENC THENC0658 3 DO;C0659 3 CTR*R6ACSBYT£;C0660 4 RETLRN;00661 4 ENC ;

CC662 3 IF CTP=TEPMINATOR THEN00E63 3 DC;C0E64 3 . ENCSCFiRECCRD=TRU£;00665 4 RETURN;C0666 4 ENC;00667 3 END;00668 2 CALL REAC JErCSMARK;(0669 2 ENO RE ACSVAR 1ABLE

;

C067C 100671 1

CC672 1 WRITEC0673 2 CECLARE CCLNT ACDPESS;CC674 2 CALL SfJIJC;00875 2 BASE=C$ACCR (1);00676 2 CCLNT=C JACCP(2) ;

00677 2 CC hHILE (fcJBYTE(CCUNT:=COUNT-l»<>« • ) AND (CCUNTOO);00878 2 ENC;C0679 2 CC A$CTR=0 TC CCUNT;CC88C 2 CALL WR ITEieYTE(3$9YTE(A$CTR») ;

00681 3 ENC;00682 2 CALL wP ITEJcNCSMARK ;

CC883 2 END WRITESVARI ABLE;00884 1

C0885 1

CC886 1 RcACJ0C687 2 CALL Sf T J I ic

;

C0668 2 BASE=C$ACCR (1)

;

006b9 2 OC A*CT3=0 TC C$AP0R(2)-l;CC890 2 IF (BtBYTEUiCTh) :=READSBYTE) = TERMINATCR THENCC891 3 DC;CC692 3 END$OF$RECCRD=TRUc ;

0C893 4 RETURN;0C694 4 ENC;CC695 3 ENC;0CS96 2 CALL REACJEf^ClMARK;0C697 2 END RFAD$T01MfcVCRY;00893 1

(C899 1

C0900 1 WRITE00901 2 CALL SETlliC:0CSO2 2 BASE=C$tCCfi(l) ;

0CS03 2 DC A$CTk=0 TC C$ADDR<2 J-l;C0S04 2 CALL WRITE JBYTE(BtBYTE(A$CTR> );0O9O5 3 ENC;CC906 2 CALL WP HE 1ENCSMAPK ;

00907 2 ENO WH ITESFPCMiPEMCRY;(-0908 1

155

Page 319: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 320: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

"C0909(0910COSHC0912CC913C0914C0915009160091700 "513CC919(0920C0921:o922C092300924C092500926009270C928C0929(093000931009220093300934CC925009360C937C0938C0939C094000941C09420C9430C944C0945CC94600947CC948CC949CC950CC9 51C095200953C09540095500956009570C958CC959CC9600C96100962CC963009O4CC96500S660C967CC96800969CC97C00971C0972CC9730CS7400975009760C977C097800979(C980CC961CC982CC983CC984C0985CC9860C9870C988C0989(C990CC9910C992CC9930C994CC995CC9960C997CC998CC999C1CO001CC101C02C1C0301C04C1C05C100601CC7C1C08C1CC9C1C1001C11C101201013J1C14C 1 1 5C1C1601C17

/*•»»**•»* RANDOM, 1-0 PROCEDURES **»****/SETSRANDCM$PCINTER: PROCEDURE:

THIS PRCCht-ICH RECTHAT RECCSET FOR I

*/CE

EDLRE READS THE RANOGM KEY ANO COMPUTESCRC NEECS TC BE AVAILABLE IN THE eLFFERRC IS MACE AVAiLABLE ANC THE POINTERSNPLT OR OUTPUT

CAevPFExIFCCIFCA

BUIFCCrC

CLARE (

EXTELL SET5TEiCCLNCCRC=SFTENT=SFEXTENT

'writesLL CLCS

FCE1IF CDC ;

ENC;D;FFSPTP:FCEiBY

EYTESCCUNT .RECORD) ADDRESS,NT BYTE;IK:T=(CiADDR<2)+2>*CCNVERT$TOiHEX(CJACCR<3) , CtBYTE<8) )

R

(

EYTEICCUNT, 7) ;

R (RECORD, 7) :

<>FCB$BYTEIEXTENTSCFFSET> THEN

NARK THEN CALL WR

I

TE$RcCCRD ;

E (CSAOOR ) ;

BYTE(EXTENTSOFFSET»=EXTENT;PEMCiAODRJOO THEN

IF SHR(CUPRcNT$FLAGi 1) THEN CALL K AKE ( C$ ACDP ) ;

ELSE 1NVAL1Q=TRUE;

(eYTEJCCLNT AMD 7FH) + SUFFSSTART -1:TE(PEC$N0)O{CTP.:=LCW( PECORDJAND 7FH1 THEN

ENENC SE

B$eYfE(CALL

C;TJRANCCMJFC INTER;

22)=CTR;SEACSRECORD;

GET$RCCCEC

RFCCCCNT

ENC8LFIFCALELSCAL

$NU U

LARF(IJ(BU

JNUMI=C= 0;

DC

F(4 )

(I

eEF: FROCECURE;(RECNUM, K) ADDRESS,

,CNT) EYTE,4) ACCFESS INITIAL ( 1 OOOC , 1 000 , 100 , 1 C 1

,

FF(5) BYTE;

= SHL ( F CO SBYTEt EXTENT JOFF SET) , 7)+FCB$EYTE(REC«NC)TC 3;

hHIRC

C;FF ( I )=CNT + '0'

LE REC$,NUM> = (K: =J( I ) ) ;

ECSNUf< = RECSNUM - K;m=cnt + l:

MODOF I

CA

= RSC JMJM-f' 0' ;

C18YTF (6) ) < = 5 THENVEI .ELFF +4-I ,C$A0DR(3) , I );

LL(CJACCR,I-5,' 'J:LL MCVCl .BUFF, CSAQ0R(3)«- 1-6, 5);

ENC;END CETIRECtNUf EER;

WRITE1ZER01PECCFC: PRCCECURE;CC A$CTR=1 TC CSACCS(2):

CALL WPITESBYTE(O);ENC:

ENC WRITEiZEFCJPECORD;

WR1TE1RANCCC : PRCCECURE;CALL SETJRANCCMJPC INTER;CALL WR ME JFRCMIHEMORY;CALL INC1PTRI9);

ENC WR ITEIRANCCf- ;

BACKSCNESFECCRC : FRCCEOURE;CALL 'FlilSC;

IF (ELFFSPTR : = »LFF SPT?.- (C S AGDR ( 2 J +2 ) ) >=6U FF $ST AP T THEN RETURN;8LFFiPT'3 = 6LFFiE'jn)-( "3UFFSSTART - SUFFtPTR);IF ( FCBieYTE(REC$NO) :=PC3$BYTE(REC$NO)-l)=255 THENCC;FCEtEYTE (EXTENT$CFFS5T)=FC8$BYTE( EXTENT SOFFSET 1-1 ;

IF CPEN(C$AD0R)<> THENCC;CALL PF1M <ERRCR(»OP' ) ;

INVAL10=TRUE

;

ENC;FCeiBYTE(REC$N0)=127;

EKC;CALL "=EAC$PECCRD;

ENC EACKSCNE JPECCPO;

/» * » * * 4 * * * * MCVES * * »<*./INC1FCLD: FPCCECLRE;

FCL3=HCLC l;CTR=Ctr • l;

ENC INCIHCLC;

LOADJINC: PPCCECLRE;F ! P Y T 5 = °. I S Y 1 E ;

EA ;E=tiASc-t 1 ;

CAU INCJHCLC;ENC LCACtlNC;

156

Page 321: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 322: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

cioia 1C1C19 1 CHECKIEOIT: FF CCE CURE < CHAR )

;

01020 2 CECLARF Chas BYTE;01021 2 IF (CHAR='0 (

) OR (CHAR='/"> THEN CALL INCJHCLO;01022 2 ELSE IF CHAR='B' THEN01C23 2 DC;01024 2 H$e>TE = • •;01025 3 CALL INCSHCLO;CIC26 3 ENO;01C27 2 ELSE IF CHAP= , A< THENC1C28 2 OC;C1029 2 IF NCT LETTE R (

B

SBYTE ) THEN CALL PR INT SERRCR ( IC ' I

;

C1C30 3 CALL LCACJINC;01C31 3 ENO;01032 2 ELSE IF CHAR='9 < THEN01C33 2 CC;01C34 2 IF NCT NUMERIC (BtBYTE) THEN CALL PR 1 NT JERROR (

• iC

• )

;

C1C35 3 CALL LCACSINC;C1026 3 ENC:01C37 2 ELSE CALL LCAC$INC;C1C38 2 ENC CHECKSECIT;C1C3S 1C1C40 I /»********** MACHINE ACTIONS * * *********/01041 1

01C42 1

C1043 1 STCP: PROCECLRE;C1C44 2 CALL PFINTt.'EOF $);01C45 2 GC TC BCCT;C1C46 2 ENC STCP;01C47 1

CIC48 1

C1C49 1 /*»**************»*********$»*»****C1C50 1

01051 1 THE PPOCECURE BELCW CONTROLS THE EXECUTION CF THE COCE.01C52 1 IT CECOCES EACH GP-CCOE AND PERFORMS THE ACTIONS01C53 101054 1 **********************************/01C55 1

ClC5t 1

01C57 1 EXECLTE: PPCCECLRE;C1C58 2 CC FOREVER;C1C59 2 DO CASE CETSCP$CODS;C1C60 3OlCfcl 3 ; /> CASE ZERO NOT USED */C1C62 4C1C63 4 /* ACC */01C64 4C1C65 4 Cf-Ll ADD;C1C66 4C1C67 4 /* SL'B «/C1C68 4C1C69 4 CC;C1C70 4 CALL CCf PL I MENT (0 )

;

01071 5 IF SIC-NO THEN S I GN0 = NEG1T I V E ;

01C72 5 ELSE S I GNO= PCSI T I VE

;

01C73 5 CALL AUD;01C74 5 ENC;C1C75 4C1C76 4 /* CLL */01C77 4C1C78 4 CC;C1C79 4 DECLARE I BYTE;C1C80 5 CALL SETSMULT $01 V

;

01C81 5 DECPT1,DECPT2=CECPT1 + CECPTC;01C8 2 5 CALL ALL I GN;01C83 5 CALL f tJL T I PL Y ( SHR ( P. 1 ( I : =9 ) , 4 ) ) ;

01064 5 DO INDEX=l TC 9:01C85 5 CALL M'JLTI°LY(Rl< I : = I-1) ANO OFH);01C66 6 CALL MULTIPLY (SHR(Rl ( IJ ,4J )

;

01C87 £ ENC;C1C88 5 END;C1C89 4C1C90 4 /* CIV */C1C91 401C92 4 C/LL CIVIDE;C1C93 4 /* NEC «/C1C94 401C95 4 ERANCH$FLAG=FALSc ;

01C9t 401C97 4 /* STP /C1C98 4C1C99 4 CALL STCP;C1100 4C1101 4 /* Stl */C1102 401103 4 CALL STCRESIMMEDIATE;01104 4C1105 4C11C6 4 /* PNC »/011C7 4C1108 4 CC;C1109 4 CALL STORESIMMEDIATE;C1110 5 CALL FILH .R2,10,0) ;

01 111 5 R2 (9)=l:01112 5 CALL AOD;C1113 5 ENC;01114 401115 4 /* RET »/C1116 401117 4 CC;CI 1 18 4 IF CJAOOROO THENCI 119 5 DO;C 1 120 5 A$CTR = CtAOOR:01121 6 CSAOOR=0;01122 6 PRCGRAM$COUNTER=A$CTR ;

01123 6 END:01124 5 ELSE CALL 1NCSPTR(2I;CI 125 5 ENC;

157

Page 323: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 324: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

CI 126 401127 4 /» CIS */C1126 4CU29 4 cc;01130 4 CALL SETSISO;01131 5 IF WRITEiMARK THEN CALL WR I T EtRECORD

;

01132 5 CALL CLOSE ( C SAOOR ) ;

01133 5 CALL INC$PTR(2>;0113* 5 ENC;01135 4C1136 A /* SER */01137 4CI 138 4 DC;CI 139 4 IF OVERFLOW THEN PROGRAM SCCUNTER = CSAODR;C1140 5 ELSE CALL INCSPTR12);C1141 5 END;01142 4 /» eFN /01143 401144 4 fPCCRAK$CCUNTER=C$ADOR;C1145 4C1146 4 /* CFN */01147 401148 4 CALL GPENtFILE(l) ;

C1149 4CI 15C 4 /* CP1 »/01151 401152 4 CALL GPENJFILE(2) ;

01153 401 154 4 /* CF2 */01 15.5011T6

44 CALL 0PENSFILE<3) ;

C1157 4C1150 4 /* PC-T */CI 159 4C1160 4 CC;01161 4 IF NOT SIGN2 ThEN01162 5 9RANCH$FLAo=NCT BRANChiFLAG;01163 5 CALL COND I T I CNALSBRANCH (0 ) ;

C1164 5 ENC;01165 401166 4 /* SLT */C1167 4C1168 4 CC;C1169 4 IF SIGN2 THENC1170 5 RRANCHSFLAG=NCT BRANC

H

JFL AG

;

01171 5 CALL CCNDITICNAL$3RANCH(0) ;

01172 5 ENC ;

C1173 401 174 4 /» PEC */01175 4C1176 4 CC;01177 4 IF NOT ZERCSRESULT THENC1178 5 BRANCH*FLAG=NCT 8RANCHSFLAG ;

C1179 5 CALL CONDI TI CNAL SERANCh(O) ;

CI 180 5 ENC;CI 18 1 4C1182 4 /* INV */C1183 401164 4 CALL INCREMENT$OR$BP.ANCH(INVAL 10) ;

C1185 401166 4 /* ECR */0118 7 4C1188 4 CALL INCREKENTS0RS2PANCH ( ENCSQF JRECORO) ;

C 1 189 4C1190 A /* ACC */01191 401192 4 CALL ACCEPT;01193 4C1194 4 /* CIS */C1195 40119 6 4 C*LL DISPLAY;01197 4C1198 4 /* ST C */CI 199 4C1200 4 cc;C1201 4 CALL DISPLAY;C1202 5 CALL STCP;01203 5 ENC;01204 401205 4 /* LCI */01206 401207 4 CC ;

C1208 4 CiAD0R(3)=CCNVERT$T0SHEX(CiACCR,C$8YTE (2) 1

C1209 5 CALL INC$PTR(3);CI 210 5 ENC;C12U 401212 4 /* CEC */C1213 401214 4 cc;01215 4 IF CSAOOROO THEN C $ ADDR = C $ A CDS- 1

;

01216 5 IF CJAD0fi = ThEN PROGR£XSCOLNTER = C

$

ADDP I 1 )

C1217 5 ELSE CALL INCJPTR(4);CI i 18 5 ENC;C1219 40122C 4 /* SIC /01221 401222 4 CC;01223 4 CALL STORE $NUfER IC

;

01224 5 CALL INC$PTR(4);01225 5 ENC;C1226 4C1227 4 /* S11 */C1228 4C1229 4 CC;01230 4 CALL STCRE SMJM r R IC ;

01231 5 CALL SE T SZONe (C $ADDR*C t eYT E ( 2 I- 1 I

;

_C1232 5 ENC;

158

Page 325: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 326: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

01223 401234 4 /* ST2 V01235 401236 401237 4C1238 5C1239 5C1240 401241 4 /* $13 */01242 401243 4C1244 401245 501246 5C1247 5C1248 5C1249 4C1250 4 /» S14 */01251 401252 401253 401254 501255 501256 501257 5C1258 401259 4 /* S 15 */C I 2 6 4C1261 4C1262 401263 501264 501265 501266 501267 4C1268 4 /* LCD */C1269 4C1270 4

C1271 401272 4 /* LCI »/C1273 401274 401275 4C1276 4 /* LC2 /01277 4C1278 4C1279 4C1280 5C1201 501282 501283 501284 601285 601286 501287 5ci2ea 6C1289 6C1290 501291 5C1292 4C1293 4 /* LC3 */01294 401295 401296 4C1297 5C1298 5C1299 5C1300 601201 601202 501303 5C1304 601305 601306 601307 5C1208 4C1309 4 /* LC4 */C 1 3 1

C

401211 401212 401313 501314 501315 501216 5C1217 501218 4C1219 4 /* LC5 */01220 401221 401222 4012 2 3 501324 501325 501226 5012 2 7 401228 4 /* LC6 /01329 4(1220 401321 4C1332 501333 5

C1334 5

01235 501336 501237 6C1238 5C1339 5CI ?40 5

DC;

ENC;

DC;

END;

CALL STORE SNUMERIC;CALL SETSZONE(CJADCR) ;

CALL CHECKSOECIMAL:BASE=CSADOR C$CYTE(2) - 1;CALL STORcSASSCHAR (CS8YTE (21 - 1);CALL SET$SIGN$SEP(C$AOCR + C$BYTE(2) -1);

CC;

END!

CC;

CALL CHECKSOECIMAL;BASE=CSADDR + C$BYTE(2);CALL ST0RESASSCHAR(CSBYTE(2)-1) ;

CALL SETSSIGNSSEP(CSAOCR) ;

CALL CHECKSOECIMAL ;

R2(9)=R2(91 CR S I G.N2 ;

CALL M0VEI.R2 + 9 - CI e YTE ( 2 ) , CSAOCR ,

C

t 3YTE ( 2 )

)

CALL INCSPTR14);eno:

CALL LQADSNUMSLIT;

CALL LCAOSNUMERIC;

DC;

ENC;

CC;

END:

CC;

ENCj

CC;

Ere;

CC;

FNC

CECLARE I BYTE;HCLG=CSADPR;IF CHECKSFOR$SIGN<CTR:=H$BYTE( I : =C SBYTE (2 >-l ) ) THENDC;

CALL SETSLCAC(POSITIVE) ;

1=1+1;END;ELSE DO;

CALL SETSLCAD(NEGITIVE) ;

CALL L3A0SASCHAR(CTR-ZCNE) ;

END;CALL LOADSNUMBERS(C$ADCR,I )

;

HCLD=CSADOR I

IF CHECKSFORSSIGNIHSBYTE) THEMDC;

CALL SETSLCAD(POSITIVE) ;

CALL LCADSNUMBERS (CSACCR,CSBYTE{2»>;END;ELSE 03;

CALL SETSLCAC(NEGITIVE) :

CALL LOADS MINERS (CSACCR + l,C»aYTE<2)-l>CALL LQACSASCHAR(HSeYTE-ZONE) ;

END;

holc=csaddr;IF h$BYTE(CS6YTE< 2) - 1) = •• THEN

CALL SETSLOADdJ;ELSE CALL SETSLOAC(O) ;

CALL LOADSNUM6EPS(CSA0CR,CSeYlE(2) -1)

HCLD=CSADDR;IF(HJBYTE=' +

' ) THEM CALL SETSLOADll);ELSE CALL SETJLOAC(O) ;

CALL LOADSNUMBERS (CSAOCR, CSeYTEl 2) -1»

DECLARE I BYTE;H01D=C$ADDR:CALL S-:TSLOAC(HSBYTE<I : = CSBYTE<2)-1)»BASE=BASE 9 - I

;

DC CTR = TO I

;

eiBYTE(CTR)»H$9YTE(CTR);END;8SBYTE(CTR)=B$BYTE(CTR) AND OFOH;CALL IfJCSPTR(5);

159

Page 327: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 328: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

01341 401342 4 /» PER */C1343 4C1344 401345 401346 501347 501348 5C1349 4C1350 4 /* CNL */01351 401352 401353 401354 4 /* CNJ */01355 401356 401357 401358 4 /* C4L */C1359 4Cli60 4C1361 401362 4 /* P V £ */01363 4C1364 401365 401366 5C1367 5C1368 5C1269 4C 1 3 7 4 /* CL£ */01371 401372 401373 4C1374 501375 5C1376 5C 1 3 7 7 4C1378 4 /» RCF "1C1379 4C1380 401201 4C1382 501333 5C1334 401385 4 /* W1F */C13Q6 401387 4C1238 4C1289 5£1390 501391 401392 4 /» RVL */01393 4C1294 401395 401396 4 /* fcVL */01397 401398 4C1399 4C1400 4 /» SCR »/C1401 4C1402 401403 401404 501405 5C1406 5014C7 4014C8 4 /* SCT »/C1409 401410 401411 401412 4 /* <n */0U13 401414 401415 401416 4 /» SEC */01417 4C1418 4C1419 4C142C 4 /» fCV */01421 401422 401423 401424 501425 501426 501427 5C1428 401429 4 /* RP S */01*20 4C1431 401432 401433 501434 5C1435 501436 401437 4 /* WPS 0/01438 4C1429 4C1440 40144 1 501442 5.01443 5

oc;

ENC;

BASE=C$AD0R( l)+l;B$AQCR=CSAD0R(2) ;

PROGRAMiCOUNTER=C$ADDR!

CALL copsmimsunsigned;

CALL CCfPJNUMJSIGN;

CALL CC*P$ALPHA;

CC;CALL BACKJCNEtRECCRC;

CALL WRITESFRCPSMEMORY;CALL INC$PTR(6»;

END;

CC ;

CALL BACK$CNE$RECCRC;CALL WRITES2EKCSREC0RD;CALL 1NCSPTR(6);

ENC;

DC;

ENC;

CC;

ENC;

CALL READSTOSMEMORY;CALL INC$PTR<6);

CALL WRITE SFRC M $ U E."C!RY;CALL INC$PTR(6) ;

CALL P.EAOJVARIABLE;

CALL WRITE$VARI ABLE;

DC;SUBSCRIPT(C$8YTe(2) )=

CONVERTS TO $HEX(C$A0 OR, C$eYT£<3)CALL INCSPTRU);

ENC;

CALL STPINGSCCMPAREd I ;

CALL STRING$CCMPARE(01 ;

CALL STRINGSC0MPARE12 )

;

CC;

ENC;

CALL MOVE(RES(CJAOCR( I ) ) , P. E S (C SADDR ) ,CiACDR(2) ) ;

IF C$AD0R(3)<>0 THEN CALLF1LL(°.ES(C$ADDR( 1 ) ) < C $ ADDR ( 2 ) , C i ACOR ( 3 I , ' ')

CALL INCSPTRO);

CC;

ENC;

CALL REAOSTOSVEMORY;CALL GtTtRECiNUMBER;CALL INCSPTR<9);

CC;CALL UP ITE$FROM$MFMCHY;

CALL GET IRECiNUMBERlCALL INCSPTR<9);

ENC;

160

Page 329: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 330: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

UULU10000200C03COCOA00C05COC0600CC7CCCC8CCCC9COUO00C110C012C0013C0014000150CC1600C1700C1800C19C0020CC02100C22C0C230CC240410250002600C27C0C26C0C29C0C30CC03100C3200C3300C34GCC35C0C360CC37C0C36C0C3VCOCOC0C41C0C42C0C4300C44flCWJC0C4600C'i7coc^eC0C49C0C50C0C51C0C52COC53C0C c.A0OC55C0C560CC57C0C58CCC59C0C600CC610CC62C0C63C0C6A0OC65C0C6600C67C0C68C0C69COC7C0OC71C0C720OC73C0C740OC75C0C760CC7 7C0C78C0C79CCCL'OCCC81C0C82CCC83CCC04CCC35GGC86JCC87CCC88C0C89CCC900CC91CCC920CCS3

/* THIS PRCGPAM TAKES THE CCDE OUTPUT FRCM THE C08CL COMPILERAND BUILCS THE ENVIRONMENT FOR THE COBOL INTERPRETER */

FR

YTE

10CH:

CECLAPE

LITBCCTBDCSTRUEFALSEFOFEVFeeFceteI

ACCRCHARBUFFIINTEFCCCESREACEINTERINTERI 13YTCCCESCSEY7BJS:e$acces&YT

/* LCAD PCINT */

LITERALLYLITLITLITLITLITACCRESSeASED

ACCRESSeASEOLIT(33)eYTE

LIT

FCB

•LITERALLY' ,

•0' ,

•5',l'i•0'

,

•WHILE TRUE"

,

INITIAL (5CH!BYTE,

ENDPSFC3NCT$SET-SLCCATICNFSADDRESS ADDRESSPICONTENT BASEOE EASEDCTR ACCRESS,E EASED CODESCTR BYTE,

ACCFESS,R - eASED BASE ADDRESS,E EASED BASE BYTE;

INITIAL (lOOh),ADDR BYTE,

' 100H*

,

BYTE INITI ALIO, 'CINTERP COM , , C , C , C )

,

INITIAL (TRUE),• 1C80H< ,

INITI AH2000F) ,

INTERPSADDRESS ACCRESS,1NTEPPSADDRESS BYTE,

MCM: PROCECLRE (F,A);CECLARE F EYTE, A ACCRESS;CC 70 BCCS;

END MCNl;

MCN2: PRCCECLRE (F,A) BYTE;OECLARE F EYT C

, A ACCRESS;gc tg eccs;

END KCN2;

PPINTJCHAR: FF CC ECURS ( CHAR )

;

CECLAPE CFAF 2YTE;CALL MCNK2 .CHAR) ;

ENC PRINTSCHAS;

CRLF: PRCCECLRE;CALL PR UT!Ct-AP<13) ;

CALL PR1NT1CFARUC) ;

END CRLF;

PRINT: PRCCECLRE (A)

;

CECLARE A ACCRESS;CALL CRLF:CALL MCMlS ,A) ;

ENC PRINT;

CFEN: PRCCECLRE (A) BYTE:CECLARE A ACCFESS;RETURN VCN2 ( 15, A) ;

ENC CFEN;

MCVE: PRCCECLRE (FPCf , DEST, COUNT);CECLARE (FRCN, DEST, COUNT) ACCRESS,

(F 9ASED FRCf, D GASEO CEST) BYTE;CC V.HILE (CCLNT:=CCUNT-1)OOFFFFH;

C = F;FRO=FFCf+l;DEST=CESTU;

ENC:END KCVE;

GETSCt-AR: PRCCECURE BYTE:IF (AOCR:=ACCR 1)>=BUFF$ENC THENCC!

IF .VCN2(20,FC3)<>0 THEN

DO;CALL PRINT(.'END OF INPUT $'

GC TC BCCT;ENC;ACCR=eCF ;

END;FETUPN CHAP;

ENC CETSCHAR;

161

Page 331: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 332: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

CCC94 1

CCC95 1

0CC96 20CC97 2

CCC98 1

CCC99 1

C0100 100101 2C0102 200103 200104 2C0105 3C0106 300107 3C0108 2C0109 2COilO 300111 300112 3C0113 2C0114 IC0115 1

00H6 100117 200118 2C0119 2C0120 2ooia 3

00122 200123 200124 300125 300126 300127 3

C0128 3

C0129 4C0130 400131 300132 2C0133 100134 1

C0135 1

C0136 200137 2C0138 2CC139 200140 200141 200142 1

C0143 1

00144 1

00145 200146 200147 2CC148 1

C0149 1

CC150 I

00151 200152 2

00153 200154 200155 a

C0156 200157 2C0158 2C0159 T

C0160 200161 2C0162 1

N6XTSCHAR: FFCCECURE;CHAR=GET$ChAR;

END NEXT$CHAR;

STCRE: PROCcCUREtCCUNT ) ;

CECLARE CCLM BYTE;IF CGDE5NCUSET THENco;

CALL FFINT(. 'COCF. ERRORS')CALL NEXTSCHAR;RETUFN;

END;CC 1=1 TC CCLNT;

C$6YTE=ChAR;CALL NEXTiCHAR;CGCS JCTR=C0DE$CTR*1 ;

ENC;END STCRE;

BACKSSTUFF: FFCCECURE;CECLARE (HCLC .STUFF) ADDRESS;eASE=.HCLC ;

CC 1=0 TC 3;e$GYTE ( I)=GETJCI-AR;

ENC;CC FCREVEa;

3 A S E = F C L D

;

HOLC=eiACDR;6SACCR=STUFF ;

IF FCLC=0 THENDO

;

CALL NEXTSCHAR;RETURN;

ENC ;

ENC;ENC eaCKSSTLFF;

STARTSCCOE: FFCCECURE;CO0c5fJOT1SET = FALSE;IiBYTE=C E TSCFAP ;

ISBYTS ( l)=GETiCHAR;CCCESCTR=INTERP$CCNTENT;CALL NEXTSCFAR;

END STARTKCCE;

GCiCEPENCING : PPCCECURE;CALL STC'E(l);CALL STCFE(5I-L(CHAR,1) + 4);

ENC GCICEPENCING;

INITIALIZE: FFCCECURE;CECLARE (CCLNT, hFERE .HCWSMANY) ADORESS;EA SE = . WHERE ;

CC 1=0 TC 3;BS8YTE ( I)=GET$CHAR;

ENC;eASE=HHERE - l;CC COUNT = 1 TO HGWSMANY;

B$3>TE(CCUNT )=GET$CHAR;end;CALL NEXTiCFAR;

END INITIAL 126;

162

Page 333: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 334: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00163C01640016500166C0167C0163CC169C017C0017100172001730C174C017500176001770C17S0C179C01800C1810C1820018300184C0185C01860C1670C188C0189CC190CC191CC1920C1930C19m0C1950C1960C197CC198CC199C02G0C02C1C020200203C02040020 =

C0206002C7C02C8C02C9C021000211CC2120021300214002150021600217C0218C0219C0220C02210022200223C0224002250022600227C022800229C0230

BUILC: PROCECUDECLAREF2 LITF3f,F5F6F7F9F1CFUF13CCPINTESTTERSCC

LITLI1LITLITLITLITLITLITLITLITLITLITLI T

L IT

RE;

•8'•9'•21

•29

54tc61•£2't2'c4•c5• 6c

CC FOREVER;IF OARELSE

"

ELSEELSEELSEELSEELSEELSEELSEELSEELSEELSE

< F2IF CHARIF CHARIF CHARIF CHARIF CHARIF CHARIF ChARIF CHARIF CHARIF CHA°IF CHAR

THEN< F3

ELSE IF CHARELSE IF CHAR

" IF CHARELSEDC;

FAF5F6F7F9F10FUF13GDPGOPDSTINTTER

ALLHENHENHENHENHENHENTHETHETHETHETHETHETHETHE

STOPCALLCALLCALLCALLCALLCALL

N CALN CALN CALN CALN CALN CALN CALN

(l)

;

STORSTORSTORSTORSTORSTOR

L STOSTOSTOSTOGCJBAGINI

E(2) ;

E(3) ;

E(A) ;

E(5)

;

E(6) ;

E(7) ;

RE<9)RcdORE( 11RQ(13CEP ENK$STUTIALI

)

;

)

;

I

;

t ING!FF;2E;

CALL PRINTl.'LOAO FINISHED*');RETURN;

ENC;ENC;

ENC ELILC;

ENC;ELSE IF CHAR = SCC THEN CALL STARTSCOCE;ELSE CC;

IF CHARCALL NEX

<> OFFH THEN CALL PRINT!. 'LCAD ERRORS')'TSCHAR;

/* PROGRAM EXECUTION STARTS HERE »/

Fce$evTE=o;CALL ?-CVE(. ( 'C1N' ,0, C, 0,0) ,FCB + 9,7);IF OPENIFCB ) =25 5 THENCO;

CALL PPINTC.'FILE NCT FOUND S');CC TO BCCT ;

ENC;CALL NEXTSCHAR;CALL BUILC;CALL yCVc( . INTEKFJFCB ,FC3,33);IF GFEN(FC6)=255 THENCO;

CALL PRINT (.• INTERPRETER NCT FCUNDCC TO BCCT;

END;CALL PCVElRSADEPfLOCATICN, 60H, 80H);GO TO 80H;ECF

*•);

163

Page 335: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 336: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

OOCOl00002000030CC0400CO50CC060OCC7cocoeC0C09CCC10000110OC12000130001400C15C0C16C0C17cooieC0C19COC200OC21C0C22COC23C0C24C0C25C0C2600C27C0C28C0C29CCC30C0C310OC32C0033C0C34C0C35C0C36C0C37C0C38C0C39COCAOC0C41C0C42CCCA30OC4*.CC045C0CA600CA7C0C48COCASC0C50C0C510CC52CCC530C05AC0C55C0C56COC57C0C58C0C59C0C6000C61CCC62C0C63JCC640OC650OCb60CC67CCC66CGC69C0C70000710CC72CCC730OC7A00C7500C76C0077C0C78C0C79CCC80CCC81CCC82CCC83CCC8ACCC850CC8600C8700C88CCC89CCC90CCC91CCC92C0C93CCC940CC95CCCS60CC97CCC98CCC99C01000010100102C0103

/» THIS FRCGRAM TAKES THE CCOE OUTPUT FROM THE COBCL COMPILERANC CONVERTS IT INTO 4 R6A0A8LE OUTPUT TO FACILITATE CEBUGGING */

100H:

CECLAPE

LITBCCTBOOSFeeFCeiBYTEI

AOCR-CHARCtACCPBUFF JENDFILE1TYPE

/* LOAD POINT */

LITERALLYLITLITACCRESSEASEDeYTE,ACCRESSeASEDEASED ACDRLITCATA ('C

f:b

•LITERALLY'

,

'0«,•5',INITIAL (5CHJ,BYTE,

INITIAL (iOOHl,ADDR BYTE,

ADDRESS,•OFFH*

,

I « , ' N • )

;

KCM: PRCCECLRE (F,A);CECLARE F eYTE, A ADCRESS;CC TC BCCS;

ENC fCNl;

MCN2: PPOCECLRE (F T AI BYTE;CECLARE F eYTE, A ADDRESS;GC TC ECCS;

END l*CN2;

PBINT5CHAR: P PC

C

ECURE < CHAR )

;

CECLARE CHAP BYTE;CALL KCM (2 ,CFAR) ;

END PPINTJCHAF. ;

CRLF: PRCCECLRE;CALL PR INTJCHARI 13) ;

CALL PR INTJCFAR(IO) i

ENC CPLF

;

P: PRCCEDURE(ACC1 );CECLARE ACCi ACCRESS, C BASED ADD1 BYTE;CALL CPLF;CC 1=0 K 2:

CALL FP 1NT$CHAR(C< III;END;CALL PPINTICFARC <);

END P ;

GETtCFAfi: PRCCECLRE BYTE;IF IACCR:=ACCR + 1)>6UFF$END THENCC;

IF fCN2(20,FCB)<>0 THENCO;

CALL P( - 'END' );CALL TIfEl 10)

;

CC TO SCOT;ENC;A0CF=6CH;

END;RETURN CFAR;

END CETiCFAP;

CSCHAR: PRCCECLPE ( 0LTPUTSBYT6 )

;

CECLARE CLTfLTSBYTE BYTE:IF CUTFL-T $EYTE<10 THEN CALL PR I NT $CHAR < OUT PLTSBYT

E

ELSE CALL P F I NT SCHAR ( OUTPU

T

SBYTE 37H);END C1CHAR;

D: PROCEDURE (CUNT):CECLARE (CCLNT , J) ADDRESS;DC J=l TC CCLNT;

CALL C JCHAR( SHR(GETSCHA=,4 J ) ;

CALL CKHARICHAR AND OFhj;CALL PPINTJCHARC •);

ENC;END 0;

PRINT1PEST: FPCCEDURE;

+ 30h);

CECLAREF2 LIT i • ,

F3 LITs;».F'. LIT

F5 LIT 25' ,

F6 LI 1 1:-

:' t

F7 LIT 39' ,

F9 LIT 4 9' ,

F1C LIT 54' ,

Fll LIT (C ,

F 1 3 lIT tl ',

CCP LIT 62« ,

INT LI 7 (!' i

6ST LI T £4' ,

TEP LIT ti ',

SCO LIT tt' ;

164

Page 337: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 338: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

00104C0105C0106C01O7C0108C0109CO 11000111C0112001130011400115001160011700 1 1800119C012000121001220012300124C0125C0126001270012800129C0130C0131C01320013300134001350013600137C0138C0139C014000141001420014300144C0145C014600147C0148C0149C015C001510O1520015300154CC1550015600157C015GC0159CCJ6000161C01620C16300164C0165C016600U7016 8

CC169C017000171OC1720017300 17 4001750017600177CO 178C0179CC1800C181CC182001830C18400185CCI&600187C0188CCIH9CC190CC1SI0CI92OCK-3CC1940C195CC1960C197CC198CC199C0200C0201C020200203C020400205

ENC

CHARCHAPCHARCHARCHARChAPCHARCHARCHARCHARCHARCHARCHAR= INTCHAR=8STCHAR=1ERCHAR=SCDCHAR <>

F2F3F4F5F6F7F<5

F1C

= CCF

FllF13C-CP

THENTHENTFENTHENTHENTHENTHENTHENTHENTF C NTHEN

RETURN;DC; CALL

THENTHENTHENTHENTF5N

oc;oo;oc;DO;DO;00;DC;DO:oc;

CO;do;CO;DO;DO;

CALLCALLCALLCALLCALLCALLCALLCALLCALL

CALLCALLCALLCALLCALL

D ( l ) :

C(2) ;

0(3) ;

0(4);C(5) ;

0(b) ;

0(3)C(Q )

D( 10)0(12)

RETURNRETURNRETURNRETURNRETURNRETURNRETURN;RETURN;

; RETL'KM

ENC;ENC;ENC;ENC;ENC;ENC :

ENC;ENC;END:

R1NT$REST ;

CFFH THEN CALL

return; enc;CALL C(5HL(CHAR,l ) +5)

;

CALL C(CJACCRRETURN; ENC;

" TC eCOT; END;ENC;

0(1);D(3)D14)P( . 'END' I : GO0(2); return;P( . -xxx' )

;

return: eno;retlrn; enc;

'/« PROGRAM EXECUTION STARTS HERE */

FARCASEP( .

P( .

P( .

F(.F( .

P(.P( .

F( .

f ( .

F ( .

F ( .

P( .

F( .

F ( .

F ( .

F( .

P( .

P(.F( .

F(.F( .

P< .

P( .

F( .

P( .

P(.P( .

F(.P( .

P(.F( .

P( .

P(.F( .

P(.P( .

F(.P( .

F( .

F( .

P(.P(.P(.F( .

F(.P( .

P(.P( .

P(.F ( .

P(.F(.P( .

P( .

P(.F( .

P( .

P( .

P( .

P( .

P( .

F( .

P(.F(.F( .

F( .

CF CNT IPCF t

66NO

00UBL'L

tvEGTPTI\CETLSERRNFNPIP2GTLTC

NVr r

cc! SI

CIECVCt:T2T3T41 5CODl0203D404D6ERNUNS4LViSLSOF1 F

VLVLCRGTLIEflrvRSRSPRPRw RLRenN^?DNTSTFRCOE ST;

THEN DO CASE CHAR;USED */

FCB$BYTE=0;CC I=C TO 2:

FC8$8YTEU*9)*FILE*TYPElI)iENC;

IF HCK2(15»FCB»«255 THFN DO; CALL P(.'ZZZ'); GC TO BOOT; END;

CO HHILE l;IF GET$C; /»

CALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCALCAL

END; /*CALL PRI

ENC; /* ENOEOF

ATEHENT */

Lc V

165

Page 339: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 340: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Ul 444C144501«6C1448C1449C1450C1451C145201453C145401455C1456C1457C145801459C1460C1461014620146301464014650146601 46 7

C1468CL469C1470014710147201473C1474C14750147601477C1478C1479C1460C14810148201463C1484C1485C1486C1487oi4eaC1489C149001491C149201493C1494014950149601497C1498C1499C150001501C15020150301504C1505015060150701508CI 509

/* RRR */

/* WriR */

/* RfcR */

/* CLR »/

/* MED */

CC;CALL SET$RANDCMSPOINTERiCALL READ$TC$MEMORY;CALL INCJPTR19);

ENC;

CALL WP ITESRANDOM;

CALL WRITESRANDOM;

CC;

END;

CC:

/* PNE */

/» CCP */

ENC:

cc;

ENC;

CALL SETJRAN'CCMSPOINTER;CALL WRITE J Z t SO $ RECORD

;

CALL INC$PTR(9);

CALL M0VE(C$ADDR(3) , CiACDR ,CJA00R(4 J )

;

e*SE=CSADDR( 1>

;

HOLD=CSACOR;CTR=0;DO WHILE (CTR<C$ADOR( 1 ) ).'.NC(CTR<C$ACCR (4) )

CALL CHECK1EDIT(HJ8YTE) ;

END;IF CTR < C$ADCR<4) THEN

CALL F 1LL(H0LD,C1ADDR(4)-CTR, • ');

declare offset 3yte;offset=convert$to$hex<c:aocr<1> .csbyte(l)-l);if offset > csdyte + i thendo;

call printserrorl 'gc! i

call inc sptr (shli c1byte,1 ) «• 6 > ;

END;ELSE FROGRAMSCOUNTER = C$ADDR ICFFSET > 2 i ;

ENC

BA SEPRCGCALLFCF

ENIENO; /*EXECUTE

/* » *

:=ccde$sRAP $CulEXECUT

; /* ENO OF CASE STATEMENT */ENC CF DC FOREVER */

* * * PROGRAM EXECUTION STARTS HERE »*****»/TAPT ;

NTEP=eiACCR ;

E;

166

Page 341: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 342: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

OOLUlC3002COC03CCCO'tOOC0500006CCC07C0C0800009COC10C0C1100012C0C13C0C14C0C1500C16C0C17C0018C0C19COC200OC21C0C22C002300C24COC25C0C2600C27C0C23C0C29C0C30C0C31C0C3200C33C0C34C0C3S00C3600C370OC38coc39coco00CA1000-1200CA300C44C0C4500C.600C47C0C.80OC4SCCC5C

/* COBCL CCf-FILER PART 2 PEACER */

/* THIS FRCC-PAM IS LOADED IN WITH THt PART 1 PROGRAMANC IS CALLEC WHEN PART 1 IS FINISHED. THIS PROGRAMOFENS T (-E PAPT2.COM FILE THAT CONTAINS THE CODE FORPART 2 CF THE COMPILER, AND READS IT INTO CCRE. ATTHE END CF THE READ CPEPATICN, CONTROL IS PASSED TCTHE SECCNC FART PROGRAM. */

31C0H: /* LCAC POINT */

DECLARE

6CCT LITERALLY «0H' f

BOGS LITERALLY «5H«, /* ENTRY TO THE OPERATING SYSTEM */START LITERALLY '1C0H', /* STARTING LOCATION FOR PASS 2 */FCB (33) BYTE I M T I AL I ,

• PASS2 COM , , , , ) ,

LASTCMA ADCRESS I MT I AH2480H ) , /* 80 LESS THAN MEMCRY */I ACCRESS;

MCNA: PRCCECLRE (F.a);CECL6RE F EYTE, A AOCP.ESS;GC TO BCCS;

ENC MCNA;

MCNb: PPCCECLREIF.AIBYTE;DECLARE F BYTE, A ADOP.ESS;GC TC BDCS;

END MCNB;

EFRCP: PFOCECuRE (CODE 1 ;

DECLARE CCCE Af-ORESS;CALL MCNA ( 2 .(HIGH (CCCE) ) ) ;

CALL MCNA (2 , ILCrt(CCCE) ) );CALL TIMF( K ) ;

CC TC BCCT;ENC ERROR:

/* OPEN FASS2.CCM */IF MONEt 15, .fCe>-255 THE\' CALL ERRCR('02');

/* REAO IN FILE */CO I=100H K LASTCMA eY 30H;

CALL MGNA(2t,I); /* SET DMA »/IF MQNB12C, .FCeiOO ThEN CALL ERRCR( , P2');

L MCN'A(26,8CH) ; /» RESET DMA */TC START;

ENDCALGCEOF

OOCOl 100C02 1

0OCO3 1

00004 1C0C05 10OCC6 1

OOCC / 10CC08 1

C0C09 1

COCIO 1

0OC11 100C12 1

0OC13 1

00014 I

C0C15 I

C0C16 100C17 1

0OC18 1

C0C19 2COC20 2C0C21 2C0C22 1

00023 1

C0C24 20OC25 2C0C26 200C27 1

C0C28 IC0C29 1C0C30 2C0C31 20OC32 I00C33 1

/* COBOL CCMPILER - INTERP REACER */

CRLINTSrrM

C ^t Mal^ Crkk^ n

BY>,ly

E §U IL ° "CGPAM AFTERCBLINT.CCM HAS BEcN CPENIcD, ANC READS THE CCCE INTC MEMCRY

80H: /* LCAC FCINT */

CECLAPE

BCCTBCOSSTAkTLASTDMAI

LITEOALLY '0H»,LITERALLY '5H', /* ENTRY TO THE OPERATING SYSTFV »/L4 nr

TRr^ L¥

IJ??1

?:.' , . 'V! ARTIfjG LCCaticn fgrpass 2 */

ADCRESS-INITUL<16a0H 't /* 80 LESS T(-AN MEMCRY */

MCNA: PRCCECLRE <F, A)

;

cc!c^ R

iccF

sr TE ' A adcress:END HCNA;

MCNB: FROCECLREIF.AJBYTE;DECLARE F 6YTE\ A ACCRESS;LL 10 BCCS;

END MCN8;

00 I=1C0H TC LASTDMA BY EOH;(

fA

:

L!j„

f'£* ;!,£4 ' I »5 '* i^T DMA */

ENC-^0^8(20, JChlOO THEN GO TO BOOT;

GC TO START;ECF

167

Page 343: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 344: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

LIST OF PEFEPfcNCES

1. American National Standards Institute* CObOL Standard,ANSI X3. 23-1974.

?. Aho* A. V. ana 3. C. Johnson, LR Parsing* ComputingSurveys* Vol. 6 No. 2* June 1 Q 7 4

.

bauer* r . L. ana J. Eickel* editors* Compiler Construc-tion - An Advanced Course* Lecture notes is ComputerScience* Springer-Verlag* New York 197o.

Digital Pesearcn* a n Introduction to C P / M Features andFacilities* 19 7b.

5. Digital Researcn, CP/M Interface Guide* 1 9 7 o

.

b. tubanks* bordon E. Jr. A Microprocessor Implementationof Extended Basic* Masters Thesis* f^ v a I Postgradu-ate School* December 197b.

7. Intel Corporation* 600* and 8080 P L / M Program mina Manu-al * 1«7S.

8. Intel Corporation* 80^0 Simulator software Packaae*19/4.

9 . Knuth* Uonald F. On tne Translation of Languaoes TromLeft to Right* Information and Control Vol. o* No.b* 196b.

10. Software Development Division, AOPF Selection Office*Department of the Navy, nYPO-CuBOL, April 19/S.

11. Strutynski, Kathryn B . Information on the C P / M inter-face Simulator, internal 1 v a i strip u tea technicalnote.

12. University of Toronto* Comouter Systems Research Group

168

Page 345: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 346: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

Technical Report CSPG-2, "An Efficient lALRGenerator^" oy to . R . L a 1 o n g e / Aoril 1971.

Parser

169

Page 347: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 348: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

INITIAL DISTRIBUTION LIST

I. Defense Documentation CenterCame ron 5t a t ionAlexandria* Virginia P2314

No. Copies

2

2. Library, Code 0212Naval Postgraduate SchoolMonterey* California Qi^aO

i. Department Chairman, Code b<?

Department of Comouter Sciencenaval Postgraduate SchoolMonterey, California ° 5 ^ 4

4 . Assoc Professor G. A. K i 1 da 1 1 r Code 5 2 K d

Department of Comouter ScienceNaval Postgraduate SchoolMonterey, California ^i^UO

Lt L . V . Rich, Code 52ksDepartment of Comouter ScienceNaval Postgraduate SchoolMonterey/ California °3940

o. ADPt Selection OfficeDepartment of the NavyWashington, D. C. c: i 7 6

7. Capt A. S. Craiq, USMCtoll Canyon Drive,Sorinaville, I'tan 64&6i

170

Page 349: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 350: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 351: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:
Page 352: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

TresisC78215c.l

c ra i g~ J J b -f

D1MIC*0-C0B0L an •

standard Hvon°f WavX

fQr* m/crn

C060'-

bas^ com °Pr0ce^or.

1 C: q'

Crai g

MICRO-COBOL an im-

nl^rnpntst- • on r>f MaVystandard HYPO-COBOLfor a microprocessor-based computer system.

6^

Page 353: MICRO-COBOL : an implementation of Navy standard HYPO-COBOL … · 2016-06-04 · Calhoun: The NPS Institutional Archive Theses and Dissertations Thesis Collection 1977-03 MICRO-COBOL:

3 2768 002 09925 1DUDLEY KNOX LIBRARY

flu

.:.,:..;':'

\ -,

r

»