BANCStar

BANCStar is a language that was used in production in finance in the 1990s, even though it looks like an esoteric language.

Language capabilities
There is no real documentation, so a lot of the information we know is based on archaeological research and experimentation.

Syntax
A BANCStar program is a sequence of lines. Each line consist of a list of four comma-separated fields, each of which can contain an integer or be blank. The comma field delimiters are required even when some fields are left blank.

The first number in the list is the opcode, which describes the operation being performed by this line. See the table below for the list of opcodes discovered so far.

The numbers can be positive or negative, and are probably limited to between -32768 and 32767.

Instructions
Known values for opcodes are detailed below.

Arithmetic instructions
The most complicated type of instruction seems to be arithmetic instructions. Here, the first number is 10000+d, where d is the address of one of the 2000 variable cells ("prompts") as the destination operand.

The other three numbers are of the form (10v+p) or (22000+10n+p) where p is an operation code, v is a variable cell in the range [1, 2000], and n is a constant literal integer.

When a parameter is unneeded, it is usually set to 22002 (i.e. "add 0").

The arithmetic instructions which can be constructed are as in the following table. Here dest is the destination cell from the first number and p1/p2/p3 are the operation codes extracted from the other three numbers. Where an operand's value is always being treated as an address it is marked v1; when it's always a literal number it's written n1; and if it can be either then it is written a1.

If an operand must be left unused (22002), then its operation code is blank.

In some cases, a spare operand can optionally be used to squeeze an extra operation onto the same line: we call these "arithterms". Such operands are marked with "A" in the table below. If you don't want to use the arithterm, set that number to 22002, which is equivalent to the arithterm "add 0". An example of how arithterms work follows this table.

In all cases, we don't know how error conditions (divide by zero, substring out of range, etc) are treated.

In LIST, these are decoded by L_COMMTS.C lines 869–1691.

Arithterm example
An arithterm is used to squeeze an extra operation onto the same line as an existing one. Each arithterm takes up a single BANCStar number and encodes one of the four arithmetic operators (+-×÷) plus a constant or variable cell.

Arithterms are encoded in the way mentioned above (i.e. as 10v+p or 22000+10n+p). The operation code p can be one of the following:

The arithterm takes effect after the main operation. For example, this BANCStar line calculates the logarithm of the literal number 42, and saves it into variable cell 222:

10222,22427,22002,22002

Note the two optional arithterms have been left as 22002. Now we will change one of them to "subtract 64", which encodes as 22641.

10222,22427,22641,22002

Executing this single line now calculates the logarithm of 42, subtracts 64, and stores the result in cell 222. We can add one more arithterm:

10222,22427,22641,7773

Now this single line calculates log(42), subtracts 64, multiples by the value of variable cell 777, and finally stores the result in cell 222.

Conditional instructions
The various conditional instructions (conditional, block conditional, reverse block conditional) use a different encoding for operands.

The first operand (x) must always be a variable cell ("prompt"). It is given simply as the prompt number, in the range [1, 2000].

The second operand may be one of the following:

The operation argument op in the conditional instructions are encoded differently depending on the remaining operands.

Page conditionals
The op argument may have 10 added to it (i.e. {12, 13, 14, 15, 16}), in which case it signifies a "page conditional". The meaning of this is unclear, but it looks like any conditional statement may be used as a "page conditional".

Unary operations
Two unary operations are available by omitting the last operand (y) or setting it to zero. The following operand table is used in this case:

General comparisons
The table below is used if both operands are numbers, or if x is an "alpha" (string?) variable and y is an ASCII character:

Special
If the first operand is a prompt of type 7 (alpha, believed to be a string), and the second operand is not an ASCII character, the following table is used:

The last two operators seem to provide some sort of looping capability.

File instructions
Add 16000 to get the instruction number (see above). Note there seems to be some duplication of functionality here, I don't know if there is any hidden meaning.

Table instructions
See the entry for 30000+p in the main instruction table.

Each table operator has parameters p, x, y, and z as specified earlier. p is always a prompt. x may be a prompt number, or 10000+n, denoting some number n in [0, 9999]. y and z are both simple numbers unless otherwise specified.

Prompt file
The "prompts" (variable cells) used by a BANCStar program seem to have some metadata stored in a prompt file (*.PFL). It is probable that the prompt number is just the line number in this file. Each line has three comma-separated values: name (a human-readable string), type (an integer of unknown meaning), and length (an integer unknown meaning).

Some sample prompt entries:

Pmts/Year,2304,2 Term(# Pmts),204,3 Principal,205,10 BALANCE,205,10 Payment,205,8 Balloon,205,7 Intrest Rate,206,7 Total P&I,205,12 Date,2303,12 Trans Date,3,12
 * 1) 1 Pmt Date,2303,12

Prompt type
The LIST source code specifies the following prompt types:

Prompts of type 8 are used solely as on-screen display text, e.g.:

Press the ENTER key to continue. . .,8,

However, the sample data with the program include prompts with other type codes, e.g. 2304. The last digit always seems to match up with the above table. It's not known what the rest of the type code means.

Prompt length
The length value seems to be related to the size of the text entry box displayed alongside the prompt. Possibly the size specified in the prompt-display command must be less than or equal to this length?

Special variables
There seems to be some "special variables" (details are not quite known for certain):
 * 1547 = Pause flag
 * 1908 = Half of the return address
 * 1909 = Half of the return address

Implementation
The implementation is not available yet. We heard someone was trying to rescue the original implementation from an old floppy disk, but he then went missing. We are sure there's nothing fishy about this.