HAL/S Development Chain
Table of Contents
Template Library, the Inclusion Library, and the SDF Library
The Template Library and the "
D INCLUDE TEMPLATE" Compiler DirectiveThe Inclusion Library and the "
D INCLUDE" Compiler DirectiveThe Template Library Part 2: The SDF Library and the "
D INCLUDE SDF" Compiler Directive
Introduction
The principal claim to fame of the HAL/S computer language is that the bulk of the flight software for the Space Shuttle was written in it, as supplemented by source code in the assembly language of the Shuttle's General Purpose Computers (GPC). GPCs were IBM AP-101S computers or (for early missions) IBM AP-101B computers. HAL/S also seems to have been used for the flight software of the Galileo probe, though in that case the onboard computers were based on RCA 1802 COSMAC microprocessors.
Aside: The other claim to fame is that HAL/S has an optional pseudo-mathematical notation in which arithmetical expressions look a bit more like mathematical formulas as traditionally printed than they generally do in other programming languages. This more-traditional appearance supposedly eased program readability.
HAL/S was devised by the company Intermetrics, Inc., and touted as one of the "standard" languages in which NASA flight software should be written. In spite of the two successes I mentioned above, I haven't found much evidence that it ever became a NASA standard. Indeed, a 1983 report that investigated the language candidates HAL/S versus ADA versus Modula 2 concluded that only ADA met all of the desired criteria. Today, with sympathetic apologies to the folks who developed it (and using it) back in the day, I'd regard HAL/S as a dead language, though I'd be happy to be instructed otherwise.
One factor greatly in its favor, both as a language for flight software and for general-purpose computing, is a very fine book about the language, namely Michael Ryer's Programming in HAL/S. That may sound like an odd advantage to mention, but "very fine books about them" are something that computer languages with a minimal user base tend to lack. Authors have more incentive to spend their time writing about widely-successful languages with large numbers of users.
Nevertheless, the Space Shuttle's flight software was written in HAL/S, so anybody interested in working with that flight software, even if only as a self-enrichment pastime, also needs appropriate development tools for working with HAL/S. The Space Shuttle's flight software came in two very-different flavors, namely the primary flight software (PFS, but more-commonly even if more-loosely referred to as PASS) and the backup flight software (BFS), with the BFS being basically a clean-room implementation of a subset of PASS functionality. By emphasizing PASS and BFS I don't mean to disparage Galileo's software. However, I have seen no Galileo flight software, and as far as I know right now have no prospect for ever getting my hands on it. If you have Galileo flight software source code, or even related documentation, by all means contact me. I'll expand the scope of my HAL/S efforts quicker than you can bat an eyelash.
A 1981 article summarizes the HAL/S activity up to that point in time, describing 16 implementations of HAL/S compilers and cross-compilers for various combinations of host- and target-computers. None of those host- or target-computers are (or even were, I suppose) available for computers accessible to the general public. In particular, the so-called "IBM PC" is not on the list. The IBM PC didn't even become available until 1981 anyway, and (as I can tell you from personal experience) the personal computers available prior to that were literally sneered at as toys by the mass of mainframe computer users who hadn't the vision to even consider the possibility that widely-available low-cost computers available to everybody might largely supplant the giant mainframes upon which their careers depended. But time ticks on, obviously, and if normal peons such as myself want to use HAL/S today, we need HAL/S development tools that run on the computers actually available to us. Which is to say, on Linux, Mac OS, or Windows computers. (Or on hand-held devices, though I confess that it's hard to envisage working with HAL/S software on a cellphone!)
My initial iteration of a solution to this problem was to develop a Linux/Mac/Windows based HAL/S compiler which could translate HAL/S source code into a language I called PALMAT, for which I also had an emulator. The compiler and emulator could optionally be combined into a HAL/S interpreter, into which the user could input HAL/S statements and immediately see the result of executing that statement. I called this software yaHAL-S-FC. The software functions pretty well, though it never reached the point of implementing 100% of HAL/S's features, nor of being extremely polished for user friendliness. I halted work on it mainly because the effort of extending it to 100% functionality seemed to be expanding rather than contracting. But it could be useful as an interactive learning aid for those who (for example) are working their way through Ryer's book. The software remains available in the Virtual AGC software repository, and is the subject of two of our pages, one about the compiler itself and one about the interpreter alone. I will not mention it again here.
The HAL/S development tools we focus on here are:
- HAL/S compiler(s). That's the topic of the present page, of course!
- An IBM AP-101S assembler.
- An IBM AP-101S linker.
- IBM AP-101S emulator/debugger(s). See the emulator page.
- HALMAT emulator/debugger(s). See the emulator page.
The principal HAL/S compiler, which I will refer to as HALSFC, is based on the source code for the original Intermetrics HAL/S compiler called HAL/S-FC. We'll also have call to discuss HALSFC's "baby brother" (in terms of capabilities) but "big brother" (in terms of age), and still incredibly useful, HAL_S_FC.py.
Back in the day, Intermetrics actually had three separate HAL/S compilers that I know about:
- HAL/S-360 was a compiler that converted HAL/S source code into IBM 360 object code.
- HAL/S-FC was the compiler that compiled the primary flight software (PASS) and produced AP-101S object code.
- HAL/S-BFC was the compiler that compiled the backup flight software (BFS) and produced AP-101S object code.
Aside: The surviving documentation is almost silent on the subject of having separate compilers for PASS vs BFS, but here's my understanding of what happened:
- At first, say in 1975, there was a single HAL/S-FC compiler for producing AP-101S object code.
- But at some unknown point, differences between PASS and BFS became too tricky to be handled by a single compiler. This problem may have been caused or exacerbated by the fact that Intermetrics was writing PASS, whereas Rockwell International was responsible for independently writing BFS, and they weren't always conforming to the same conventions. But whatever the reason, to handle these differences, the source code for HAL/S-FC branched into two separate source-code trees that proceeded to be developed independently from each other. And of course, divergent software trees only continue diverge over time, rather than magically converging back into a single tree.
- Still later, at PASS release 23V2 and BFS release 6V0 in late 1991, management noticed that it was twice as expensive to develop two compilers as it was to develop just one compiler, said "aw, shucks!", kicked up some dirt with their boot tips, grumbled menacingly, and commanded that the source-code trees once again be merged into a single tree. [Editor's note: I made up some of that.]
- But even though the source code for the two compilers has once again been unified into a single release that eventually evolved into the release 32V0/17V0 that we have today, it turns out that there were still two separate methods for building that source code, thus producing two separate compiler programs anyway. The "HAL/S Compiler System Specification" expresses it thusly: "Although much of the source became common between the two compilers, there exist differences that can be attributed to required PASS/BFS interfaces and certain desired but not required compiler features". Besides the two different build methods for the HAL/S compilers, there's also the consideration of the runtime libraries needed to actually run the AP-101S object produced by the two compilers. And in fact, the runtime libraries needed for the flight software were not merged, and continued to be different in PASS versus BFS. I.e., there are still two separate runtime libraries, similar perhaps, but not merged into a single source-code tree.
- And as for how this dichotomy affected other development tools, there was a separate linker for BFS versus the linker for PASS, as well as a bunch of separate BFS utilities that seem not to have survived.
- Finally, as far as I can tell, Intermetrics/USA developers simply refer to these two versions of the compiler as "the PASS compiler" and "the BFS compiler". I will sometimes refer to them as HAL/S-FC and HAL/S-BFC, respectively, although generally I'll just use HAL/S-FC as a generic term when it doesn't really matter which of the two compilers I'm referring to.
And if all of that weren't enough for you, the structure of HAL/S-FC, in either the PASS or BFS version, is actually more complex than I may have implied. In fact, HAL/S-FC was not just one program, but rather seven stand-alone "passes", some of them optional, that were run in succession to perform the full compilation:
| Description | HAL/S-FC | HAL/S-BFC |
|---|---|---|
| Cross-compile HAL/S source code to HALMAT intermediate language | PASS1 | PASS1B |
| Produce some optional reports about the HALMAT. Sometimes called "FLOWGEN" | FLO | |
| Optimize the HALMAT representation | OPT | OPTB |
| Optimize it some more! | AUX | |
| Cross-compile the HALMAT intermediate language to AP-101S object code | PASS2 | PASS2B |
| Produce optional Simulation Data Files (SDF) | PASS3 | PASS3B |
| Print optional reports about the SDF | PASS4 |
Aside: Probably, you're beginning to see a truly explosive confusion of usages of the word "pass". For one thing, there are 7 passes of the compiler, some of which are named PASSx and some of which are not. But meanwhile, "PASS" is also the name of the primary flight software! Worse, as explained below in the glossary, the correct acronym for the primary flight software was actually "PFS" rather than "PASS", but the term "PASS" became deeply entrenched while the official acronym "PFS" became mostly disused in the everyday language of the original developers. For compiler passes, Intermetrics somewhat-interchangeably used the following alternate terminology, which is less confusing, and I may use it from time to time as well:
- The term "Phase 1" corresponds to PASS1 of the compiler. It is where HAL/S source code is parsed.
- The term "Phase 1.5" corresponds to FLO, OPT, and AUX of the compiler. It is where optimization occurs.
- The term "Phase 2" corresponds to PASS2 of the compiler. It is where object-code generation occurs.
- The term "Phase 3" corresponds to PASS3 of the compiler. It is where diagnostic and simulation data (i.e., Simulation Data Files, AKA SDF) is produced.
- The term "Phase 4" corresponds to PASS4 of the compiler. It dumps Simulation Data File (SDF) contents for debugging purposes.
And to pile misery atop misery, Microsoft Windows reserves the name "AUX" in a way that makes it extremely difficult to use as the name of a file or a directory. That includes variations like AUX.exe as well. So to save ourselves a world of grief, even if not working on Windows, the AUX pass of the compiler is henceforth referred to as AUXP.
The original Intermetrics compilers, HAL/S-FC and HAL/S-360, were written in a high-level computer language I call XPL/I, with some "inline" IBM 360 machine code. The original developers, and other online references you'll see, refer to it simply as "XPL". But I regard that as confusing and inaccurate, since XPL was a standard language (even if very rare then and dead now) but not the enhanced version of it that Intermetrics used, hence my insistence on the term XPL/I instead. In order to create our modern HAL/S compiler, HALSFC, I first had to write an XPL/I compiler that I call XCOM-I, and then use XCOM-I to compile Intermetrics's source code for HAL/S-FC. There's a separate page dedicated to the XPL/I language and to XCOM-I. Neither topic will be mentioned further here, except in passing.
Aside: I intended the suffix "/I" in "XPL/I" to stand for "Intermetrics". But it happens that XPL was itself a dialect of the general-purpose computer language PL/I, so it's also possible to read "XPL/I" as being "PL/I" with a prefix of "X". This pun is entirely unintentional on my part, and I didn't even notice it for several years afterward, but I have to say I do like it!
Also of note: Prior to the very-painful decision to create XCOM-I, I had made a similarly-painful decision to manually port the source code for PASS1/PASS1B of HAL/S-FC into the Python 3 language. The result was a working version of PASS1/PASS1B that I call HAL_S_FC. This Python port remains very useful for cross-checking HALSFC, though it's no longer primarily intended to be run directly by developers. I've created no separate documentation for it beyond what's covered on the XCOM-I page, though I'll have some occasion below to mention it further.
As compiled by XCOM-I, the various passes of HAL/S-FC actually have filenames like HALSFC-PASS1[.exe] or HALSFC-OPTB[.exe].
I know that all of this probably seems very complex, and perhaps overly so. I sympathize! Fortunately for actual use, HALSFC has been designed to hide almost all of the internal complexity from the developer. So I hope that in practice you'll find operation of HALSFC to be more simple to use than the explanation so far implies.
HALSFC
As I've mentioned, the many pieces of the modern HAL/S compiler are referred to by the blanket name HALSFC, and HALSFC is the only program you need to invoke to compile a HAL/S program into IBM AP-101S object code.
Let's just briefly examine how to use HALSFC. Since we haven't yet covered how to install the program — that's covered in the next section! — you can't actually try out the commands I show you yet, but you can come back after installation and try them. Installation, unfortunately, does have some complexity associated with it, and I'd prefer to encourage you with the simplicity first, before discouraging you with the complexity. Besides, having a clear idea of what HALSFC can do and what it cannot do at present may help you to decide whether you want to install it at all.
Work with HALSFC is done from so-called "command line", because there's no graphical interface. So let's suppose you're at a command line with the current working directory being an empty one. Or rather, let's suppose that the directory is empty except for a simple-minded HAL/S file called HELLO.hal that looks like this:
text
DEBUG ¢D¢E¢F
HELLO: PROGRAM; DECLARE I INTEGER; DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); DECLARE INTEGER, J; REPLACE PRINTER BY "6"; WRITE(PRINTER) 'THE BEGINNING'; DO FOR I = 1 TO 5; WRITE(PRINTER) I, 'HELLO, WORLD!'; DO FOR J = 2 TO 8 BY 2; WRITE(PRINTER) J, MY_NAME, 'SAYS ISN''T THIS FUN?'; END; END; WRITE(6) 'THE END'; CLOSE HELLO;
What this program does isn't important, though most of it is just
silliness that's probably obvious at a glance. And other
than the first line, the rest is easily understood by consulting
Ryer's book. The first line is an example of a compiler
directive, which in this case is specific to the Intermetrics
implementation — so Ryer's book won't tell you anything about it —
and just affects what items appear in the compiler's
printouts. I've altered the background color of this snippet
of code to call attention to the fact that compiler directives
(and full-line comments) begin in column 1, whereas all code
begins or beyond column 2.
**HALSFC** itself is actually a Python script that compiles a
single HAL/S source-code file. (Or more accurately, it's
two scripts, in that it's really hard to run a Python
program from the command line in Windows, so there's an additional
batch script called HALSFC.bat that manages the bookkeeping
details of running **HALSFC** proper. But that's
essentially transparent to you, so you can now forget that I told
you about it!)
**HALSFC** is invoked like so:
> ```text
HALSFC [OPTIONS] SOURCEFILE.halActually, SOURCEFILE.hal
can come after the OPTIONS,
before them, or in the midst of them. The order is
insignificant. We'll cover the available OPTIONS later, but some
of the more-significant that are worth knowing about immediately
are:
--testcauses a validity check to be performed on the results of the compilation ... or more accurately, it comparison-tests the two available implementations of the PASS1 of the HAL/S compiler. The test is to compile the source file twice, once with HALSFC and once with HAL_S_FC (as mentioned above), and then to extensively compare the results. We have no means at present to similarly test subsequent passes of the compiler.--parms="PARAMETERS"specifies the "PARM field" covered in the section on compiler options. For example, it might look like--parms="SRN,LIST,LISTING2,X6,NOTABLES".-o OBJECTFILEcauses the output object-code file, by default "cards.bin" to be duplicated with the name OBJECTFILE.
Let's just try compiling HELLO.hal:
text
HALSFC HELLO.hal --parms="LIST"
After a short period of time we're told:
> ```text
Compilation successful. Results in "HALSFC HELLO.hal 2026-03-05 07-15-57.results".Or whatever your actual date and time is!
Our directory now contains both the HELLO.hal we started with, but also a lot of output files generated by the compiler, including a sub-directory called something like "HALSFC HELLO.hal 2026-03-05 07-15-57.results" that contains not only those files, but a lot more besides. Ouch! What's going on? Well, the extra files that are retained in your current working directory are all of the files generated by the compiler that I personally have found to be of immediate interest, and therefore that I suppose you might find of use as well: e.g., reports by the various passes (covered later) of the compiler, files needed for examining or emulating program execution using HALMAT, the AP-101S object file itself, and so on. What about the big "HALSFC ...".results directory? Well, that contains every file generated by the compiler, not just the ones I claim are "immediately interesting". A lot of these are covered later on. Every time you run HALSFC, a new "HALSFC ...".results directory is created.
As a convenience, if your operating system allows it, you'll also find some symbolic links to the results directories of recent HALSFC runs, so that if you do want to access the files in them, you don't have to keep typing awful directory names ("HALSFC ...".results) that are continuously changing:
- "current.results": The most-recent HALSFC run.
- "current-1.results": The run before that.
- "current-2.results": The run before that.
I'm told that some operating systems — I'm looking at you, Microsoft Windows — don't allow programs like HALSFC without administrative privileges to create these links, so ... too bad, Windows users.
Aside: Why maintain all of those extra files, and not just discard them? Perhaps one glorious day, when HALSFC is so mature that we have great confidence that it's 100% reliable, we'll do just that. As for today, though, it's not. And if we want to compile a complex HAL/S program that may consist of hundreds of source-code files (such as actual Shuttle flight software) I feel that it's a good idea to keep the compiler-generated files around to diagnose problems that are encountered. With that said, at present not everyone — by which I mean "no one" — has the same use-case for HALSFC that I do, and this arrangement for managing the files generated by HALSFC is not pleasing to everyone. To be honest, it's not very pleasing to me, either. So here are some things that may help you to manage the situation more to your liking:
- HALSFC's command-line option
--cleancauses all of the generated files (with some exceptions) to be cleared from the working directory and thus to be preserved only in the *.results directories. (The exceptions are the files for the template library, the include library, and the SDF library, all of which are covered later: TEMPLIB[B]/, TEMPLIB[B].json, INCLIB[B]/, INCLIB[B].json, and SDFLIB[B]. These are needed if you perform a series of HALSFC runs for related HAL/S files that together comprise a complete program, and so not having them would limit you to programs that are completely contained in a single HAL/S source-code file. If you are just experimenting with simple uses of HAL/S, one file at a time, you won't have these anyway.)- HALSFC's command-line option
--archivecauses all of the "HALSFC ...".results directories to be stored in a directory called archive.results/ rather than directly in the current working directory.
Of the files which are likely to be interesting, the one we usually look at first is the report (pass1.rpt) created by the "phase 1" compiler pass, which is where our HAL/S source code is parsed, and in which most or all errors will have been detected. Here's what that report looks like:
text
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 8, 2024 12:51:35.21 PAGE 1HAL/S COMPILER PHASE 1 -- VERSION OF AUGUST 8, 2024. CLOCK TIME = 4:31:2.00.
TODAY IS AUGUST 8, 2024. CLOCK TIME = 12:51:35.21.
PARM FIELD: LIST
COMPLETE LIST OF COMPILE-TIME OPTIONS IN EFFECT
*** TYPE 1 OPTIONS ***
NOADDRS
NODECK
NODUMP
NOHALMAT
NOHIGHOPT
LFXI
LIST
NOLISTING2
MICROCODE
NOREGOPT
NOSDL
NOSREF
NOSRN
NOTABDMP
TABLES
NOTABLST
NOTEMPLATE
NOVARSYM
ZCON
*** TYPE 2 OPTIONS ***
BLOCKSUM = 400
CARDTYPE =
COMPUNIT = 0
DSR = 1
LABELSIZE = 1200
LINECT = 59
LITSTRINGS = 2000
MACROSIZE = 500
MFID =
PAGES = 2500
SYMBOLS = 200
TITLE =
XREFSIZE = 2000*** NO LANGUAGE SUBSET IN EFFECT ***
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 8, 2024 12:51:35.21 PAGE 2 STMT SOURCE REVISION
D| EBUG `D`E`F |HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 8, 2024 12:51:35.21 PAGE 3 STMT SOURCE CURRENT SCOPE
1 M| HELLO: |HELLO 1 M| PROGRAM; |HELLO 2 M| DECLARE I INTEGER; |HELLO 3 M| DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); |HELLO 4 M| DECLARE INTEGER, J; |HELLO 5 M| REPLACE PRINTER BY "6"; |HELLO 6 M| WRITE(PRINTER) 'THE BEGINNING'; |HELLO ^^^^^^^ 7 M| DO FOR I = 1 TO 5; |HELLO 8 M| 1 WRITE(PRINTER) I, 'HELLO, WORLD!'; |HELLO ^^^^^^^ 9 M| 1 DO FOR J = 2 TO 8 BY 2; |HELLO
E| , |10 M| 2 WRITE(PRINTER) J, MY_NAME, 'SAYS ISN''T THIS FUN?'; |HELLO ^^^^^^^ 11 M| 1 END; |ST#9 12 M| END; |ST#7 13 M| WRITE(6) 'THE END'; |HELLO 14 M| CLOSE HELLO; |HELLO
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 8, 2024 12:51:35.21 PAGE 4
**** C O M P I L A T I O N L A Y O U T ****
HELLO: PROGRAM;
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 8, 2024 12:51:35.21 PAGE 5
S Y M B O L & C R O S S R E F E R E N C E T A B L E L I S T I N G :
(CROSS REFERENCE FLAG KEY: 4 = ASSIGNMENT, 2 = REFERENCE, 1 = SUBSCRIPT USE, 0 = DEFINITION)DCL NAME TYPE ATTRIBUTES & CROSS REFERENCE
1 HELLO PROGRAM FLAGS=20040, NEST=0, SCOPE=1, PTR=2, LENGTH=0, LINK1=-1, LINK2=0, SYT_NO=1, ARRAY=-8192, ADDR=0, CLASS=2, TYPE=73 XREF: 0 0001 2 I INTEGER SINGLE, ALIGNED, STATIC, FLAGS=808208, NEST=1, SCOPE=1, PTR=0, LENGTH=0, LINK1=0, LINK2=0, SYT_NO=2, ARRAY=0, ADDR=0, CLASS=1, TYPE=6 XREF: 0 0002 4 0007 2 0008 3 MY_NAME CHARACTER(20) ALIGNED, STATIC, INITIAL, FLAGS=8A08, NEST=1, SCOPE=1, PTR=0, LENGTH=20, LINK1=0, LINK2=0, SYT_NO=3, ARRAY=0, ADDR=0, CLASS=1, TYPE=2 XREF: 0 0003 2 0010 4 J INTEGER SINGLE, ALIGNED, STATIC, FLAGS=808208, NEST=1, SCOPE=1, PTR=0, LENGTH=0, LINK1=0, LINK2=0, SYT_NO=4, ARRAY=0, ADDR=0, CLASS=1, TYPE=6 XREF: 0 0004 4 0009 2 0010 5 PRINTER REPLACE MACRO FLAGS=C000, NEST=1, SCOPE=1, PTR=0, LENGTH=0, LINK1=0, LINK2=0, SYT_NO=5, ARRAY=0, ADDR=0, CLASS=6, TYPE=0, MACRO TEXT="6" XREF: 0 0005 2 0006 2 0008 2 0010
L I T E R A L T A B L E D U M P:
LOC TYPE LITERAL
1 ARITH 4214000000000000 2 CHAR RON BURKEY 3 ARITH 4160000000000000 4 CHAR THE BEGINNING 5 ARITH 4110000000000000 6 ARITH 4150000000000000 7 ARITH 4160000000000000 8 CHAR HELLO, WORLD! 9 ARITH 4120000000000000 10 ARITH 4180000000000000 11 ARITH 4120000000000000 12 ARITH 4160000000000000 13 CHAR SAYS ISN'T THIS FUN? 14 ARITH 4160000000000000 15 CHAR THE END
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 8, 2024 12:51:35.21 PAGE 6
OPTIONAL TABLE SIZESNAME REQUESTED USED ^^^^ ^^^^^^^^^ ^^^^
LITSTRINGS 2000 68 SYMBOLS 200 5 MACROSIZE 500 2 XREFSIZE 2000 13 BLOCKSUM 400 0
CALLS TO SCAN = 85 CALLS TO IDENTIFY = 14 NUMBER OF REDUCTIONS = 202 MAX STACK SIZE = 9 MAX IND. STACK SIZE = 5 END IND. STACK SIZE = 1 END ARRAY STACK SIZE = 0 MAX EXT_ARRAY INDEX = 1 STATEMENT COUNT = 14 MINOR COMPACTIFIES = 0 MAJOR COMPACTIFIES = 0 REALLOCATIONS = 0 MAX NESTING DEPTH = 1 FREE STRING AREA = 16620316
END OF HAL/S PHASE 1, AUGUST 8, 2024. CLOCK TIME = 12:51:35.22.
17 CARDS WERE PROCESSED. NO ERRORS WERE DETECTED DURING PHASE 1 .
NUMBER OF FILE 6 LOCATES = 1 NUMBER OF FILE 6 READS = 0 NUMBER OF FILE 6 WRITES = 0
TOTAL CPU TIME FOR PHASE 1 0:0:0.02. CPU TIME FOR PHASE 1 SET UP 0:0:0.01. CPU TIME FOR PHASE 1 PROCESSING 0:0:0.00. CPU TIME FOR PHASE 1 CLEAN UP 0:0:0.01.
There's lots of information here, though the most-significant
thing is probably the message "NO ERRORS WERE DETECTED DURING
PHASE 1". What phase 1 (PASS1) has accomplished is mostly to
output a processed form of our HAL/S program as expressed in an
"intermediate language" called HALMAT. The HALMAT form of
the program is the file halmat.bin.
After phase 1, the compiler then proceeded to further process
halmat.bin, using the "phase 1.5" programs (FLO, OPT, and
AUXP). Those programs don't *usually* produce useful
reports, at least not by default. However, what they do is
to "optimize" the HALMAT, producing new HALMAT-related files
called optmat.bin and auxmat.bin. **Note:**
optmat.bin is a valid HALMAT file, and can be parsed with **unHALMAT.py**; auxmat.bin is not, and cannot.
<a id="report2"></a>The "phase 2" program (PASS2) then pulls in
all of those HALMAT and HALMAT-related files, and generates
AP-101S object code from them. Let's look at PASS2's report,
pass2.rpt:
> ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF AUGUST 8, 2024. CLOCK TIME = 4:32:17.00
HAL/S PHASE 2 ENTERED AUGUST 8, 2024. CLOCK TIME = 12:51:35.64
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 2
SYMBOL TYPE ID ADDR LEN(HEX) LEN(DEC) BLOCK NAME
$0HELLO SD 0001 000000 000040 64 HELLO
#EHELLO SD 0002 000000 000006 6
#DHELLO SD 0003 000000 000033 51
@0HELLO ER 0004
#QIOINIT ER 0005
#QCOUT ER 0006
#QHOUT ER 0007
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 3
LOC CODE EFFAD LABEL INSN OPERANDS SYMBOLIC OPERAND
0000000 ST#1 EQU *
00000 #EHELLO CSECT ESDID= 0002
00000 0000 DC X'0000'
00001 0000 DC X'0000'
00002 00000700 DC A'00000700' #DHELLO
00004 0000 DC X'0000'
00005 0000 DC X'0000'
00000 $0HELLO CSECT ESDID= 0001
0000000 HELLO EQU *
00000 E8F3 0000 LHI R0,0() @0HELLO
00002 E9F3 0000 LHI R1,0() #DHELLO
00004 B914 0005 STH R1,5(R0)
00005 E0FB 0014 IAL R0,20()
00007 EB11 0004 LA R3,4(R1)
00008 BB24 0009 STH R3,9(R0)
0000009 ST#2 EQU *
0000009 ST#3 EQU *
00009 #DHELLO CSECT ESDID= 0003
00009 000008 ORG *-1
00008 140A524F DC X'140A524F'
0000A 4E204255 DC X'4E204255'
0000C 524B4559 DC X'524B4559'
000000E ST#4 EQU *
000000E ST#5 EQU *
000000E ST#6 EQU *
00009 $0HELLO CSECT ESDID= 0001
00009 BEE8 LFXI R6,6
0000A BDE5 LFXI R5,3
0000B D0FF 3800 SCAL@# R0,0(R1,R3) #QIOINIT
0000D EAAD 002B LA R2,43(R1) C'THE BEGINNING'
0000E D0FF 3800 SCAL@# R0,0(R1,R3) #QCOUT
0000010 ST#7 EQU *
00010 BFE3 LFXI R7,1
00011 DF84 0033 BCF 7,*+34 B LBL#3 (WITHIN ST#12)
0000012 LBL#4 EQU *
0000012 ST#8 EQU *
00012 BEE8 LFXI R6,6
00013 BDE5 LFXI R5,3
00014 D0FF 3800 SCAL@# R0,0(R1,R3) #QIOINIT
00016 1DE7 LR R5,R7
00017 D0FF 3800 SCAL@# R0,0(R1,R3) #QHOUT
00019 EA8D 0023 LA R2,35(R1) C'HELLO, WORLD!'
0001A D0FF 3800 SCAL@# R0,0(R1,R3) #QCOUT
000001C ST#9 EQU *
0001C BCE4 LFXI R4,2
0001D DF3C 002D BCF 7,*+16 B LBL#5 (WITHIN ST#11)
000001E LBL#6 EQU *
000001E ST#10 EQU *
0001E BEE8 LFXI R6,6
0001F BDE5 LFXI R5,3
00020 D0FF 3800 SCAL@# R0,0(R1,R3) #QIOINIT
00022 1DE4 LR R5,R4
00023 D0FF 3800 SCAL@# R0,0(R1,R3) #QHOUT
00025 EA21 0008 LA R2,8(R1) MY_NAME
00026 D0FF 3800 SCAL@# R0,0(R1,R3) #QCOUT
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 4
LOC CODE EFFAD LABEL INSN OPERANDS SYMBOLIC OPERAND
00028 EA61 0018 LA R2,24(R1) C'SAYS ISN'T THIS FUN?'
00029 D0FF 3800 SCAL@# R0,0(R1,R3) #QCOUT
000002B ST#11 EQU *
0002B BCE4 LFXI R4,2
0002C 840F 0007 AH R4,3(R3) J
000002D LBL#5 EQU *
0002D BC0F 0007 STH R4,3(R3) J
0002E B5E4 0008 CHI R4,8
00030 DE4E 001E BCB 6,*-18 BLE LBL#6 (WITHIN ST#9)
0000031 LBL#7 EQU *
0000031 ST#12 EQU *
00031 BFE3 LFXI R7,1
00032 870B 0006 AH R7,2(R3) I
0000033 LBL#3 EQU *
00033 BF0B 0006 STH R7,2(R3) I
00034 B5E7 0005 CHI R7,5
00036 DE96 0012 BCB 6,*-36 BLE LBL#4 (WITHIN ST#7)
0000037 LBL#8 EQU *
0000037 ST#13 EQU *
00037 BEE8 LFXI R6,6
00038 BDE5 LFXI R5,3
00039 D0FF 3800 SCAL@# R0,0(R1,R3) #QIOINIT
0003B EA4D 0013 LA R2,19(R1) C'THE END'
0003C D0FF 3800 SCAL@# R0,0(R1,R3) #QCOUT
000003E ST#14 EQU *
000003E LBL#2 EQU *
0003E C9F9 0000 0000 SVC 0(R1) H'21', X'0015'
0000E #DHELLO CSECT ESDID= 0003
0000E 000000 ORG *-14
00000 0015 DC X'0015'
00004 000013 ORG *+15
00013 00075448 DC X'00075448'
00015 4520454E DC X'4520454E'
00017 4400 DC X'4400'
00018 00145341 DC X'00145341'
0001A 59532049 DC X'59532049'
0001C 534E2754 DC X'534E2754'
0001E 20544849 DC X'20544849'
00020 53204655 DC X'53204655'
00022 4E3F DC X'4E3F'
00023 000D4845 DC X'000D4845'
00025 4C4C4F2C DC X'4C4C4F2C'
00027 20574F52 DC X'20574F52'
00029 4C442100 DC X'4C442100'
0002B 000D5448 DC X'000D5448'
0002D 45204245 DC X'45204245'
0002F 47494E4E DC X'47494E4E'
00031 494E4700 DC X'494E4700'
END
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 5
RLD INFORMATION
POS.ID (P) IS THE ESDID OF SD FOR THE CONTROL SECTION THAT CONTAINS THE ADDRESS CONSTANT
REL.ID (R) IS THE ESDID OF ESD ENTRY FOR THE SYMBOL BEING REFERRED TO
FLAG TYPE ACTION PERFORMED
V00000ST YCON RELOCATION FACTOR IS ADDED TO ADDRESS CONSTANT. IF ADDRESS IS GREATER THAN 15 BITS, SET BIT "0" ON.
000001ST ACON RELOCATION FACTOR IS ADDED TO ADDRESS CONSTANT.
V00100ST ZCON ADD RELOCATION FACTOR TO FIRST HALFWORD. IF GREATER THAN 15 BITS, UPDATE BSR FIELD.
(BRANCH RELOCATION FOR 32-BIT BRANCH)
V10000ST ZCON UPDATE DSR FIELD WITH HIGH ORDER 4 BITS OF THE 19-BIT RELOCATION FACTOR.
(DATA RELOCATION FOR 32-BIT BRANCH)
V01000ST ZCON UPDATE BSR FIELD WITH HIGH ORDER 4 BITS OF THE 19-BIT RELOCATION FACTOR.
(BRANCH RELOCATION FOR 32-BIT DATA)
V10100ST ZCON ADD RELOCATION FACTOR TO FIRST HALFWORD. IF GREATER THAN 15-BITS, UPDATE DSR FIELD.
(DATA RELOCATION FOR 32-BIT DATA)
V = SIGN OF THE YCON IN THE TEXT RECORD
0 = THE YCON IS POSITIVE
1 = THE YCON IS THE ABSOLUTE VALUE OF A NEGATIVE NUMBER
S = DIRECTION OF RELOCATION
0 = POSITIVE
1 = NEGATIVE
T = TYPE OF NEXT RLD ITEM
0 = NEXT RLD ITEM HAS DIFFERENT R OR P POINTERS; THEY ARE IN THE NEXT ITEM
1 = NEXT RLD ITEM HAS SAME R AND P POINTERS; HENCE THEY ARE OMITTED
POS.ID CSECT(P) ADDRESS FLAGS REL.ID CSECT(R)
0001 $0HELLO 000001 00 0004 @0HELLO
0001 $0HELLO 000003 00 0003 #DHELLO
0001 $0HELLO 00000C 00 0005 #QIOINIT
0001 $0HELLO 00000F 00 0006 #QCOUT
0001 $0HELLO 000015 00 0005 #QIOINIT
0001 $0HELLO 000018 00 0007 #QHOUT
0001 $0HELLO 00001B 00 0006 #QCOUT
0001 $0HELLO 000021 00 0005 #QIOINIT
0001 $0HELLO 000024 00 0007 #QHOUT
0001 $0HELLO 000027 00 0006 #QCOUT
0001 $0HELLO 00002A 00 0006 #QCOUT
0001 $0HELLO 00003A 00 0005 #QIOINIT
0001 $0HELLO 00003D 00 0006 #QCOUT
0002 #EHELLO 000002 10 0001 $0HELLO
0002 #EHELLO 000002 40 0003 #DHELLO
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 6
VARIABLE OFFSET TABLE
LOC IS THE CSECT-RELATIVE ADDRESS IN HEX OF THE DECLARED VARIABLE.
B IS THE BASE REGISTER USED FOR ADDRESSING THE DECLARED VARIABLE. IF B IS NEGATIVE, THIS IS A VIRTUAL REGISTER AND CODE
MUST BE GENERATED TO LOAD A REAL REGISTER.
DISP IS THE DISPLACEMENT USED FOR GENERATING BASE-DISPLACEMENT ADDRESSES FOR ACCESSING THE DATA ITEMS.
LENGTH IS THE SIZE IN DECIMAL HALFWORDS OF THE VARIABLE.
BIAS IS THE AMOUNT OF THE ZEROTH ELEMENT OFFSET.
NAME IS THE NAME OF THE VARIABLE.
LOC B DISP LENGTH BIAS NAME
UNDER HELLO STACK=20
000006 1 006 1 0 I
000008 1 008 11 0 MY_NAME
000007 1 007 1 0 J
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 7
MEMORY MAP FOR DATA CSECT #DHELLO
NAME LEN(DEC) OFFSET(DEC) B DISP(HEX) SCOPE
**LOCAL BLOCK DATA** 2 4 HELLO
I 1 6 1 0006 HELLO
J 1 7 1 0007 HELLO
MY_NAME 11 8 1 0008 HELLO
TOTAL SIZE OF ALIGNMENT GAPS FOR CSECT: 0 HW
INSTRUCTION FREQUENCIES
INSN COUNT
LFXI 12
LR 2
STH 4
LA 6
AH 2
SCAL 11
IAL 1
BCB 2
BCF 2
SVC 1
LHI 2
CHI 2
OPTIONAL TABLE SIZES
NAME REQUESTED USED
^^^^ ^^^^^^^^^ ^^^^
LITSTRINGS 2000 68
LABELSIZE 1200 8
42 HALMAT OPERATORS CONVERTED
47 INSTRUCTIONS GENERATED
70 HALFWORDS OF PROGRAM, 51 HALFWORDS OF DATA.
MAX. OPERAND STACK SIZE =9
END OPERAND STACK SIZE =0
MAX. STORAGE DESCRIPTOR STACK SIZE =1
END STORAGE DESCRIPTOR STACK SIZE =0
NUMBER OF MINOR COMPACTIFIES =0
NUMBER OF MAJOR COMPACTIFIES =0
NUMBER OF REALLOCATIONS =5
FREE STRING AREA =16623408
END OF HAL/S PHASE 2 AUGUST 8, 2024. CLOCK TIME = 12:51:35.65
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 8
TOTAL CPU TIME FOR PHASE 2 0:0:0.01
CPU TIME FOR PHASE 2 SET UP 0:0:0.00
CPU TIME FOR PHASE 2 GENERATION 0:0:0.00
CPU TIME FOR PHASE 2 CLEAN UP 0:0:0.01The most-significant thing about PASS2's report is probably that it gives us a glimpse — well, actually a full listing ... sort of! — of the assembly-language into which the compiler has transformed our HAL/S sample program. PASS2 doesn't actually default to putting such a listing in its report. It only did so in this case because we compiled it with the LIST option. After all, software that's merely printed in a report has very little use from the computer's point of view. But I've included it in the report as eye candy! You can read more about it in the document "Space Shuttle Model AP-101S Principles of Operation, with Shuttle Instruction Set".
But useful object code is emitted by the PASS/PFS version of the HAL/S compiler in the form of a file, called cards.bin. The cards.bin object file is what would be used by a linker or loader, apparently called just the "AP101 linker". As for the object file, though containing IBM AP-101S PASS/PFS object code, it is in the OS/360 Object File Format ... or at least, according to my write-up of it, very close to that format! If you're curious what's in an object file but don't want to read a description, I've provided a program that can parse the object file for you:
text
readObject101S.py cards.bin
The BFS version of the HAL/S compiler is entirely different in this
respect: It used an entirely different linker, PILOT, which
stood for Program Integration and Loading Tool. Moreover, the
BFS compiler outputs object code in the form of a PDS (Partitioned
Data Set), cards/, which is in PILOT-compatible format. There
is no surviving information available about PILOT that I'm aware of,
but fortunately [its
format has in fact been decoded](https://www.ibiblio.org/apollo/HALLINK101S.html), or at least mostly so.
Rather than compiling HELLO.hal using the command given earlier,
you might compile it using the command
> ```text
HALSFC HELLO.hal --test --parms="LIST,LISTING2"The difference, you'll recall, is that --test
additionally performs some verification of the compiler
results. LISTING2
means to produce a secondary, "unformatted" source-code listing.
In fact, here are the messages we get,
text
====================================================== PASS1 cross-comparison test: Files pass1A.rpt and pass1pA.rpt are identical Files FILE1.bin and halmat.bin are identical Files LISTING2p.txt and listing2.txt are identical
Compilation successful. Results in "HALSFC Wed 08-21-2024 7-39-24.00.results".
What we're told is that essentially the same compilation has been
performed as before, but that additionally we gained some
confidence that the various of the compiler outputs are correct in
the sense that the two compilers available to us, **HALSFC**
and **HAL\_S\_FC**, produce identical results, even down to the
reports they generate. By the way, the secondary listing
triggered by the LISTING2 compiler-option looks like this:
> ```text
1 H A L C O M P I L A T I O N -- P H A S E 1 -- U N F O R M A T T E D S O U R C E L I S T I N G PAGE 1
- D| EBUG `D`E`F | 1
0 1 M| | 2
0 1 M| HELLO: PROGRAM; | 3 HELLO
0 1 M| DECLARE I INTEGER; | 4 HELLO
0 2 M| DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); | 5 HELLO
0 3 M| DECLARE INTEGER, J; | 6 HELLO
0 4 M| REPLACE PRINTER BY "6"; | 7 HELLO
0 5 M| WRITE(PRINTER) 'THE BEGINNING'; | 8 HELLO
0 6 M| DO FOR I = 1 TO 5; | 9 HELLO
0 7 M| WRITE(PRINTER) I, 'HELLO, WORLD!'; | 10 HELLO
0 8 M| DO FOR J = 2 TO 8 BY 2; | 11 HELLO
0 9 M| WRITE(PRINTER) J, MY_NAME, 'SAYS ISN''T THIS FUN?'; | 12 HELLO
0 10 M| END; | 13 HELLO
0 11 M| END; | 14 HELLO
0 12 M| WRITE(6) 'THE END'; | 15 HELLO
0 13 M| CLOSE HELLO; | 16 HELLOThe characters in column 1 of this report are so-called ANSI control characters, as described later, and they affect the format when the report is printed on an IBM line-printer, assuming anyone still has such a thing on which to print the report.
The next compiler pass, Phase 3 (PASS3) is a little trickier to understand, in that it creates something called a Simulation Data File (SDF) for your HAL/S file and storing it in an "SDF library" for later use. The SDF library is just a local directory, and the SDF is just a file (called "##HELLO .sdf"; filenames are always exactly 8 characters) in that directory. An SDF is something like a glorified symbol table that's useful in (surprise!) running your program in a digital simulation. Like I did for a long time, you may be thinking, Aha! I have no use for this, since I don't have access to the simulation environment in which this would be used! True, and at the same time, not true. It turns out that the original developers figured out that these SDFs were of use not in the current compilation, but rather in later compilations of other HAL/S files that depend on the file currently being compiled. Therefore, you actually do need the SDF unless you're doing something a extraordinarily simple as compiling HELLO.hal. The report from PASS3 is singularly uninformative, but it's short, so here it is in all its glory:
text
PAGE 1
HAL/S COMPILER PHASE 3 -- VERSION OF AUGUST 3, 2026. CLOCK TIME = 19:25:45.00
HAL/S PHASE 3 ENTERED AUGUST 4, 2026. CLOCK TIME = 6:22:30.19
SIMULATION DATA FILE ##HELLO HAS BEEN CREATED
NUMBER OF FILE 6 LOCATES = 1 NUMBER OF FILE 6 READS = 0 NUMBER OF FILE 6 WRITES = 0
PAGING AREA SIZE (PAGES) = 398 NUMBER OF LOCATES = 304
PREDICTED SDF SIZE (PAGES) = 3 ACTUAL SDF SIZE (PAGES) = 2
DIRECTORY FREE SPACE (BYTES) = 60 DATA FREE SPACE (BYTES) = 60 SDF SIZE (BYTES) = 1694 SDF DENSITY (%) = 50 NUMBER OF BLOCK NODES = 1 NUMBER OF SYMBOL NODES = 6 NUMBER OF STATEMENT NODES = 15
NUMBER OF BLOCKS DELETED = 0 NUMBER OF SYMBOLS DELETED = 0 NUMBER OF TEMPLATES DELETED = 0 NUMBER OF MINOR COMPACTIFIES = 0 NUMBER OF MAJOR COMPACTIFIES = 0 NUMBER OF REALLOCATIONS = 0
END OF HAL/S PHASE 3 AUGUST 4, 2026. CLOCK TIME = 6:22:30.22 TOTAL CPU TIME IN PHASE 3 0:0:0.04 CPU TIME FOR PHASE 3 INITIALIZATION 0:0:0.01 CPU TIME FOR PHASE 3 FILE GENERATION 0:0:0.00 CPU TIME FOR PHASE 3 FILE EMISSION 0:0:0.03
The final compiler pass, Phase 4 (PASS4), is much easier to
understand in principle: It simply writes reports about the
SDF just created, or about the contents of the SDF library in
general. What isn't so easy to understand is this: PASS4 can
produce four different kinds of reports, known as BRIEF, TABLST,
TABDMP, and ALL ... but only *two* of those (TABLST, TABDMP)
can be selected via [compiler
options](#moron)., while two (BRIEF, ALL) cannot. Indeed, by **HALSFC**
default (NOTABST, NOTABDMP), PASS4 receives no parameters at all
and just produces an empty report. Isn't that fun? A
report-generation program that runs by default but by default
generates no results! Sounds like Congress. Who says
the Shuttle wasn't ahead of its time? Nevertheless, you can
produce TABLST and/or TABDMP reports by specifying their
parameters at compile-time.
As for the BRIEF or ALL reports, you have to do something unusual
among the compiler's passes, which is to run PASS4 *stand-alone*
rather than as part of the compilation process. The original
Shuttle developers even assigned their own name to PASS4 when run
in that fashion, namely **SDFLIST**, and we may as well do
that too, to run PASS4 for you in stand-alone fashion. Just
typing "`SDFLIST`" will give you an explanation of the
options available, but I'll show you some too, so that we can see
some of the reports available.
> **Note:** The *gotcha!*
> here is that to invoke **SDFLIST** you usually have to
> supply the name of particular SDFs you're interested in ... and
> those are *never* the name of the HAL/S file itself:
>
> - start with the name of the HAL/S object;
> i.e., the name of the `PROGRAM`, `PROCEDURE`,
> `FUNCTION`, or `COMPOOL` *within*
> the source file
> - remove all underscore characters
> - truncate to 6 characters
> - prefix by "##"
>
> So in the case of HELLO.hal, it contains a `PROGRAM`
> called `HELLO`, and that translates to an SDF name
> of "`##HELLO`". The enclosing double-quotes
> are necessary when you use that name on the command line, at
> least in Linux or Mac OS, because the characters `##`
> would otherwise be treated as the beginning of a comment, and
> the remainder of the command line would be ignored.
> Sounds easy! Well, yes, for HELLO.hal it is. For a
> file called RUN\_A\_TEST.hal that contains a procedure called "`MY_TEST_46`",
> you'd have to compile RUN\_A\_TEST.hal but generate reports for
> "`##MYTEST`". The report from the compiler's
> PASS3, as you'll notice in the cut-and-paste above, does tell
> you the name, if you have any doubts or are too lazy to figure
> it out: "`SIMULATION DATA FILE ##HELLO HAS BEEN
> CREATED`".
> **Note:** Any
> place that **SDFLIST** accepts the name of an SDF, it
> can actually accept any number of SDF names, separated by
> spaces. I won't bother to demo that.
By default, **SDFLIST** produces TABLST reports, as for
example
> ```text
SDFLIST "##HELLO"We will abridge most of the reports I show you below, but lets see the TABLST report in all its glory:
text
S D F L I S T REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 5, 2026 6:34:25.27 PAGE 1
SDFLIST -- VERSION OF AUGUST 4, 2026. CLOCK TIME = 15:8:46.00
TODAY IS AUGUST 5, 2026. CLOCK TIME = 6:34:25.27
PARM FIELD: TABLST
S D F L I S T REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 5, 2026 6:34:25.27 PAGE 2
FORMATTED DUMP OF SDF ##HELLO
D I R E C T O R Y D A T A
FLAGS: SRN,FC,NON_UNIQUE_SRNS
COMPUNIT: 0
# OF LAST PAGE: 1
DATE/TIME: AUGUST 5, 2026. CLOCK TIME = 6:3:18.25
SDF VERSION #: 35
# OF LAST DIRECTORY PAGE: 0
# OF EXTERNAL BLOCKS: 0
# OF BLOCKS: 1
# OF SYMBOLS: 6
# OF EMITTED INSTRUCTIONS: 51
FREE SPACE (BYTES): 568
LIST HEAD PTR (ALPHABETIC): 1
LITERAL ADDRESS (#D): 30
LIST HEAD PTR (#D#P DATA): 1
START OF INITIAL LITERAL AREA (#D) : 0
END OF INITIAL LITERAL AREA (#D) : 0
ROOT OF HIERARCHY TREE: 1 HELLO
ROOT OF ALPHABETICAL TREE: 1 HELLO
FIRST STMT #: 1
LAST STMT #: 15
# OF EXECUTABLE STMTS: 10
TOTAL # OF STMTS: 15
BLOCK # OF COMP. UNIT: 1
SYMBOL # OF COMP. UNIT: 1
NUMBER OF STACK WALKS: 0
FIRST SRN & INCLUDE COUNT: 0
LAST SRN & INCLUDE COUNT: 0
SYMBOLS 6/200
MACROSIZE 2/500
LITSTRINGS 75/2000
XREFSIZE 14/2000
CARDTYPE: FCRMUDVMWCXCYCZMS D F L I S T REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 5, 2026 6:34:25.27 PAGE 3 BLOCK# NAME TYPE CLASS FLAGS
B L O C K D A T A
1 HELLO PROGRAM
CSECT NAME = $0HELLO SYM# OF BLOCK NAME = 1
TEMPLATE VERSION = 1
STACK ID = 1
SYMBOLS = 1 TO 6 STMTS = 1 TO 15
FIRST POST-DECLARE STMT = 7S D F L I S T REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 5, 2026 6:34:25.27 PAGE 4 SYMB# NAME TYPE CLASS FLAGS
S Y M B O L D A T A****************** BLOCK: 1 HELLO
1 HELLO PROGRAM LABEL LATCHED,BLOCK_DATA
ALPHABETIC LINK = 2 ADDRESS LINK = 2 PHASE1 LINK = 2
LABEL DEFINED ON STMT 1
ADDRESS = 00000004( 4) SIZE = 00000002( 2)
CROSS REFERENCE: 0 0001
2 I SP INTEGER VARIABLE
ALPHABETIC LINK = 3 ADDRESS LINK = 3 PHASE1 LINK = 5
ADDRESS = 00000006( 6) SIZE = 00000001( 1)
CROSS REFERENCE: 0 0002 4 0008 2 0009
3 J SP INTEGER VARIABLE
ALPHABETIC LINK = 4 ADDRESS LINK = 5 PHASE1 LINK = 6
ADDRESS = 00000007( 7) SIZE = 00000001( 1)
CROSS REFERENCE: 0 0005 4 0010 2 0011
4 MY_NAME CHARACTER VARIABLE INITIAL
ALPHABETIC LINK = 5 ADDRESS LINK = 0 PHASE1 LINK = 3
ADDRESS = 00000013( 19) SIZE = 0000000B( 11)
CHARACTER(20)
CROSS REFERENCE: 0 0004 2 0011
5 POOKIE CHARACTER VARIABLE
ALPHABETIC LINK = 6 ADDRESS LINK = 4 PHASE1 LINK = 4
ADDRESS = 00000008( 8) SIZE = 0000000B( 11)
CHARACTER(20)
CROSS REFERENCE: 0 0003
6 PRINTER REPLACE LABEL
PHASE1 LINK = 0
REPLACE TEXT(1 BYTE): "6"
CROSS REFERENCE: 0 0006 2 0007 2 0009 2 0011 S D F L I S T REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 5, 2026 6:34:25.27 PAGE 5 STMT# TYPE SRN INCL ORIG SRN
S T A T E M E N T D A T A****************** BLOCK: 1 HELLO
1 BLOCK 0 LABEL(S): 1=HELLO
2 DECLARE 0
3 DECLARE 0
4 DECLARE 0
5 DECLARE 0
6 REPLACE 0
7 WRITE 0
8 DO FOR 0 TARGET(S): 2=I
9 WRITE 0 RHS VARS: 2=I 10 DO FOR 0 TARGET(S): 3=J
11 WRITE 0 RHS VARS: 3=J, 4=MY_NAME
12 END 0
13 END 0
14 WRITE 0
15 CLOSE 0
S D F L I S T REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 5, 2026 6:34:25.27 PAGE 6
END OF SDFLIST AUGUST 5, 2026. CLOCK TIME = 6:34:25.27
NUMBER OF SDFPKG LOCATES = 91 NUMBER OF SDFPKG READS = 1 NUMBER OF SDFPKG SELECTS = 2 NUMBER OF SDFPKG GETMAINS = 0 SDFPKG FCB AREA SIZE (BYTES) = 2048 SDFPKG PAGING AREA SIZE (PAGES) = 5
NUMBER OF MINOR COMPACTIFIES = 0 NUMBER OF MAJOR COMPACTIFIES = 0 NUMBER OF REALLOCATIONS = 0
TOTAL CPU TIME IN SDFLIST 0:0:0.01
The command line to get a TABDMP report would instead be:
> ```text
SDFLIST --tabdmp "##HELLO"But since TABDMP reports are mostly just hexadecimal listings of the SDF files, I won't bother to show you a sample. That's left as an exercise for the reader. Similarly, a BRIEF report,
text
SDFLIST --brief "##HELLO"
is just a shortened form of a TABLST.
Finally, there's `SDFLIST --all`. What
distinguishes --all is that you no longer have to select a
specific SDF (or SDFs), but can simply get a report for every SDF
in the SDF library, all at once, integrated into a single report.
Or, you could add either of the switches `--brief` or
`--tabdmp` along with `--all` to get a
shortened combined report or a TABDMP combined report.
# <a id="Installation"></a>Installation of HALSFC
Because development of software-development tools related to the
Space Shuttle remains somewhat rapid at this writing, installation
methods continue to be somewhat ponderous. Hopefully this
situation will improve in the future, and installation will be
slicker and smoother. For now, ... well, I apologize for the
inconvenience.
## <a id="properHALSFC"></a>The Compiler(s) and Assembler
I daresay that the easiest approach for installing the HAL/S
compiler(s) (**HALSFC** and **HAL\_S\_FC.py**) and the
AP-101S assembler (**ASM101S**) is just to install [a Virtual
AGC virtual-machine image](https://www.ibiblio.org/apollo/download.html), and run this VM under VirtualBox,
VMware, QEMU, Hyper-V, Parallels, or whatever. This gives
you the entire system of Virtual AGC software (*including*
the Shuttle development tools), preinstalled and preconfigured on
the VM.
> **Important
> note:** Since the VM is a large download, it's not
> updated too often on our download page. Whereas all HAL/S
> and AP-101S related material is currently undergoing
> relatively-rapid change. Therefore, *as downloaded*,
> the VM is not likely to contain the *latest* version of
> Shuttle-related material. After the VM is running, you'll
> therefore want to take the step of immediately updating its
> Virtual AGC installation via the provided desktop icon.
But if you don't have the admittedly large amount of space needed
for the VM, or simply don't want to work inside of a Linux VM, you
can instead follow the installation instructions below for Linux,
Mac OS, or Windows.
1. [Install
**XCOM-I**, per the instructions on the XPL/I page](https://www.ibiblio.org/apollo/XPL-I.html#Installation).
2. (Optional in principle, but very strongly recommended.)
Verify that **XCOM-I** works, by following the instructions
appropriate to your computer type, as given in the following
sections of the XPL/I page:
> - [Testing the
> Installation](https://www.ibiblio.org/apollo/XPL-I.html#testTheInstallation)
> - [Emulating
> the IBM System/360 CPU](https://www.ibiblio.org/apollo/XPL-I.html#sim360)
> - [Insane
> Bootstrapping!](https://www.ibiblio.org/apollo/XPL-I.html#compilingXCOM)
3. Build HALS/S-FC executable files, using [the
instructions on the XPL/I page](https://www.ibiblio.org/apollo/XPL-I.html#halsfc).
4. Install the AP-101S assembler, using [the
instructions on the ASM101S page](https://www.ibiblio.org/apollo/ASM101S.html#Installation).
For the true enthusiast using Microsoft Windows, I've found a
peculiar [extension
for Microsoft Visual Studio, namely "HAL/S NASA Space Shuttle
Language", by Zane Hambly](https://marketplace.visualstudio.com/items?itemName=ZaneHambly.hals-lsp). Of course, the extension
only helps with editing HAL/S source code, providing such stuff as
syntax highlighting. There's no compiler, emulator, or
anything of that nature. Not being a Windows user myself,
I've naturally not tried out this extension personally, so I'm in
no position to evaluate it beyond noting the fun fact of its
existence.
## <a id="linkerAndEmulators"></a>Linker and Emulators
There are several tools you'll see used on this page that are
related to the HAL/S-FC compiler(s) and AP-101S assembler, but
that are nevertheless not installed by the instructions
above. These tools are:
- The AP-101S object-file linker (**lnk101**)
- The AP-101S CPU emulator(s) (**gpc** *et al*.)
- The HALMAT emulator(s) (**yaHALMAT2** *et al.*)
If you want to *run* any HAL/S programs, you need either **yaHALMAT2**
or else **lnk101**+**gpc**. And if you have both, all
the better! For installation/usage instructions, see [our linker page](https://www.ibiblio.org/apollo/HALLINK101S.html)
and [our
emulation page](https://www.ibiblio.org/apollo/emulation-shuttle.html).
# <a id="wildThings"></a>Where the Wild HAL/S Files Are
Naturally, the most-important HAL/S source-code files for us *would*
be the PASS and BFS source-code files of the Space Shuttle.
Or Galileo source code. But constraints placed on me by
individuals and fear of potential constraints by government
agencies prevent me from disseminating any such code at
present. I do look forward to the time when I'm allowed to
freely post PASS and BFS source code for you, or when somebody
else lifts the burden from my shoulders and does it for me.
Whilst awaiting some unexpected outbreak of common sense that
would allow me to do so, however, it would be nice to have some
HAL/S source-code files other than files like HELLO.hal that we
have to write for ourselves! Fortunately, several groups of
source-code files are available in the Virtual AGC source tree:
- [Ryer's
book *Programming in HAL/S* 2nd edition](https://www.ibiblio.org/apollo/Shuttle/Programming%20in%20HAL_S%20Sept%201978.pdf) (or [first
edition](https://www.ibiblio.org/apollo/Shuttle/NASA-CR-151872%20-%20Programming%20in%20HAL-S.pdf)) is a rich source of source code and documentation
for it. [A
hundred or so short source-code files have been extracted from
Ryer](https://github.com/virtualagc/virtualagc/tree/master/yaShuttle/Source%20Code/Programming%20in%20HAL-S).
- One of the Intermetrics crew sent in a dozen or so unofficial
but contemporary (though alas undocumented) [source-code
files intended to demonstrate capabilities of HAL/S](https://github.com/virtualagc/virtualagc/tree/master/yaShuttle/Source%20Code/BENCH).
- [The
HAL-S-360 Users Manual](https://www.ibiblio.org/apollo/Shuttle/19740017615.pdf#page=35) provides [a
source-code file called DEMO.hal](https://github.com/virtualagc/virtualagc/tree/master/yaShuttle/Source%20Code/HAL-S-360%20Users%20Manual).
> **Aside:** The Users Manual's
> description of DEMO.hal is also interesting because it also
> shows us what the original compiler listing was supposed to look
> like. That listing is not *quite* the same as ours
> today. But given that it was a version of the HAL/S
> compiler 30 years younger than ours, and that the compiler used
> was HAL/S-360 rather than HAL/S-FC, it's hardly surprising that
> there are some differences.
There may be other HAL/S source code among our collected
documentation (or elsewhere!) that I've overlooked. If you are
aware of any — or for that matter, *have* any! — let me know.
But regarding the contemporary PASS and BFS source code on hand,
there's a complete lack of provenance for it. I.e., *somebody*
collected it at some point, after which it passed through *some
number of hands*, and finally reached me. Answers to the
questions of who, when, where, why, or how are unanswered.
That uncertainty, combined with the non-specificity of software
versioning of the surviving Shuttle documentation (such as the
Flight Readiness Reviews), in spite of its monstrous mass of
bureaucratic volume, actually leaves us guessing a little bit as to
exactly what we have. Indeed, if you like, you can maintain a
completely skeptical attitude and say that none of it is what I
purport it to be. But if so, greater the fool you are for
reading this far! As far as I know, though, not even the
greatest (if there is such a thing) moon-landing denier has ever
claimed that there's no such thing as a Space Shuttle. (I
suppose that must be the province of the flat-earthers, though I'm
not interested enough to google it and find out.)
> **Aside:** Amusingly, that
> appears to me to be a valid defense if someone, somewhere, were
> to release this code freely to the public: Since no
> commercial or government organization, including NASA, has
> seemingly retained any of this source code — at least, that's
> what the system requirements dictated, and what NASA says when
> confronted with FOIA requests —, how would the government
> legally prove that this is Space Shuttle flight software if they
> found it posted online somewhere? Perhaps it's just a hoax
> or some kind of performance art? Treating it legally as Space Shuttle software
> would be equivalent to arranging some seashells in a vaguely
> womanly shape, and then being sued for possessing a stolen
> copy of the Mona Lisa. And if they couldn't prove that
> it's Shuttle software, then how could they prove it's functional
> software for a launch vehicle? And if not, why would its
> export be restricted? Unfortunately, it's risky to assert
> that something *cannot* be done, and I haven't the courage
> of my convictions, so I won't be testing this novel legal theory
> myself.
Here's my own analysis and conclusions about what's available:
| Flight Software | Version | HAL/S Compiler | Possible First Flight | Notes |
| --- | --- | --- | --- | --- |
| PASS (PFS+FCOS) | OI-34.07 (OI340700) | **HAL/S-FC** v32.0 | STS-134 FRR 31 Mar 2011 Launch 16 May 2011 | **Regarding the flight software**: We have no *contributed* source code, but rather have memory dumps from the computers, accompanied by contemporary disassemblies of those memory dumps, made at the time by a program called **MAFGEN**. **MAFGEN** disassemblies are quite complete, because they draw not only upon the memory data from the computers, but also a lot of additional metadata (such as symbol tables) generated by the HAL/S compiler. Why do I say it's OI-34.07? The reports explicitly say "AT RELEASE 034 VERSION 070" right on them. **Note:** One very important proviso is that this is not what would have appeared in actual GPC memory in-flight in STS-134. Why? As you'll see later on, the HAL/S compiler can be run with various [compiler options](file:///mnt/STORAGE/home/rburkey/git/virtualagc-web/HAL.html#moron), and compiling the same source code with different compiler options results in executable code that's not quite identical. In the case of *this* code, it was compiled with the SDL compiler option. "SDL" stands for Software Development Lab, later to be known as the Software Production Facility (SPF). But regardless of what you call it, code was compiled with the SDL option when it was intended to be run in the SDL — i.e., *on the ground* — as opposed to being run in-flight in an actual Shuttle. In fact, I'd guess that that's the very reason we even have the software to begin with, because the reports we scraped it from were useful for software testing/debugging/simulation, but would have been of little value for flight software. There would probably have been little reason to produce these monstrously-large reports unless you had some immediate need for them. Yes, that's all well and good, but would code compiled with the SDL option have run in flight if they had tried it? That's a question I can't answer at present, but it would be great to know the answer. The good news is that it has proven possible to *reconstruct* the OI-34.07 source code. The changes reside in 5 (out of 1000+ total) operating-system (FCOS) files, and it is only necessary to substitute these files into the OI34.06 (see below) source tree. We've thoroughly documented the changes within the source-code files themselves, but the changes all relate to interactions between the GPC and peripheral devices. For example, the GPS is enabled in OI340700 but disabled prior to that. **Regarding the compiler**: For STS-134, we have an extensive report by a contemporary program called **HALSTAT**. The HALSTAT report explicitly states that the compiler used was "FC-32.0", which I'd interpret as referring to **HAL/S-FC** release 32.0. I would note that the **HALSTAT** report itself precedes the **MAFGEN** reports by something like a year, and there are small discrepancies between the two. **Regarding the flight number**: The **MAFGEN** reports explicitly say "STS134", though as far as we can tell, the software could have been flown earlier as well. |
| PASS (PFS+FCOS) | OI-34.06 (OI340600) | **HAL/S-FC** v32.0 | STS-128 FRR 18 Aug 2009 Launch 28 Aug 2009 | **Regarding the flight software**: As far as I know right now, this is a complete source-code tree. Why do I say it's OI-34.06? For one thing, it was labeled "oi340600" when I received it. But also in so far as program comments are concerned, the highest PASS version mentioned in the software change logs is OI-34.06, and dates are consistent as well. **Regarding the compiler**: The OI-34.07 **HALSTAT** report lists the compilation dates for various of the modules comprising OI340700 (see above), and those compilation dates are often years earlier. The earliest compilation date for OI340700 is listed as 31 Jul 2006. If **HAL/S-FC** 32.0 was being used in 2006, that strongly suggests that it was used for *all* OI-34 flight-software versions, and hence it would have been used specifically for OI-34.06. **Regarding the flight**: I've gone through this source code and extracted all of the internal references to problem reports (CR's and DR's) that are cross-referenced to OI-34.*xx* version numbers. Cooper Lushbaugh (thanks, Cooper!) then found that all of the OI-34.06 modifications were explicitly listed in the [STS-128 MOD FRR](https://www.ibiblio.org/apollo/Shuttle/FRR/STVD/STS-128%20FRR%20STVD.pdf#page=15) as having been implemented already in flight STS-128, as well as almost all of the OI-34.05 and OI-34.04 modifications as well. It's difficult to avoid the inference that this software version was flown on STS-128. |
| BFS+BOS | OI-34.01 | **HAL/S-BFC** v16.1 | STS-128 FRR 18 Aug 2009 Launch 28 Aug 2009 | **Regarding the flight software**: The available source code is very fragmentary, and I'd estimate that we have perhaps 10% of it or less. It is not extensive enough to provide many internal clues. The latest date and OI I've found mentioned in the code itself are 12 Feb 2008 (file ENTRYS.asm), and "OI341", respectively. The source code itself was extracted from a report whose page headings say BFS341XX LISTINGS", both of which suggest to my mind that the software is a part of OI-34.01. Separately, the report strongly suggests compilation/assembly entirely on 17 Mar 2008. **Regarding the Backup Operating System (BOS)**: I don't know how complete the code is, but there are ~450 variables that are indicated as `EXTRN`, so it's definitely not self-contained. **Regarding the compiler**: The report from which the source code was extracted references "BFC-16.1", from which I'd infer that it was compiled with **HAL/S-BFC** version 16.1. Note that the source code for the compilers **HAL/S-FC** and **HAL/S-BFC** available to us are integrated, and are for **HAL/S-FC** 32.0 and **HAL/S-BFC** 17.0 Thus **HAL/S-BFC** 16.1 is an earlier version of the compiler than available to us. **Regarding the flight**: If OI-34.06 was flown in STS-128, as inferred previously, then by process of elimination, since STS-128 was the 1st flight using OI-34, if this software has been flown it must have first been flown in STS-128. |
| PASS (PFS+FCOS) | OI-30.17 (OI301700) | **HAL/S-FC** prior to 32.0 | STS-114 FRR 29 Jun 2005 Launch 26 Jul 2005 | **Regarding the flight software**: This is a mostly-complete version of the Primary Flight Software (PFS) source code, I think, with gaps that can mostly be filled in without difficulty from other available code. What is my reason for believing that this is in fact version OI-30.17? For whatever it's worth, it was labeled "oi301700" when I received it, so somebody in the chain of custody, whatever that may have been, believed it to be so. But as far as evidence verifiable by me is concerned, I note that OI-30.17 is the highest version mentioned in the change-logs provided by the comments within the source code. Further, the latest date found on those change logs is consistent with OI-30. **Regarding the compiler**: The latest date in **HAL/S-FC** 32.0 source-code program comments is 10 Jun 2005; that indeed is prior to the launch of STS-114, but as mentioned above, the compilation of the flight-software modules may be years prior to the flight launch. While not impossible, the interval between June 10 and the launch date seems too brief to support the notion of **HAL/S-FC** 32.0 having been used for STS-114 flight software. **Regarding the flight**: What is my reason for believing that this may have been flown on STS-114? OI-30 was flown on STS-114 through -118 and -121. Source-code comments don't often reference STS-*x* flight numbers, but comments in the OI340600 code base (see above) mention STS-115, whereas the corresponding source-code file OI301700 code base doesn't mention it, so I think we can infer that this software was not flown on STS-115. By process of elimination, if this version was flown its first flight could only have been STS-114. |
# <a id="differences"></a>Some Differences Between the Old and the New
## <a id="ebcdic"></a>EBCDIC vs ASCII
The original HAL/S compiler, running on an IBM System/360 computer
as it did, expected that the underlying encoding of textual
characters such as letters and numbers was [EBCDIC](https://en.wikipedia.org/wiki/EBCDIC).
EBCDIC, to put it mildly, is no longer a common encoding for
character sets. The current common practice, which I'll stick
my neck out and assume will continue into the future, is for
character sets to be encoded in what's known as UTF-8, a scheme in
which a variable number of bytes (from 1 to 6) is used for each
unique glyph, but that the vast majority of all software source code
is encoded in the 7-bit subset of UTF-8 known as [ASCII](https://en.wikipedia.org/wiki/ASCII).
Oh, and another thing ... we can't just say "EBCDIC" and leave it at
that. The term EBCDIC actually covers lots different character
encodings that differ in some details, even though alphanumerics,
blank spaces, and some common punctuation are treated the same way
in all of them. Two characters in the HAL/S character set *not*
treated the same way in all EBCDIC tables are the square brackets,
'[' and ']', which EBCDIC tables commonly list as having the
hexadecimal codes 0xBA and 0xBB. They *don't* have those
codes as far as the HAL/S compiler is concerned, and are instead
hard-coded in the HAL/S compiler itself as 0xAD and 0xBD
respectively. (Thanks to Dan Weaver for discovering
this!) It has been pointed out (thanks Don Schmidt!) that this
arrangement corresponds to the [EBCDIC
character set known as IBM1047](https://www.compart.com/en/unicode/charsets/IBM1047), which we're told by Google AI
"is specifically good for running C/C++ applications and
POSIX-compliant UNIX environments on IBM mainframes", but which was
only invented in 1995 and doesn't seem like a natural choice for a
HAL/S compiler that had been in development since ... well, I don't
know "since when", though the oldest comments I find in the compiler
source code itself are from 1977. But who really knows which
specific EBCDIC character set was being used? The
documentation certainly doesn't tell us, and the comments in the
HAL/S compiler's source code mention nothing whatever about the
particular EBCDIC character set (or "code page") required.
In the case of HAL/S source code, as originally specified in the
early 1970's, it so happens that the legal character set contained
basically:
- All printable characters *common* to both EBCDIC and
ASCII.
- Except that the ASCII characters carat (^), tilde (~),
backtick (`), and backslash (\) were not legal.
- Whereas the non-ASCII characters logical-NOT (¬), U.S. cent
(¢), and the punchcard-but-non-EBCDIC "end-of-file" character
were legal.
I say "basically", because technically there are some quibbles
about some of the characters (^, \, and end-of-file) with which I
will not bore you. But I will mention that in spite of the
technical illegality of it, legacy HAL/S and XPL source code often
already uses either '~' or '^' in place of '¬'.
Given these facts and the obvious technical advantages (for
portability now and into the future) of using a 7-bit character
set for everything, the modern tool-set:
- Expects HAL/S source code to be provided in 7-bit ASCII, with
the caveats mentioned below. Specifically, EBCDIC source
code is not accepted.
- Uses '~' in place of both '¬' and '^'. If either of the
latter is encountered in HAL/S source code, it is translated to
the former.
- Uses '`' in place of '¢', again with automatic translation to
the former.
- Uses '\' in place of end-of-file character, though this is
very, very rare indeed.
[](file:///mnt/STORAGE/home/rburkey/git/virtualagc-web/encodingDEU.png)These restrictions apply only to HAL/S
source code. Any human-readable reports generated by our
modern ports of the HAL/S compiler are pure 7-bit ASCII with the
substitutions mentioned, and may contain tab characters.
This should *not* be taken to imply that character data is
maintained internally by the modern compiler(s) in ASCII encoding,
nor that all files output by the compiler have text encoded in
ASCII. In fact, that's not true: Internally, the
modern compiler, just like the original compiler, continues to use
mostly EBCDIC, only translating to ASCII as needed.
But in passing it's worth mentioning the following difference in
behavior between the Intermetrics HAL/S compiler and "standard"
HAL/S compilers, even though it's *not* a difference in
behavior between the original Intermetrics compiler and our modern
ports of it: The peripheral device in the Shuttle that
displayed textual data, namely the Display Electronics Unit (DEU),
did *not* encode that textual data in EBCDIC, but rather in
encoding peculiar to the DEU, seen in the figure to the
right. While the DEU encoding is neither EBCDIC nor ASCII,
it is ASCII-like in some ways. The HAL/S compiler, *both*
in the original and the modern ports, caters to the needs of the
DEU like so:
- All quoted character strings are encoded (internally to the
compiler) using DEU
- All other text (such a symbol names) are encoded using EBCDIC
For example, if you had a HAL/S statement such as "`DECLARE
HELLO CHARACTER(20) INITIAL('HELLO');`", the compiler
would encode the *symbol* `HELLO` in EBCDIC as
the hexadecimal C8 C5 D3 D3 D6, but encode the *string*
'HELLO' in hexadecimal as 48 45 4C 4C 4F (which just happens to be
identical to the ASCII encoding as well).
What happens, you ask, if you needed a quoted string containing
one of the DEU character set's weird non-textual glyphs, such as
the division symbol or a right-arrow? That's where the red
notations in the figure to the right (click to enlarge) come into
play. Those are *escape sequences* that can be used in
quoted strings to get the "weird" characters. For example,
if you wanted a HAL/S statement to print the string "A ÷ B → C",
you might use
> ```text
WRITE(6) 'A ¢/ B ¢3 C';or more likely, as explained above,
text
WRITE(6) 'A / B 3 C';
See the [HAL/S-FC
User's Manual](https://www.ibiblio.org/apollo/Shuttle/HAL_S-FC%20User's%20Manual%20Nov%202005.pdf#page=102) for more info on this, though the table you'd
see there has a couple of errors in it that are corrected in our
representation of it here. (Thanks to Dan Weaver for the
info and the corrections!)
## <a id="common2"></a>COMMON Memory
Much of the data transferred from one compiler pass to the next
resided in so-called `COMMON`
memory. I refer here not to the HAL/S compilation unit known
as a `COMPOOL`, but
rather to sections of IBM 360 memory which XPL/I programs expected
to be left intact when one pass of the compiler (say, PASS2)
terminated and the next pass of the compiler (say, PASS3) was
loaded and began executing. Given that the modern HAL/S
compiler implements each pass of the compiler as a stand-alone
program, no such continuity of physical memory is possible.
So some other means must be used to preserve this data.
The modern compiler handles this by storing `COMMON` data in files.
Upon termination, a compiler pass writes an output-file describing
the state of `COMMON`
memory. And similarly, upon startup, a compiler pass reads
and input-file describing the state of `COMMON`
memory. The compiler maintains a model of the IBM 360 24-bit
memory space, and the addresses of all `COMMON`
data remain the same in this 24-bit model throughout any
compilation run.
## <a id="overstrike"></a>Overstruck Lines in Reports
Since the original compiler physically printed reports and could
control whether or not the printer advanced the paper, it was
capable of overstriking those printed lines with decorations such
as underlines. The corresponding reports output by the
modern compiler are plain ASCII text, and overstriking is not
possible. For example, in a source-code listing, expansion
of a macro was originally indicated by underlining the macro.
The modern compiler mimics the original underlining in a line of
text, such as
> ```text
THIS IS MY UNDERLINED TEXTwith two lines of text, thusly:
text
THIS IS MY UNDERLINED TEXT ^^^^^^^^^^
While this nicely conveys the underlining effect, I think, the
fact that some single printed lines are replaced by dual printed
lines does affect the vertical alignment and the pagination.
# <a id="notused"></a>HAL/S Features That Are Not Used
You'll see constant whining throughout these writings about
software features that are not well documented, leaving us in the
position of taking our best guess and winging their
implementation. Conversely, there are HAL/S features that
are well documented, sometimes *ad nauseum*, which are
essentially not used at all in Space Shuttle flight software. This
leads to a tricky situation sometimes, in which we'd *like*
to implement everything in HAL/S, but which would be a waste of
effort insofar as Space Shuttle support is concerned. When
the features are those provided by the HAL/S compiler itself,
there's no problem at all: If the compiler supported those
features back in the day, then it supports them now!
Nevertheless, there are other features whose implementation
requires a lot more work, and about whose scope we're much less
clear.
I have no comprehensive list of the features in question, but a
major area is the question of what to do about runtime errors,
such as those related to arithmetic — divide by zero, inverse of
singular matrices, etc. — or to i/o. To handle such stuff,
the contemporary documentation tells us that there's a set of
"standard fixups" that are transparently supplied by the
system. Usually, those standard fixups make little or no
sense, sometimes to the extent of making your eyes cross.
For example, in spite of what I just said a couple of sentences
ago, there isn't any error trap for divide-by-zero. There's
an error trap for dividing by 0 in the `REMAINDER`
library function (namely, just return the dividend) and for
dividing a `VECTOR` or `MATRIX` by 0
(namely, return the original `VECTOR` or `MATRIX`),
but not for just dividing a regular old number by 0. And the
inverse of a singular matrix? Returns the identity matrix.
With those kinds of default behaviors, it's not surprising that
something better might be desired. In fact, HAL/S provides a
rather comprehensive set of alternatives via the `ON ERROR`
family of statements, in which error handling can be specified for
a very wide range of specific errors or groups of errors.
The entirety of section 25 of the [*HAL/S
Programmer's Guide*](https://www.ibiblio.org/apollo/Shuttle/HAL_S%20Programmers%20Guide%20Nov%202005.pdf#page=315) covers the ON ERROR
statements. The entirety of Appendix C of the [*HAL/S-FC
User's Guide*](https://www.ibiblio.org/apollo/Shuttle/HAL_S-FC%20User's%20Manual%20Nov%202005.pdf#page=199) is spent detailing just the arithmetic
errors I mentioned. The [Orbiter
Avionics Software Programming Standards Document](https://www.ibiblio.org/apollo/Shuttle/IBM-82-SS-4556%20-%20Rev%204%20-%20Space%20Shuttle%20Orbiter%20Avionics%20Software%20-%20Programming%20Standards%20Document%20-%20Shuttle%20Flight%20Software.pdf#page=45), revision
4, devotes section 3.3.1.10 to discussing how to use ON ERROR for
i/o operations. This feature set is partially implemented,
at least for the **yaHALMAT2** emulator, so you can use quite
a lot of the error-trapping behavior in your HAL/S code. Why
"partially" implemented? The Space Shuttle's primary flight
software (PASS) does not use these features at all, and the backup
flight software (BFS) simply has a generic override in a couple of
its programs (APU\_FUEL and APU\_SPD) to abort the programs entirely
upon *any* error, but all fine-grained control is
eschewed. Extensive documentation indeed for a feature which
is never used, or used only in primitive form! Why did we
even implement this stuff at all? I didn't know it wasn't
used. I trusted what I read. (Admittedly, we don't
have full BFS source code, so perhaps the feature is used more
there than I know.)
Or, we have the so-called real-time features, in which there are
all kinds of subtleties about how to schedule or cancel tasks or
programs for future execution. Three whole chapters in the *HAL/S
Programmer's Guide* are devoted to them. How many are
used in actual PASS or BFS code? Well ... I won't lie to
you, some of them are. The *vast* majority simply
start a task or program running in the background and don't use
any of the subtleties at all.
The lesson here is that if you learn all of the many ins and outs
of HAL/S, you'll have learned a lot more than you need to know for
just PASS or BFS. 
# <a id="dangers"></a>Dangers Lurking in *New* HAL/S Source Code
Legacy HAL/S source code is, of course, syntactically perfect and
error-free. Or at least, we would sincerely hope so. By
which I mean that if it *used* to compile and work properly in
the old days using the old development tools, then pragmatically
speaking, it behooves us to make sure that the new development tools
can work with the identical HAL/S source code on the same basis,
expecting equally-good results. A corollary is that if there
are any traps to be avoided in the special developers' dance we have
to perform when writing HAL/S source code, the old developers
already did that dance when they wrote the legacy code, but they
seldom left any warnings behind for us when they did so and thus
those traps are still lurking for *us* if we choose to write *new*
HAL/S code.
Oh, and this section is pretty technical, by the way, but the good
news is that you can probably [just nod wisely and proceed to the next section](#options1)
rather than reading it!
Of course, we already heard about some of these traps, such as the
character set and character encoding, in the preceding
section. And many others are covered in HAL/S documentation,
even if not flagged there as being traps. Others are just pure
traps that you have no way to prepare yourself for unless someone
warns you. Still, it's instructive to observe some of the
traps we see naive developers innocently falling into easily when
trying to write HAL/S source code without feedback from working
development tools:
- **TAB characters.** There was no such thing as a tab
character on a punch card, so no legacy HAL/S code contains tab
characters, thus preventing any problem associated with their
interpretation. But your text editor might sneak some tabs
into source code when you edit it. The compiler works
around this potential problem by replacing each tab character it
finds in HAL/S source code by enough space characters to move to
the next "tab stop". Tab stops are by default assumed to
be at 8-column intervals. You can change that default in **HALSFC**
using the `--tab=N` command-line parameter.
- **Compilation Units.** Any given file of HAL/s source
code contains a *single* compilation unit: PROGRAM,
PROCEDURE, FUNCTION, or COMPOOL.
Separate compilation units are in separate files. Of
course, definitions of blocks like PROCEDURE, FUNCTION,
etc., can be local to another block, so in that sense there can
be multiple such blocks included within the same file.
- **Don't use the fancy multi-line "mathematical" format when
writing code.** It's great as an automatically-created
format for generated program listings, but not for source-code
input to the compiler. It does work, but you won't enjoy
yourself.
- **Column 1 is special.** Use it only for C (full-line
comment), D (compiler directive), or a blank space (normal line
of code).
- **The symbol** **\*** **is** ***not*****a multiplication sign.** There is no multiplication
sign!
- **HAL/S documentation is sometimes wrong!** Or put
differently, the HAL/S language as implemented by the
Intermetrics/USA HAL/S-FC compiler sometimes doesn't match the
documentation. I'll discuss whatever examples I discover
below.
> I've actually found only one case so far where the PFS version
> of HAL/S-FC flat-out does something that contradicts the HAL/S
> documentation. That's something we might call "the illegal
> event-expression problem" ([see
> GitHub issue #1270 for more info](https://github.com/virtualagc/virtualagc/issues/1270#issuecomment-3835567355)), error code E102.
> (The BFS version of the compiler has this problem too. But
> as you'll see in the next bullet point, the BFS version does a *lot*
> of stuff that contradicts the HAL/S documentation, so lapses
> hardly surprise us the way problems in the PFS version
> do!) This is a tricky problem to describe, because
> explaining here what an *event expression* is would
> probably take us too far afield, on a top of which you're likely
> not too interested in them at this moment. Suffice it to
> say that an event expression is basically any *boolean
> expression* — such as A AND NOT (B OR C) — in
> which rather than being boolean variables, the entities A,
> B, and C are *event variables* or *process
> variables*. Again, don't worry about what those
> are. Suffice it to know that these things all relate to
> scheduling *tasks* to be spontaneously executed when *events*
> occur, or to be paused while waiting for events to occur.
> All available HAL/S documentation agrees that the syntactical
> forms of *event expressions* and *boolean expressions*
> are the same. Indeed, PASS1 of HAL/S-FC, which is
> responsible for all parsing of HAL/S source code, *processes*
> event expressions in the form of arbitrary boolean expressions
> with flying colors. Not so PASS2, which is HAL/S-FC's
> object-code generator! Certain event expressions move
> through PASS2 with ease, while others fail PASS2 with an error
> message that looks like the following (though likely with a
> different "HAL/S STATEMENT" number):
>
> > ```text
***** E102 ERROR #1 OF SEVERITY 2 OCCURRED *****
***** DURING CONVERSION OF HAL/S STATEMENT 6.*****
***** INVALID EVENT EXPRESSION
***** CONVERSION ABANDONEDFor instance, the example of A AND NOT (B OR C) that we saw above would trigger an E102 error if used as an event expression, even though it's perfectly fine as a boolean expression, HAL/S documentation be damned! Here's a summary of the event-expression formats that will be okay as far as PASS2 is concerned:
- Expressions containing no logical operators at all.
- Expressions containing only NOT operators (or the aliases ~ or ¬)
- Expressions containing only AND operators (or the alias &)
- Expressions containing only OR operators (or the alias |)
In other words, it's illegal to mix different types of logical operators within a single event expression. That sounds mighty fishy, so it would be fair of you to be suspicious that this is not a real failure in Intermetrics/USA's PASS2, but instead is my failure somehow in my compilation of it into our "modern" HAL/S compiler HALSFC. Indeed, I was suspicious myself. But I'm innocent! Tracking down where error E102 is generated in the original PASS2 source code (PASS2.PROCS/GENERATE.xpl), we discover the following program comments:
text
/* OR OPERATOR IS BEING PROCESSED. IF THE /*CR13220*/
/* AND OPERATOR HAS NOT PREVIOUSLY BEEN USED /*CR13220*/
/* THEN CONTINUE, ELSE EMIT E102 ERROR. /*CR13220*/
/* NOT OPERATOR IS BEING PROCESSED. THE NOT /*CR13220*/
/* OPERATOR MAY NOT BE USED IN AN EXPRESSION /*CR13220*/
/* WITH MORE THAN 1 EVENT VARIABLE OR WITH /*CR13220*/
/* MULTIPLE NOT OPERATOR. IF THE NOT /*CR13220*/
/* OPERATOR IS USED ILLEGALLY EMIT E102 ERROR. /*CR13220*/
/* AND OPERATOR IS BEING PROCESSED. IF THE /*CR13220*/
/* OR OPERATOR HAS NOT PREVIOUSLY BEEN USED /*CR13220*/
/* THEN CONTINUE. ELSE EMIT E102 ERROR. /*CR13220*/>
> So these E102 errors really are due to a deficiency in the
> original Intermetrics/USA PASS2, insofar as consistency with HAL/S
> documentation is concerned. In fact, the notation
> /\*CR13220\*/, when compared to comments elsewhere in GENERATE.xpl,
> tells us that generation of E102 was added to HAL/S-FC on
> 2001-01-15 in release 31V0/16V0. Before that, I can only
> assume that PASS2 would presumably fail in some mysterious way
> without even a relevant error message as soon as it encountered an
> event expression it didn't like. Whee!
- **The BFS version of the HAL/S language, and of the HAL/S
compiler, are second-class citizens!** By that I mean
that they lack features that the PFS version of the language
has::
> > **Aside:**
> > Some of the issues described below turn out to be documented
> > in the "[HAL/S Compiler System Specification](https://www.ibiblio.org/apollo/Shuttle/hal-s_compiler_system_specification.pdf#page=485)",
> > section 8.0, "PASS/BFS Differences".
- In almost every compilation unit (or at least in most `PROGRAM`,
`PROCEDURE`, or `FUNCTION` units) using
the BFS version of the HAL/S compiler, an instance of a `%SVCI(N)`
macro should be the last statement preceding the `CLOSE`
of the compilation unit. PASS1 of the compiler, which
parses your source code, won't care about this, and hence
you'll get no warning until PASS2, the object-code generator,
that anything's wrong. What is `%SVCI(N)`,
you ask? I believe that `%SVCI` is a variant
of the `%SVC` macro, which inserts an [AP-101S
assembly language instruction](https://www.ibiblio.org/apollo/Shuttle/Shuttle%20GPC%20Software%20Model%20AP-101S.pdf) `SVC`
(Supervisor Call) wherever it appears. What are the
legal values of *`N`*? Table 8-1 in the
"HAL/S Compiler System Specification" lists legal values for `%SVC`,
albeit not for `%SVCI`. -1 and 0 are
definitely legal values for `%SVCI` and seem to
have the same interpretations as for `%SVC`.
Until more-definitive advice comes along, I'd suggest
just having `%SVCI(0)` as the last statement
before the `CLOSE` of each compilation unit.
PASS2 will do essentially that anyway if you leave out `%SVCI`
entirely, but it will complain about doing so, and nobody
likes a whiny compiler.
- BFS apparently does not have any of the "real-time"
functionality designed into HAL/S. In other words, most
or all of what you find in [Ryer's
Chapter 12, "Real-Time Statements"](https://www.ibiblio.org/apollo/Shuttle/Programming%20in%20HAL_S%20Sept%201978.pdf#page=229) isn't supported by
the BFS version of the HAL/S compiler. This includes the
keywords `SCHEDULE`, `TERMINATE`, `CANCEL`,
`WAIT`, `UPDATE`, `PRIORITY`,
`SIGNAL`, `SET`, `RESET`, `SEND`,
`ERROR` (see next bullet point), `RUNTIME`,
`CLOCKTIME`, `DATE`, `PRIO`,
`ERRGRP`, `ERRNUM`, and `EXCLUSIVE`.
- The BFS form of the compiler doesn't allow a number of
features for the error trap ("`ON ERROR` ...") that
standard HAL/S and the PFS form of the compiler do:
- In BFS, the `ON ERROR` feature supports *only*
the form "`ON ERROR statement;`", and
does not support the forms "`ON ERROR$(group:) statement;`"
or "`ON ERROR$(group:number) statement;`"
or "`ON ERROR SYSTEM;`" or "`ON ERROR
IGNORE;`".
- In BFS, `ON ERROR` can only be in a `PROGRAM`
or `TASK` block (and not within `PROCEDURE`
or `FUNCTION`).
- In BFS, only one `ON ERROR` is allowed per `PROGRAM`
or `TASK`.
# <a id="templib"></a>Template Library, the Inclusion Library, and the SDF Library
## <a id="DINCLUDETEMPLATE"></a>The Template Library and the "`D INCLUDE TEMPLATE`" Compiler Directive
The so-called *template library*, not surprisingly, stores
"templates". Stereotypical examples of templates are: a
description of a HAL/S PROCEDURE in term of it
parameters, a FUNCTION in terms of its parameters and
return value, or a BASED structure in terms of its field
hierarchy. It often happens in HAL/S that an object like a
PROCEDURE is defined in one compilation unit, but
actually used in different compilation units. The template
of the PROCEDURE tells these other compilation units
using it what legal usages are supposed to look like. Often,
HAL/S source code gathers together many of these kinds of
definitions with a so-called COMPOOL, which when
compiled may then be associated with lots of templates.
Thus HAL/S templates are similar in concept to the "function
prototypes" and struct object definitions often found in
C-language "header files", with the difference being that in HAL/S
these are all gathered together into a central library rather than
being distributed across multiple header files.
Additionally, the HAL/S compiler manages the template library and
(optionally) adds all of the templates to it, as opposed to the
C-language process of having programmers manually create the
conceptually-similar header files. Another innovation in
HAL/S is that each template has a version code (from 1 to 255)
that increments every time the template has been changed.
(But no, you cannot store two different versions of the template
in the library at the same time.)
When using **HALSFC**, the template library itself is in the
form of a folder called TEMPLIB/ (or TEMPLIBB/ for BFS) and a file
called TEMPLIB.json (or TEMPLIBB.json for BFS), both residing in
the current working directory. By default, **HALSFC**
will only *read* templates from the library, but if the
TEMPLATE parameter is added to the list of compiler options, as in
> ```text
HALSFC SOME_PROCEDURE.hal --test --parms="TEMPLATE,LIST,NOTABLES"then the library will also be updated with templates for the file being compiled.
Within HAL/S source code, if you want to use a PROGRAM, PROCEDURE, FUNCTION, or COMPOOL that's defined in a
different source-code file, you'll first need to include the
template for that object. For example, suppose you want to
call an external PROCEDURE
named SOME_PROCEDURE.
It might look something like this in your HAL/S source code:
text
.
.
.D INCLUDE TEMPLATE SOME_PROCEDURE . . . CALL SOME_PROCEDURE(X, Y); . . .
The line "`D INCLUDE TEMPLATE
SOME_PROCEDURE`" is not a line of HAL/S code *per
se*, but is rather a "compiler directive" that tells the
HAL/S compiler to go into the template library and determine just
what `SOME_PROCEDURE`
is. In doing so, it will discover that `SOME_PROCEDURE` is an
external `PROCEDURE` that
it has at least two arguments, as well as the datatypes of those
arguments, and whether or not `CALL`
`SOME_PROCEDURE` will need
an associated `ASSIGN`
clause, and the number of arguments and datatypes in the `ASSIGN` clause. In
other words, it will find out everything needed to *interface*
to `SOME_PROCEDURE`,
without any details as to `SOME_PROCEDURE`'s
internals.
This is a little less straightforward than it sounds, because the
template for `SOME_PROCEDURE`
is not actually stored in the template library under the name
"SOME\_PROCEDURE". Instead, the name is first modified under
a process HAL/S refers to as "descoring", and the template is
stored under the descored name. Descoring works like this:
- All underscores are removed from the name. (Thus
"SOME\_PROCEDURE" would become "SOMEPROCEDURE".)
- It's then shortened to 6 characters. (Thus becoming
"SOMEPR".)
- If shorter than 6 characters, it's right-padded with
blanks. (Still leaving us with "SOMEPR".)
- It's then prefixed with "@@". (Thus giving us the
"@@SOMEPR" as the final descored procedure name.)
Sounds weird, yes, but it's partially a consequence of IBM
System/360 file-naming restrictions. One unpleasant
side-effect is that all symbols which descore to the same
8-character string are treated identically. So heaven help
you if you have a set of procedures with names like `SOME_PROCEDURE1`, `SOME_PROCEDURE2`, and `SOME_PROCEDURE3`, because
they're all going to end up in the template library as
"@@SOMEPR". Whichever one of them whose template was
processed by **HALSFC** *last* will overwrite the others
and win!
Similarly, you can have multiple compiler directives including `SOME_PROCEDURE`'s template
that *look* different, perhaps due to misspellings, but that
nevertheless have an identical effect. Thus all of the
following are the same:
> ```text
D INCLUDE TEMPLATE SOME_PROCEDURE
D INCLUDE TEMPLATE SOMEPROCEDURE
D INCLUDE TEMPLATE SOMEPROAnother headache is that HAL/S files for which templates will be needed later must be compiled before the HAL/S files that need those templates are compiled. Naively, this sounds relatively simple. But when you look at actual source code (say, for Space Shuttle flight software), you see hundreds of HAL/S source files that include (say) 10 templates each, and each of the HAL/S source-code files for those templates include 10 other templates, and so on. It turns out to be a nasty business figuring out an appropriate compilation order unless it's automated.
Then too, when beginning a sequence of compilations of related HAL/S source-code files, you might want to start with clean configuration that involves an empty template library. That's pretty simple to do manually, but I've provided a Python program (and associated Windows batch-script) to do this for you. Just 'cd' into your working directory from which you want to perform HAL/S compilations and do one of the following,
text
prepareTEMPLIB
to insure that a template library exists at all, or
> ```text
prepareTEMPLIB --clearto insure that it not only exists but is empty.
Finally, note that the template library exists simultaneously in two
different forms: the folder TEMPLIB/ (or TEMPLIBB/) is
maintained by and for the full version of the HAL/S compiler (HALSFC),
whereas the file TEMPLIB.json (or TEMPLIBB.json) is maintained by
and for the alternate version of the compiler (HAL_S_FC.py)
that's invoked only by the HALSFC option --test. It's unfortunate
in retrospect that I decided to implement two different versions of
the same library. In spite of having very different
implementations, TEMPLIB/ and TEMPLIB.json contain identical
information. If these two versions of the template library
are not synchronized, then HALSFC --test
operations may begin to fail because the two versions of the
compiler are no longer maintaining their versions of the library in
the same way, and the reports being generated will reflect those
differences. It may be possible to regain synchronization
simply by repeating a HALSFC --test
operation which has failed ... but failures are distressing when
they happen, if you're the suspicious type (like me); you can help
but asking if that's really the reason the comparison
failed! You can, of course, compare the compiler reports
(pass1.rpt for the main compiler vs pass1p.rpt for the alternate
compiler); look at the final line in the report, which is usually
the culprit in this situation. But it is better, I think,
simply to always use --test
whenever you use the compiler TEMPLATE
option, so that the libraries never get the chance to become
unsynchronized.
And finally finally, I'll let you in on a very fun little secret. Or perhaps a "pro tip". Everything I just told you is 100% right and exactly per the book. All the documentation agrees! Plus, it seems to works when you try it. You definitely needed to know about it. And yet ... it's also misleadingly wrong. I'll eventually explain that below when we arrive at a discussion of the SDF library.
The Inclusion Library and the "D INCLUDE" Compiler Directive
In addition to the template library, which is something that the original compiler HAL/S-FC explicitly provided for, in the "modern" ports HALSFC and HAL_S_FC.py we additionally have something I call an "inclusion library" that existed originally just because of the particulars of IBM System/360 "partitioned data sets" but for which HAL/S-FC didn't need to make any specific provisions.
Just as the template library existed for the purpose of
implementing the compiler directive "D INCLUDE TEMPLATE name" discussed above,
the inclusion library exists to serve the compiler directive "D INCLUDE name".
This directive instructs the compiler to insert the entirety of
the HAL/S source-code file name
at the current point. The distinction, in case it isn't
clear, is that while a "D INCLUDE TEMPLATE name" inserts information about
how to interface to an external object, "D INCLUDE name"
inserts the full source code for the object itself. Although
in the latter case the included file doesn't have to be the source
code for an object like a PROCEDURE
or FUNCTION, but can be
any sequence of HAL/S statements whatever that are legal in the
current context. Typically, an included file is used for
lists of macro (REPLACE)
definitions and STRUCTURE
definitions, enabling you to use those same definitions in lots of
source-code files without having to copy them.
Unfortunately, though, in we can't just include arbitrary files from arbitrary directories, hence the need for a library that contains the files we know we'll need to include in other files. Our inclusion library is modeled after our template library: For HALSFC, the library for PASS compilations is just a folder (INCLIB/) that contains all of those files, suitably preprocessed. For BFS compilations by HALSFC, only the name has been changed (INCLIBB/). And for compilations by HAL_S_FC.py, the inclusion library is instead one of the files INCLIB.json or INCLIBB.json.
Note: Filenames for inclusion files are limited to 8 characters. Furthermore, I think that the compiler will "descore" any filename you specify in "
D INCLUDE name" by removing all underscores, truncating to 8 characters, and then right-padding with blanks to 8 characters if necessary. So if you were to write your own, new inclusion files, beware of of the mangling that the compiler is going to do to their filenames behind the scenes!
Aside: In case you're interested, the "suitable preprocessing" is this: the filename extension ".hal" is removed, all lines in the file are truncated or padded to exactly 80 characters (with no newlines at the ends). And for the HALSFC version of the library, everything is recoded in EBCDIC.
So the question becomes, How do we get our include-files into the inclusion library? The answer is that there's a Python script called prepareINCLIB (and its associated Windows script prepareINCLIB.bat) which I've provided for that purpose and others. The basic usage is:
text
prepareINCLIB [OPTIONS]
Without any *`OPTIONS`*,
all this will do for you is to create a PASS inclusion library
(INCLIB/ and INCLIB.json) if one doesn't already exist. With
the option `--bfs`, it'll
be a BFS inclusion library (INCLIBB/ and INCLIBB.json)
instead. With the option `--clear`,
it'll additionally empty the existing PASS or BFS template
library, whichever is appropriate. But the real magic occurs
when the option `--include=D`
is added, where `D`
is the name of a directory containing HAL/S include-files.
If so, all \*.hal files in the specified directory are added to the
inclusion library, and this option can be used multiple times on
the same command line. Or it can be used to incrementally
add new files to an existing library, as long as you don't use the
`--clear` switch.
## <a id="sdfLibrary"></a>The Template Library Part 2: The SDF Library and the "`D INCLUDE SDF`" Compiler Directive
[Earlier we had
an extensive discussion of the so-called "template library"](#DINCLUDETEMPLATE),
and indeed it was perhaps a discussion that was more in-depth than
desired, for many folks' tastes. Well, it only gets worse,
and before proceeding I'd advise you to refresh your memory about
templates if you need to.
The melodramatic cliffhanger at the end of the earlier discussion
was that the explanation of the template library was both 100%
correct and yet misleadingly wrong. What's up with that?
One notable feature of the Intermetrics HAL/S development stack
was its eventual reliance on the very large amount of metadata
(beyond just the usual object code) generated by the
software-compilation process. This metadata was embodied in
something known as a Simulation Data File (SDF). As you may
imagine from the name, the SDF is produced by the HAL/S compiler
for the purpose of facilitating simulation of the compiled code
... at least, *originally*. You can think of an SDF as
a souped-up symbol table, which I think it may have been all it
was originally, but over the course of time as its use expanded, a
lot more metadata about the code was piled into it. As you
may recall, the HAL/S compiler is partitioned into several
"phases", of which phase 1 parses HAL/S source code, phase 2
produces object code that can be separately linked and run, while
phase 3 produces an SDF. So in that limited perspective, the
SDF file is nice to have, optionally, but it's not needed for
producing an object file, and if you have no intention (or means)
of running simulations then there's really no need for the SDF (or
for phase 3 of the compiler) at all. As I understand it, the
problem with that mode of thinking is that eventually *so much*
data was piled into the SDF that the SDF and software associated
with it — like the **MAFGEN** and **HALSTAT** report
generators — became indispensable parts of the development process
rather than occasionally-useful tools. In other words, at
some point both phase 3 and the SDF were no longer truly
"optional", even if could get by without them, albeit
inconveniently.
What does that mean for us? Well, it has an implication
that's nowhere mentioned in any of the "standard" documentation
about HAL/S and HAL/S compilation, nor in the
Intermetrics/USA-specific documentation. Or if it is
mentioned, it's so subtle and obscure that you can only find it
mentioned if you already know about it.
At some point over the decades in which Space Shuttle
flight-software development took place, it occurred to somebody to
wonder why compilation of the flight software took so long.
One culprit was the templates being loaded via the "`D
INCLUDE TEMPLATE file`" directives. While
it's true that many flight-software source-code files don't
include any templates, the average is nevertheless about 6
template inclusions per source file, with the champion being a
whopping 103 inclusions. Realize that a template for a
source-code file, in spite of having been produced by the
compiler, remains a HAL/S source code file; it hasn't been parsed,
but has merely been "compressed" by removal of multiple blank
spaces. So *every* time a template is included by
another source-code file, it is recompiled. If it is
included in 100 files, it is compiled 100 times. Somebody
then had the bright observation that the SDF for a `COMPOOL`
contained all of the information in the `COMPOOL`'s
template, but had already been precompiled! Therefore, if
the HAL/S compiler's first pass had means of including an SDF in
place of a template, for example via a compiler directive like "`D
INCLUDE SDF file`", then compilation could be *a
lot faster*, since the already-compiled symbol-table info in
the SDF's could be used directly, without the time-wasting
recompilation there would have been with a template.
Good catch! On the other hand (they must have thought to
themselves) ... well, I don't know, going into all of the existing
source code and replacing all of the "`D INCLUDE TEMPLATE file`"
directives by "`D INCLUDE SDF file`" directives
sounds boring and time-consuming. Sigh! What to do,
what to do? Oh, oh, I know! Let's get them to change
the HAL/S compiler itself, so that when it finds a "`D
INCLUDE TEMPLATE file`" directive in a source code
file, it's silently replaces it with an "`D INCLUDE SDF file`"
directive, and only falls back on "`D INCLUDE TEMPLATE file`"
if the "`D INCLUDE SDF file`" didn't
work. Swell, everybody happy, work minimized!
And there's an additional advantage, beyond just compilation
speed-up, from using SDF's in place of templates. Since they
are precompiled, inclusion of SDF's is no longer as order-sensitive
as inclusions of templates is. For example, if `COMPOOL`
A defines a `STRUCTURE` needed by `COMPOOL`
B, then *template* A must be included prior to template B or
else there will be an undefined-symbol error. But there's no
such dependence in the SDF's, so SDF A could be included either
before or after SDF B without any error. That allows the HAL/S
developer to become much sloppier in terms of verifying the
dependencies in their inclusions.
In a perfect world, of course, it would have been nice if they had *documented*
that they were doing this so that hapless chumps such as ourselves
would have known not to trust the now-misleading documentation about
"`D INCLUDE TEMPLATE`" and the entirely-absent
documentation about "`D INCLUDE SDF`", but ... oh well,
that's life, isn't it?
Unfortunately, that "advantage" for the original developers
becomes a *dis*advantage if you have only templates and
don't have the SDF's, because you will experience mysterious
undefined-symbol errors that should not exist in flight software
that's known to compile correctly. Well, now you know
why! (There happens to be a workaround for this particular
problem, which you can read about in [the section on preprocessors](#morePreprocessors), but
it's just slapping a bandage on a wound that really requires a few
stitches.)
> **Aside:**
> At this writing, PASS1 of the compiler does not yet read
> SDF's. So my remarks below will be forward-looking rather
> than describing what actually exists in the modern HAL/S
> development system.
Or similarly, with SDF's you can have symbols that are defined in
multiple `COMPOOL`'s, and as long as they are always
defined in the same way, there will be no problem. Whereas
with templates, you would experience multiply-defined-symbol
errors at compile time. As far as I know, there is no
workaround for this problem if you have only templates available
for inclusion. You need either transparent inclusion of
SDF's or else transparent inclusion of something very similar to
an SDF.
Like templates and include-files, SDF's are collected in a
"library" after they're created, and when the compiler seeks to
load an SDF, it does so from such a library. For us, for
PASS, this library will be a directory called SDFLIB/, and I don't
yet perceive there to be any need for a BFS equivalent.
Moreover, unlike with the template library and file-inclusion
library, the same SDFLIB/ is used for both the HALSFC and for
HAL\_S\_FC.py ports of the HAL/S compiler.
# <a id="options1"></a>Compiler Options, Part One
There are a number of options that are specific to the modern
HAL/S compiler versus the original HAL/S compiler (which naturally
didn't have these "modern" options). I'll resist the
temptation of going through those in detail. If you're
interested, I'd suggest using the command
> ```text
HALSFC-PASS1 --helpto get descriptions of them. Most of them relate to debugging the HAL/S compiler itself, and hence are of little value to anybody wishing merely to use the compiler. All of the other compiler passes (HALSFC-FLO, HALSFC-OPT, and so on) will list all of the same options, so you needn't look past HALSFC-PASS1.
However, there are quite a few options, too, that are command-line replacements for what were specified to the original HAL/S compiler by its Job Control Language (JCL), and specifically for attaching various input files or output files to the various compiler passes. I'll cover those options here, briefly. There's a later section that describes the uses of these file-attachment options in detail, ad nauseum.
--ddi=N,F[,U][,E]— This attaches an input file for sequential reading.Fis the path to the file. You can think of these as being text files that are read in a line at a time. The lines are padded or truncated to 80 columns, as necessary. TheUclause, in the unlikely event that it's present, means that the text should be automatically translated to upper case as it is read in. The optionalEclause would be used if the input file contains EBCDIC, or more precisely, if the text does not need to be recoded as it is read in. But by default, the input text is assumed to be 7-bit ASCII and will be recoded into EBCDIC as it is read in. The compiler thinks of the file as being a numbered device. The value ofN(0 through 9) is the number of the device to which the file is assigned.--ddo=N,F[,E]— Same as--ddi, but for output files rather than input files. TheUclause is not available. Note that the same sequential file shouldn't be simultaneously attached for both input and output.--pdsi=N,F[,E]— Same as--ddi, but for Partitioned Data Sets (PDS) rather than sequential files. A PDS is more similar a directory than to a file, thus it is implemented as a directory andFin this case is the name of a directory. A PDS has named members which the software can select at runtime, and it's the named members that act like files.--pdso=N,F[,E]— Same as--pdsi, but for output rather than for input. The same directory can be attached simultaneously for both input and output.--raf=I,R,N,F— Attaches "random-access file"Fto device numberN. Think of these as being binary files of fixed record sizes, which are read or written only in integral numbers of records. The value ofI(I,O, orB) determines in principle whether the file is used for input, output, or both, but in practice it is alwaysBfor both. The record size is determined byR. By the way, note that while the--ddi,--ddo,--pdsi, and--pdso, options share the same pool of device numbers among themselves, the pool of device numbers for--rafis separate from them. For example, deviceN=5for--rafcould be reused for--ddiwithout any unpleasant side effects. Data from a random-access file never undergoes any recoding or translation (such as EBCDIC-to-ASCII or vice-versa) upon reading or writing.--commoni=``F— Path to the file containing the state ofCOMMONmemory upon program start.--commono=``F— Same as --commoni, except that it's the state ofCOMMONat program termination. Warning: Do not use the same file simultaneously for both--commoniand--commonoon the same compiler pass.--tabs=N— Sets the tab-stop size in HAL/S source code. The default is 8.
More on the Compiler Options
In the preceding section, we talked about options specific to the modern compiler, principally as they involved attaching input- or output-files to the compiler. Now let's talk about the compiler options inherited from the original HAL/S compiler. There are many such options that can be presented to the HAL/S compiler to affect its behavior.
These options were presented to the original compiler via a so-called "PARM field" in its Job Control Language (JCL). In the modern implementation, there's no such thing as JCL, so such options are instead provided to the compiler via the command line. For example,
text
HALSFC-PASS1 --parm="..." etc.
where the "..." represents a list of options, delimited by commas,
without additional blank spaces. For example, `--parm="LIST,SRN,TITLE=MY COMPILER``"`.
(Yes, I said "without spaces", but I meant without spaces between
the options. The space in this example is within the `TITLE` option, which has a
value that's a string.)
As it happens, many of the passes of the HAL/S compiler don't
directly accept such options, but instead expect them to have been
provided to an earlier compiler pass (such as PASS1 or PASS1B), and
to persist throughout the remaining compiler passes via `COMMON` memory. If you'll
recall the compiler report from PASS1 for the program HELLO.hal that
I used as an example earlier, you may also recall that it began with
a list of the options in effect for that particular program run:
> ```text
PARM FIELD: LIST
COMPLETE LIST OF COMPILE-TIME OPTIONS IN EFFECT
*** TYPE 1 OPTIONS ***
NOADDRS
NODECK
NODUMP
NOHALMAT
NOHIGHOPT
LFXI
LIST
NOLISTING2
MICROCODE
NOREGOPT
NOSDL
NOSREF
NOSRN
NOTABDMP
TABLES
NOTABLST
NOTEMPLATE
NOVARSYM
ZCON
*** TYPE 2 OPTIONS ***
BLOCKSUM = 400
CARDTYPE =
COMPUNIT = 0
DSR = 1
LABELSIZE = 1200
LINECT = 59
LITSTRINGS = 2000
MACROSIZE = 500
MFID =
PAGES = 2500
SYMBOLS = 200
TITLE =
XREFSIZE = 2000In contrast, the sample compiler report from PASS2 lists no such parameters, and yet it partakes of some of them (such as LIST) selected by invoking PASS1.
Many but not all of the allowed behavioral options are described in the HAL/S-FC User's Manual (section 5), but I'll give you my own take on them here. Overall, the options can be categorized in several ways. For one thing, they can be of "type 1" (meaning that they are mere on/off) or else of "type 2" (meaning that they have numerical or textual values). For another, they can be "printable" or "unprintable". All of the options you see in the compiler report above are printable; there are other options in effect, namely the unprintable ones, but the unprintable ones weren't printed in the report. Moreover, each of the options has a default value it assumes if it's not specified directly. Each of the type-1 options (i.e., the toggles) can be provided either in the positive form (meaning that the option is enabled) or the negative form (meaning that it is disabled). For example, the LIST option is enabled by putting LIST in the parm field, and is disabled by putting NOLIST in the parm field, though it is actually disabled by default anyway. Most options have both a long and a short form by which they can be specified. LIST is a long form. Its corresponding short form is simply L, whereas the short form of NOLIST is NL. Or at least, that's the case for PASS1 and PASS1B; for PASS4, LIST has instead become a type-2 option, and takes a numerical value, thus having no corresponding NOLIST or NL. But LIST appears to be the only parameter which changes its form in this chameleon-like way.
The table below shows the various compiler options accepted by different compiler passes. Remember that the pass at which the option is accepted is not necessarily the pass at which it has any effect, and is not even any indication that the option is used for anything at all. Some of the descriptions given in the table below are pasted or adapted from the HAL/S-FC User's Manual.
PARM-Field Options and Defaults, by Compiler Pass
| Accepted in PASS1 | Accepted in PASS1B | Accepted in PASS4 | Description |
| Type 1, Printable | |||
| DUMP (off, DP) | DUMP (off, DP) | Requests the compiler to produce a memory dump if internal compiler failures occur; useful only for compiler generation and debugging. | |
| LISTING2 (off, L2) | LISTING2 (off, L2) | Causes PASS1 to generate an "unformatted" source listing, which is an output-file (listing2.txt by default) separate from the normal compiler report generated by PASS1. The nature of such a secondary listing is perhaps best illustrated by simply showing you one from our sample HELLO.hal program: ```text | |
| 1 H A L C O M P I L A T I O N -- P H A S E 1 -- U N F O R M A T T E D S O U R C E L I S T I N G PAGE 1 |
- code
D| EBUG `D`E`F | 1
0 1 M| | 2
0 1 M| HELLO: PROGRAM; | 3 HELLO
0 1 M| DECLARE I INTEGER; | 4 HELLO
0 2 M| DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); | 5 HELLO
0 3 M| DECLARE INTEGER, J; | 6 HELLO
0 4 M| REPLACE PRINTER BY "6"; | 7 HELLO
0 5 M| WRITE(PRINTER) 'THE BEGINNING'; | 8 HELLO
0 6 M| DO FOR I = 1 TO 5; | 9 HELLO
0 7 M| WRITE(PRINTER) I, 'HELLO, WORLD!'; | 10 HELLO
0 8 M| DO FOR J = 2 TO 8 BY 2; | 11 HELLO
0 9 M| WRITE(PRINTER) J, MY_NAME, 'SAYS ISN''T THIS FUN?'; | 12 HELLO
0 10 M| END; | 13 HELLO
0 11 M| END; | 14 HELLO
0 12 M| WRITE(6) 'THE END'; | 15 HELLO
0 13 M| CLOSE HELLO; | 16 HELLO
0 14 M| | 17 HELLO
<a id="ANSI"></a>Perhaps the only thing not immediately clear to you would be the markings in the first column ('1', '-', '0'). These are so-called *ANSI control characters* (plus some IBM extensions to them) that would have informed a line printer as to disposition of the line. These are useful to know, because HAL/S code can use them in `OUTPUT(1)` statements as well. Here's what I think are all their possible values, although not all of them are ultimately used in secondary listings: - ' ': Single-space and print. - '0': Double-space and print. - '-': Triple-space and print. - '+: Overstrike the preceding line. - '1': Advance to the next page and print. - 'H': Don't print, but use the line as the heading for subsequent pages. - '2': Don't print, but use the line as the subheading for subsequent pages. - 'E': (Used only by HAL\_S\_FC.py, unrecognized by HALSFC-PASS1.) Eject the page immediately, printing a new page header. | | LIST (off, L) | LIST (off, L) | | Causes PASS2 to include AP-101S assembly-language for the compiled HAL/S program in the report it prints. (As you've seen above in [the PASS2 report generated from our sample HELLO.hal program](#report2).) | | TRACE (on, TR) | TRACE (on, TR) | | (I'm not sure what TRACE does, but the comments in HAL/S-FC source code indicate that it is for the IBM 360 target only, and thus is irrelevant to AP-101S.) | | VARSYM (off, VS) | VARSYM (off, VS) | | If specified, symbol-table information about the variables declared in the HAL/S program will be included in the AP-101S object-code file(s) generated by PASS2. Our sample HELLO.hal program, for example, has declarations for the integer variables `I` and `J`, and the string variable `MY_NAME`. Without VARSYM, while the object code would could correctly manipulate the data for these `I`, `J`, and `MY_NAME` by referencing their memory addresses, it would not include the symbolic names of `I`, `J`, and `MY_NAME`, nor their types (integer vs string), nor other interesting info about them. Such additional information would be useful, for example, in performing symbolic debugging of the AP-101S code. See the section on SYM records in [the Wikipedia article about the IBM 360 Object File Format](https://en.wikipedia.org/wiki/OS/360_Object_File_Format). | | DECK (off, D) | DECK (off, D) | | If specified, an additional copy (by default, deck.bin) of the object file produced by Phase 2 (by default, cards.bin or cards/) is produced. For the PASS version of the compiler, deck.bin is identical to cards.bin. For the BFS version of the compiler, the deck.bin differs from cards/. See [the section about the files produced by the compiler](#filesUsed). | | TABLES (on, TBL) | TABLES (on, TBL) | | With the TABLES option, PASS3 and PASS4 of the HAL/S compiler are enabled, with the advantage that a Simulation Data File (SDF) is created, and an informative report is generated about the SDF. Whereas by specifying NOTABLES, those passes are not performed, and compilation terminates after generation of object code by PASS2. | | TABLST (off, TL) | TABLST (off, TL) | TABLST (off, TL) | Causes PASS4 of the compiler to produce a formatted dump of the Simulation Data File. | | ADDRS (off, A) | ADDRS (off, A) | | Causes the Simulation Data Files (SDF) produced to include statement address information. | | SRN (off) | SRN (off) | | This should be specified if the source program is line numbered. It causes the compiler to scan columns 1-72 only, allowing columns 73-78 to be used for line numbers. **Note:** The Shuttle's PASS and BFS source code *does* have line numbers in columns 73-78, confing source code to columns 1-72, so the SRN option should always be used when compiling PASS/BFS source code. | | SDL (off) | SDL (off) | | Used to indicate to the compiler that this compilation is for SDL (Software Development Lab) use. The HAL/S-FC User's Manual goes on to describe a lot of [additional implications](https://www.ibiblio.org/apollo/Shuttle/HAL_S-FC%20User's%20Manual%20Nov%202005.pdf#page=68) of this that I won't bother to describe here. In brief, the Software Development Lab and its successor the Software Production Facility (SPF) were where the flight software was tested by running it in a simulated environment. Thus, option NOSDL meant the software would be built for Shuttle onboard usage, whereas option SDL meant the software would be built for ground-testing purposes. Additional reading: "[Spacecraft Avionics Software Development Then and Now: Different But the Same](https://www.ibiblio.org/apollo/Shuttle/20120013307.pdf)" and "[HAL/S-FC SDL Interface Control Document](https://www.ibiblio.org/apollo/Shuttle/HAL-S-FC-SDL-INTERFACE-CONTROL-DOCUMENT.pdf)". | | TABDMP (off, TBD) | TABDMP (off, TBD) | TABDMP (off, TBD) | Causes PASS4 to produce a hexadecimal dump of the Simulation Data File. | | ZCON (on, Z) | ZCON (on, Z) | | Causes calls to out-of-line routines (external references) to be performed via long indirect address constants. This is connected to the concept of `DECLARE`'ing data with the `REMOTE` attribute, which has caused me quite a lot of confusion personally, so I'll say a few words about it here. Given that the General Purpose Computers (GPC's) in a Shuttle intercommunicate among themselves, you might suppose that `REMOTE` data is data residing on a different GPC than the one running the HAL/S program. That's *not* what it is. Rather, `REMOTE` pertains to data which while residing on the local GPC is nevertheless not near enough in the address space of the GPC to the instruction using that data to be addressable in an efficient fashion. In particular, data which is farther away in the address space than 16 bits (in terms of 16-bit "halfwords") is not directly accessible in any simple fashion by AP-101S instructions. Data accessible via short address displacements (YCONs) can therefore be accessed more efficiently, whereas data accessible only via long addresses (ZCONs) is accessed much less efficiently and is `DECLARE`'d using the `REMOTE` attribute. What the ZCON compiler option does, I think, is the equivalent of implicitly causing all external symbols to be considered `REMOTE`. | | HALMAT (off, HM) | HALMAT (off, HM) | | If specified, HALMAT and literal tables are included in the SDF generated by PASS3. NOHALMAT will reduce the size of the SDF considerably. | | REGOPT (off, R) | REGOPT (off, R) | | Used to indicate to the compiler that register optimization is desired. Allows borrowing of register 3 for addressing `COMPOOL` data. The [HAL/S User's Manual](https://www.ibiblio.org/apollo/Shuttle/HAL_S-FC%20User's%20Manual%20Nov%202005.pdf#page=67) describes additional subtleties *vis-à-vis* the SDL option (see above). | | | SCAL (on, SC) | | NOSCAL inhibits the use of the AP-101S instructions `SCAL` and `SRET` for subroutine linkage, even if the MICROCODE option (see below) was also chosen. MICROCODE and NOSCAL together thus cause HAL/S linkage to be used instead of the `SCAL`/`SRET` instructions. If NOMICROCODE was specified, neither SCAL or NOSCAL has any effect. | | MICROCODE (on, MC) | MICROCODE (on, MC) | | Allows use of AP-101 instructions which only exist on late versions of the Space Shuttle GPC. This includes `SCAL`, `SRET`, `MVS`, `MVH`, and `BIX`. I've found no definitive explanation of how or when these late-model GPC instructions appeared. However, it may be worth remembering that *originally* the Shuttle's GPCs were IBM AP-101B computers. The upgraded AP-101S computers only began to be flown (with modifications to the flight software from OI-8F onward) in 1991. So far, the only descriptions I've found of the changes in the AP-101S vs the AP-101B have made no mention at all of new instruction types, and in particular, alas, we do not have a list of the AP-101B instruction set. My *guess* is that the newer instructions were present in the AP-101S but absent in the AP-101B. | | SREF (off, SR) | SREF (off, SR) | | Causes only those variables from an included `EXTERNAL COMPOOL` which are actually referenced by the unit being compiled to be printed in the cross reference listing. | | QUASI (off, Q) | QUASI (off, Q) | | (I'm not sure what QUASI does, but the comments in HAL/S-FC source code indicate that it is for the IBM 360 target only, and thus is irrelvant for AP-101S.) | | TEMPLATE (off, TP) | TEMPLATE (off, TP) | | Causes the generation of a template for the compilation unit. For example, if a HAL/S source-code file contains (say) a `FUNCTION`, then the TEMPLATE option causes a prototype for that function to be placed in the shared template library. By using a compiler directive (`D INCLUDE TEMPLATE ...`), independently-compiled HAL/S units can reuse that previously-defined function without having to know how to explicitly declare it themselves. (Or using an analogy, if C compilers had a TEMPLATE option, they could automatically generate a C header file from a C source-code file.) | | HIGHOPT (off, HO) | HIGHOPT (off, HO) | | The high optimization option (HIGHOPT) allows the compiler to perform optimizations that may not be valid under certain circumstances which [the HAL/S-FC User's Manual lists](https://www.ibiblio.org/apollo/Shuttle/HAL_S-FC%20User's%20Manual%20Nov%202005.pdf#page=66). In other words, optimization is better when the HIGHOPT option is used, but certain programming practices have to be avoided. Basically, HIGHOPT turns off certain kinds of datatype-checking, so that certain kinds of macros or manipulations of `NAME` variables which bypass the type-checking system should not be used. Thus HIGHOPT is probably safe to use except with code written by Very Clever People™ or by people who aspiring to be Very Clever. | | | | ALL (off) | (Note that this option is available only when PASS4 is run in stand-alone mode, rather than as part of **HALSFC**.) The comments in PASS4 source code indicate that "ALL" means "process all SDFs", though it's not quite clear to me what the implications of that are. | | | | BRIEF (off) | (Note that this option is available only when PASS4 is run in stand-alone mode, rather than as part of **HALSFC**.) If BRIEF is in effect, PASS4 does not print a formatted dump of the SDF in its output report. BRIEF automatically applies the TABLST and NOTABDMP compiler options. | | *Type 1, Unprintable* | | | | | PARSE (off, P) | PARSE (off, P) | | Debug. Gives parsing location information if an error is encountered. | | LSTALL (off, LA) | LSTALL (off, LA) | | Debug. Causes *both* assembly language (like LIST) *and* HALMAT to appear in PASS2's output report. | | LFXI (on) | LFXI (on) | | Causes the AP-101S instruction `LFXI` to be used in preference to `LHI`, `LE`, or `SER` instructions under certain circumstances. | | X1 (off) | X1 (off) | | <a id="x1"></a>[Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=625) (and [here](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661)) claims that option X1 disables optimization. However, in unmodified HAL/S-FC source code it has no actual effect on the output from the OPT pass, so perhaps it is something that had effect in HAL/S-360 but no longer had an effect in HAL/S-FC. *However*, HALSFC[.bat] differs from pure HAL/S-FC in this regard, in that the optimization pass (HALSFC-OPT) does indeed take the X1 option into account to disable optimization as described. Why did I bother to do that? Or perhaps better to ask, Why might one wish to disable optimization? Well, there's a commonly-used HAL/S code pattern, text
DO FOR INDEX = START TO END;
IF CONDITION THEN STATEMENT;
which compiles perfectly well in the first pass of the HAL/S compiler, but *sometimes* (not always, or even not usually) may subsequently be"optimized" by the optimization pass and accompanied by a fatal error such as the following: text
***** ZO3 ERROR #1 OF SEVERITY 1 OCCURRED *****
***** DURING CONVERSION OF HAL/S STATEMENT NNN.*****
***** LOOP INVARIANT PULLED FROM IF-THEN GROUP AT STATEMENT NNN
***** COULD RESULT IN UNINTENTIONAL GPC ERROR...DR103032
When this error occurs during optimization, object code cannot be generated by the compiler. I can almost hear you thinking something to the effect of, "That's so dumb it can't be real! There must be a bug in HALSFC, not in the original HAL/S-FC." Good thinking! But unfortunately it turns out not to be the case. The *HAL/S-FC User's Manual*, both on [page 8-28](https://www.ibiblio.org/apollo/Shuttle/HAL_S-FC%20User's%20Manual%20Nov%202005.pdf#page=110) and on [page B-73](https://www.ibiblio.org/apollo/Shuttle/HAL_S-FC%20User's%20Manual%20Nov%202005.pdf#page=197), describes this error, and in the latter reference even gives you a workaround for it if you can figure out exactly what's triggering the error and are willing to modify the HAL/S source code. Which is too bad, since while I can potentially fix a bug I introduced into HALSFC myself, I cannot fix a bug of this magnitude in the original HAL/S-FC source code. Or at any rate, I am not going to attempt doing so. The *User's Manual*'s suggested workaround, which is to "REFERENCE A VARIABLE CONTAINED IN THE EXPRESSION IN THE CONDITIONAL PART OF THE IF STATEMENT" may be effective for all I know, but forces you to introduce actual executable code that that otherwise would be completely unnecessary. It also requires a bit of investigation, thought, and probably experimentation to implement for each instance of ZO3 that you encounter. Another workaround for error ZO3 not mentioned by the user manual is to take advantage of [the `H(1)` "debugging aid"](#h1), by inserting compiler directives text
DO FOR INDEX = START TO END;
DEBUG H(1)
IF CONDITION THEN STATEMENT;
DEBUG H(1)
both immediately before and after the offending line or block of code. This has the effect of disabling optimization but just for the enclosed statement or block. This workaround is better, I think, than the one given in the *User's Manual*, since it doesn't introduce any extra HAL/S statements, but simply affects the optimizer. Both of the workarounds just mentioned are inconvenient in that they involve modifying the HAL/S source code itself, which you don't want to do when working with legacy code such as PASS or BFS, or when there are a *lot* of ZO3 errors strewn throughout the code base (which again, is true for PASS). Instead using the X1 compiler option involves no modification of HAL/S source code and is a much easier change to implement. On the other hand, the `H(1)` workaround disables optimization only for a few statements rather than for the entire file, and thus is a less-intrusive change to the generated object code. | | | | X3 (off) | [Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=626) (and [here](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661)) claims that option X3 causes the phase 1.5 (optimization) to list HALMAT changes. This must be false for HAL/S-FC, which does not even accept the X3 option in its PARM field. It's likely the documentation is referring to HAL/S-360 — alas, unavailable to us — instead, since HAL/S-360 does accept the X3 option. | | X4 (off) | X4 (off) | X4 (off) | (Apparently unused.) | | X5 (off) | X5 (off) | X5 (off) | <a id="X5"></a>The X5 option enables a TRACE functionality (not to be confused with the IBM 360 TRACE option described above) during the OPT pass. [Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661) describes it as printing program flow and data bases. Here's an excerpt from OPT's output report from HELLO.hal that shows the effect: text
PAGE 1
SYMBOL_SHRINKER(2): 2 I SYMBOL_SHRINKER(3): 3 MY_NAME SYMBOL_SHRINKER(4): 4 J SYMBOL_SHRINKER(5): 5 PRINTER
PAGE 2
HAL/S OPTIMIZER -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:38:48.00
HAL/S OPTIMIZER ENTERED AUGUST 11, 2024. CLOCK TIME = 8:28:19.16
FINAL_PASS: 0 ASSIGNMENT: 27 ASSIGNMENT: 45
NO REL 2 2 I 3 3 MY_NAME 4 4 J 5 5 PRINTER STACK_DUMP: LEVEL=1, BLOCK#=2, INL#=0, OLD_LEVEL=0, OLD_BLOCK#=0, VAL_SIZE=1
LEVEL STACKED_BLOCK# STACK_TAGS PULL_LOOP_HEAD 0 1 00000000 -1 1 2 00000000 -1
RECORD_TOP(CATALOG_ARRAY)= 1 RECORD_TOP(VALIDITY_ARRAY)= 1 RECORD_TOP(ZAPS)= 1 ZAP_BASE=1, PULL_LOOP_HEAD(LEVEL)=-1 SYT_SIZE=5, SYT_WORDS=0, SYT_USED=0
VALIDITY ZAPS LOOP_ZAPS 00000000 00000014 00000014 ASSIGNMENT: 45 ⋮
| X6 (off) | X6 (off) | X6 (off) | The X6 option causes timing and other statistics to be collected and printed about the optimization process during execution of the OPT and AUXP passes. In the sample below, generated from the HELLO.hal program, the green parts represent the contribution of X6 to OPT's report. As for what it means, I couldn't tell you, other than that very little optimization seems to be have been needed for HELLO.hal. ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:38:48.00
HAL/S OPTIMIZER ENTERED AUGUST 10, 2024. CLOCK TIME = 18:36:29.10
CSE'S FOUND = 0
COMPARE CALLS = 0
SCANS = 0
MAX_NODE_LIST = 0
MAX_CSE_TAB = 1
MINOR COMPACTIFIES = 0
MAJOR COMPACTIFIES = 0
FREE STRING AREA = 16637938
END OF HAL/S OPTIMIZER AUGUST 10, 2024. CLOCK TIME = 18:36:29.10
TOTAL CPU TIME FOR OPTIMIZER 0:0:0.00
CPU TIME FOR OPTIMIZER SETUP 0:0:0.00
CPU TIME FOR OPTIMIZER CRUNCHING 0:0:0.00
CPU TIME FOR OPTIMIZER CLEAN UP 0:0:0.00
END OF HAL/S OPTIMIZER AUGUST 10, 2024. CLOCK TIME = 18:36:29.10
``` In the case of AUXP, the report would normally be completely empty, so the entire report is contributed by X6: ```text
PAGE 1
HAL/S AUXILIARY HALMAT GENERATOR -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:39:10.00
HAL/S AUXILIARY HALMAT GENERATOR ENTERED AUGUST 10, 2024. CLOCK TIME = 18:55:22.04
END OF HAL/S AUXILIARY HALMAT GENERATOR AUGUST 10, 2024. CLOCK TIME = 18:55:22.04
TOTAL CPU TIME FOR AUXILIARY HALMAT GENERATOR : 0:0:0.01
CPU TIME FOR AUXILIARY HALMAT GENERATOR SETUP : 0:0:0.01
CPU TIME FOR AUXILIARY HALMAT GENERATOR CRUNCHING : 0:0:0.00
TOTAL NUMBER OF GARBAGE COLLECTIONS = 2
MAXIMUM NUMBER OF USED CELLS = 499
TOTAL TIME SPENT IN GARBAGE COLLECTION = 0:0:0.00
TOTAL TIME SPENT IN PRETTY PRINTING AUXMAT = 0:0:0.00
MAXIMUM STACK LEVEL = 1
NUMBER OF MINOR COMPACTIFIES = 0
NUMBER OF MAJOR COMPACTIFIES = 0
FREE STRING AREA = 16582621
``` |
| | | X7 (off) | (Apparently unused.) |
| | | X8 (off) | (Apparently unused. Comments in PASS2 erroneously indicate that it is used there, but are in actuality referring to the MICROCODE option.) |
| | | X9 (off) | (Apparently unused.) |
| XA (off) | XA (off) | XA (off) | (Apparently unused.) |
| XB (off) | XB (off) | | The XB option adds information to PASS3's output report about deleted symbols. |
| XC (off) | XC (off) | | The XC option adds a symbol-table dump to PASS3's output report. |
| | | XD (off) | (Apparently unused.) |
| XE (off) | | XE (off) |
| XF (off) | XF (off) | XF (off) |
| | | XG (off) |
| | | XH (off) |
| | | XI (off) |
| | | XJ (off) |
| | | XK (off) |
| | | XL (off) |
| | | XM (off) |
| | | XN (off) |
| | | XO (off) |
| | | XP (off) |
| *Type 2, Printable* | | | |
| TITLE ("", T) | TITLE ("", T) | TITLE ("", T) | Specifies a (1 to 60 character) title to be printed by PASS1 as a header at the top of each page of its output report. The header should be specified precisely as it is to appear. It may contain spaces, but should *not* contain any commas, since commas are delimiters between options appearing in the PARM field. The default is "T I T A N S Y S T E M S C O R P .", presumably because Intermetrics merged with the Titan Corporation in March of 2000. The default title had previously been "I N T E R M E T R I C S", but was changed a couple of years after the merger. Titan was later acquired by L-3 Communications, but I have no information as to whether the default was changed again. |
| LINECT (59, LC) | LINECT (59, LC) | LINECT (59, LC) | Sets the maximum number of lines to be printed on any one page of the primary or unformatted secondary (see the LISTING2 option above) source listing. This concept is trickier than it sounds, and if you actually count the number of lines on a page you may be confused into thinking the option doesn't work. I think it probably does work, if keep in mind the various complications: - Double- or triple-spacing of lines via ANSI control characters (see LISTING2). - [Overstruck lines](#overstrike). - Page headings and subheadings. - Expansions of macros or templates. - PASS1's desire to advance to a new page for each `PROGRAM`, `PROCEDURE`, `FUNCTION`, or `COMPOOL`. |
| PAGES (2500, P) | PAGES (2500, P) | PAGES (10000, P) | Sets the maximum number of pages to be used for the primary compilation listing output by PASS1. |
| SYMBOLS (200, SYM) | SYMBOLS (200, SYM) | | Specifies the initial size of the symbol table to be used by the compiler. As the value is exceeded, the system will automatically allocate more space for it within the available memory. Each symbol requires 53 bytes of storage plus 1 byte of storage for each character in the symbol name. The default value may seem exceedingly optimistically small, insofar as Space Shuttle flight software is concerned, but remember that only a single compilation unit (`PROGRAM`, `PROCEDURE`, `FUNCTION`, `COMPOOL`) is compiled in any given run of the compiler, and the number of symbols in any given source-code file is rather modest in comparison to PASS as a whole. |
| MACROSIZE (500, MS) | MACROSIZE (500, MS) | | Specifies the initial number of characters allowed in the combined text of all `REPLACE` macro definitions. As the value is exceeded, the system will automatically allocate more space for it within the available memory. |
| LITSTRINGS (2000, LITS) | LITSTRINGS (2000, LITS) | | Specifies the maximum total number of characters permitted in all character literals in the program to be compiled. (Note that the amount used for each character string in the program is 1 more than the number of characters in the string). |
| COMPUNIT (0, CU) | COMPUNIT (0, CU) | | Specifies a compilation unit number, which is made available in the SDF and in the Block Data Areas, and which allows an analysis of active blocks in a core dump. |
| XREFSIZE (2000, XS) | XREFSIZE (2000, XS) | | Specifies the initial number of cross reference table entries available to the compiler. As the value is exceeded, the system will automatically allocate more space for it within the available memory. Each entry requires four bytes of storage. |
| CARDTYPE ("", CT) | CARDTYPE ("", CT) | | Allows statements with non-standard characters in the first column to be treated in the standard HAL/S fashion. A mapping of non-standard characters into standard types (E, M, S, C, D and blank) is specified by coding pairs of characters. E.g., if “CARDTYPE=XCYM” (or "CT=XCYM") were coded, any lines with X in the first column would be read as comments (C), while lines with Y in the first column would be read as regular main source code lines (M). **Aside:** If you experience difficulty using a literal blank as a replacement character, use M as the replacement character instead. M is completely equivalent to a blank space, insofar as column 1 is concerned. You may be puzzled why such a thing would be needed, or how it might be used. Generally speaking, it is used only exceedingly rarely. The best way to think of it may be as a way of implementing conditional compilation. For code which you may or may not want to include in your program, and want a convenient way of enabling it or disabling it at compile time, you might put a special character in column 1, say "G". At compile time, you could specify the option CARDTYPE=GM if you wanted to include the code, or CARDTYPE=GC if you wanted to comment it out. This could be used for debugging, for compiling different configurations, as hints for software other than the compiler itself, etc. As of this writing, the following list describes all of the characters you could find in column 1 of HAL/S files (in PASS, BFS, our adaptation of sample code from *Programming in HAL/S*, etc.), and some which you will not (even though a theoretical interpretation is assigned to them): - The following column-1 characters are standard in HAL/S, thus requiring no `CARDTYPE` parameter for correct processing: - ␢ (i.e., ' ', a blank space): normal source code. - C: full-line comments. - D: compiler directives. - E: exponent lines. - M: normal source code. - S: subscript lines. - The following characters have no currently-known column-1 use in existing code, and are therefore available for your own programming pleasure as a burgeoning HAL/S developer. Unfortunately, we have no way of knowing if some of these may perhaps have been used in PASS versions not available to us, in BFS (very little of which is available to us), or in legacy non-PASS/BFS code (which is out there somewhere in the world, even if it's hidden away somewhere out of public view). - I, J, K, L, P, Q, and (possibly, but I don't know for sure) all non-alphabetic characters. - The following column-1 character interpretations were invented by Intermetrics or by the United Space Alliance (USA) for use in the original PASS source code. I'll give a short summary here, but a more-complete explanation follows later on. Other than the explicit exceptions noted below, all of the following column-1 characters are generally be equated to C (full-line comments) when compiling PASS source code: - A: Use `CARDTYPE=AM` for module GKDASC. - B: Use `CARDTYPE=BD` for modules CPTOSV and CPUSLS. - F: Use `CARDTYPE=FD` for module GKDASC. - G: Use `CARDTYPE=GD` for module GKRORB. - H: Use `CARDTYPE=HD` for module GKGMNV. - N: Use `CARDTYPE=NM` for module GKGMNV. - O: Use `CARDTYPE=OM` for module GKRORB. - R: Use `CARDTYPE=RM` for modules GKDASC and GKGMNV. Use `CARDTYPE=RC` for modules GKRORB, but `CARDTYPE=RM` otherwise. - T: Use `CARDTYPE=TM` for OI301700 (*not* for OI340600) module GKFHOR. - The following column-1 character interpretations were invented the Virtual AGC Project: - For "modern" compilation (by **HALSFC** or **HAL\_S\_FC.py**), for the *very* rare cases in which the original PASS source code needed tweaking to be compiled using the modern compilers. (At the present writing, "*very* rare" means "none at all".) - U: Use `CARDTYPE=UD` for modern compilation, but `CARDTYPE=UC` for contemporary compilation. (Opposite of X.) - V: Use `CARDTYPE=VM` for modern compilation, but `CARDTYPE=VC` for contemporary compilation. (Opposite of W.) - W: Use `CARDTYPE=WC` for modern compilation, but `CARDTYPE=WM` for contemporary compilation. (Opposite of V.) - X: Use `CARDTYPE=XC` for modern compilation, but `CARDTYPE=XD` for contemporary compilation. (Opposite of U.) - For HAL/S source-code files intended to compile with both the BFS flavor of the HAL/S compiler and the PASS flavor as well, such as newly-written HAL/S programs or the sample programs from the book *Programming in HAL/S*. Example: For the BFS flavor of the compiler, each `PROGRAM`, `PROCEDURE`, or `FUNCTION` *must* end with the statement "`%SVCI(N);`" (for some integer *`N`*) to avoid compile-time errors. Whereas "`%SVCI(``N)`" is not even supported by the PASS compiler and would thus trigger a compile-time error if present. - Y: `CARDTYPE=YM` for BFS version of the HAL/S compiler versus `CARDTYPE=YC` for the PASS version of the HAL/S compiler. (Opposite of Z.) - Z: `CARDTYPE=ZC` for BFS version of the HAL/S compiler versus `CARDTYPE=ZM` for the PASS version of the HAL/S compiler. (Opposite of Y.) **Note:** If you don't supply **HALSFC** with a `--parms` parameter, or if CARDTYPE= is not among the compiler options you provide via `--parms`, HALSFC will construct a default CARDTYPE for you from the list above, namely: - CARDTYPE=UDVMWCXCYCZY for PFS - CARDTYPE=UDVMWCXCYMZC for BFS Now regarding the use of conditional compilation in actual surviving PASS source code, finding the answer as to how to do so involved picking through the PASS source code to find any relevant comments ... and sometimes using some guesswork and trial-and-error. The most-informative (and at the same time most-troublesome) uses and comments are found in the PASS file GKPMNV.hal. This file is not actually a HAL/S compilation unit of itself, but rather a file that is "included" via the compiler directive "D INCLUDE GKPMNV" into one or the other of the PASS modules GKDASC, GKRORB, or GKGMNV. Below is a short excerpt from the source code of GKPMNV.hal, showing how some of these column-1 characters are used in it. Notice that the baleful effects of column 1 extend to columns 2, 3, and 4 as well! ```text
.
.
.
DECLARE GKP_ERR_MSG_REQ BOOLEAN AUTOMATIC INITIAL(OFF); 009900AA
DECLARE GKP_ITEM BIT(16) AUTOMATIC INITIAL (HEX'0000'); 010000AI
DECLARE GKP_ITEM_NO BIT(16) AUTOMATIC INITIAL (HEX'0000'); 010100AI
DECLARE GKP_CASE_ARRAY_NO INTEGER AUTOMATIC INITIAL (0); 010200AI
DECLARE GKP_ITEM_DATA_SC SCALAR DOUBLE AUTOMATIC INITIAL (0.0); 010300AI
DECLARE GKP_ITEM_DATA_INT INTEGER DOUBLE AUTOMATIC INITIAL (0.0);010400AI
RG13 DECLARE GKP_TGT_CASE ARRAY(19) INTEGER 010500AA
RG13 CONSTANT(3,1,1,1,1,6,6,6,4,4,7,8,9,10,11,5,2,2,2); 010600AA
OG2 DECLARE GKP_TGT_CASE ARRAY(20) INTEGER 010700AA
OG2 CONSTANT(3,1,1,1,1,6,6,6,4,4,7,0,0,0,0,5,2,2,2,8); 010800AA
AG1 DECLARE GKP_NON_TGT_CASE 010900AA
AG1 ARRAY(14) INTEGER CONSTANT(0,0,0,2,3,1,5,0,4,4,4,4,4,4); 011000AA
OG2 DECLARE GKP_NON_TGT_CASE 011100AA
OG2 ARRAY(14) INTEGER CONSTANT(0,0,0,2,3,1,0,0,4,4,4,4,4,4); 011200AA
NG3 DECLARE GKP_NON_TGT_CASE 011300AA
NG3 ARRAY(19) 011400AA
NG3 INTEGER CONSTANT(5,5,5,2,3,1,0,8,4,4,4,4,4,4,9,10,6,11,7); 011500AA
DECLARE GKP_GMBL_L_R_Y_COORD ARRAY(3) INTEGER CONSTANT(-67,-94,-121); 011600AA
.
.
.
``` Yikes! But we're fortunate, because the comments at the top of the source-code file do explain what's going on. I quote the entire explanation: ```text
C******************************************************************* 000100AA
C* THE SAME SOURCE MODULE, GKPMNV, IS USED FOR MANEUVER KIPS 000200AA
C* IN OPS 1,2 AND 3. 000300AA
C* 000400AA
C* IN GKPMNV: 000500AA
C* EXECUTABLE CODE UNIQUE TO OPS 1 HAS AN 'A' IN COL 1. 000600AA
C* INCLUDE CARDS UNIQUE TO OPS 1 HAVE AN 'F' IN COL 1. 000700AA
C* EXECUTABLE CODE UNIQUE TO OPS 2 HAS AN 'O' IN COL 1. 000800AA [and OPS 8, I think]
C* INCLUDE CARDS UNIQUE TO OPS 2 HAVE A 'G' IN COL 1. 000900AA [and OPS 8, I think]
C* EXECUTABLE CODE UNIQUE TO OPS 3 HAS AN 'N' IN COL 1. 001000AA
C* INCLUDE CARDS UNIQUE TO OPS 3 HAVE AN 'H' IN COL 1. 001100AA
C* EXECUTABLE CODE COMMON TO OPS 1&3 HAS AN 'R' IN COL 1.001200AA
C* INCLUDE CARDS COMMON TO ALL OPS HAVE A 'D' IN COL 1. 001250AG
C* 001300AA
C* FOR OPS 1, GKPMNV IS COMPILED WITH PARAMETER 001400AA
C* 'CARDTYPE=AMOCNCRMFDGCHC' IN THE HAL COMPILE CARD. 001500AA
C* THIS CREATES PROCEDURE GKD_ASC_MNVR_KIP BY TREATING 001600AA
C* AS COMMENTS SOURCE STATEMENTS HAVING 'R' OR 'O' IN COL 1. 001700AA
C* 001800AA
C* FOR OPS 2, 'CARDTYPE=ACOMNCRCFCGDHC' TO CREATE GKR_ORB_MNVR_KIP001900AA
C* 002000AA
C* FOR OPS 3, 'CARDTYPE=ACOCNMRMFCGCHD' TO CREATE GKG_MNVR_KIP. 002100AA
C* 002200AA
C* IN ADDITION, LINES UNIQUE TO A GIVEN OPS HAVE THE 002300AA
C* FOLLOWING SPECIFIC CODES AS THE FIRST 2 OR 3 CHARACTERS: 002400AA
C* 'G1' FOR OPS 1 UNIQUE LINES 002500AA
C* 'G2' FOR OPS 2 UNIQUE LINES 002600AA [and OPS 8, I think]
C* 'G3' FOR OPS 3 UNIQUE LINES 002700AA
C* 'G13' FOR OPS 1&3 COMMON LINES 002800AA
C* ' ' FOR OPS 1,2&3 COMMON LINES (I.E. CODE COMMON TO ALL OPS002900AA
C* HAS NO SPECIAL CHARACTERS). 003000AA
C* 003100AA
C* THE VARIOUS CODES ARE REPLACE NAMES FOR BLANKS AND AT 003200AA
C* COMPILE TIME THEY HAVE NO EFFECT IN THE COMPILATION OTHER THAN 003300AA
C* IDENTIFYING THE OPS TO WHICH A STATEMENT BELONGS. 003400AA
C* 003500AA
C******************************************************************** 003600AA
REPLACE G1 BY " "; 003700AA
REPLACE G2 BY " "; 003800AA
REPLACE G3 BY " "; 003900AA
REPLACE G13 BY " "; 004000AA
C********************************************************************** 004100AA
``` I've added the notes about OPS 8 above because PASS module GKRORB, to which the specified settings apply, appears in both OPS 2 and OPS 8 GPC memory images. It's perhaps worth noting also that several flight-software modules have comments similar to this one we find in the module CPUSLS, ```text
C********************************************************************** 000005AG
C************************ ******************* 000010AG
C THIS MODULE IS SET UP FOR THE SM PREPROCEESOR TO 000015AG
C GENERATE THIS COMPOOL FOR S2 ONLY OR S4 ONLY OR 000020AG
C BOTH OPS. 000025AG
C THIS MODULE MAY CONTAIN F,A AND B CARDS TO BE 000030AG
C USED BY THE PREPROCESSOR TO GENERATE THIS TABLE. 000035AG
C THE PROCEDURE ON HOW TO UPDATE THIS MODULE WILL BE 000040AI
C CONTAINED IN THE SAMS. 000045AG
C************************ ******************* 000050AG
C********************************************************************** 000055AG
``` which tells us that HAL/S source code was at least sometimes coded with the expectation of being preprocessed in some manner no longer possible for us now. The term "SAM" used in the note above (as "SAMS") may refer to the so-called Software Awareness Memos, as described in the *[Space Shuttle Programs Orbiter Avionics Software Programming Standard Document](https://www.ibiblio.org/apollo/Shuttle/IBM-82-SS-4556%20-%20Rev%204%20-%20Space%20Shuttle%20Orbiter%20Avionics%20Software%20-%20Programming%20Standards%20Document%20-%20Shuttle%20Flight%20Software.pdf)*. Alas, as of this writing we have not a single SAM in our possession. **Aside:** Regarding the "SM PREPROCEESOR" mentioned in the program comments quoted above, there are several documents in our library pertaining to HAL/SM, which is described as being a dialect of the HAL/S language appropriate for something called the Concept Verification Test (CVT) environment rather than the Space Shuttle itself. The SM preprocessor is said to "convert HAL/SM source language modules into HAL/S source language modules, perform minimal syntax verification, and provide various support features which cannot be conveniently or adequately performed by the HAL/S-360 Compiler." See also: - "[HAL/SM Language Specification](https://www.ibiblio.org/apollo/Shuttle/NASA-CR-144100%20-%20HAL,%20SM%20Language%20Specification.pdf)" - "[HAL/SM System Functional Design Specification](https://www.ibiblio.org/apollo/Shuttle/19760007755.pdf)" - "[HAL/SM System Software Requirements Specification](https://www.ibiblio.org/apollo/Shuttle/NASA-CR-144099%20-%20HAL,%20SM%20System%20Sofware%20Requirements%20Specification.pdf)" |
| LABELSIZE (1200, LBLS) | LABELSIZE (1200, LBLS) | | Specifies the initial number of labels which can be recognized by the compiler. As the value is exceeded, the system will automatically allocate more space for it within the available memory. "Labels" in HAL/S, recall, are things like ```text
MY_LABEL: ...
``` that can be used as the targets of `GOTO` statements. A name of a `PROGRAM`, `PROCEDURE`, `FUNCTION`, or `COMPOOL` may also technically be a "label", but it's TBD as to whether they're included in this count or not. |
| DSR (1) | DSR (1) | | "Specifies the value to be used for the data sector register in the right hand halfword of the `R2` operand of the `MVH` instruction. The compiler will use this value explicitly when it is not possible to use a standard z-type address constant in which the DSR field is filled in by the link editor." That's a direct quote from the HAL/S-FC User's Manual, but I personally haven't much of a clue as to what it may mean, other than that it relates to AP-101S assembly language, and I guess, to the linking process for it. |
| BLOCKSUM (400, BS) | BLOCKSUM (400, BS) | | Specifies the initial size of the PASS1 internal compiler table used for collecting information for printing block summaries. As this value is exceeded, the system will automatically allocate more space for it within the available memory. |
| MFID ("") | | | Allows specification of the Major Function ID. Implemented in the PASS version of the compiler only (versus the BFS version). |
| | OLDTPL ("", 0) | | (No longer a valid option, even though accepted by the compiler. It involves the record length used in template files, which is now fixed at 80.) |
| | | LIST (1, L) | (Do not confuse with the LIST option for PASS1. Although PASS4 does accept the type-2 LIST option, it does not appear to me that it uses the value of the option in any way.) |
# <a id="debuggingAids"></a>Debugging-Aid Options
In addition to compiler options originally supplied by JCL, but
now supplied by command-line switches as described in the
preceding section, there are also compiler options which can be
supplied within the HAL/S source code itself. These
typically (but not always) differ from the command-line options in
that they tend to take effect at the position in the HAL/S source
code at which the compiler encounters them. As the title of
this section implies, such options are often (but not always) for
the purpose of debugging the compiler itself.
Such options are inserted into the code via `DEBUG` compiler directives
aligned with column 1 of the source code, and you can see examples
of them (highlighted in green) in our little sample HELLO.hal
program:
> ```text
DEBUG ¢D¢E¢F
HELLO: PROGRAM;
DECLARE I INTEGER;
DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY');
DECLARE INTEGER, J;
REPLACE PRINTER BY "6";
WRITE(PRINTER) 'THE BEGINNING';
DO FOR I = 1 TO 5;
WRITE(PRINTER) I, 'HELLO, WORLD!';
DO FOR J = 2 TO 8 BY 2;
WRITE(PRINTER) J, MY_NAME, 'SAYS ISN''T THIS FUN?';
END;
END;
WRITE(6) 'THE END';
CLOSE HELLO;This example turns on debugging-aid options D, E, and F.
Important reminder! If you're in the U.S., you probably have no way to easily produce the cent character (¢) from your keyboard. But our HAL/S compiler(s) internally use the back-tick (`) instead of the cent, so you can (and probably should) use that instead. Nevertheless, ¢ is what the Shuttle developers would have used back in the day on their IBM System/360 based development systems, so it's nice to remember that.
Section 2.2.7 ("Debugging Aids") of the HAL/S-FC & HAL/S-360 Compiler System Program Description describes many such options, although as you've probably come to expect, by no means all of them.
Debugging-aid options are of two general types:
- Options of the form ¢T, where T is a hexadecimal digit (0-9 or A-F) or the letter G, are used mainly (but not entirely) for PASS1. They can:
- Enable the option if specified as ¢T+
- Disable the option if specified as ¢T-
- Toggle the option if specified merely as ¢T with no suffix. The options are all disabled by default, and so in our HELLO.hal example above, the three toggles for D, E, and F enable all of them.
- Options of the form H(N), where N is a decimal
number (0-255), are used in compiler passes subsequent to
PASS1. I haven't put any of them in our HELLO.hal example
above, but they too are specified within
DEBUGcompiler-directives. PASS1 simply inserts N into a tag field in the next HALMAT intermediate-languageSMRKinstruction generated — which is at the beginning of the next HAL/S statement —, and then resets N=0 internally. Yes, I know it's not obvious what that means, but the point is that if multiple H(N) switches were encountered at the same time, then only the final one could take effect (at the beginning of the next statement). However, multiple H(n) settings can be accumulated and be in effect at the same time, it's merely that they have to be passed along in separateSMRKrecords. Roughly speaking,
- PASS1 is not affected by any H(n).
- H(1) through H(99) affect OPT.
- H(100) through H(127) affect FLO.
- H(128) through H(199) affect AUX.
- H(200) through H(255) affect PASS2.
Here's a table of the debugging-aid options that I'm aware of, usually with samples of how the options affect the reports output by the various compiler passes. You won't have to look too long to realize that any of these options, if they remain enabled, can increase the size of output reports dramatically. And if options are combined, the increase can be astounding. So rather than just enabling options at the beginning of the HAL/S program and leaving them enabled as I do in many of these examples for illustrative purposes, a more-normal usage would be to enable an option just prior to some place in the source code just prior to where a problem has been observed, and to disable them after the problematic section of code.
| Aid | PASS1 | FLO | OPT | AUX | PASS2 | Description |
| ¢0 | Yes | No | No | No | No | Interlists HALMAT intermediate language with HAL/S source code in PASS1's output report. Here's an excerpt for HELLO.hal, with changes highlighted in green, showing the effect of this option: ```text |
| ⋮ | ||||||
| 1 M | HELLO: | HELLO | ||||
| 1 M | PROGRAM; | HELLO | ||||
| HALMAT LINE 4: 4( 1),N, 0 |
: 1( 0) 0,1 2 M| DECLARE I INTEGER; |HELLO
HALMAT LINE 6: 4( 1),N, 0
: 2( 0) 0,0
HALMAT LINE 8: 841( 2),0, 2
: 3(SYT) 0,0
: 2(LIT) 0,0
3 M| DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); |HELLO
HALMAT LINE 11: 4( 1),N, 0
: 3( 0) 0,0
4 M| DECLARE INTEGER, J; |HELLO
HALMAT LINE 13: 4( 1),N, 0
: 4( 0) 0,0
5 M| REPLACE PRINTER BY "6"; |HELLO
HALMAT LINE 15: 4( 1),N, 0
: 5( 0) 0,0
HALMAT LINE 17: 31( 0),N, 1
HALMAT LINE 18: 25( 1),N, 0
: 2(IMD) 0,0
HALMAT LINE 20: 27( 1),N, 0
: 4(LIT) 0,0
HALMAT LINE 22: 21( 1),0, 0
: 6(IMD) 0,0
HALMAT LINE 24: 26( 0),0, 0
6 M| WRITE(PRINTER) 'THE BEGINNING'; |HELLO
^^^^^^^
⋮
| ¢1 | Yes | No | No | No | No | Stop processing at the end of Phase 1. Originally this meant that processing would stop after PASS1 had completed, but for the modern compiler the passes don't directly chain together, so this option no longer really halts processing. However, it does affect the messages printed when PASS1 terminates. |
| ¢2 | No | No | No | No | Yes | Stop processing at the end of Phase 2. Like ¢1 (see above), except for PASS2 rather than PASS1. |
| ¢3 | Yes | No | No | No | No | Turns on the Phase 1 identifier trace. This trace info shows up in PASS1's output report. Here's a short excerpt of changes (highlighted in green) to the output listing, if I add ¢3 to the `DEBUG` compiler directive at the top of HELLO.hal: ```text
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 10, 2024 20:5:9.54 PAGE 3
STMT SOURCE CURRENT SCOPE
1 M| HELLO: |HELLO
1 M| PROGRAM; |HELLO
I : TOKEN = <IDENTIFIER>, IMPLIED_TYPE = 0, SYT_INDEX = 2, CONTEXT = 5
2 M| DECLARE I INTEGER; |HELLO
MY_NAME : TOKEN = <IDENTIFIER>, IMPLIED_TYPE = 0, SYT_INDEX = 3, CONTEXT = 5
3 M| DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); |HELLO
J : TOKEN = <IDENTIFIER>, IMPLIED_TYPE = 0, SYT_INDEX = 4, CONTEXT = 5
4 M| DECLARE INTEGER, J; |HELLO
PRINTER : TOKEN = <IDENTIFIER>, IMPLIED_TYPE = 0, SYT_INDEX = 5, CONTEXT = 10
5 M| REPLACE PRINTER BY "6"; |HELLO
PRINTER : TOKEN = -1, IMPLIED_TYPE = 0, SYT_INDEX = 5, CONTEXT = 0
AT 3 NEXT_CHAR=246 MACRO_EXPAN_LEVEL=1 MACRO_TEXT(1)=239 PARM_REPLACE_PTR(0)=0
AT 4 NEXT_CHAR=64 MACRO_EXPAN_LEVEL=1 MACRO_TEXT(1)=239 PARM_REPLACE_PTR(0)=0
AT 5 NEXT_CHAR=93 MACRO_EXPAN_LEVEL=0 MACRO_TEXT(-1)=0 PARM_REPLACE_PTR(0)=0
6 M| WRITE(PRINTER) 'THE BEGINNING'; |HELLO
^^^^^^^
I : TOKEN = <ARITH ID>, IMPLIED_TYPE = 0, SYT_INDEX = 2, CONTEXT = 0
⋮
``` |
| ¢4 | Yes | No | No | No | No | Turns on the Phase 1 token trace. This is a bit tricky to explain in a meaningful way, so I'll just say that the first operation of most compilers or interpreters tends to be to "scan" the input source code and convert it into a series of "tokens"; subsequent action by the compiler merely analyzes the sequence of tokens rather than the raw source code itself. The token trace gives a running account of the tokens the scanner identifies. Here's an excerpt from PASS1's output report showing the effect of the option. It's helpful to know that `BCD` is the token just identified (shown as a string) and that `NEXT_CHAR` is the EBCDIC code (in decimal) of the not-yet-analyzed, non-blank character following the current token. ```text
⋮
1 M| HELLO: |HELLO
1 M| PROGRAM; |HELLO
SCANNER: 103, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: DECLARE, NEXT_CHAR: 201
SCANNER: 131, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: I, NEXT_CHAR: 201
SCANNER: 105, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: INTEGER, NEXT_CHAR: 94
SCANNER: 10, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 196
2 M| DECLARE I INTEGER; |HELLO
SCANNER: 103, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: DECLARE, NEXT_CHAR: 212
SCANNER: 131, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: MY_NAME, NEXT_CHAR: 195
SCANNER: 118, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: CHARACTER, NEXT_CHAR: 77
SCANNER: 3, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 242
SCANNER: 136, NUMBER_VALUE: 421400000, VALUE: 20, CURRENT BCD: 20, NEXT_CHAR: 93
SCANNER: 9, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 201
SCANNER: 104, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: INITIAL, NEXT_CHAR: 77
SCANNER: 3, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 125
SCANNER: 132, NUMBER_VALUE: 00, VALUE: 10, CURRENT BCD: RON BURKEY, NEXT_CHAR: 93
SCANNER: 9, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 94
SCANNER: 10, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 196
3 M| DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); |HELLO
SCANNER: 103, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: DECLARE, NEXT_CHAR: 201
SCANNER: 105, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: INTEGER, NEXT_CHAR: 107
SCANNER: 14, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 209
SCANNER: 131, NUMBER_VALUE: 00, VALUE: 0, CURRENT BCD: J, NEXT_CHAR: 94
SCANNER: 10, NUMBER_VALUE: 00, VALUE: 0, NEXT_CHAR: 217
4 M| DECLARE INTEGER, J; |HELLO
⋮
``` |
| ¢5 | No | No | No | No | Yes | <a id="cent5"></a>This option adds HALMAT intermediate-language to PASS2's output report. Recall that optimization (FLO, OPT, and AUX) may have altered the HALMAT so that it's no longer quite the same as what was output by PASS1 (see ¢0 above). ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:39:23.00
HAL/S PHASE 2 ENTERED AUGUST 11, 2024. CLOCK TIME = 5:39:17.69
HALMAT: 005( 1), 0,0:0.0
HALMAT: 02B( 1), 0,0:0.2
1( 1), 0,0 :0.3
HALMAT: 004( 1), 0,0:0.4
1( 0), 0,1 :0.5
HALMAT: 004( 1), 0,0:0.6
2( 0), 0,0 :0.7
HALMAT: 841( 2), 2,0:0.8
3( 1), 0,0 :0.9
2( 5), 0,0 :0.10
HALMAT: 004( 1), 0,0:0.11
3( 0), 0,0 :0.12
HALMAT: 004( 1), 0,0:0.13
4( 0), 0,0 :0.14
HALMAT: 004( 1), 0,0:0.15
5( 0), 0,0 :0.16
HALMAT: 031( 0), 1,0:0.17
HALMAT: 025( 1), 0,0:0.18
2( 6), 0,0 :0.19
6( 6), 0,0 :0.23
HALMAT: 027( 1), 0,0:0.20
4( 5), 2,0 :0.21
HALMAT: 021( 1), 0,0:0.22
HALMAT: 026( 0), 0,0:0.24
HALMAT: 004( 1), 0,0:0.25
6( 0), 0,1 :0.26
HALMAT: 010( 4), 1,0:0.27
2( 1), 0,0 :0.29
AUX: 29 1 2(1) 0,0
1( 2), 0,1 :0.28
6( 5), 0,0 :0.31
5( 5), 0,0 :0.30
⋮
``` |
| ¢6 | No | No | No | No | Yes | Adds assembly language to PASS2's output report: ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:39:23.00
HAL/S PHASE 2 ENTERED AUGUST 11, 2024. CLOCK TIME = 5:47:27.31
I (1) 000002 002(1) 0
J (1) 000003 003(1) 0
MY_NAME (11) 000004 004(1) 0
*** HAL/S STATEMENT 1
000000:HELLO EQU *
000000: LHI 0,@0HELLO
000002: LHI 1,
000004: STH 1,5(0,0)
000005: IAL 0,0+DELTA.HELLO
000007: LA 3,0(0,9)
000009: STH 3,9(0,0)
*** HAL/S STATEMENT 2
*** HAL/S STATEMENT 3
*** HAL/S STATEMENT 4
*** HAL/S STATEMENT 5
*** HAL/S STATEMENT 6
00000A: LFXI 6,8
00000B: LFXI 5,5
00000C: SCAL 0,#QIOINIT
00000E: LA 2,=C'THE BEGINNING'
000010: SCAL 0,#QCOUT
⋮
``` |
| ¢7 | Yes | No | No | No | No | Immediately prints a symbol table and then disables the option. In the following excerpt from PASS1's output report, I've inserted this option just prior to HAL/S statement 7. (Recall that the characters '`' and '¢' are equivalent to the compiler, but that the compiler internally always uses '`'.) ```text
⋮
5 M| REPLACE PRINTER BY "6"; |HELLO
6 M| WRITE(PRINTER) 'THE BEGINNING'; |HELLO
^^^^^^^
D| EBUG `7 |HELLO
S Y M B O L & C R O S S R E F E R E N C E T A B L E L I S T I N G :
(CROSS REFERENCE FLAG KEY: 4 = ASSIGNMENT, 2 = REFERENCE, 1 = SUBSCRIPT USE, 0 = DEFINITION)
DCL NAME TYPE ATTRIBUTES & CROSS REFERENCE
1 HELLO PROGRAM FLAGS=20040, NEST=0, SCOPE=1, PTR=2, LENGTH=0, LINK1=-1, LINK2=0, SYT_NO=1,
ARRAY=-300, ADDR=0, CLASS=2, TYPE=73
2 I INTEGER SINGLE, ALIGNED, STATIC, FLAGS=800208, NEST=1, SCOPE=1, PTR=0, LENGTH=0,
LINK1=0, LINK2=0, SYT_NO=2, ARRAY=0, ADDR=0, CLASS=1, TYPE=6
3 MY_NAME CHARACTER(20) ALIGNED, STATIC, INITIAL, FLAGS=A08, NEST=1, SCOPE=1, PTR=0, LENGTH=20, LINK1=0,
LINK2=0, SYT_NO=3, ARRAY=0, ADDR=0, CLASS=1, TYPE=2
4 J INTEGER SINGLE, ALIGNED, STATIC, FLAGS=800208, NEST=1, SCOPE=1, PTR=0, LENGTH=0,
LINK1=0, LINK2=0, SYT_NO=4, ARRAY=0, ADDR=0, CLASS=1, TYPE=6
5 PRINTER REPLACE MACRO FLAGS=0, NEST=1, SCOPE=1, PTR=0, LENGTH=0, LINK1=0, LINK2=0, SYT_NO=5, ARRAY=0,
ADDR=0, CLASS=6, TYPE=0, MACRO TEXT="6"
7 M| DO FOR I = 1 TO 5; |HELLO
8 M| 1 WRITE(PRINTER) I, 'HELLO, WORLD!'; |HELLO
^^^^^^^
⋮
``` |
| ¢8 | Yes | No | No | No | No | Print a Phase 1 production trace. Here, a "production" is a rule in the Backus-Naur Form (BNF) of the grammar of the HAL/S language. For identification purposes, each such rule is given a unique number, and all of [the production numbers are related to the BNF rules according to comments in the compiler's source code](https://github.com/virtualagc/virtualagc/blob/master/yaShuttle/Source%20Code/PASS.REL32V0/PASS1.PROCS/%23%23DRIVER.xpl). As they used to say, "You could look it up!" For example, production number 1 is the `<COMPILATION>` rule, number 2 is the `<COMPILE LIST>` rule, and so on: ```text
⋮
/* 1 <COMPILATION> ::= <COMPILE LIST> _|_ */ 00000750
00000800
/* 2 <COMPILE LIST> ::= <BLOCK DEFINITION> */ 00000850
/* 3 | <COMPILE LIST> <BLOCK DEFINITION> */ 00000900
00000950
/* 4 <ARITH EXP> ::= <TERM> */ 00001000
/* 5 | + <TERM> */ 00001050
/* 6 | - <TERM> */ 00001100
/* 7 | <ARITH EXP> + <TERM> */ 00001150
/* 8 | <ARITH EXP> - <TERM> */ 00001200
⋮
``` What the ¢8 option does is to provide an inline trace to the PASS1 output file of each BNF rule processed: ```text
⋮
D| EBUG `8`D`E`F |
->->->->->->PRODUCTION NUMBER 308
->->->->->->PRODUCTION NUMBER 309
->->->->->->PRODUCTION NUMBER 311
->->->->->->PRODUCTION NUMBER 305
->->->->->->PRODUCTION NUMBER 302
------------------------------------------------------------------------------------------------------------------------------------------------------
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 11, 2024 6:17:20.50 PAGE 3
STMT SOURCE CURRENT SCOPE
1 M| HELLO: |HELLO
1 M| PROGRAM; |HELLO
->->->->->->PRODUCTION NUMBER 362
->->->->->->PRODUCTION NUMBER 389
->->->->->->PRODUCTION NUMBER 386
->->->->->->PRODUCTION NUMBER 380
->->->->->->PRODUCTION NUMBER 374
->->->->->->PRODUCTION NUMBER 366
->->->->->->PRODUCTION NUMBER 361
->->->->->->PRODUCTION NUMBER 346
->->->->->->PRODUCTION NUMBER 344
->->->->->->PRODUCTION NUMBER 343
2 M| DECLARE I INTEGER; |HELLO
->->->->->->PRODUCTION NUMBER 333
->->->->->->PRODUCTION NUMBER 349
->->->->->->PRODUCTION NUMBER 362
⋮
``` **Note:** In using a "modern" version of the HAL/S compiler, i.e., **HALSFC** or **HAL\_S\_FC.py**, there's an improved form of the production trace available, though at present it applies to the entire HAL/S source-code file, and cannot selectively be activated or deactivated on a statement-by-statement basis like ¢8. Simply add the option `--pretty-bnf` to the compiler command line. This feature is always available in **HAL\_S\_FC.py**, but for **HALSFC** requires **HALSFC-PASS1** to have been built with the option `-DALLOW_PRETTY_BNF`. That's not the default, however. [See the section on debugging XPL/I programs in on the XPL/I page](https://www.ibiblio.org/apollo/XPL-I.html#debugging). The improvement is that you automatically see the full text of the BNF rule for each "production", without the ultimately rather tedious effort of looking anything up: ```text
->->->->->->PRODUCTION NUMBER 230: <SUBSCRIPT> ::=
->->->->->->PRODUCTION NUMBER 216: <ARITH VAR> ::= <PREFIX> <ARITH ID> <SUBSCRIPT>
->->->->->->PRODUCTION NUMBER 27: <PRIMARY> ::= <ARITH VAR>
->->->->->->PRODUCTION NUMBER 15: <FACTOR> ::= <PRIMARY>
->->->->->->PRODUCTION NUMBER 11: <PRODUCT> ::= <FACTOR>
->->->->->->PRODUCTION NUMBER 9: <TERM> ::= <PRODUCT>
->->->->->->PRODUCTION NUMBER 4: <ARITH EXP> ::= <TERM>
->->->->->->PRODUCTION NUMBER 181: <EXPRESSION> ::= <ARITH EXP>
->->->->->->PRODUCTION NUMBER 288: <WRITE ARG> ::= <EXPRESSION>
``` |
| <a id="cent9"></a>¢9 | No | No | No | No | Yes | Includes a stack trace in PASS2's output report. And misspells "stack" in some places, which seems like a real accomplishment. ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:39:23.00
HAL/S PHASE 2 ENTERED AUGUST 11, 2024. CLOCK TIME = 6:21:39.17
GOT STAK 1
RET STACK 1
GOT STAK 1
GOT STAK 2
RET STACK 2
⋮
RET STACK 2
RET STACK 1
GOT STAK 1
GOT STAK 2
RET STACK 2
RET STACK 1
STACK NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 3
20 HELLO
OPTIONAL TABLE SIZES
NAME REQUESTED USED
^^^^ ^^^^^^^^^ ^^^^
LITSTRINGS 2000 68
LABELSIZE 1200 8
⋮
``` |
| ¢A | Yes | No | No | No | No | Immediately terminates PASS1. |
| ¢B | Yes | No | No | No | No | In the PASS1 output report, print HALMAT intermediate language after each "block". I'm not sure what a "block" is, but I'm sure that a HAL/S `PROGRAM`, `PROCEDURE`, or `FUNCTION` must certainly be one. Note that the HALMAT statements may be reordered versus those inlined with the HAL/S source code by the ¢0 option (see above). ```text
⋮
1 M| HELLO: |HELLO
1 M| PROGRAM; |HELLO
2 M| DECLARE I INTEGER; |HELLO
3 M| DECLARE MY_NAME CHARACTER(20) INITIAL('RON BURKEY'); |HELLO
4 M| DECLARE INTEGER, J; |HELLO
5 M| REPLACE PRINTER BY "6"; |HELLO
6 M| WRITE(PRINTER) 'THE BEGINNING'; |HELLO
^^^^^^^
7 M| DO FOR I = 1 TO 5; |HELLO
8 M| 1 WRITE(PRINTER) I, 'HELLO, WORLD!'; |HELLO
^^^^^^^
9 M| 1 DO FOR J = 2 TO 8 BY 2; |HELLO
E| , |
10 M| 2 WRITE(PRINTER) J, MY_NAME, 'SAYS ISN''T THIS FUN?'; |HELLO
^^^^^^^
11 M| 1 END; |ST#9
12 M| END; |ST#7
13 M| WRITE(6) 'THE END'; |HELLO
14 M| CLOSE HELLO; |HELLO
------------------------------------------------------------------------------------------------------------------------------------------------------
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 11, 2024 6:29:48.84 PAGE 4
STMT SOURCE CURRENT SCOPE
*** HALMAT BLOCK 0 ***
HALMAT LINE 0: 5( 1),0, 0
: 87( 0) 0,0
HALMAT LINE 2: 2B( 1),0, 0
: 1(SYT) 0,0
HALMAT LINE 4: 4( 1),N, 0
: 1( 0) 0,1
HALMAT LINE 6: 4( 1),N, 0
: 2( 0) 0,0
HALMAT LINE 8: 841( 2),0, 2
: 3(SYT) 0,0
: 2(LIT) 0,0
HALMAT LINE 11: 4( 1),N, 0
: 3( 0) 0,0
⋮
``` |
| ¢C | Yes | No | No | No | No | Print Phase 1 state trace. The compiler is a kind of [state machine](https://en.wikipedia.org/wiki/Finite-state_machine), with each state having a unique identifying number. However, the state transitions are table-driven, with both the state numbering and the state-tables having been computer generated by an automated system based on the book *A Compiler Generator* by McKeeman *et al*. The point of that techno-babble explanation is that the compiler's "states" are extremely human-unfriendly, and indeed almost uninterpretable without computer assistance, so it's unclear how to make use of any knowledge about them. (Perhaps that's my own ignorance getting the better of me, so I'd be interested to hear any explanation of how the state trace might be helpful. Though if you do try to explain it to me, it may become more of a state trance than a state trace.) ```text
⋮
D| EBUG `C |
COMP: STATE=1 I=0 J=0
COMP: STATE=138 I=2 J=0
COMP: STATE=1118 I=251 J=0
COMP: STATE=655 I=688 J=1
COMP: STATE=1119 I=859 J=1
COMP: STATE=394 I=701 J=1
COMP: STATE=1121 I=1079 J=1
COMP: STATE=647 I=702 J=1
COMP: STATE=1115 I=825 J=1
COMP: STATE=391 I=687 J=1
COMP: STATE=1112 I=1073 J=1
------------------------------------------------------------------------------------------------------------------------------------------------------
HAL/S REL32V0 T I T A N S Y S T E M S C O R P . AUGUST 11, 2024 6:35:35.36 PAGE 3
STMT SOURCE CURRENT SCOPE
1 M| HELLO: |HELLO
1 M| PROGRAM; |HELLO
COMP: STATE=618 I=686 J=1
COMP: STATE=345 I=706 J=1
COMP: STATE=144 I=901 J=1
COMP: STATE=538 I=283 J=1
COMP: STATE=1172 I=375 J=1
⋮
``` |
| ¢D | Yes | No | No | No | No | Documentation describes this option as "Turn on standard Phase 1 listing". The "standard source listing" is the inclusion of the HAL/S source code in PASS1's output report that has been ubiquitous in all of the PASS1 reports we've seen so far. However, in practice ¢D operates in an unexpected way. Inclusion of the standard source listing is by default initially *enabled*, but in the table of ¢*T* options is (like all ¢*T* options) initially marked as *disabled*. Therefore, the first time ¢D is encountered, inclusion of the standard output listing simply remains enabled. Subsequent occurrences of ¢D will then properly toggle it. To avoid confusion, it's best to always use ¢D+ or ¢D-, rather than simply expecting ¢D to produce the desired result. I'd regard this as a bug in the original compiler. |
| ¢E | Yes | No | No | No | No | This adds a table of numeric and string literals to PASS1's output report. Numbers, even if integers rather than floating-point, are printed as hexadecimal representations of double-precision [IBM hexadecimal floating-point](https://en.wikipedia.org/wiki/IBM_hexadecimal_floating-point) format. For example, the integer literal 20 will be printed as 4214000000000000. As obtuse as that seems at first glance, it's actually useful information: The compiler communicates the values of literals from one compiler pass to the next in a file (the "literal file"), and the literal file does use the IBM hex format for all numbers. Thus knowing the IBM hex values is exactly what's needed for interpreting the literal file. (See [the next section](#filesUsed) for more info about files produced by the compiler.) ```text
⋮
S Y M B O L & C R O S S R E F E R E N C E T A B L E L I S T I N G :
(CROSS REFERENCE FLAG KEY: 4 = ASSIGNMENT, 2 = REFERENCE, 1 = SUBSCRIPT USE, 0 = DEFINITION)
DCL NAME TYPE ATTRIBUTES & CROSS REFERENCE
1 HELLO PROGRAM XREF: 0 0001
2 I INTEGER SINGLE, ALIGNED, STATIC XREF: 0 0002 4 0007 2 0008
4 J INTEGER SINGLE, ALIGNED, STATIC XREF: 0 0004 4 0009 2 0010
3 MY_NAME CHARACTER(20) ALIGNED, STATIC, INITIAL XREF: 0 0003 2 0010
5 PRINTER REPLACE MACRO MACRO TEXT="6" XREF: 0 0005 2 0006 2 0008 2 0010
L I T E R A L T A B L E D U M P:
LOC TYPE LITERAL
1 ARITH 4214000000000000
2 CHAR RON BURKEY
3 ARITH 4160000000000000
4 CHAR THE BEGINNING
5 ARITH 4110000000000000
6 ARITH 4150000000000000
7 ARITH 4160000000000000
8 CHAR HELLO, WORLD!
9 ARITH 4120000000000000
10 ARITH 4180000000000000
11 ARITH 4120000000000000
12 ARITH 4160000000000000
13 CHAR SAYS ISN'T THIS FUN?
14 ARITH 4160000000000000
15 CHAR THE END
⋮
``` |
| ¢F | Yes | No | No | No | No | This adds some extra info to the symbol-table listing provided in PASS1's output report. ```text
⋮
S Y M B O L & C R O S S R E F E R E N C E T A B L E L I S T I N G :
(CROSS REFERENCE FLAG KEY: 4 = ASSIGNMENT, 2 = REFERENCE, 1 = SUBSCRIPT USE, 0 = DEFINITION)
DCL NAME TYPE ATTRIBUTES & CROSS REFERENCE
1 HELLO PROGRAM FLAGS=20040, NEST=0, SCOPE=1, PTR=2, LENGTH=0, LINK1=-1, LINK2=0, SYT_NO=1,
ARRAY=-8192, ADDR=0, CLASS=2, TYPE=73 XREF: 0 0001
2 I INTEGER SINGLE, ALIGNED, STATIC, FLAGS=808208, NEST=1, SCOPE=1, PTR=0, LENGTH=0,
LINK1=0, LINK2=0, SYT_NO=2, ARRAY=0, ADDR=0, CLASS=1, TYPE=6 XREF: 0 0002
4 0007 2 0008
3 MY_NAME CHARACTER(20) ALIGNED, STATIC, INITIAL, FLAGS=8A08, NEST=1, SCOPE=1, PTR=0, LENGTH=20,
LINK1=0, LINK2=0, SYT_NO=3, ARRAY=0, ADDR=0, CLASS=1, TYPE=2 XREF: 0 0003
2 0010
4 J INTEGER SINGLE, ALIGNED, STATIC, FLAGS=808208, NEST=1, SCOPE=1, PTR=0, LENGTH=0,
LINK1=0, LINK2=0, SYT_NO=4, ARRAY=0, ADDR=0, CLASS=1, TYPE=6 XREF: 0 0004
4 0009 2 0010
5 PRINTER REPLACE MACRO FLAGS=C000, NEST=1, SCOPE=1, PTR=0, LENGTH=0, LINK1=0, LINK2=0, SYT_NO=5,
ARRAY=0, ADDR=0, CLASS=6, TYPE=0, MACRO TEXT="6" XREF: 0 0005 2 0006 2 0008
2 0010
⋮
``` |
| ¢G | No | No | No | No | No | (The compiler accepts option ¢G, but it is apparently not used for anything.) |
| H(0) | No | Yes | Yes | Yes | Yes | Has no effect. |
| H(1) | No | No | Yes | No | No | <a id="h1"></a>[Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661) describes this as "Optimizer off until next such statement encountered. No CSE's recognized across the pair of DEBUG's". The "optimizer off" part may seem clear until you actually try it out. If you have the same unsettling experience I did when I first tried it, you may find that it seems not to alter the output HALMAT (optmat.bin) from what it was without H(1). And not only that, optmat.bin continues to be different from the unoptimized HALMAT (halmat.bin), whereas you'd expect them to be the same if optimization were turned off. You'd be forgiven for thinking that H(1) doesn't work after all! But no, it *does* work, and does so essentially as advertised. The trick, I think, is to recognize that a directive like ```text
DEBUG H(1)
``` seems to have no effect if it precedes the first HAL/S statement. For example, if you put it at the very first line of the source code, then that will precede any HAL/S statements, and hence it will have no apparent effect. *But* if it follows at least one executable statement — realizing that a comment is *not* a "statement" in this context —, I have observed that it really seems to disable optimization. Even so, optmat.bin will still probably differ from halmat.bin, since whatever optimization took place before the compiler directive will still alter the output. As for the "No CSE's ..." part, I don't claim to fully understand it, though I can say a couple of things about it. CSE stands for Common Sub-Expression, and one thing the optimizer tries to do is to find them when it can, so as to reduce the amount of time-wasting arithmetic being performed. Documentation gives the example of initial code that looks like ```text
F = A - D + B - C;
G = D - C - B + A;
``` but which optimization transforms into ```text
CSE1 = A - C;
CSE2 = B - D;
F = CSE1 + CSE2;
G = CSE1 - CSE2;
``` thus turning 6 arithmetical operations into just 4. Often, the values of these CSE's can just be stuck into a CPU register and kept there for their period of usefulness, thus making operations involving them even faster. Presumably, saying that "no CSE's are recognized across a pair of DEBUG's" is similar to saying that when a pair of compiler directive like "`DEBUG H(1)`" is encountered that turn the optimizer off and then on again, the CSE's which have been computed prior to optimization being turned off are no longer trusted after optimization is turned on again. |
| H(2) | No | No | Yes | No | No | [Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661) describes this as "Same as above, but CSE's may be recognized across the pair". A more-understandable explanation would be nice, but it seems to me that it's saying that H(2) is similar to H(1), but is a little more trusting insofar as longevity of the common sub-expressions it identifies and computes is concerned. Note that the positioning of "`DEBUG H(2)`" is constrained similarly to that of "`DEBUG H(1)`" as described above. |
| H(3) | No | No | Yes | No | No | [Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661) describes this as "WATCH status changed", which appears to mean that printing of HALMAT changes is toggled on or off. In my few experiments with it, I've seen no changes due to it in OPT's output report. Whether this option is available in HAL/S-FC versus whether it is confined to HAL/S-360 is TBD. A more-understandable explanation is TBD. |
| H(4) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "TEST PUSH HALMAT". It institutes an immediate action, and is not a toggle. Here's an example of the changes to OPT's output report when using it, when I've positioned the directive "`DEBUG H(4)`" just prior to our example HELLO.hal's final "`CLOSE HELLO`;" statement: ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 5:47:58.95
85 PUSHED BY 1716
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 5:47:58.95
``` I believe that what this addition to the report represents is the number HALMAT statements which have been output by whatever point in the program that the compiler directive has been placed. But using this aid is quite an adventure. For one thing, using it anywhere in the source code *other* than just prior to the compilation unit's close tends to cause OPT to abort, and the AUX pass following it to fail. Using more than one of the directives in the same file seems to cause an infinite loop from which OPT never exits. Of course, either or both of these unpleasant side-effects could be due to bugs introduced in my porting of OPT and/or AUX to the modern age, but given the seemingly-limited utility of H(4) I have little inclination to figure it out. |
| H(5) | No | No | Yes | No | No | Toggles tracing that's similar to that of [the X5 compiler option](#X5), so I won't take up space by showing a near-duplicate here. This aid is positional, though, so the output you get does depend on where the compiler directive that activates it is positioned in the source code. In my experiments, I've found that positioning the compiler directive prior to the compilation unit causes OPT to crash, while positioning it after the compilation unit causes no additions to OPT's output report. The former would appear to be a bug, but I've not investigated it. |
| H(6) | No | No | Yes | No | No | The H(6) option embeds HALMAT into OPT's output report. Put another way, it does for OPT what [¢5](#cent5) does for PASS2. Here's a sample from OPT's output report: ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 6:32:42.39
HALMAT: 005( 1), 0,0:0.0
HALMAT: 02B( 1), 0,0:0.2
HALMAT: 004( 1), 0,0:0.4
STATEMENT# 1
HALMAT: 004( 1), 0,0:0.4
STATEMENT# 1
HALMAT: 004( 1), 0,0:0.6
STATEMENT# 2
HALMAT: 004( 1), 0,0:0.6
STATEMENT# 2
HALMAT: 841( 2), 2,0:0.8
HALMAT: 004( 1), 0,0:0.11
.
.
.
STATEMENT# 14
HALMAT: 004( 1), 0,0:0.85
STATEMENT# 14
HALMAT: 002( 0), 1,0:0.87
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 6:32:42.39
``` |
| <a id="H7"></a>H(7) | No | No | Yes | No | No | [Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661) describes this as "HALMAT\_BLAB status changed", by which it means that it is toggled. The following illustrates the kind of effect on OPT's output report. As you can see, it's similar to H(6), but with a bit extra. (I guess that's the "blabbing".) ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 6:27:1.83
HALMAT: 005( 1), 0,0:0.0
87( 0), 0,0 :0.1
HALMAT: 02B( 1), 0,0:0.2
1( 1), 0,0 :0.3
HALMAT: 004( 1), 0,0:0.4
STATEMENT# 1
1( 0), 7,1 :0.5
HALMAT: 004( 1), 0,0:0.6
STATEMENT# 2
2( 0), 0,0 :0.7
HALMAT: 841( 2), 2,0:0.8
3( 1), 0,0 :0.9
2( 5), 0,0 :0.10
HALMAT: 004( 1), 0,0:0.11
.
.
.
STATEMENT# 14
14( 0), 0,1 :0.86
HALMAT: 002( 0), 1,0:0.87
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 6:27:1.84
``` |
| H(8) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "NO PHASE 2". It is a setting, not a toggle. Its purpose would seem to be allowing OPT to complete its normal optimization, but upon exit to inhibit subsequent compiler passes (FLO, PASS2) even if there has been no error. However, the architecture of **HALSFC** (vs **HAL/S-FC**) is such that no such action with OPT will disable subsequent compiler passes. |
| H(9) | No | No | Yes | No | No | Causes an immediate termination (with error code 1) of OPT. |
| H(10) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "SUB EXPANSION TRACE". It is a toggle. But so far, I've been unable to generate any examples in which OPT's output report differs. |
| H(11) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "LOOP COMBINE TRACE". It is a toggle. Here's an example of changes to OPT's output report: ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 7:8:12.14
INIT_ARCONFS
**********STATEMENT 1
**********STATEMENT 2
**********STATEMENT 3
**********STATEMENT 4
**********STATEMENT 5
**********STATEMENT 6
**********STATEMENT 7
**********STATEMENT 8
**********STATEMENT 9
**********STATEMENT 10
**********STATEMENT 11
**********STATEMENT 12
**********STATEMENT 13
CHECK_LIST(0,0):
INIT_ARCONFS
**********STATEMENT 14
CHECK_LIST(0,0):
INIT_ARCONFS
CHECK_LIST(0,0):
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:8:12.14
``` |
| H(12) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "STACK TRACE". It is a toggle. The effect is similar but not identical to that of [compiler option X5](#X5). Note that to produce any change to OPT's report, `DEBUG H(12);` has to be within the compilation unit (i.e., `PROGRAM HELLO` in this case). Placing it prior to the compilation unit causes OPT to terminate abnormally. |
| H(13) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "NODE DUMP". It is a toggle. But so far, I've been unable to generate any examples in which OPT's output report differs. |
| H(14) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "CROSS STATEMENTS". It is a toggle, appearing to effect whether one type of optimization is enabled or disabled. Here's an example of change to OPT's output report: ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 7:20:19.94
CROSS STATEMENT LOOP COMBINING AND INVARIANT PULLING DISABLED AT HAL/S STATEMENT 1
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:20:19.94
``` |
| H(15) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "CSE\_TAB\_DUMP OF CATALOG AND ENTRY NODES". It is a toggle. But so far, I've been unable to generate any examples in which OPT's output report differs. |
| H(16) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "STACK DUMP". It triggers an immediate action, and is not a toggle. Using H(16) multiple times will trigger multiple stack dumps. Here's an example of changes to OPT's output report with a single use of H(16): ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 7:23:47.53
NO REL
2 2 I
3 3 MY_NAME
4 4 J
5 5 PRINTER
STACK_DUMP: LEVEL=0, BLOCK#=1, INL#=0, OLD_LEVEL=0, OLD_BLOCK#=0, VAL_SIZE=1
LEVEL STACKED_BLOCK# STACK_TAGS PULL_LOOP_HEAD
0 1 00000000 -1
RECORD_TOP(CATALOG_ARRAY)= 0
RECORD_TOP(VALIDITY_ARRAY)= 0
RECORD_TOP(ZAPS)= 0
ZAP_BASE=0, PULL_LOOP_HEAD(LEVEL)=-1
SYT_SIZE=5, SYT_WORDS=0, SYT_USED=0
VALIDITY ZAPS LOOP_ZAPS
00000000 00000000 00000000
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:23:47.53
``` |
| H(17) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "EXTRA HALMAT DUMPS". It is a toggle. But so far, I've been unable to generate any examples in which OPT's output report differs. |
| H(18) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "NOT USED". It does nothing. |
| H(19) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "DUMP VALIDS". It triggers an immediate action, and is not a toggle. Multiple `DEBUG H(19);` directives can be used, at different HAL/S statements, each triggering a separate message in the output report. Here's an sample in which I used four of them: ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 7:30:43.26
SYT# REL# CATALOG_PTR VARIABLE NAME FOR VALID VARS, LEVEL =0, BLOCK# =1
SYT# REL# CATALOG_PTR VARIABLE NAME FOR VALID VARS, LEVEL =0, BLOCK# =1
SYT# REL# CATALOG_PTR VARIABLE NAME FOR VALID VARS, LEVEL =0, BLOCK# =1
SYT# REL# CATALOG_PTR VARIABLE NAME FOR VALID VARS, LEVEL =1, BLOCK# =2
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:30:43.26
``` |
| H(20) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "STATISTICS". It is a toggle. Here's an example of changes to OPT's output report: ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 7:33:39.36
CSE'S FOUND = 0
COMPARE CALLS = 0
SCANS = 0
MAX_NODE_LIST = 0
MAX_CSE_TAB = 1
MINOR COMPACTIFIES = 0
MAJOR COMPACTIFIES = 0
FREE STRING AREA = 16637946
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:33:39.36
TOTAL CPU TIME FOR OPTIMIZER 0:0:0.00
CPU TIME FOR OPTIMIZER SETUP 0:0:0.00
CPU TIME FOR OPTIMIZER CRUNCHING 0:0:0.00
CPU TIME FOR OPTIMIZER CLEAN UP 0:0:0.00
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:33:39.36
``` |
| H(21) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "MOVE HALMAT TRACE". It is a toggle. But so far, I've been unable to connive any examples in which OPT's output report differs. |
| H(22) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "BLAB FIRST HALMAT BLOCK". It is a setting, not a toggle. It's seemingly identical in effect to [H(7)](#H7). |
| H(23) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "BLAB SECOND HALMAT BLOCK". It is a setting, not a toggle. Here's a sample of OPT's output report (34 pages of it, if shown in full!): ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 7:42:39.78
HALMAT: 000( 0), 0,0:0.1800
HALMAT: 000( 0), 0,0:0.1801
HALMAT: 000( 0), 0,0:0.1802
HALMAT: 000( 0), 0,0:0.1803
HALMAT: 000( 0), 0,0:0.1804
.
.
.
HALMAT: 000( 0), 0,0:0.3599
HALMAT: 000( 1), 0,1:0.3600
HALMAT: 000( 5), 0,3:0.3602
HALMAT: 001( 17), 0,1:0.3608
19( 1), 0,2 :0.3609
21( 1), 0,3 :0.3610
23( 1), 0,4 :0.3611
25( 1), 0,5 :0.3612
.
.
.
51( 3), 0,2 :0.3625
HALMAT: 003( 53), 0,3:0.3626
55( 3), 0,4 :0.3627
57( 3), 0,5 :0.3628
.
.
.
0( 1), 0,0 :0.3678
0( 1), 0,0 :0.3679
HALMAT: 001( 0), 0,1:0.3680
HALMAT: 001( 0), 0,1:0.3681
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 34
HALMAT: 001( 0), 0,2:0.3682
HALMAT: 001( 0), 0,2:0.3683
HALMAT: 001( 0), 0,3:0.3684
HALMAT: 001( 0), 0,3:0.3685
HALMAT: 001( 0), 0,4:0.3686
HALMAT: 001( 0), 0,4:0.3687
HALMAT: 001( 0), 0,5:0.3688
HALMAT: 001( 0), 0,5:0.3689
HALMAT: 001( 0), 0,6:0.3690
HALMAT: 001( 0), 0,6:0.3691
HALMAT: 001( 0), 0,7:0.3692
HALMAT: 001( 0), 0,7:0.3693
HALMAT: 002( 0), 0,0:0.3694
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:42:39.80
``` |
| H(24) | No | No | Yes | No | No | I'm not aware of any documentation, but comments in OPT source code call this "BLAB BOTH HALMAT BLOCKS". In other words, a combination of H(22) and H(23). |
| H(25)-H(40) | No | No | Yes | No | No | Future expansion, I believe. |
| H(41)-H(99) | No | No | Yes | No | No | [Documentation](https://www.ibiblio.org/apollo/Shuttle/19760020796.pdf#page=661) for H(64) describes this as "Set VALIDITY TRACE status changed"; in fact, H(40) through H(99) are all identical in OPT source code to H(64). A more-understandable explanation is TBD. Here's an example of its effect on OPT's output report: ```text
PAGE 1
HAL/S OPTIMIZER -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:46:46.00
HAL/S OPTIMIZER ENTERED MARCH 9, 2026. CLOCK TIME = 7:48:50.12
SET_VALIDITY(2,0)
SET_VALIDITY(4,0)
SET_VALIDITY(4,0)
END OF HAL/S OPTIMIZER MARCH 9, 2026. CLOCK TIME = 7:48:50.12
``` |
| H(100) | No | Yes | No | No | No | I'm not aware of any documentation, but from FLO source code I'd say that this triggers a "VMEM DUMP", which is a report on VMEM. It is not a toggle. Note that FLO's output report is normally empty. ```text
PAGE 1
INCLUDE LIST HEAD: FFFFFFFF
STMT DATA HEAD: 7FC
SYT VPTRS(0):
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 2
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 3
PAGE 000 ..00 ..04 ..08 ..0C ..10 ..14 ..18 ..1C ..20 ..24 ..28 ..2C
0000 00000001 00000001 FE691970 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
07E0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000820 FFFFFFFF 0000081C FFFFFFFF 00000000
0810 00000000 00000016 00010001 00010001 00000840 000007FC FFFFFFFF FFFFFFFF 00000000 00000000 00000015 00020001
0840 00000860 00000820 FFFFFFFF FFFFFFFF 00000000 00000000 00000015 00030001 00000890 00000840 FFFFFFFF FFFFFFFF
0870 00000000 00000000 00000015 00040001 FFFFFFFF 0001F600 00000880 FFFF0000 000008B0 00000860 FFFFFFFF FFFFFFFF
08A0 00000000 00000000 00000019 00050001 000008D0 00000890 FFFFFFFF FFFFFFFF 00000000 00000000 00001003 00060001
08D0 000008F4 000008B0 FFFFFFFF 000008F0 00000000 00000000 00000013 00070001 00018002 00000914 000008D0 FFFFFFFF
0900 FFFFFFFF 00000000 000009DC 00001003 00080001 00000938 000008F4 FFFFFFFF 00000934 00000000 00000000 00000013
0930 00090001 00018004 00000958 00000914 FFFFFFFF FFFFFFFF 00000000 000009E4 00001003 000A0001 00000978 00000938
0960 FFFFFFFF FFFFFFFF 00000000 00000000 00000008 000B0001 00000998 00000958 FFFFFFFF FFFFFFFF 00000000 00000000
0990 00000008 000C0001 000009B8 00000978 FFFFFFFF FFFFFFFF 00000000 00000000 00001003 000D0001 FFFFFFFF 00000998
09C0 FFFFFFFF FFFFFFFF 00000000 00000000 00000006 000E0001 00000000 00080001 00020000 00080002 00040003 00000000
``` |
| H(101) | No | Yes | No | No | No | I'm not aware of any documentation, but from FLO source code I'd say that this triggers a "FORMATTED DUMP". It is not a toggle. However, I notice no effect on FLO's output report when using it. |
| H(102) | No | Yes | No | No | No | I'm not aware of any documentation, but from FLO source code I'd say that this sets "DON'T LINK". The intent seems to be to allow FLO to complete processing and exit normally but *without* chaining to the next pass of the compiler (namely OPT). In the architecture of **HALSFC** (vs **HAL/S-FC**), individual programs don't control this chaining anyway, so H(102) has no effect. |
| H(103) | No | Yes | No | No | No | I'm not aware of any documentation, but from FLO source code I'd say that this toggles "PROCEDURE TRACE". ```text
PAGE 1
GET_STMT_VARS(6,24)
GET_EXP_VARS_CELL
GET_STMT_VARS(7,27)
GET_EXP_VARS_CELL
GET_STMT_VARS(8,42)
GET_EXP_VARS_CELL
GET_STMT_VARS(9,45)
GET_EXP_VARS_CELL
GET_STMT_VARS(10,63)
GET_EXP_VARS_CELL
GET_STMT_VARS(13,80)
GET_EXP_VARS_CELL
``` |
| H(104) | No | Yes | No | No | No | I'm not aware of any documentation, but from FLO source code I'd say that this toggles "WALK TRACE". I notice no effect on FLO's output report when using it, but perhaps I'm not using appropriate HAL/S sample code for testing it. |
| H(105) | No | Yes | No | No | No | I'm not aware of any documentation, but from FLO source code I'd say that this sets "HALMAT DUMP", which takes effect at the end of processing. It is not a toggle. Note that it requires the HALMAT compiler option as well. ```text
PAGE 1
STATEMENT 1
20001
102B0
10011
STATEMENT 2
STATEMENT 3
30001
2028410
30011
20051
.
.
.
STATEMENT 14
20001
10300
10011
``` |
| H(106)-H(114) | No | Yes | No | No | No | Future expansion, I believe. |
| H(128) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this toggles "AUXMAT\_REQUESTED". AUX's report: ```text
PAGE 1
0. 0 : 29,1(00), 0, 2(01)
0. 2 : 47,1(00), 0, 4(01)
0. 4 : 32767,6(00), 0, 0(00)
``` |
| H(129) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this toggles "PRETTY\_PRINT". AUX's report: ```text
PAGE 1
HALMAT: 005( 1), 0,0: 0. 0
87( 0), 0,0: 0. 1
HALMAT: 02B( 1), 0,0: 0. 2
1( 1), 0,0: 0. 3
HALMAT: 004( 1), 0,0: 0. 4
1( 0),129,1: 0. 5
HALMAT: 004( 1), 0,0: 0. 6
.
.
.
13( 0), 0,1: 0. 82
HALMAT: 030( 1), 0,0: 0. 83
1( 1), 0,0: 0. 84
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 3
HALMAT: 004( 1), 0,0: 0. 85
14( 0), 0,1: 0. 86
HALMAT: 002( 0), 1,0: 0. 87 AUXMAT: 0. 4 : 32767,6(00), 0, 0(00)
``` |
| H(130) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this toggles "STACK\_DUMP". AUX's report: ```text
PAGE 1
HALMAT_PTR = 83
STACK_PTR = 1
MAX_CASE_LENGTH = 0
FRAME_START = 2
FRAME_TYPE = 1
FRAME_FLAGS = 0
FRAME_INL = 1
FRAME_BUMP_FACTOR = 0
FRAME_BLOCK_PTR = 1
FRAME_CB_NEST_LEVEL = 0
FRAME_SYT_REF (1) =
50000000
FRAME_VAC_REF (113) =
00000000 00000000 00000000
FRAME_SYT_PREV_REF (0) =
00000000
FRAME_VAC_PREV_REF (0) =
00000000 00000000 00000000
FRAME_UVCS (3) =
01 4 00 47 2 --> 01 2 00 29 0 --> 0
FRAME_CASE_LIST (0) =
0
FRAME_MAP_SAVE (0) =
0
CASE_LIST_PTRS (0) =
0
VAC_BOUNDS = (1) =
00 2 00 17 0 --> 0
HALMAT_PTR = 83
STACK_PTR = 0
MAX_CASE_LENGTH = 0
FRAME_START = 0
FRAME_TYPE = 0
FRAME_FLAGS = 0
FRAME_INL = -1
FRAME_BUMP_FACTOR = 0
FRAME_BLOCK_PTR = 0
FRAME_CB_NEST_LEVEL = 0
FRAME_SYT_REF (0) =
00000000
FRAME_VAC_REF (0) =
00000000 00000000 00000000
FRAME_SYT_PREV_REF (0) =
00000000
FRAME_VAC_PREV_REF (0) =
00000000 00000000 00000000
FRAME_UVCS (0) =
0
FRAME_CASE_LIST (0) =
0
FRAME_MAP_SAVE (0) =
0
------------------------------------------------------------------------------------------------------------------------------------------------------
PAGE 2
CASE_LIST_PTRS (0) =
0
VAC_BOUNDS = (4) =
00 2 00 84 0 --> 0
``` |
| H(131) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this toggles "OPCODE\_TRACE". AUX's report: ```text
PAGE 1
HALRATOR =004 (0,6)
HALRATOR =841 (0,8)
HALRATOR =004 (0,11)
HALRATOR =004 (0,13)
HALRATOR =004 (0,15)
HALRATOR =031 (0,17)
HALRATOR =025 (0,18)
HALRATOR =027 (0,20)
HALRATOR =021 (0,22)
HALRATOR =026 (0,24)
HALRATOR =004 (0,25)
HALRATOR =010 (0,27)
HALRATOR =004 (0,32)
HALRATOR =025 (0,34)
HALRATOR =027 (0,36)
HALRATOR =027 (0,38)
HALRATOR =021 (0,40)
HALRATOR =026 (0,42)
HALRATOR =004 (0,43)
HALRATOR =010 (0,45)
HALRATOR =004 (0,51)
HALRATOR =025 (0,53)
HALRATOR =027 (0,55)
HALRATOR =027 (0,57)
HALRATOR =027 (0,59)
HALRATOR =021 (0,61)
HALRATOR =026 (0,63)
HALRATOR =004 (0,64)
HALRATOR =011 (0,66)
HALRATOR =004 (0,68)
HALRATOR =011 (0,70)
HALRATOR =004 (0,72)
HALRATOR =025 (0,74)
HALRATOR =027 (0,76)
HALRATOR =021 (0,78)
HALRATOR =026 (0,80)
HALRATOR =004 (0,81)
HALRATOR =030 (0,83)
HALRATOR =004 (0,85)
HALRATOR =002 (0,87)
``` |
| H(132) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this toggles "TARGET\_TRACE". But this appears to have no effect within AUX source code, and I see no effect on AUX's output report. |
| H(133) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this toggles "NOOSE\_TRACE". But this appears to have no effect within AUX source code, and I see no effect on AUX's output report. |
| H(134) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this toggles "TIME\_EXIT". By design, this simply triggers an error exit from AUX of type BI412, "COMPILATION ENDED IN AUXMATTER PHASE DUE TO DEBUG TOGGLE 134 BEING SET". It's apparently one of those "don't push this button!" kind of things. More seriously, I suspect that once upon a time H(134) did something useful but was eventually discontinued. |
| H(135) | No | No | No | Yes | No | I'm not aware of any documentation, but from AUX source code I'd say that this sets "SHRUNKEN SYMBOL TABLE INDEX DUMP". It is not a toggle. AUX's report: ```text
PAGE 1
HAL/S AUXILIARY HALMAT GENERATOR -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:47:10.00
HAL/S AUXILIARY HALMAT GENERATOR ENTERED MARCH 9, 2026. CLOCK TIME = 9:48:23.27
SYMBOL( 2) = 1
SYMBOL( 3) = 2
SYMBOL( 4) = 3
SYMBOL( 5) = 4
``` |
| H(200) | No | No | No | No | Yes | In PASS2's output report, disables HALMAT (¢5-), assembler code (¢6-), and stack trace (¢9-) |
| H(201) | No | No | No | No | Yes | In PASS2's output report, enables HALMAT (¢5+), assembler code (¢6+), and stack trace (¢9+) |
| H(202) | No | No | No | No | Yes | In PASS2's output report, disables HALMAT (¢5-) and assembler code (¢6-) |
| H(203) | No | No | No | No | Yes | In PASS2's output report, enables HALMAT (¢5+) and assembler code (¢6+) |
| H(204) | No | No | No | No | Yes | In PASS2's output report, toggles the register trace. There's an excerpt below of PASS2's output report from HELLO.hal showing the effect. Presumably it would be more-meaningful intermixed with HALMAT or assembly code, but in the interest of space I haven't done that. While I cannot give you a full explanation of how to read the trace, I'd venture the following guesses: - R indicates a particular AP-101S CPU register. - NAME tells you the identifier of the variable stored in it. - VAR gives you the "DCL" number of the variable in the symbol table in PASS1's output report - TYP indicates the datatype of the variable stored in the register. 2 is `CHARACTER`, 5 is `SCALAR`, 6 is `INTEGER`. (The complete list of numeric codes for datatypes can be found beginning at punchcard 00150900 in [HAL/S-FC source-code file PASS1.PROCS/##DRIVER.xpl](https://github.com/virtualagc/virtualagc/blob/master/yaShuttle/Source%20Code/PASS.REL32V0/PASS1.PROCS/%23%23DRIVER.xpl), though since most of the datatypes won't fit in a single CPU register, not all of the codes are applicable to the register trace.) ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:39:23.00
HAL/S PHASE 2 ENTERED AUGUST 11, 2024. CLOCK TIME = 9:34:6.06
R USE LIN CTN TYP VAR XR XS XC CONST XCON MULT VR2 NAME
5 1 0 5 6 0 0 0 0 3 0 0 0
6 1 0 5 6 0 0 0 0 6 0 0 0
R USE LIN CTN TYP VAR XR XS XC CONST XCON MULT VR2 NAME
7 1 0 1 6 2 0 0 0 0 0 0 0 I
R USE LIN CTN TYP VAR XR XS XC CONST XCON MULT VR2 NAME
5 1 0 1 6 2 0 0 0 0 0 0 0 I
6 1 0 5 6 0 0 0 0 6 0 0 0
7 1 0 1 6 2 0 0 0 0 0 0 0 I
R USE LIN CTN TYP VAR XR XS XC CONST XCON MULT VR2 NAME
4 1 0 1 6 4 0 0 0 0 0 0 0 J
R USE LIN CTN TYP VAR XR XS XC CONST XCON MULT VR2 NAME
4 1 0 1 6 4 0 0 0 0 0 0 0 J
5 1 0 1 6 4 0 0 0 0 0 0 0 J
6 1 0 5 6 0 0 0 0 6 0 0 0
R USE LIN CTN TYP VAR XR XS XC CONST XCON MULT VR2 NAME
5 1 0 5 6 4 0 0 0 3 0 0 0
6 1 0 5 6 0 0 0 0 6 0 0 0
R USE LIN CTN TYP VAR XR XS XC CONST XCON MULT VR2 NAME
4 1 -1 10 6 4 0 0 0 0 0 0 0
STACK NAME
20 HELLO
⋮
``` |
| H(205) | No | No | No | No | Yes | In PASS2's output report, toggles HALMAT (¢5). |
| H(206) | No | No | No | No | Yes | In PASS2's output report, toggles assembler code (¢6). |
| H(207) | No | No | No | No | Yes | In PASS2's output report, toggles binary code: ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:39:23.00
HAL/S PHASE 2 ENTERED AUGUST 11, 2024. CLOCK TIME = 9:53:49.38
000000: 49, 0001
000000: 38, 0002
000000: 80000000
000000: 0, 0000
000001: 0, 0000
000002: 43, 1001
000002: 43, 4003
000002: 55, 0001
000002: 00000700
000004: 0, 0000
000005: 0, 0000
000000: 38, 0003
⋮
``` But binary of what? Not of anything obvious, I'm afraid! These messages are emitted under various conditions, which you can find if you search for the variable `BINARY_CODE` in [HAL/S-FC's PASS2 source code](https://github.com/virtualagc/virtualagc/tree/master/yaShuttle/Source%20Code/PASS.REL32V0/PASS2.PROCS). Which is not anything I'd normally suggest, since I'd like to thoroughly digest all of this subject matter and spit it out explicitly for you, so you don't have to worry about it instead of more important subjects like What's for dinner? (Hmm, that makes me hungry ... what *is* for dinner?) No, I mention it because I have no coherent explanation to offer you, and perhaps you'd enjoy the challenge of figuring it out for yourself. And documenting it! What an idea! But I've been forced to look into it a little, and what little I discovered may as well be written down somewhere, so I *can* tell you that there are 3 types of these messages: 1. The most-common messages are emitted by the `EMITC` `PROCEDURE`. These are of the format "`%06X:%6d, %04X`", where the fields are a "current location counter", a "type" and an "instruction". What those mean is unclear to me right now, but even from the short sample output above, you can see that there's typically a sequence of these operations at any given location, before moving to the next location. 2. Then there are the messages emitted by the `EMITW` `PROCEDURE`, which have the format "`%06X: %08X`", where the fields are the current "location counter" and a "data word". 3. Finally, there are the messages emitted by the `SAVE\_LITERAL` `PROCEDURE` in GENERATE.xpl. These messages are of the format "`%6d:%08X %8X`", where the fields are a "pointer", a "value", and (optionally) an "xvalue". As usual, I'm not clear what those mean, but I can say a few things about them. These are *not* literals stored in the literal file output by the compiler, as discussed elsewhere on this page, but rather items in HALSFC-PASS2 memory prior to migrating into the object file. The "pointer", I think, may be a simple index starting at 1 and incrementing by 1 thereafter. Note that the same data may appear elsewhere as type #1 records. |
| H(208) | No | No | No | No | Yes | In PASS2's output report, toggles subscript trace. Our simple HELLO.hal test program doesn't actually have any array variables in it, so a subscript trace shows nothing at all. Let's instead use [the EXAMPLE\_2 program](https://github.com/virtualagc/virtualagc/blob/master/yaShuttle/Source%20Code/Programming%20in%20HAL-S/106-EXAMPLE_2.hal) from [p. 6-6 of Ryer's "Programming in HAL/S"](https://www.ibiblio.org/apollo/Shuttle/Programming%20in%20HAL_S%20Sept%201978.pdf#page=106), which looks like so: ```text
EXAMPLE_2:
PROGRAM;
DECLARE GYRO_INPUT ARRAY(4, 3) INTEGER
INITIAL(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
DECLARE ATT_RATE ARRAY(4, 3) SCALAR;
DECLARE SCALE ARRAY(3) CONSTANT(.013, .026, .013);
DECLARE BIAS SCALAR INITIAL(57.296);
DO FOR TEMPORARY I = 1 TO 4;
DO FOR TEMPORARY J = 1 TO 3;
M ATT_RATE = GYRO_INPUT SCALE + BIAS;
S I,J I,J J
END;
END;
WRITE(6) ATT_RATE;
CLOSE EXAMPLE_2;
``` Compiling this with the H(208) option enabled gives the following PASS2 output report: ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF AUGUST 9, 2024. CLOCK TIME = 12:39:23.00
HAL/S PHASE 2 ENTERED AUGUST 11, 2024. CLOCK TIME = 10:7:31.25
INX_CON=0, SUB#=1
INX_CON=0, SUB#=2
INX_CON=0, SUB#=2
INX_CON=0, SIZE/ROW=1, COLUMN=0
INX_CON=0, SUB#=1
INX_CON=0, SUB#=2
INX_CON=0, SUB#=2
INX_CON=0, SIZE/ROW=1, COLUMN=0
INX_CON=0, SUB#=1
INX_CON=0, SUB#=1
INX_CON=0, SIZE/ROW=1, COLUMN=0
STACK NAME
20 EXAMPLE_2
OPTIONAL TABLE SIZES
NAME REQUESTED USED
^^^^ ^^^^^^^^^ ^^^^
LITSTRINGS 2000 0
LABELSIZE 1200 10
46 HALMAT OPERATORS CONVERTED
45 INSTRUCTIONS GENERATED
68 HALFWORDS OF PROGRAM, 54 HALFWORDS OF DATA.
MAX. OPERAND STACK SIZE =10
END OPERAND STACK SIZE =0
MAX. STORAGE DESCRIPTOR STACK SIZE =3
END STORAGE DESCRIPTOR STACK SIZE =0
NUMBER OF MINOR COMPACTIFIES =0
NUMBER OF MAJOR COMPACTIFIES =0
NUMBER OF REALLOCATIONS =5
FREE STRING AREA =16623296
END OF HAL/S PHASE 2 AUGUST 11, 2024. CLOCK TIME = 10:7:31.25
TOTAL CPU TIME FOR PHASE 2 0:0:0.01
CPU TIME FOR PHASE 2 SET UP 0:0:0.01
CPU TIME FOR PHASE 2 GENERATION 0:0:0.00
CPU TIME FOR PHASE 2 CLEAN UP 0:0:0.00
``` |
| H(209) | No | No | No | No | Yes | Same effect as [¢9](#cent9). |
| H(210) | No | No | No | No | Yes | I'm aware of no documentation, but in PASS2 source code this toggles "STACK\_DUMP". Here are some differences in PASS2's output report: ```text
PAGE 1
HAL/S COMPILER PHASE 2 -- VERSION OF MARCH 8, 2026. CLOCK TIME = 10:47:22.00
HAL/S PHASE 2 ENTERED MARCH 9, 2026. CLOCK TIME = 9:58:55.71
N FM LOC LOC2 TP B DISP RG IX XS XC RW CL DL CY VM BR NX NXI SC SX S XM
1 18 1 1 1 0 0 -1 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 1
N FM LOC LOC2 TP B DISP RG IX XS XC RW CL DL CY VM BR NX NXI SC SX S XM
2 5 2 0 2 0 0 -1 0 0 0 10 0 0 0 0 -1 0 0 0 0 0 1
1 1 3 3 2 0 0 -1 0 0 0 20 0 0 0 0 -1 0 0 0 0 0 1,MY_NAME
.
.
.
N FM LOC LOC2 TP B DISP RG IX XS XC RW CL DL CY VM BR NX NXI SC SX S XM
2 5 -1 -1 6 0 0 -1 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 1
2 5 -1 -1 6 0 0 -1 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 1
1 5 -1 2 6 0 0 -1 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 1
2 3 -1 -1 14 0 0 2 0 0 0 1 0 0 0 0 2 0 0 0 0 0 1
1 8 4 2 2 0 0 2 0 0 0 7 0 0 0 0 -1 0 0 0 0 0 1
.
.
.
END OF HAL/S PHASE 2 MARCH 9, 2026. CLOCK TIME = 9:58:55.71
TOTAL CPU TIME FOR PHASE 2 0:0:0.01
CPU TIME FOR PHASE 2 SET UP 0:0:0.00
CPU TIME FOR PHASE 2 GENERATION 0:0:0.01
CPU TIME FOR PHASE 2 CLEAN UP 0:0:0.00
``` |
| H(211) | No | No | No | No | Yes | I'm aware of no documentation, but in PASS2 source code this toggles "LITTRACE". But LITTRACE seems to have no effect in PASS2 source code, and there are no differences in PASS2's output report. |
| H(212) | No | No | No | No | Yes | I'm aware of no documentation, but in PASS2 source code this toggles "LITTRACE2". But LITTRACE2 seems to have no effect in PASS2 source code, and there are no differences in PASS2's output report. |
| H(222) | No | No | No | No | Yes | I'm aware of no documentation, but in PASS2 source code this immediately exits PASS2. |
| H(254) | No | No | No | No | Yes | I'm aware of no documentation, but in PASS2 source code this sets INITIAL\_ON(0)=TRUE. This appears to be a value communicated to compiler PASS4, and causes something called the "#D/#P INFORMATION" at the end of the output listing to be more verbose. |
| H(255) | No | No | No | No | Yes | I'm aware of no documentation, but in PASS2 source code this sets INITIAL\_ON(1)=TRUE. This appears to be a value communicated to compiler PASS4, and causes something called the "#D/#P INFORMATION" at the end of the output listing to be less verbose. |
# Files Used or Created by the HAL/S Compiler
Among themselves, the seven passes of HAL/S-FC use a
somewhat-consistent scheme for associating filenames to file
numbers, though not all of the passes necessarily use all of the
files. I say "somewhat", because files output by one pass are
occasionally input to another pass using a different file
number. Here's a handy table that summarizes the file usage of
each pass. When you see something italicized, such as *`halmat.bin`*
in `--raf=B,7200,1,halmat.bin`,
I mean to imply that while these are the names that the shell script
**HALSFC** uses, you may or may not want to choose a different
name if you were to bypass **HALSFC** and concoct your own
program flow. On the other hand, the names must be consistent
between the passes outputting them and the passes using them as
input. The cells that have been highlighted in color emphasize
those places in which the *same* file must be used on
successive passes; in the case of the virtual-memory file, I don't
know if the same file is used on successive passes or not, so I
haven't highlighted it, but I've been using the same file without
any apparent difficulty. As a convenience, the conventional
filenames used by **HAL\_S\_FC.py** are also shown (in the PASS1
column, in [brackets]), although they are mostly fixed rather than
selectable via command-line options.
| HAL/S-FC Usage | PASS1 or PASS1B [or HAL\_S\_FC.py] | FLO | OPT or OPTB | AUXP | PASS2 or PASS2B | PASS3 or PASS3B | PASS4 | Notes |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Input HAL source code | **`--ddi=0,SOURCEFILE.hal`****or** **`stdin`**`[--hal=SOURCEFILE.hal]` | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | |
| Output report | **`--ddo=0,pass1.rpt`****or** **`stdout`**`[>pass1p.rpt]` | **`--ddo=0,flo.rpt`****or** **`stdout`** | **`--ddo=0,opt.rpt`****or** **`stdout`** | **`--ddo=0,auxp.rpt`****or** **`stdout`** | **`--ddo=0,pass2.rpt`****or** **`stdout`** | **`--ddo=0,pass3.rpt`****or** **`stdout`** | **`--ddo=0,pass4.rpt`****or** **`stdout`** | |
| Output error messages | **`stderr`**[stderr] | **`stderr`** | **`stderr`** | **`stderr`** | **`stderr`** | **`stderr`** | **`stderr`** | |
| Extra listing file, plus SPACELIB error messages | **`--ddo=2,listing2.txt`**[LISTING2p.txt] | **n/a** | **n/a** | **n/a** | **n/a** | **TBD** | **TBD** | This file is produced by PASS1 if "LISTING2" is among the compiler options. (The memory-management system may also direct certain error messages to this device, but that's presently TBD.) |
| AP-101S object code | **n/a** | **n/a** | **n/a** | **n/a** | **`--ddo=3,cards.bin,E`** (PASS) or `--pdso=3,cards,E` (BFS) | **TBD** | **TBD** | Generated object code. The file cards.bin is in a format similar to the IBM 360 object-code format. The PASS and BFS versions of the compiler differ, in that the PASS version outputs a single object file per HAL/S input file, whereas the BFS version output a number of output files as members of a partitioned data set in a format called PILOT. While contemporary documentation is lacking, [these formats can be understood from our page](https://www.ibiblio.org/apollo/HALLINK101S.html) describing our linker program. |
| Object code "deck" | **n/a** | **n/a** | **n/a** | **n/a** | **`--ddo=4,deck.bin,E`** | **TBD** | **TBD** | An optional copy of the object code. For the PASS version of the compiler, it's identical to `cards.bin` (see above). For the BFS version, it's a single-file format, unlike the PDS format of `cards`. |
| Template library | **`--pdsi=4,TEMPLIB,E --pdso=6,TEMPLIB,E`**`[TEMPLIB.json, TEMPLIBB.json]` | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | The output is optional, depending on whether or not "TEMPLATE" is among the compiler options. For use with the compiler directive "`D INCLUDE TEMPLATE name`". |
| Include library | **`--pdsi=8,INCLIB,E`**`[INCLIB.json, INCLIBB.json]` | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | For use with the compiler directive "`D INCLUDE name`". |
| Temporary include library | **`--pdso=8,"&&TEMPINC",E`****`--pdsi=9,"&&TEMPINC",E`** | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | For use with the compiler directives "`D DEFINE name`" and "`D CLOSE name`", followed by subsequent use (with the *same* source-code file) of "`D INCLUDE name`". |
| Input error-message library | **`--pdsi=5,/path/to/ERRORLIB`**`[ERRORLIB.json, ERRORLIBB.json]` | **`--pdsi=5,/path/to/ERRORLIB`** | **`--pdsi=5,/path/to/ERRORLIB`** | **`--pdsi=5,/path/to/ERRORLIB`** | **`--pdsi=5,/path/to/ERRORLIB`** | **TBD** | **TBD** | `ERRORLIB` is a library of standardized error messages supplied with the HAL/S compiler source code, contained in the source tree as "*virtualagc*/yaShuttle/Source Code/PASS.REL32V0/ERRORLIB". **Important note:** If you accidentally use an *incorrect* path for this library, it will be essentially transparent to you as long as the HAL/S code being compiled is error-free. But if compilation errors are encountered and the path for ERRORLIB is incorrect, the original compiler source code doesn't seem to recognize the possibility that the desired error message may simply not exist in ERRORLIB. Consequently, the compiler endlessly searches the missing ERRORLIB for the error message it wants to print, and thus never exits. Lesson: Get this path correct! The easiest way is simply to copy ERRORLIB into the working folder which you're using for compiling HAL/S programs, so that the path to it is simply "ERRORLIB". |
| Input access-rights library | **`--pdsi=6,ACCESS`**`[FILE6.bin]` | **n/a** | **n/a** | **n/a** | **n/a** | **TBD** | **TBD** | `ACCESS` is a library of access-code rights, by which different sections of HAL/S code can be restricted in terms of what other code they can access. The supplied version of `ACCESS` is empty. |
| Extra listing | **n/a** | **n/a** | **n/a** | **n/a** | **`--ddo=7,extra.txt`** | **TBD** | **TBD** | TBD |
| Source comparison | ```text
--ddo=9,comparison.txt
``` | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | **n/a** | The compiler is able to compare two versions of the HAL/S source code and to produce an output report on the differences. But so far I'm in the dark as to the mechanics of how to feed in the "patches" and instigate the comparison. (If you're keen to figure this out and impress me — or more importantly, I'm sure, impress others who may chance to peruse these scribblings —, you should probably start with [the file SOURCECO.xpl of the HAL/S compiler's original source code](https://github.com/virtualagc/virtualagc/blob/master/yaShuttle/Source%20Code/PASS.REL32V0/PASS1.PROCS/SOURCECO.xpl). The lines reading "`OUTPUT(9) = ...;`" are the ones where the report is output.) |
| Output or input HALMAT | **`--raf=O,7200,1,halmat.bin`**`[FILE1.bin]` | **`--raf=I,7200,1,halmat.bin`** | **`--raf=I,7200,1,halmat.bin`** | **`--raf=O,7200,1,auxmat.bin`** | **`--raf=I,7200,1,auxmat.bin`** | **TBD** | **TBD** | HALMAT is the "intermediate" language into which HAL/S code is converted prior to generation of machine code. Various versions are created by the several compiler passes; see also `optmat.bin`, below. Contemporary documentation for [the format of halmat.bin and optmat.bin has not survived, but our reconstructed documentation is available](https://www.ibiblio.org/apollo/Halmat.pdf). I don't know the format of auxmat.bin. |
| Literal file | **`--raf=B,1560,2,litfile.bin`**`[FILE2.bin + LIT_CHAR.bin]` | **`--raf=I,1560,2,litfile.bin`** | **`--raf=B,1560,2,litfile.bin`** | **`--raf=I,1560,2,litfile.bin`** | **`--raf=B,1560,2,litfile.bin`** | **`--raf=B,1560,2,litfile.bin`** | **TBD** | This is a "random-access file" that the compiler uses to store the values of string, floating-point, and bit-string literals. I'm not sure the format of it is documented anywhere, but [we've provided a little Python script whose comments describe the format, and whose actions produce a human-readable dump of the file](https://github.com/virtualagc/virtualagc/blob/master/yaShuttle/Source%20Code/PASS.REL32V0/unLitfile.py). |
| Workfiles | **`--raf=B,1600,3,icfile.bin`** | **n/a** | **n/a** | **n/a** | **`--raf=B,1600,3,objcode.bin`** | **TBD** | **TBD** | TBD, but I think that `icfile.bin` holds values of `INITIAL` and `CONSTANT` clauses for `DECLARE` statements, which may be swapped out of memory if there are too many of them. (More specifically, it holds images of the internal arrays `IC_VAL`, `IC_LOC`, `IC_LEN`, `IC_FORM`, and `IC_TYPE`.) Presumably it is just a workfile not used by other compiler passes. I think that *`objcode.bin`* is a workfile into which data used for object-generation is swapped to preserve memory. In spite of the name I used for it, I don't think it is object code as such. |
| Second HALMAT file | **n/a** | **n/a** | **`--raf=O,7200,4,optmat.bin`** | **`--raf=I,7200,4,optmat.bin`** | **`--raf=I,7200,4,optmat.bin`** | **TBD** | **TBD** | See the comments for *`halmat.bin`* and *`auxmat.bin`* above. |
| SDF | **`--sdfi=SDFLIB`** | **n/a** | **n/a** | **n/a** | **n/a** | **`[--sdfo=SDFLIB]`** | **`--sdf=SDFLIB`** | Library of Simulation Data Files (SDF). These operations bypass the file-operation conventions established by the **XCOM-I** runtime library, but nevertheless work with a folder of files that contain individual SDF's corresponding to the HAL/S source-code files being compiled, thus modeling the Partitioned Data Set (PDS) used by the original HAL/S compiler, though lacking any metadata (such as file versioning) implemented in the original PDS. PASS3 of the compiler has the option shown here as its default, so it is not necessary to explicitly provide the `--sdfo=SDFLIB` option on the command line unless you want the library to be called something other than "SDFLIB". |
| Virtual-memory file | **`--raf=B,3360,6,vmem.bin`** | **`--raf=B,3360,6,vmem.bin`** | **`--raf=B,3360,6,vmem.bin`** | **`--raf=B,3360,6,vmem.bin`** | **`--raf=B,3360,6,vmem.bin`** | **`--raf=B,3360,6,vmem.bin`** | **TBD** | This is a "random-access file" that the compiler uses to store blocks of virtual memory which have been temporarily unloaded from memory. |
| Input `COMMON` file | **n/a** | **`--commono=``COMMON0.out`** | **`--commoni=``COMMON1.out`** | **`--commoni=``COMMON2.out`** | **`--commoni=``COMMON``3.out`** | **`--commoni=``COMMON4.out`** | **`[--commoni=``COMMON``5.out]`** | The state of `COMMON` memory upon program start. In PASS4, this is optional, in the sense that it is present when PASS4 is run as part of the compiler, but is absent when PASS4 is run in "stand-alone" mode. In stand-alone mode, several options ("ALL" and "BRIEF") are available that are not available when run within the compiler. |
| Output `COMMON` file | **`--commono=``COMMON0.out`** | **`--commono=``COMMON1.out`** | **`--commono=``COMMON2.out`** | **`--commono=``COMMON3.out`** | **`--commono=``COMMON4.out`** | **`--commono=``COMMON5.out`** | **TBD** | The state of `COMMON` memory upon program end. **Warning:** The input and output files cannot have the same name. |
In addition to this miscellany of files, the compiler also
automatically outputs many other files without any user directive
to do so. Note that for the purpose of file-naming, the
compiler often refers to its passes by number rather than
name: 0 for PASS1, 1 for FLO, 2 for OPT, 3 for AUX, 4 for
PASS2, 5 for PASS3, and 6 for PASS4. (Why? Stupidity,
I guess. Mine, I mean.)
Among the more-significant files produced in this way are:
- Each pass of the compiler creates a snapshot of the literal
file (see the table above), renamed as litfile0.bin,
litfile1.bin, etc., according to the compiler pass. Though
in principle different, in so far as I can ascertain these files
are all identical.
- Upon exit, each pass of the compiler creates a gzipped
snapshot of the System/360 memory space in which it thinks it's
running, called COMMON0.out.bin.gz, COMMON1.out.bin.gz, etc.,
according to the compiler pass. These files are *not*
forms of COMMON*x*.out, by the way, in spite of the
confusing naming, but they do fill the similar role of
preserving the contents of memory between compiler passes.
Typically, litfile*x*.bin requires the assistance of COMMON*x*.out.bin.gz
for a full interpretation, because litfile*x*.bin usually
contains some pointers to string data residing in COMMON*x*.out.bin.
(By "gzipped", I mean that it's compressed and can be
uncompressed via the GNU **gunzip** utility, or via the
standard **zlib**/**libz** library available for most
programming languages.)
- comment.txt preserves the HALSFC HAL/S compiler's command-line
parameters. This is convenient for later rerunning a
compilation using identical parameters.
- monitor13.parm is used by compiler PASS1 to communicate its
so-called PARM list to later compiler passes.
# <a id="validation"></a>Validating the Compiler
## <a id="mindReader"></a>My Mind-Reading Trick
I will now perform a mind-reading act: I predict that you
trust software you download from the online sources. I'm
referring not to the security aspects of such downloaded software,
but to the functionality of it. You may well be worried that
the software is a scam somehow. But barring that, you assume
that it works correctly as advertised You trust the
developers. You have no interest in whatever means were used
to develop the software you've downloaded or to validate that it
operates correctly.
Was I right about you? If was, then
Congratulations! Give yourself a gold star. You don't
need to read this section. You're all done absorbing
information about the HAL/S compiler. That's why I've stuck
this section at almost the very end. It's easier to skip it
that way.
However, that's not a very productive way of thinking if you're the
one actually trying to resuscitate ancient software that was
originally used by very few people, in a protected, secretive
environment, and trying to do so in the absence of the environment
and the tools (and often, the documentation) that those original
developers relied on. That's just not the digital archaeology
way of thinking! No, in situations like that, we have to make
an enormous effort to check and cross-check everything we can think
of, to insure the highest degree of authenticity we can.
So that's what this optional section is about.
## Validating PASS1
As I mentioned earlier, we actually have two separately-developed
modern versions of the HAL/S compiler's phase 1: namely, the
ubiquitous PASS1 (AKA **HALSFC-PASS1**) that has been discussed
so much above, *and* a Python 3 port of phase 1 that I call **HAL\_S\_FC**.
In an ideal world, I'd like to say that these two programs were
developed completely independently, in clean-room fashion.
Unfortunately, I can't say that, because I developed both of them
myself, albeit at different times, though using entirely-different
development methods and relying on my sieve-like memory to have
forgotten everything in the meantime. Hopefully, that's good
enough to let us pretend that they were independently
developed. Because **HALSFC-PASS1** and **HAL\_S\_FC**
were developed separately, using different methods, it is likely
that although they could individually be buggy, it is extremely *unlikely*
that they are buggy in the same ways at the same places in their
code. Thus by closely comparing the results of the two, we can
debug (or alternatively, validate) both of them at once.
Now unfortunately, to support my claim that these two
implementations of phase 1 can each be used to validate the other,
we do have to talk a little bit about how the modern HAL/S compiler
was developed, and I doubt that that's something of too much
interest to you. But if we have to, we have to. Here's a
side-by-side comparison of the development methods:
| Stage of Development | HAL\_S\_FC | PASS1 |
| --- | --- | --- |
| First stage: separate development | 1. **HAL/S-FC** source code for PASS1 manually translated from from XPL/I language and IBM 360 assembly language to Python 3, calling it **HAL\_S\_FC**. 2. Manually debugged until compilation of a HAL/S program could proceed to its conclusion without aborting. 3. Manually debugged until the compiler report and output files (literals, HALMAT) seemed plausible. | 1. [Developed **XCOM-I**](https://www.ibiblio.org/apollo/XPL-I.html), a general-purpose XPL/I-to-C cross compiler. 2. Extensively tested **XCOM-I** with legacy XPL code (such as source code of 1970's XPL compilers). 3. Manually developed C-language "patches" for the small amount of IBM 360 machine code in **HAL/S-FC**. 4. Created C-language version of **HAL/S-FC**, using **XCOM-I** and C-language patches. 5. Compiled the C code, calling the resulting executable **HALSFC-PASS1**. |
| Second stage: joint debugging | 1. Compiled all existing HAL/S source-code files using both **HAL\_S\_FC** and **HALSFC-PASS1**, with the same compiler options for each. 2. Used automated comparisons (such as **diff**) of: compiler reports, HALMAT files, and literal files. 3. Where discrepancies were found, corrected either **HAL\_S\_FC** or **XCOM-I** or IBM 360 "patches" of **HAL/S-FC**. 4. Went back to step 1 until no more discrepancies were found! 5. Went back to step A until no more HAL/S source-code files are available. | |
The end result of that process, obviously, is that all available
HAL/S source-code files (eventually including Space Shuttle flight
software) were compiled to give matching results in the two
implementations of phase 1.
We already know, of course, that the comparison of **HALSFC-PASS1**'s
results to those of **HAL\_S\_FC** can be performed with any/every
compilation, simply by using the TEST feature of **HALSFC**.
My claim *right now* is that in doing so, we've validated our
modern version of PASS1.
## Validating Phases 1.5, Phase 2, and Phase 3
Unfortunately, we have no independent implementations of FLO, OPT,
AUX, or PASS2 against which to compare **HALSFC-FLO**, **HALSFC-OPT**,
**HALSFC-AUX**, and **HALSFC-PASS2**.
However, there are other means of performing an adequate validation
test. Two methods are available to use, applicable to
different versions of the flight software:
- Flight software version OI-30.17: For this software version, I
didn't receive actual source code, but instead received what
amount to compiler listings from phase 1 of the compiler and
assembly listings from the assembler. Source code was
extracted from these listings, and unlinked object code (FCOS
only) was extracted from the assembly listings. The latter
facilitated debugging and validation of our AP-101S assembler
- Flight software version OI-34.06/07: For this software
version, I received contributed source code for OI-34.06,
disassembled memory dumps for OI-34.07, and a so-called **HALSTAT**
report intermediate between the two. It was therefore
possible to assemble all of the assembly-language source-code
files, compile all of the HAL/S source code files, link the
object files, and compare the result to the disassembled memory
dumps. This process was used to help debug the assembler,
compiler, and linker. *Fortunately*, it turned out
that there are very few differences between OI-34.06 and
OI-34.07, so this process was feasible, if not necessarily
smooth and easy. A side benefit was that the source code
for the version-related differences could be reconstructed as
well.
At this writing, I can tell you that our compilation+linking of
OI-34.06 is *identical* to the OI-34.07 memory dumps except
for the following:
- Memory locations *known* to have values that changed
after compile+link time
- A bug in the original **HAL/S-FC**'s floating-point
arithmetic that appears in less than a handful of places
How many such differences do we actually ignore? Well,
overall, there are a little more than 100K (halfwords) of
them. 100K! Yes, but those are spread across 8
different memory configurations, each over 300K (halfwords) in
size, so the cross-check coverage is still around 96%.
## <a id="DebuggingCompiler"></a>Debugging the Compiler Itself
Of course, if the validation process described above fails, then
the HAL/S compiler itself may need to be fixed somehow.
That's quite a tall order, and I cannot give much general guidance
for doing so that covers *all* possible cases! In
general, though, I can say this: The source code for the
HAL/S compiler, written in XPL/I and IBM 360 Basic, must be
regarded for this discussion as 100% complete and correct.
This assertion of perfection is obviously factually false, but may
as well be true since substantively modifying the original source
code is prohibited by the Virtual AGC Project's
admittedly-unwritten principles. Any errors must therefore
be sought elsewhere, in the modern code provided by the Virtual
AGC Project itself. That leaves two possibilities:
1. The "modern" XPL/I compiler (**XCOM-I**) has bugs that must
be fixed. If so, address them in the Python 3 source code
for **XCOM-I** in the XCOM-I/ folder of the Virtual AGC
source tree. The top-level Python file is XCOM-I.py, but
it directly or indirectly imports additional custom Python
modules as well (parseCommandLine.py, auxiliary.py,
xtokenize.py, generateC.py, parseExpression.py, etc.).
2. Or else some manually-produced "patch files" in which IBM 360
Basic assembly-language source code has been ported to the C
language have bugs that must be fixed. The source code for
those patch files (patch\*.c) are found in the subfolders PASS*X*.PROCS/,
FLO.PROC/, AUX\_PROCS/, and OPT.PROCS/ of the folder
"yaShuttle/Source Code/PASS.REL32V0/".
(Or both.) Either possibility is dreadful, but for what
it's worth (very little!) possibility #2 is slightly less
dreadful, and is often a slightly better place to start looking
anyway.
[What little
else I can say about debugging can be found on the XPL/I page](https://www.ibiblio.org/apollo/XPL-I.html#debugging).
# <a id="morePreprocessors"></a>More About Preprocessors
I've mentioned "preprocessors" a number of times already, in a
variety of different contexts:
- I said that the HAL/S statement `REPLACE`, which
is used to replace selected identifiers with arbitrary strings,
possibly with parameter replacement, is not actually a HAL/S
statement after all, but rather a preprocessor command.
This is true, in a sense, since this kind of replacement occurs
prior to any true evaluation of HAL/S statements.
Nevertheless, the replacement process takes place entirely
within the HAL/S compiler itself, so there's not actually any
standalone "preprocessor" program that performs these
replacements.
- Similarly, I've stated that all `COMPOOL`s must be
processed for inclusion in a "template library" prior to
compiling any source-code files that depend on those `COMPOOL`s.
But again, this preprocessing is done by the compiler itself
rather than by a program dedicated to that purpose, just by
managing the order in which we compile HAL/S source-code files.
- And I've said that "inclusion files" must be processed prior
to their use, by means of a program I call **prepareINCLIB**.
But this so-called processing is really nothing more than
recoding the files from ASCII to EBCDIC, and of course would
have been unnecessary for the original compiler HAL/S-FC in the
original System/360 computing environment.
So as these things go, it's a stretch even to distinguish these
kind of activities as preprocessing. Too fancy!
On the other hand, there are preprocessors we *know* were used
by the original developers, even though our visibility into how
those preprocessors worked is limited, and the source for them is
non-existent as far as we know. But to fully compile PASS,
those preprocessors are needed, and hence we must recreate them
ourselves.
*(Work in progress.)* One
of those preprocessors relates to the display formats used in the
Multifunction Display Units (MDU). Consider the display
format in the illustration to the right, apparently used in PASS
version OI-34 in OPS 1, 2, 3, 6, and 8. It is my
understanding, perhaps wrong, that such formats were loaded into
the electronics of the MDU directly from mass memory, and weren't
something of which PASS was directly cognizant. And yet ...
there are often HAL/S source-code files in PASS related to such
display formats. I was unaware of this myself, and thanks go
to Elliot Nunn for bringing it indirectly to my attention by
insightful questioning on the basis of the contemporary
documentation. Elliot's realization has actually solved a
long-standing knowledge gap (for me) in terms of what PASS source
code actually contains. You see, when this stuff comes to me
— referring to PASS source code, BFS source code, even HAL/S-FC
source code — it's just in the form of thousands of files with
8-character filenames and no filename extensions to tell us what
kinds of files those are. For anyone old enough to remember
MS-DOS, think of 8.3 filenames+extensions, but with no ".3".
Are these HAL/S source source code? Are they XPL? Are
they IBM System/360 Basic Assembly Language (BAL), or perhaps
AP-101S assembly language? JCL? CLIST? Reports
of some kind? Something else? There's no way to tell,
other than going through them all, figuring each of them out one
by one, and renaming them with appropriate filename extensions
like .hal, .xpl, .bal, and so on, so that some of the confusion
can be dispelled. That's one of my many little duties here,
admittedly self-appointed, for which you may envy me at your
leisure.
But I wasn't able to figure out everything on my own.
Interspersed with HAL/S source-code files are a number of files
the purpose of which I had had little clue, other than an idle
suggestion offered by someone that perhaps these unknown files
related somehow to the display units. For example: In
retrospect, I now see that an otherwise-inexplicable file called
CG0180 is related to the display format illustrated to the
right. But how were they related, what was supposed to be
done with the file? Print it out and rub it on the display
units? I think not! That's a stupid suggestion.
Well (thanks again, Elliot!), there's now an answer to that:
These unknown files do indeed relate to the display formats.
They seem to contain descriptions of what variables from the PASS
software are displayed at which display-screen coordinates, and of
how that data is supposed to be formatted. Presumably, the
afore-mentioned data loaded into the MDU electronics from mass
storage would have been the unchanging template onto which these
variables were superimposed. For example, you see various
text in this display at the right like "SURF", "DPS", "CNTLR",
"NAV", and so on; these would have part of the template, and not
something described by the display-format files we're talking
about now.
We also know now what was supposed to be *done* with these
display-format files: There was a preprocessor called the
Display Format Generator (DFG), and that preprocessor converted
these display-format description files into HAL/S source-code
files for regular compilation! How we know that is somewhat
interesting. As you may recall, we have two version of PASS
source code, namely OI301700 and version OI340600. If you
were to compare these two versions, as I have belatedly done,
you'd find that where one of these display-format files appears in
OI340600, there's quite often a HAL/S source code file of the same
name in OI301700. In the particular example we're
illustrating here, the file CG0180.hal in OI301700 corresponds to
file CG0180 in OI340600. And if you look within the HAL/S
file, in addition to HAL/S source code, you'll find the complete
text of the display-format file, commented out. I think the
reason is this: In spite of what I said above, the OI301700
source code was not actually supplied to me in the form of
source-code files, but rather in the form of reports from which I
extracted the source code. But in these reports, the DFG
preprocessing had already been performed, so the source-code I
extracted for OI301700 was the HAL/S source code *produced*
by DFG rather than the input files for it that we have in
OI340600.
At any rate, now that we have this understanding, we'll be using
the filename extension .dfg for these display-format files in the
future.
Of course, the source code for the original DFG program is gone
with the wind, as far as we know, but that doesn't stop us from
needing a functional replacement for it. Elliot has tasked
himself with creating it, naming it **yaDFG**, so once again,
thanks Elliot! He'll be able to do that because we have a
lot of the .dfg files from OI340600 and the corresponding .hal
files from OI301700, so it's possible even in the absence of
documentation to figure how to convert the one to the other.
We look forward to seeing it in action in the not-too-distant
present.
*(Work that's just a gleam in my eye.)* There are at
least two additional large groups of PASS files of unknown
function and unknown processing requirements, which could
conceivably require conversion into HAL/S form. Such details
are presently TBD. Those two groups of files are:
- Files stored in a directory called PDTIN/. PDT
apparently stands for Parameter Tape Update, and each file seems
to correspond to a particular `COMPOOL`.
- Files stored in a directory called PSFIN/. I don't know
what "PSF" stands for. These files are similar
in format to PDT files. Like PDT files they correspond to
specific `COMPOOL`s.
For example, somehow corresponding to the COMPOOL CGCCOM.hal, there
are the files PDTIN/#@CGCCOM and PSFIN/CGCCOM$P. Any
additional facts, though, are TBD.
*(The unknown.)* Finally, there's the HAL/SM-to-HAL/S
converter, which could be viewed as a kind of preprocessor.
TBD
# <a id="compilePASS"></a>Compiling the Space Shuttle Primary Flight Software
Now, for the reasons mentioned in the preceding section, among
others, it's not yet feasible to entirely compile any version of
PASS. But we can make a start of it. Yes, I know that
very few of you have access to the Space Shuttle's Primary Flight
Software (PFS, or PASS) at present. Less than two,
actually. I'm sorry about that! But I'm an optimist,
so I hope that someday you will, and I'll pretend that you do, in
which case you'll want to know how to compile that software.
If that seems tone-deaf you you, feel free to flip me the bird and
skip this section entirely!
Space Shuttle flight-software source-code is, of course since
it's secret right now, not kept in Virtual AGC's GitHub
repository, but rather in a git repository I call PFS, located ...
somewhere. And encrypted ... somehow. But let's posit
that you've somehow cloned this git repository on your local
computer system, and hence have a directory called *PFS*/.
For the purpose of this discussion, there are two sub-directories
of significance, namely:
- *PFS*/OI301700/, which contains the source code for PASS
release OI-30.17.
- *PFS*/OI340600/, which contains the source code for PASS
release OI-34.06.
Either of the sub-directories OI340600 or OI301700 contains a
number of sub-directories of its own, of which the following is an
inventory:
- APPLSRC/ contains "application software" written in HAL/S.
- CON80/ contains lists of source modules included in an any
given build.
- INCL80/ contains HAL/S source-code files that are intended
only for importation into other HAL/S files via the HAL/S
compiler directive "`D INCLUDE name`".
They typically contain just fragments of HAL/S code, such as
macro definitions (HAL/S `REPLACE`
statements) and structure-type definitions (HAL/S `STRUCTURE` statements),
rather than complete compilation units like a `PROGRAM`, `PROCEDURE`, `FUNCTION`, or `COMPOOL`. As a
result, you usually can't successfully compile any of them on a
stand-alone basis.
- MLIB80/ contains AP-101S assembly-language files that can be
imported into other AP-101S assembly-language files via the `COPY` pseudo-op.
Among these are files of definitions of AP-101S macros.
- PDTIN/ is TBD.
- PSFIN/ is TBD.
- SSSRC/ contains "system software" written in HAL/S and in
AP-101S assembly language.
- TOOLIN/ is TBD.
Hundreds of HAL/S source-code files and hundreds of AP-101S
assembly-language files are involved in compiling either OI340600
or OI301700. Inconveniently, the order in which the HAL/S
files are compiled is very important, since the compilation of
most of them can only succeed if certain other HAL/S source-code
files they required have *already* been compiled.
To relieve you of the burden of worrying about those matters,
I've provided some Python scripts to automate the process.
Since compilation occurs from the command line, the first thing to
do is to open a command-line and get into the directory containing
the version of PASS that you want to compile:
> ```text
cd PFS/OI340600If you've done any previous compiling of HAL/S in this directory, it may be littered with the results of those compilations in a series of sub-directories with names of the form *.results. The existence of those sub-directories doesn't hurt anything, but they do clutter up the place, and you might be confused by them later. I'm sure that there will be enough to be confused by later even without them, so perhaps you might want to delete them all before proceeding.
Before doing any actual compiling, though, for repeatability you might want to prepare the template and inclusion libraries into known useful states, such as a state in which:
- The template library has been cleared of all templates that
might be imported via the "
D INCLUDE TEMPLATE name" compiler directive. - The inclusion library has been pre-loaded with all HAL/S files
which might be imported via the "
D INCLUDE name" compiler directive.
Here's how to do that:
text
prepareTEMPLIB --clear prepareINCLIB --clear --include=INCL80
Now you're ready to start actually compiling:
> ```text
compilePASSThe compilePASS program does quite a lot for you, but in
particular it manages the problem of compilation order of the HAL/S
files by examining all of the HAL/S files and determining a
consistent ordering. Roughly speaking, it first compiles all
of the HAL/S files containing no "D INCLUDE TEMPLATE name" compiler directives
at all, then it compiles all HAL/S files with "D INCLUDE TEMPLATE name" compiler directives
just for the files already compiled, and so on, until there's
nothing left to compile.
But compilePASS does a number of other things for you as well. For one thing, you may recall from the discussion of HAL/S compiler options earlier that there are actually quite a lot of compiler options, and nowhere are you given a clue as to what options actually need to be used ... well, other than the default settings of those options. But the defaults end up being red herrings, since those defaults often aren't the settings you need!
Aside: Actually, let me clarify that: Those aren't the settings you need if you want your compilations to reproduce the original PASS executables byte-for-byte. Since we'll only be running PASS software (or other software written in HAL/S) in a simulated environment, there's not necessarily any reason to be that compulsive about it, since the software may work perfectly well if compiled with different settings. I, on the other hand, do need to worry about that, since checking byte-for-byte exactness against the original memory dumps is the most-effective technique I have for insuring for you — and mostly me — that the HAL/S compiler actually works correctly.
Of course, most compiler options affect the presentation in reports generated by the compiler, and don't actually affect the object code generated by the compiler. But some do. Empirically I've found (via comparison to original memory dumps from the Shuttle's GPCs) that the compiler options related to code-generation that don't correspond to the defaults are NOLFXI, REGOPT, and sometimes X1. Of course, you don't really need to know about that, since compilePASS handles it for you. As explained earlier, the X1 option disables the optimization pass, and is only desirable when errors (specifically ZO3) occur during optimization, but compilePASS handles this for you by detecting if such an error has occurred and then recompiling the specific HAL/S files in which it has.
Unsurprisingly, all of this takes quite a long time to run, so probably it's best not to sit around staring at it while it works. The net results is lots and lots of object files. That doesn't mean that the build process is completed, since in addition to HAL/S files, the entire PASS version contains AP-101S assembly-language files as well, which we have not assembled here to obtain their object files. Not to mention the fact that all of those object files need to be linked together (along with the FCOS operating-system files) to obtain a true AP-101S executable load file. How to perform those additional steps is presently TBD.
And don't be fooled even about HAL/S compilation! As of this writing, the compilation process is nowhere near successfully compiling even the entirety of OI340600's HAL/S files. And I've not even attempted OI301700 yet. So take everything I've said with a really big grain of salt!
HAL/S to C Cross-Compiler
To close out the topic of HAL/S compilers, I want to bring up a somewhat nebulous topic that for reasons which will become obvious I need to leave a little mysterious.
One problem that confronts me is a head-on clash between two seemingly irreconcilable requirements:
- The need to integrate actual Shuttle flight software into any spaceflight simulator (such as Orbiter) that wants to legitimately simulate actual Shuttle performance as opposed to being a well-meaning but very pretty caricature of it.
- Versus the ridiculous theoretical legal notion that the now-many-years-obsolete Space Shuttle is a "weapons system" that threatens the security of the United States of America ... i.e., the looming specter of ITAR.
Of course, the common-sense solution is to recognize that the latter is self-evident bunkum, and simply release the flight software so that anyone anywhere could see it. Alas, I haven't the courage to do that.
An imperfect but perhaps acceptable compromise would be to devise some means for the flight software to be used in a spaceflight simulation, without revealing the source code itself in any form that would allow for recovery of its source code or AP-101S object code. This sounds impossible, but isn't really. After all, it's what happens whenever you use RSA "asymmetric" encryption: verifying your "public" key is very cheap and easy, but recovering your "private" key is so difficult that it's impossible in a practical sense. How might such an "asymmetric" difficulty system apply to the case at hand?
My proposed solution is exactly what the title of this section says: Provide a compiler that can directly generate C code, given HAL/S source code as input. It's a little more than that, in the sense that to make the reverse-engineering challenge a little trickier:
- I won't give you the compiler or tell you anything more about it. (But if you are one of the few with access to the flight software, you do have access to the compiler.)
- So if you want any C code generated for some HAL/S code, you'll have to give it to me to compile.
- I won't provide you with the C source code the compiler generates.
- I'll give you only the compiled executable. (In the case of flight software, you'll also get link libraries compatible with the discussion on our "emulators" page for integration into space-flight simulation software.)
There are some obvious practical difficulties with what I just said, in that the deliverables are tailored to your specific computing platform, which I may not be able to duplicate properly — for may not, read probably not —, and may have little inclination to do so anyway. So admittedly, the whole scheme may come to nothing in the end. In any event, at least for now, assume that compiled code can be provided only for Linux Mint on the "x86_64" CPU architecture, or something similar enough to run simple command-line programs compiled for it.
A couple of important questions remain to be answered anyway:
- Is this code really as difficult to reverse engineer as I hope? If you're a hacker who longs for eternal glory (but work for free!) apply directly to me and I'll supply you with lots of compiled code you can try to reverse engineer.
- Is this really a valid scheme for satisfying ITAR restrictions? I think so, but there's no way to know. The jury is out, figuratively speaking. Suffice it to say that in this particular area, nobody with the expertise to judge the matter will tell you anything that would help you decide.
If you want to try your hand at reverse engineering, you can already find a handful of simple pre-compiled sample programs here. I'll add more if there is any demand for them. These are very short programs, in which you're sometimes given info that would allow you to cheat ... such as the fact that you can easily find the HAL/S source code for some of these programs. Let me know your progress. If you had to use the HAL/S source code at some point other than for a final check of your results, don't bother to tell me about it. I have no hacking skills, but even I can find the source code for a program for which I've been given the source code, so it's not very impressive. You might be able to guess the source code for these programs, but not for flight software. (And if you could, why would you need the flight software source code anyway?)
One thing you may wonder about is why all of these very-simple programs end up as 300K+. They're all statically linked, so as to make them more portable, rather than being dynamically-linked and thus dependent on whatever library versions you've installed on your computer, so that 300K mostly represents all of the common library routines needed.
A Glossary and Some References
Organizations:
Intermetrics, Inc.: The company which originally developed the Space Shuttle's primary flight software and the development tool-chain for it. At this writing, its current successor is L-3 Communications.
United Space Alliance (USA): The company which eventually took over the flight-software development. It was a joint venture of Rockwell International (succeeded by Boeing) and Lockheed-Martin. It was dissolved in 2019, without a successor that I'm aware of, and no longer exists.
Rockwell International: The company which developed the Space Shuttle's backup flight software.
Timeframes:
Contemporary or original or Intermetrics: I use these terms more-or-less interchangeably to refer to the software and/or documentation created for the Space Shuttle project itself, in the rough time-frame 1975-2010.
Modern: I use this term to refer to software developed primarily by the Virtual AGC Project in the post-Shuttle era to replace or supports the contemporary development tool-chain. If you're reading this 100 or 1000 years after I wrote it, I expect that it won't seem very "modern".
Computer hardware:
IBM System/360: This, and its descendants (the 370 and 390), were the types of mainframe computers on which the development tool-chain ran.
IBM AP-101S or General Purpose Computer (GPC): This is the type of computer onboard the Space Shuttle in which the flight software ran; each Shuttle had 5 of these computers. Technically, early Shuttle flights used the AP-101B computer.
Native system: This is the term I'll use to describe the computer system you might be using today to run the software from this page; presumably not an IBM 360 or AP-101S! I have in mind any computer running the Linux operating system, or to the extent it's feasible for me to support, the Mac OS or Windows operating systems.
Computer languages:
HAL/S: The high-level computer language in which the Space Shuttle flight software was primarily written. I refer specifically to the version of HAL/S implemented by Intermetrics, Inc., which though sharing the same name, would not have been 100% compatible with HAL/S implementations by other companies for other purposes.
AP-101S assembly language: The low-level computer language in which some of the flight software was written.
HALMAT: A contemporary "intermediate language" into which HAL/S program was compiled. HALMAT is more of a binary file format than a "language", since there is no easily-human-readable form of it, nor did humans ever write programs in HALMAT. Rather, the virtues of HALMAT were that it was agnostic as to the targeted computer type, that it was subject to optimization, and that target-specific assembly language could be generated from it.
PALMAT: A modern intermediate language, similar in spirit to HALMAT, but differing from HALMAT in all details.
XPL (or sometimes, standard XPL): A computer language defined by a book called A Compiler Generator (1979), by William M. McKeeman, James J. Horning, and David B. Wortman. This language was specialized for the purpose of writing compilers for other computer languages.
XPL/I: This is an extended but ofttimes undocumented form of XPL that was implemented by Intermetrics, Inc. The term "XPL/I" is my own; Intermetrics, and everyone else as far as I know, simply referred to it as "XPL", as if it were the same thing as standard XPL.
Basic Assembly Language (BAL): This is the low-level language of the IBM System/360, 370, and 390 computers. If you look for adequate reference material, it's best to think of it as IBM 390 assembly language. Confusingly, Intermetrics/USA also referred to AP-101S assembly language as "BAL".
Python and C: Modern computer languages for native computer systems. By "Python", I refer to Python 3 (as opposed to Python 2). By "C", I refer to the language compiled by GNU gcc, or by 100%-compatible compilers such as clang.
Space Shuttle Flight Software:
Primary Flight Software (PFS): This is what's usually thought of as the flight software. Written primarily in HAL/S, but with some AP-101S assembly language.
Flight Control Operating System (FCOS): The operating system which the PFS ran atop. Written in AP-101S assembly language.
Primary Avionics Software Subsystem (PASS): PFS+FCOS. Note: Unfortunately, the original developers' verbal habit (carrying over to some documentation) seems to have become to refer to PFS by itself as "PASS". In fact, PASS became the preferred term! I fear that I've fallen into that habit myself in these writings.
Backup Flight Software (BFS): Flight software written independently of PFS, specializing only in critical tasks, to provide improved reliability; in such critical flight phases, BFS ran on one of the Shuttle's 5 GPCs while PFS ran on the other 4 GPCs, so that BFS could quickly take over for PFS if needed. Written primarily in HAL/S, with some AP-101S assembly language.
Backup Operating System (BOS): The operating system atop which BFS ran. Written in AP-101S assembly language.
Especially-relevant documentation:
McKeeman: I use this term to refer to the book A Compiler Generator (1979), by William M. McKeeman, James J. Horning, and David B. Wortman.
Ryer: I use this term to refer to the book Programming in HAL/S, second edition (1979), by Michael Ryer.
Related Virtual AGC website pages:
Other terms you may encounter here:
FSW: Flight Software.
SDF: Simulation Data Files, used when running digital simulations of the Shuttle flight software in AP-101S load-file form.
This page is available under the Creative Commons No Rights Reserved License *Last modified by Ronald Burkey on 2026-08-17
