TI-86 Link Protocol Guide v1.0 - Variable formats

##

Variable Formats

A TI-86 variable has two parts: a header and a data section. While the header may be different, the format of the data section never changes whether the variable is in a file, in a transfer packet, or in the calculator's memory. This section describes the format of the data section for most types of variables. The format for the header is described in the packet format and the file format section.

#### Variable Types

There are several types of variables that the TI-86 uses.

Real Numbers are basic floating-point numbers.
Complex Numbers are basic complex numbers with real and imaginary floating-point components.
Vectors are one-dimensional matrices with real or complex components.
Lists are sequences of real or complex numbers used in statistical calculations.
Matrices are two-dimensional matrices with real or complex components.
Constants are real or complex user-defined variables that cannot be changed from the home screen or a program.
Equations are functions that evaluate based on the values of one or more variables.
Strings are sequences of text characters.
Graphics Databases (GDB's) are stored sets of graphing functions.
Pictures are stored bitmaps of the graph screen.
Programs are sequences of commands.
Window Settings are stored sets of graph screen range parameters.

#### Real Numbers

The TI-86's representation of a real number has the following format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Flags (see table below)
1 | 2 bytes | Base-10 exponent
3 | 7 bytes | Mantissa

The flags byte has the following format:

Bit (Mask) | Description
--- | ---
0 (01h) | If set, the number is half of a complex value.
6 (40h) | Uncertain. Most likely if set, the number has not been modified since the last graph.
7 (80h) | Sign bit: If set, the number is negative.

The exponent is a 16-bit unsigned little-endian (LSB first) binary number normalized at FC00h. The real exponent can be computed by subtracting FC00h from the value stored here. Valid exponents are in the range -999 to 999.

The mantissa is stored as a 14-digit unsigned binary-coded-decimal number. The most significant digit is first and the implied decimal point is always between the first two digits. Every nybble (4 bits or half a byte) contains one digit, according to the following table:

Binary Value | Decimal Digit
--- | ---
0000 | 0
0001 | 1
0010 | 2
0011 | 3
0100 | 4
0101 | 5
0110 | 6
0111 | 7
1000 | 8
1001 | 9

#### Complex Numbers

A complex number is represented as a two real numbers, both with flag bit 0 set. The format is shown below.

Offset | Length | Description
--- | --- | ---
0 | 10 bytes | A real number describing the "real" component of the complex number.
10 (Ah) | 10 bytes | A real number describing the "imaginary" component of the complex number.

#### Vectors

A vector is represented as a one-column matrix. The format is shown below.

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Always set to 1
1 | 1 byte | Number of elements in the vector (no more than 255)
2 | n bytes | Element values, one by one, first to last. If the vector is a real vector, then each element is a 10-byte real number. If the vector is a complex vector, then each element is a 20-byte complex number.

#### Lists

A list is represented as a sequence of numbers. The format is shown below.

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Number of elements in the list
1 | n bytes | Element values, one by one, first to last. If the list is a real list, then each element is a 10-byte real number. If the list is a complex list, then each element is a 20-byte complex number.

#### Matrices

A matrix is represented as a two-dimensional array of numbers. The format is shown below.

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Number of columns in the matrix (no more than 255)
1 | 1 byte | Number of rows in the matrix (no more than 255)
1 | n bytes | Element values, one by one (see explanation below). If the matrix is a real matrix, then each element is a 10-byte real number. If the matrix is a complex matrix, then each element is a 20-byte complex number.

The element values are arranged in row definitions from top to bottom. Each row consists of a number of real or complex elements from left to right. Under this scheme, would be ordered (1,2,3,4) in memory.

#### Constants

Real constants share the same format as real numbers. Complex constants share the same format as complex numbers.

#### Equations

Equations share the same format as strings. They are always tokenized. Click here for a table of token definitions.

#### Strings

Strings are represented as a sequence of characters following a length byte:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Number of characters in the string
2 | n bytes | Characters, first to last. The string is not zero-terminated.

#### Graphics Databases (GDB's)

GDB's for each graphing mode are different, but they all consist of a window setup portion and a function library portion. The TI-86 can also use TI-85 style GDB's sent over the link cable (See TI-85 documentation for TI-85 GDB format). TI-86 style GDB's cannot be sent to a TI-85.

A function-mode GDB has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Length, in bytes, of GDB, minus two.
2 | 1 byte | Mode settings (see mode setting table below)
3 | 10 bytes | A real number: xMin
13 (Dh) | 10 bytes | A real number: xMax
23 (17h) | 10 bytes | A real number: xScl
33 (21h) | 10 bytes | A real number: yMin
43 (2Bh) | 10 bytes | A real number: yMax
53 (35h) | 10 bytes | A real number: yScl
63 (3Fh) | 10 bytes | A real number: xRes
73 (49h) | 1 byte | Number of functions defined (up to 99)
74 (4Ah) | n bytes | Function table - several function definitions one after another (see function table below)
74 (4Ah)+n | 50 bytes | Style table - 4 bits per function (see style table below)

A polar-mode GDB has the following format

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Length, in bytes, of GDB, minus two.
2 | 1 byte | Mode settings (see mode setting table below)
3 | 10 bytes | A real number: Min
13 (Dh) | 10 bytes | A real number: Max
23 (17h) | 10 bytes | A real number: Step
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl
93 (5Dh) | 1 byte | Number of functions defined (up to 99)
94 (5Eh) | n bytes | Function table - several function definitions one after another (see function table below)
94 (5Eh)+n | 50 bytes | Style table - 4 bits per function (see style table below)

A parametric-mode GDB has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Length, in bytes, of GDB, minus two.
2 | 1 byte | Mode settings (see mode setting table below)
3 | 10 bytes | A real number: tMin
13 (Dh) | 10 bytes | A real number: tMax
23 (17h) | 10 bytes | A real number: tStep
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl
93 (5Dh) | 1 byte | Number of functions defined (up to 99)
94 (5Eh) | n bytes | Function table - several function definitions one after another (see parametric function table below)
94 (5Eh)+n | 50 bytes | Style table - 4 bits per function (see style table below)

A differential-equation-mode GDB has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Length, in bytes, of GDB, minus two.
2 | 1 byte | Mode settings (see mode setting table below)
3 | 1 byte | Extended mode settings (see extended mode settings table below)
4 | 10 bytes | A real number: difTol
14 (Eh) | 10 bytes | A real number: tPlot
24 (18h) | 10 bytes | A real number: tMin
34 (22h) | 10 bytes | A real number: tMax
44 (2Ch) | 10 bytes | A real number: tStep
54 (36h) | 10 bytes | A real number: xMin
64 (40h) | 10 bytes | A real number: xMax
74 (4Ah) | 10 bytes | A real number: xScl
84 (54h) | 10 bytes | A real number: yMin
94 (5Eh) | 10 bytes | A real number: yMax
104 (68h) | 10 bytes | A real number: yScl
114 (72h) | 1 byte | FldOff x Axis (see axis table below)
115 (73h) | 1 byte | FldOff y Axis (see axis table below)
116 (74h) | 1 byte | SlpFld y Axis (see axis table below)
117 (75h) | 1 byte | DirFld x Axis (see axis table below)
118 (76h) | 1 byte | DirFld y Axis (see axis table below)
119 (77h) | 10 bytes | A real number: dTime
129 (81h) | 10 bytes | A real number: fldRes
139 (8Bh) | 10 bytes | A real number: EStep
149 (95h) | 1 byte | Number of functions defined (up to 9)
150 (96h) | n bytes | Function table - several function definitions one after another (see differential function table below)
150 (96h)+n | 50 bytes | Style table - 4 bits per function (see style table below)

The mode setting byte has the following format:

Bit (Mask) | Mode if set (1) | Mode if clear (0)
--- | --- | ---
0 (01h) | DrawDot | DrawLine (unavailable in DifEq)
1 (02h) | SimulG | SeqG (unavailable in DifEq)
2 (04h) | GridOn | GridOff
3 (08h) | PolarGC | RectGC (unavailable in DifEq)
4 (10h) | CoordOff | CoordOn
5 (20h) | AxesOff | AxesOn
6 (40h) | LabelOn | LabelOff
7 (80h) | TI-86 GDB Format | TI-85 GDB Format (See TI-85 documentation)

The extended differential equation setting byte has the following format:

Bit (Mask) | Mode if set (1) | Mode if clear (0)
--- | --- | ---
0 (01h) | SlpFld | DirFld or FldOff, depending on bits 1 and 2
1 (02h) | DirFld | SlpFld or FldOff, depending on bits 0 and 2
2 (04h) | FldOff | SlpFld or DirFld, depending on bits 0 and 1
5 (20h) | Euler | RK

Note: Exactly one of bits 0-2 must be set.

Each nybble in the style table has the following format:

Binary Value | Graph Style
--- | ---
0000 | [solid line]
0001 | [thick line]
0010 | [shade above]
0011 | [shade below]
0100 | [trace]
0101 | [animate]
0110 | [dotted line]

The differential equation axis bytes have the following format:

Value | Axis
--- | ---
0 | t
16 (10h) | Q
17-25 (11h-19h) | Q1 ... Q9
32 (20h) | Q'
33-41 (21h-29h) | Q'1 ... Q'9

Function- and polar-mode function definitions have the following format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Function ID (the number of the function) - bit 7 (0x80) is set if the function is selected
1 | n bytes | An equation defining the function

Parametric-mode function definitions have the following format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Function ID (the number of the function) - bit 7 (0x80) is set if the function is selected
1 | n bytes | An equation defining the x function
1+n | m bytes | An equation defining the y function

Differential equation function definitions have the following format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Function ID (the number of the function) - bit 7 (0x80) is set if the function is selected
1 | n bytes | An equation defining the function
1+n | 1 byte | Unknown
2+n | 10 bytes | Initial condition. If the initial condition is defined, this is a real number representing QIf, where f is the number of the function. If the condition is undefined, the first two bytes are {FFh 03h}, followed by the characters "QIf" (again, f is the number of the function), followed by five 0-valued bytes.

#### Pictures

Pictures are 128x63-pixel bitmaps. They have the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Size of picture data (always 3F0h)
2 | 1008 (3F0h) bytes | 1-bit-per-pixel bitmap data, arranged top-to-bottom in rows. Each row is defined left-to-right. (See figure below)

The following figure demonstrates byte ordering of the pixels if the bitmap is in a 1008-element array data[]:

#### Programs

Programs share the same format as strings. Because of this, a program has a maximum length of 65535 bytes, contrary to what Texas Instruments claims in their FAQ; the largest editable program is 65434 characters long. Some programs (those that use the new TI-86 features) cannot be executed by a TI-85.

TI-BASIC programs can be plain-text or tokenized, edit-locked or edit-unlocked.
Z80 assembly programs can be plain-text, tokenized or compiled.

Plain-text unlocked programs start with one NULL character (00h).
Plain-text locked programs start with two NULL characters.
Tokenized unlocked programs start with a valid token other than the edit-lock token.
Tokenized locked programs start with the edit-lock token (8Eh 29h)

Plain-text assembly programs start with one NULL character (00h) and cannot be executed.
Tokenized assembly programs start with the AsmPrgm token (8Eh 27h) and cannot be executed.
Compiled assembly programs start with the Compiled Assembly token (8Eh 28h) and cannot be edited.

Click here for a table of token definitions.

#### Window Settings

Like GDB's, window setting formats vary with graphing mode. Window settings cannot be sent to a TI-85.

A function-mode window has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 5Bh.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: xMin
13 (Dh) | 10 bytes | A real number: xMax
23 (17h) | 10 bytes | A real number: xScl
33 (21h) | 10 bytes | A real number: yMin
43 (2Bh) | 10 bytes | A real number: yMax
53 (35h) | 10 bytes | A real number: yScl
63 (3Fh) | 20 bytes | Unknown
83 (53h) | 10 bytes | A real number: xRes

A polar-mode window has the following format

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 5Bh.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: Min
13 (Dh) | 10 bytes | A real number: Max
23 (17h) | 10 bytes | A real number: Step
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl

A parametric-mode window has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 5Bh.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: tMin
13 (Dh) | 10 bytes | A real number: tMax
23 (17h) | 10 bytes | A real number: tStep
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl

A differential-equation-mode window has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 92h.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: difTol
13 (Dh) | 10 bytes | A real number: tPlot
23 (17h) | 10 bytes | A real number: tMin
33 (21h) | 10 bytes | A real number: tMax
43 (2Bh) | 10 bytes | A real number: tStep
53 (35h) | 10 bytes | A real number: xMin
63 (3Fh) | 10 bytes | A real number: xMax
73 (49h) | 10 bytes | A real number: xScl
83 (53h) | 10 bytes | A real number: yMin
93 (5Dh) | 10 bytes | A real number: yMax
103 (67h) | 10 bytes | A real number: yScl
113 (71h) | 1 byte | FldOff x Axis (see axis table)
114 (72h) | 1 byte | FldOff y Axis (see axis table)
115 (73h) | 1 byte | SlpFld y Axis (see axis table)
116 (74h) | 1 byte | DirFld x Axis (see axis table)
117 (75h) | 1 byte | DirFld y Axis (see axis table)
118 (76h) | 10 bytes | A real number: dTime
128 (80h) | 10 bytes | A real number: fldRes
138 (8Ah) | 10 bytes | A real number: EStep

A saved window (ZSTO) has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 8Ch.
2 | 10 bytes | A real number: zMin
12 (Ch) | 10 bytes | A real number: zMax
22 (16h) | 10 bytes | A real number: zStep
32 (20h) | 10 bytes | A real number: ztPlot
42 (2Ah) | 10 bytes | A real number: ztMin
52 (34h) | 10 bytes | A real number: ztMax
62 (3Eh) | 10 bytes | A real number: ztStep
72 (48h) | 10 bytes | A real number: zxMin
82 (52h) | 10 bytes | A real number: zxMax
92 (5Ch) | 10 bytes | A real number: zxScl
102 (66h) | 10 bytes | A real number: zyMin
112 (70h) | 10 bytes | A real number: zyMax
122 (7Ah) | 10 bytes | A real number: zyScl
132 (84h) | 10 bytes | A real number: zxRes

Backups | Table of Contents | File Formats

Site maintained by Romain Liévin (roms@lpg.ticalc.org) and Tim Singer (tsinger@gladstone.uoregon.edu)