Library Routines

Add

JSBR IZ 1711
P1=Address of Augend
P2=Address of Addend
P3=Address of Answer
P4=Word Length

Adds the Addend to the Augend and stores the sum in the Answer.

All three numbers must have the same word length (specified by P4). The addend and the augend are preserved, unless overlaid by the answer. No error indication is given if overflow occurs.

Add to Double Word

JSBR IZ 1713
P1=Address of Accumulator
P2=Address of Addend

The Addend is added to the Accumulator. Both are double word binary numbers.

Calculate Check Digit

JSBR IZ 1740

Calculates the “Check Digit” corresponding to the number in the A-Register on entry. On return, the A-Register contains the check digit in ASCII (the top byte of A is NUL).

The standard calculation routine returns a letter A:Z.

Clear Block of Core

JSBR IZ 1710
P1=Address of Block
P2=Word Length

Sets each word of the block to binary zeros.

Complement Double Word

JSBR IZ 1750
P1=Address of Double Word Binary Number

Subtracts the Double Word Binary number from zero. The result overlays the original number.

Compute

JSBR IZ 1747
P1=Address and Word Length of Multiplicand
P2=Address and Word Length of Multiplier
P3=Address and Word Length of Divisor
Address of Double Word Result

Multiplies the Multiplicand by the Multiplier and divides the intermediate result by the Divisor, storing the Result rounded to the nearest ½. If the Result is invalid for any reason (e.g. Divisor is zero) the answer given will be zero. The Multiplicand, Multiplier and Divisor are preserved unless overlaid by the result.

Word length may be specified as Single by setting B16 of the appropriate parameter; otherwise Word Length is taken as Double.

Parameter Format (P1, P2, P3 only)

B17
1 if Offset Address
B16
1 if Single Word
B15:B1
Address

Conversion: ASCII → Binary

JSBR IZ 1762
P1=Byte Address of ASCII Source
P2=Address of Binary Target
P3=Control Word

Converts the ASCII source string to Binary as specified by the Control Word.

On return from this subroutine, A-Register B17 will be set if the number was too large to fit in the Binary Target. The B-Register B16:B1 will contain the Byte Address of the next character following the detected end of field. In the case of a variable length source, the end-of-field character will be in the bottom of the A-Register. If a fixed-length source contained non-numeric characters, B-Register B17 will be set.

Numeric characters are the digits 0 to 9, hyphen (minus-sign), period (decimal point) and comma (ignored).

Control Word

B17
0
B16:B9
Length (characters) of Source. Set zero if the source string is Variable Length. Non-numeric characters within a fixed-length source string are ignored, except NUL which causes all following characters to be ignored.
B8:B7
Word Length of Target. Must not be zero.
B6:B5
0
B4:B1
Number of decimal places in Target. Free Format is allowed within the source string; any necessary adjustment is carried out automatically (excess digits are truncated).

Conversion: ASCII → Metacode

JSBR IZ 1737
P1=Byte Address of Source ASCII
P2=Address of Target Metacode
P3=Control Word

Converts the source string to Metacode (a system of encoding three characters per 17-bit word) until either a NUL character is encountered in the source or the source string is exhausted or an unconvertible character is encountered in the source.

The NUL character (when encountered) is inserted into the target.

The Metacode character set is restricted to a choice of 49 characters plus NUL. If an unconvertible character was encountered in the source string, the A-Register is non-zero on return from this routine.

Control Word

B17
0
B16
1
B15:B1
Maximum Length (characters) of Source

The standard Metacode character set consists of:

Conversion: Binary → ASCII

JSBR IZ 1765
P1=Control Word
P2=Address of Binary Source
P3=Byte Address of ASCII Target

Converts the Binary Number into a fixed length decimal character string formatted as specified by the Control Word. The last character of the string will contain a hyphen if the number is negative, or a space or the “check digit” (if requested) if the number is positive.

No error indication is given if the number is too large to fit the string.

Control Word

B17
1 if preceding zeros required
0 if preceding zeros are replaced by spaces in the target string.
B16:B13
Precision of Source (Number of figures after the decimal point in the Binary Source).
B12:B9
Precision of Target (Number of figures after the decimal point in the Target). If zero, the decimal point is itself omitted from the string.
B8:B7
Word length of the Binary Source.
B6
1 if the routine will calculate the Check Digit corresponding to the number and insert it in the last character position.
B5:B1
Total length of the target string, in characters, including the space, hyphen or check digit and (if non-integer) the decimalpoint.

Conversion: Binary → Octal Characters

JSBR IZ 1612
P1=Byte Address of six character Target

Converts the contents of the A-Register on entry into octal digits stored in ASCII in the six-character Target String. Leading zeros are not space filled.

Conversion: Metacode → ASCII

JSBR IZ 1637
P1=Byte Address of Target ASCII
P2=Address of Source Metacode
P3=Control Word

Converts each Word of the Source Metacode into three ASCII characters in the Target until either a NUL character is encountered in the source or the target string is exhausted.

The NUL character (when encountered) is inserted into the target string unless B17 of P3 is set.

Control Word

B17
1 if NUL not required in Target
0 otherwise
B16
0
B15:B1
Maximum Length (characters) of Target

Convert Input to Binary and test Limits

JSBR IZ 1606
P1=Single Word Minimum Value
P2=Single Word MAximum Value

Using the issuing task’s Input Buffer as the ASCII Source String, this routine converts the next numeric field within the String to a Single Word Binary Number.

If the number is outside the limits specified by P1 and P2 the Error Handler is called (ERROR is sent to the task’s I/O station and upon acknowledgement the most recent GET subroutine call issued by the task is restarted).

On return from this subroutine, the A-Register will contain the Single Word Binary Number extracted from the Input Buffer. The non-numeric character which terminated the field will be found in the bottom byte of absolute core location 000043 (the top byte will be NUL); if this word is zero then the end of the source string has been reached.

The source string may contain several numeric fields, each separated by a single non-numeric character, and successive calls to this subroutine will yield the next field (provided the Error Handler is not called).

If an attempt is made to extract a field after the source string has been exhausted, the Binary Number will be set to zero. If two non-numeric characters are adjacent in the Source String, an intervening zero field will be created. In both cases, control passes to the Error Handler if zero is outside the specified limits.

P1 must be positive or zero, P2 must not be less than P1.

Convert to Negative if Positive

JSBR IZ 1702
P1=Address of Binary Number
P2=Word Length

Tests the Binary Number and if positive subtracts it from zero.

On return, the A-Register will be clear if and only if the number was already negative when the routine was entered.

Convert to Positive if Negative

JSBR IZ 1701
P1=Address of Binary Number
P2=Word Length

Tests the Binary Number and if negative subtracts it from zero.

On return, the A-Register will be clear if and only if the number was already positive (or zero) when the routine was entered.

Divide with Remainder

JSBR IZ 1732
P1=Address and Word Length of Dividend and Remainder
P2=Address and Word Length of Divisor
P3=Address and Word Length of Result

Divides the Dividend by the Divisor, storing the Result and overlaying the Dividend with the Remainder. The Divisor is preserved. If the Divisor is zero, the result is set zero and the remainder will equal the dividend.

The division is performed by a process of repetitive subtractions coupled with right shifts.

Parameter Format

B17
1 if Offset Address
B16:B15
Word Length of the Parameter. If 0, single word length is assumed.
B14:B1
Address of Parameter

Caution

Divide and Round

JSBR IZ 1726
P1=Address and Word Length of Dividend
P2=Address and Word Length of Divisor
P3=Address and Word Length of Result

Divides the Dividend by the Divisor and stores the Result rounded to the nearest half. The Dividend and the Divisor are preserved. If the Divisor is zero, the result is set zero.

Parameter Format

B17
1 if Offset Address
B16:B15
Word Length of the Parameter. If 0, single word is assumed.
B14:B1
Address of Parameter

Caution

Divide by 10 with Remainder

JSBR IZ 1745

Divides the contents of the A-Register by 10 and stores the remainder in the B-Register.

Divide by 10 Rounded

JSBR IZ 1744

Divides the contents of the A-Register by 10, rounding the result (5 goes up).

Duplicate Block of Core

JSBR IZ 1707
P1=Address of Source
P2=Address of Target
P3=Word Length

The source is copied, word by word, to the target.

Left Shift Block of Core

JSBR IZ 1730
P1=Address of block
P2=Word Length

Left shifts B16:B1 of each word of the block by one bit position. B16 carries into B1 of the word to the left. Each B17 is unchanged.

If the block contains a binary number, its value is doubled.

Load A from Offset

JSBR IZ 1721
P1=Address of operand

This subroutine returns to the step following P1. The A-Register will contain the contents of the word addressed by P1 and the B-Register will contain the absolute value of P1.

Memory aid: 21=LDA

Move and Pad Character String

JSBR IZ 1741
P1=Byte Address of Source String
P2=Byte Address of Target String
P3=Length (characters) of Target String

The source string is copied, byte by byte, to the Target string until either a NUL byte is encountered in the Source String or the Target String is exhausted.

The A-Register is non-zero on return if the Target String was exhausted without encountering a NUL byte in, or immediately after, the Source String (this indicates truncation).

When a NUL byte is encountered in the Source string, the remainder of the target string is space-filled. The NUL byte is not entered into the target string.

Multiply

JSBR IZ 1734
P1=Address and Word Length of Multiplicand
P2=Address and Word Length of Multiplier
P3=Address and Word Length of Result

Multiplies the Multiplicand by the Multiplier and stores the Result. If the Result is rendered invalid for any reason (e.g. insufficient word length) the answer given will be zero.

Parameter Format

B17
1 if Offset Address
B16:B15
Word Length of the Parameter. If 0, single word length is assumed.
B14:B1
Address of Parameter

Caution

Multiply by 10

JSBR IZ 1761
P1=Address of Binary Number
P2=Word Length

Multiplies the Binary Number by 10 and adds the contents of the A-Register at entry to the routine to the result of the multiplication.

Maximum word length is 3.

On return, A-Register contains the overflow (if any) from the most significant word. The result overlays the original Binary Number.

Name and Address Processor

JSBR IZ 1655
P1=Address of first parameter block
P2=Address of Exit Routine
P3=Number of Calls to Exit Routine

Given any number of names and addresses, each held in ASCII in separate source strings, this routine creates an ASCII target string containing the first line from each name and address. The routine then passes control to a user-written Exit Routine, which will normally perform an output operation and which must return control, whereupon the next line from each name and address is set up in the target string and the Exit Routine is called again. The process is repeated (provided the Exit Routine returns control) until the Exit Routine has been called the number of times specified by P3, whereupon control returns to the step following P3.

Each source string is ended with a NUL byte. Each line within each source string is ended with ASCII code CR (optional on the last line). Each source string is allocated a field within the target string (the field position and length being user-defined) into which the next source line is copied byte by byte. The terminating CR is never stored in the target, neither is a NUL byte. If the target field becomes full, excess source characters are ignored. Each new source line is copied to the start of the appropriate target field, until a NUL byte indicates that the end of the source string has been reached.

The target string must be space-filled initially and upon each return from the Exit Routine (N.B. Inner Print Buffer is automatically space-filled by the Printer Output routine).

On entry to the Exit Routine, the A-Register will contain the Call Number (=1 first time). The Exit Routine will always be called exactly the number of times specified by P3. The Exit Routine may set up further fields within the target string before it is output; but in most cases it will simply output and return:

←Back Address→ EXIT ROUTINE
LDA Z 0201 CF1 (one line feed)
JSBR IZ 1644 Printer Output
JUMP I b/a Back Address

Parameter Block

There is one five-word parameter block for each source string, format as follows:

P1
Address of next parameter block (set 0 if end of chain).
P2
Byte Address of Source ASCII
P3
Byte Address of Target ASCII field.
P4
Length (characters) of Target field.
P5
Workspace (used internally as Source pointer, does not require presetting).

Pack Date

JSBR IZ 1607

This routine uses the Convert Input to Binary and Test Limits subroutine to to extract a date from the issuing task’s Input Buffer. The date must be input to the buffer in ASCII as three numeric fields (day, month and last two digits of year) separated by a single non-numeric character (usually a space).

If an error is detected in the input ASCII the Error Handler is called (ERROR is sent to the task’s I/O station and upon acknowledgement the most recent GET subroutine call issued by the task is restarted).

On return from this subroutine, the A-Register will contain a properly validated date packed in the format shown below and suitable for presentation to the Unpack subroutine.

Format of Packed Date

B17
0
B16:B10
Year (0:99)
B9:B6
Month (1:12)
B5:B1
Day (1:31)

Resolve Offset Address

JSBR  Z 1630

Tests the contents of the A-Register on entry for an Offset Address and, if found, converts the address to absolute.

On return, the A-Register contains the Absolute address. The B-Register is unchanged.

An Offset Address is indicated by B17 set.

Resolve Block of Offset Addresses

JSBR IZ 1627
P1=Address of Block

Tests each word of the block for the presence of an Offset Address and, if found, overlays the word with the resolved absolute address.

The end of the block is indicated by a zero word.

Words within the block not containing offset addresses (i.e. B17 not set) are unchanged.

Right Shift Block of Core

JSBR IZ 1727
P1=Address of Block
P2=Word Length

Right-shifts B16:B1 of each word of the block by one bit position. B1 carries into B16 of the word to the right. Each B17 is unchanged.

This routine should not be used to halve binary numbers, because the sign bit is not propagated into B16 in the most significant word.

Skip if Blocks Equal

JSBR IZ 1723
P1=Address of forst block of core
P2=Address of second block of core
P3=Word Length

Compares the first block word for word with the second block. If an inequality is detected the routine returns to the step following P3. If both blocks are identical, the routine skips this step on returning.

The Greater-than Flag will be set or clear according as P1 is greater than P2. The comparison is logical, not arithmetic (i.e. B17 of each word is not interpreted as a sign bit).

Skip if Block not Zero

JSBR IZ 1724
P1=Address of Block
P2=Word Length

Tests the block word by word for zero. If all words are zero, the routine returns to the step following P2. If a non-zero word is found, the routine skips this step on returning.

An equivalent but more efficient method for double words is:

LDA     First Word
IORA Second Word
AN0 Skip if A not 0

Space Fill Block of Core

JSBR IZ 1731
P1=Address of Block
P2=Word Length

Sets each word of the block to ASCII SP SP.

Store A at Offset

JSBR IZ 1725
P1=Address of operand

The contents of the A-Register at entry are stored at the word addressed by P1.

The subroutine returns to the step following P1 with the A-Register unchanged and the B-Register containing the absolute value of P1.

Memory aid: 25=STA.

Store Byte

JSBR IZ 1775
P1=Byte Address of operand

The bottom byte (B8:B1) of the A-Register at entry are stored at the byte addressed by P1.

The subroutine returns to the step following P1 with A-Register and B-Register undefined.

Subtract

JSBR IZ 1712
P1=Address of Minuend
P2=Address of Subtrahend
P3=Address of Answer
P4=Word Length

Subtracts the Subtrahend from the Minuend and stores the difference in the Answer.

All three numbers must have the same word length (specified by P4). The minuend and the subtrahend are preserved, unless overlaid by the answer. No error indication is given if overflow occurs.

Subtract from Double Word

JSBR IZ 1714
P1=Address of Accumulator
P2=Address of Subtrahend

The Subtrahend is subtracted from the Accumulator. Both are double word binary numbers.

Swap Blocks of Core

JSBR IZ 1707
P1=Address of first Block
P2=Address of second Block
P3=Word Length

The blocks are swapped word by word.

A block of core may be rotated by any desired number of words by swapping two suitably overlapping sub-blocks.

Unpack Date

JSBR IZ 1751
P1=Byte Address of ASCII Target

Converts the contents of the A-Register on entry into a nine-character string stored in the Target with the format:

dd mmm yy

where dd, yy are numeric and mmm is alphabetic.

The word presented in the A-Register should be a date previously packed by the Pack Date subroutine.