Standard Library
IC64 Libraries
Arithmetic at 16, 32, and 64 bits — ADD, MINUS, TIMES, DIVIDE, and more — all written in pure INTERCAL. A language that cannot add is merely difficult; one that adds the hard way is a standard library.
syslib64
The system library provides arithmetic routines at 16-bit, 32-bit, and 64-bit widths — addition, subtraction, multiplication, division, modulo, random numbers, and 64-bit bitwise operations. Every routine is implemented in pure INTERCAL. There is no native fallback: when TIMES64 runs, it is INTERCAL all the way down.
Source vs. binary
The library ships two ways, and you choose based on how much you want to know.
Binary — link and forget
Every build produces syslib64.dll, a prebuilt .NET assembly. Reference it at compile time and call its routines directly:
churn -r:syslib64.dll fizzbuzz.i
./fizzbuzz.exe
Source — read, change, recompile
The library is not a black box. It is syslib64.ic64, a few hundred lines of pure INTERCAL you can read, edit, and rebuild into your own binary:
churn -t:library syslib64.ic64
It is a glass box full of COME FROM. If you disagree with how 64-bit multiplication is done, you are welcome to do it worse yourself.
Calling a routine
The 16-bit routines take operands in .1 and .2, return the result in .3, and set an overflow indicator in .4. The 32-bit routines use the two-spots :1–:4; the 64-bit routines use the double cateyes ::1–::3.
DO .1 <- #40
DO .2 <- #2
PLEASE DO (1000) NEXT
PLEASE READ OUT .3
Routines may be called by their numeric label or by their ASCII name label. Name labels are computed by interpreting the routine name as an 8-character big-endian 64-bit integer — the label for ADD16 is the integer whose bytes are A, D, D, 1, 6 = 4702958889031696384. The programmer who finds this inconvenient is reminded that convenience has never been a design goal.
16-bit arithmetic
Operands in .1, .2. Result in .3. Overflow in .4.
| Label | Name | Description |
|---|---|---|
(1000) | ADD16 | .3 = .1 + .2 (no overflow check) |
(1009) | .3 = .1 + .2 (with overflow check) | |
(1010) | MINUS16 | .3 = .1 - .2 |
(1020) | .3 = .1 * .2 (low 16 bits) | |
(1030) | DIVIDE16 | .3 = .1 / .2, .4 = .1 mod .2 |
(1040) | TIMES16 | :3 = .1 * .2 (full 32-bit result) |
(1050) | MODULO16 | .3 = .1 mod .2 |
32-bit arithmetic
Operands in :1, :2. Result in :3. Overflow in :4.
| Label | Name | Description |
|---|---|---|
(1500) | ADD32 | :3 = :1 + :2 (no overflow check) |
(1509) | :3 = :1 + :2 (with overflow check) | |
(1510) | MINUS32 | :3 = :1 - :2 |
(1540) | TIMES32 | :3 = :1 * :2 (low 32 bits), :4 = high 32 bits |
64-bit arithmetic
Operands in ::1, ::2. Result in ::3. Called by name label.
| Label | Name | Description |
|---|---|---|
4702958910472978432 | ADD64 | ::3 = ::1 + ::2 |
5569068542595576832 | MINUS64 | ::3 = ::1 - ::2 |
6073470532629967872 | TIMES64 | ::3 = ::1 * ::2 |
Division, modulo, random, and bitwise
| Label | Name | Result |
|---|---|---|
(1030) | DIVIDE16 | .3 = quotient, .4 = remainder |
(1050) | MODULO16 | .3 = remainder |
4920558940556964658 | DIVIDE32 | :3 = quotient, :4 = remainder |
5570746397223760690 | MODULO32 | :3 = remainder |
(1900) | RANDOM16 | .1 = random 16-bit value |
5927104639891485490 | RANDOM32 | :1 = random 32-bit value |
5927104639891486260 | RANDOM64 | ::1 = random 64-bit value |
4705773660240084992 | AND64 | ::3 = ::1 AND ::2 |
5715690474052780032 | OR64 | ::3 = ::1 OR ::2 |
6363395191251927040 | XOR64 | ::3 = ::1 XOR ::2 |
5642821449895903232 | NOT64 | ::3 = NOT ::1 |
The 64-bit bitwise routines work by splitting each value into 32-bit halves, mingling the corresponding halves, applying the unary operator, selecting the result bits, and recombining. The full name-label reference for every entry point is in the repository.
Overflow
Label (1999) is the overflow handler. It is abstained from by default when calling through (1000) or (1500), and reinstated on return. Programs that call (1009) or (1509) directly receive overflow errors when the result exceeds the operand width:
(1999) DOUBLE OR SINGLE PRECISION OVERFLOW
The programmer who encounters this error is encouraged to use wider variables.
The libraries are compiled by churn and consumed by any INTERCAL-64 program — and, via cross-language interop, by C# as well.
