SAP/BSS computational subprograms¶
FORTRAN II accepts repeatable --bss module.cbn options. The loader reads
160-byte column-binary cards with P7B record markers and odd parity, checks
their BSS checksums, relocates address/decrement fields and resolves transfer
vectors. Calls execute a bounded computational subset of the IBM 704.
Build and try the independently authored ABI example:
make
python3 tools/sap.py tests/sap/double.sap -o /tmp/double.cbn
python3 tools/sap.py tests/sap/bump.sap -o /tmp/bump.cbn
python3 tools/sap.py tests/sap/hwords.sap -o /tmp/hwords.cbn
python3 tools/sap.py tests/sap/common.sap -o /tmp/common.cbn
./fortran704 --bss /tmp/double.cbn --bss /tmp/bump.cbn \
--bss /tmp/hwords.cbn --bss /tmp/common.cbn tests/sap/abi.f
This probe checks a real argument, fixed integer, COMMON, an array/EQUIVALENCE
alias, a multiword Hollerith literal and its terminator, and a function return.
Its printed values match original FORTRAN II objects loaded by the original
BSS loader on both Sim704 and native i704. The separate compiled.f fixture
also supplies a subroutine compiled by the original compiler; the local
runtime executes that original object. The checked-in object contains only
our own subroutine, with no IBM runtime or loader.
Memory and calls¶
There is one 32K physical word store. Code grows upward from address 128; FORTRAN data grows downward. COMMON starts at octal 77462, reserving the upper 205 historical system words. These are physical addresses, but local allocation does not reproduce every absolute address of original object code. The bottom 128 words are reserved for the host call bridge. Code/data collision, undefined reads and illegal stores through a live DO alias are diagnosed.
An ordinary CALL NAME(A,B) supplies the first address of each argument in
a synthetic calling sequence, with XR4 set as by TSX. Arrays descend from
their first element; text literals ascend from their first character word.
Hollerith storage persists at the call site, including mutations. Fixed
integers use a sign and a 15-bit magnitude shifted 18 bits. Tape/drum transfers
preserve raw words, including low bits not used by a fixed integer value.
A routine with n arguments returns through TRA n+1,4 and must restore
all three index registers. A transfer into the reserved call area at any
other address is diagnosed as an argument-count/return mismatch. Ordinary function names use I through N for fixed
results and return the value in AC. For example D=DOUBL(C) calls the entry
DOUBL. Terminal-F library-tape names use a different historical convention;
loading replacements for those functions is unsupported. The six built-in
library implementations remain available. A machine routine can call other
linked machine routines; it cannot call back into an AST FORTRAN unit.
Machine entry clears AC, MQ and machine indicators, sets XR1/XR2 to zero, and sets XR4 for the call. These are deterministic host-boundary values; arbitrary original compiler register context is not reproduced. Machine indicators are local to the call; MQ-overflow testing (TQO) is unsupported. At return, only S and magnitude bits 1 through 35 form the result word; Q/P are not part of a stored FORTRAN result. Execution is limited to one million instructions; unsupported instructions or floating inputs with Q/P bits set fail explicitly. No channels, trap mode, peripherals or machine timing are emulated by this bridge. It cannot boot a FORTRAN system or run an arbitrary original object main program.
Assembler subset¶
tools/sap.py requires Python 3.10+ and is an independent small assembler for bridge examples. Use
whitespace-separated label operation operand or operation operand lines.
An unlabelled operation must be a recognised mnemonic. Labels should avoid
mnemonic names. Whole-line * comments and REM are supported; fixed-column
SAP comments/macros are not. The first storage label is the default entry;
repeat --entry NAME for up to ten explicit entry points (one to six letters
or digits, beginning with a letter).
Supported directives: REL, ORG, EQU, SYN, BSS, BES, OCT, DEC,
BCD, END. ABS is rejected. Expressions allow decimal numbers, prior
EQU/SYN definitions, labels, */. for the location, addition and subtraction.
EQU/SYN cannot refer forward. Explicit NAME EQU -n denotes upper memory;
differences of lower-memory labels remain absolute. Relocation digit 11 is
emitted when the numeric field falls on the other side of the program break,
including a trailing BES label. Unsupported compound relocation is rejected.
OCT supplies raw octal words. DEC supplies sign-magnitude integers,
floating constants with 27 fraction bits, or B-scaled fixed constants.
Its decimal conversion uses bounded decimal arithmetic and truncation;
long-decimal equivalence to the historical SAP converter is not established.
BCD uses a decimal word count immediately followed by text; use a
non-digit first character (a blank can separate digit-leading text, and that
blank is retained as data). All
unfilled BSS/BES words are initialised to zero, a local assembler convention.
Transfer-vector generation, automatic COMMON reservation, historical control
cards, macros and the full original source syntax are outside this assembler.
The supported machine operations are the explicit OPCODES, PREFIX and
SENSE tables in tools/sap.py: common transfer/index, sign-magnitude and
logical operations, normalised FAD/FSB/FMP/FDP/FDH, shifts, stores and tests.
PZE and MZE are data words, not executable instructions. No unnormalised
floating instructions, HTR/HPR, I/O or traps are implemented. Execution tests
cover the bridge contract and selected instruction boundaries, not exhaustive
hardware conformance.
Loader limits and checks¶
Program cards define up to ten entries and reserve a lower-memory extent. Relocation digits 0, 10 and 11 are supported in both fields. Upper-memory references and common-reassignment/control offsets can be relocated, but data cards must stay inside an allocated lower-memory module. Absolute data cards must also be inside the current module. Initialising upper COMMON through a BSS card is not supported. Runtime stores into associated COMMON are supported. Duplicate entries, unresolved transfer names, overlaps, truncation, bad parity and checksum failures are diagnosed. Original checksum suppression/zero-checksum conventions remain accepted.
Run python3 tests/test_sap.py for the original-loader witnesses and local
corruption, alias, relocation, register, instruction-limit and persistence
checks. Validation records provenance and limits.