//Common field formats
[String] (Strings should not contain a '\0' terminator).
<length of string in bytes> --- 4 bytes
{
  <ith character of string> --- 1 byte
}

//Beginning of linkcode description
<linkcode version number> --- 1 word
<top-level module name> --- [String]

<size of code area> --- 1 word

<total number of kinds>  --- 2 bytes
[Global Kinds]
<number of global kinds> --- 2 bytes
{
  [Global Kind]
  <arity> --- 1 byte
  <name> --- [String]
}

[Local Kinds]
<number of local kinds> --- 2 bytes
{
  [Local Kind]
  <arity> --- 1 byte
}

[Type Skeletons]
<number of type skeletons> --- 2 bytes
{
  [Type Skeleton]
  {
    <Arrow = 0> --- 1 byte
    <Left argument> --- [Type Skeleton]
    <Right argument> --- [Type Skeleton]
  } or {
    <Kind = 1> --- 1 byte
    <mark local/global/pervasive> --- 1 byte
    <index into kind table> --- 2 bytes
    <arity> --- 1 byte
    <arguments> --- kind arity [Type Skeleton]s
  } or {
    <Var = 2> --- 1 byte
    <offset> --- 1 byte
  }
}

<total number of constants> --- 2 bytes
[Global Constants]
<number of global constants> --- 2 bytes
{
  [Global Constant]
  <fixity> --- 1 byte
  <precedence> --- 1 byte
  <type env size> --- 1 byte
  <name> --- [String]
  <index into type skeleton list> --- 2 bytes
}
  
[Local Constants]
<number of local constants> --- 2 bytes
{
  [Local Constant]
  <fixity> --- 1 byte
  <precedence> --- 1 byte
  <type env size> --- 1 byte
  <index into type skeleton list> --- 2 bytes
}

[Hidden Constants]
<number of hidden constants> --- 2 bytes
{
  [Hidden Constant]
  <index into type skeleton list> --- 2 bytes
}

[Strings]
<number of strings> --- 2 bytes
{
  <ith string> --- [String]
}


[Implication Goal Tables]
<number of implication goals> --- 2 bytes
{
  [Implication goal]
  [Next Clause Table]
  <number of entries in next clause table> --- 2 bytes
  {
    <entry index> --- [Constant index]
  }
  <find function code> --- 1 byte (1 = hash, 0 = sequential)
  [Search Table]
  <number of predicates> --- 2 bytes
  {
    <entry index> --- [Constant index]
    <relative address of code> --- 1 word
  }
}

[Hash Tables]
<number of hash tables> --- 2 bytes
{
  [Hash Table]
  <number of entries> --- 2 bytes
  {
    <mark local/global/hidden> --- 1 byte
    <index into constant table> --- 2 bytes
    <relative address of code> --- 1 word
  }
}

[Bound Variable Tables]
<number of bound variable tables> -- 2 bytes
{
  [Bound Variable Table]
  <number of entries> --- 2 bytes
  {
    <index> --- 1 byte
    <relative address of code> --- 1 word
  }
}

[Import Tables]//Table 0 is for top level module
<number of import tables> --- 2 byte
{
  [Import Table]
  <number of code segments> --- 1 byte
  <number of entries in next clause table> --- 2 bytes
  {
    <entry index> --- [Constant index]
  }
  <count of local constants> --- 2 bytes
  {
    <local constant index> --- [Constant index]
  }
  <find function code> --- 1 byte (1 = hash, 0 = sequential)
  [Search Table]
  <total number of predicates> --- 2 bytes
  {
    <entry index> --- [Constant index]
    <relative address of code> --- 1 word
  }
}

[Bytecode]
{
This part will consist of a sequence of instructions each 
of which is given by the op code followed by info about the 
requisite number of operands. The op codes for various 
instructions are available in the file instructions.h in the 
simulator code directory. This file also decribes a code for
each kind of operand. The presentation of operand info in the
bytecode is as follows:
   P (padding)               ---  null field
   R (register no)           ---  1 byte number
   E (env variable)          ---  1 byte number
   N (next clause in i.p.)   ---  1 byte number
   I1 (small integer)        ---  1 byte number
   I2 (larger integer)       ---  2 byte number
   CE (closure env var)      ---  1 byte number
   C  (constant index)       ---  3 bytes, 
                                    First byte indicates whether 
                                      global (0), local (1) or hidden (2)
                                      pervasive (3)
                                    Second byte indicates the index
   K  (kind index)           ---  3 bytes, 
                                    First byte indicates whether 
                                      global (0), local (1) or hidden (2), 
                                      pervasive (3)
                                    Second byte indicates the index
   MT (module table address) ---  2 byte index
   IT (impl. table address)  ---  2 byte index
   HT (hash table address)   ---  2 byte index   
   L  (code location)        ---  4 byte relative address: offset in
          bytes from start of
          instruction
   I (integer)               ---  4 bytes, encoded as a single long
          integer
   F (floating point number) ---  8 bytes: first 4 bytes are mantissa,
          second 4 bytes are exponent.
   S  (string start address) ---  2 byte index
}