{
type intref    = int ref
type aconstant = Absyn.aconstant
type akind     = Absyn.akind
	
}

OPERAND TYPES

  P                                                  /* (1 byte) padding */
  WP                                                 /* (1 word) padding */
  R      RegInd         Byte           1   int       /* argument register number */ 
  E      EnvInd         Byte           1   int       /* environment variable number */
  N      NextClauseInd  Byte           1   int       /* next clause number in impt or impl pt */
  I1     OneByteInt     Byte           1   int       /* 1 byte natural number */
  CE     ClEnvInd       Byte           1   int       /* closure environment variable number */
  SEG    ImpSegInd      Byte           1   int       /* import segment index  */ 
  C      CstIndex       TwoBytes       2   aconstant /* constant symbol table index */
  K      KstIndex       TwoBytes       2   akind     /* kind symbol table index  */
  L      CodeLabel      CSpacePtr      8   intref    /* code location  */
  I      Int            int            4   int       /* integer immediate value */
  F      Float          float          4   float     /* floating point immediate value */
  S      Str            DF_StrDataPtr  2   int       /* string pointer */
  MT     ModTab         MemPtr         2   int       /* module table address */
  IT     ImplTab        MemPtr         2   int       /* impl table address */
  HT     HashTab        MemPtr         2   int       /* hash table address */
  BVT    BranchTab      MemPtr         2   int       /* branch table for bound var indexing */
  X                                                  /* operand list terminator */
  OPCODE Byte 1


INSTR CATEGORY

  MAX OPERAND 12 

  X      [P P P P P P P X X X X X]
         X_LEN    8

  RX     [R P P P P P P X X X X X]
         RX_LEN   8; RX_R    1
 
  EX     [E P P P P P P X X X X X]
         EX_LEN   8; EX_E    1

  I1X    [I1 P P P P P P X X X X X]
         I1X_LEN  8; I1X_I1  1

  CX     [P C P P P P X X X X X X]
         CX_LEN   8; CX_C    2

  KX     [P K P P P P X X X X X X]
         KX_LEN   8; KX_K    2

  IX     [P P P P P P P I X X X X]
         IX_LEN  16; IX_I    8

  FX     [P P P P P P P F X X X X]
         FX_LEN  16; FX_F    8

  SX     [P P P P P P P S X X X X]
         SX_LEN  16; SX_S    8

  MTX    [P P P P P P P MT X X X X]
         MTX_LEN 16; MTX_MT  8
 
  LX     [P P P P P P P L X X X X]
         LX_LEN  16; LX_L    8

  RRX    [R R P P P P P X X X X X]
         RRX_LEN  8; RRX_R1  1;   RRX_R2  2
 
  ERX    [E R P P P P P X X X X X]
         ERX_LEN  8; ERX_E   1;   ERX_R   2

  RCX    [R C P P P P X X X X X X]
         RCX_LEN  8; RCX_R   1;   RCX_C   2  
  
  RIX    [R P P P P P P I X X X X]
         RIX_LEN 16; RIX_R   1;   RIX_I   8

  RFX    [R P P P P P P F X X X X]
         RFX_LEN 16; RFX_R   1;   RFX_F   8

  RSX    [R P P P P P P S X X X X]
         RSX_LEN 16; RSX_R   1;   RSX_S   8

  RI1X   [R I1 P P P P P X X X X X]
         RI1X_LEN 8; RI1X_R  1;   RI1X_I1 2

  RCEX   [R CE P P P P P X X X X X]
         RCEX_LEN 8; RCEX_R  1;   RCEX_CE 2

  ECEX   [E CE P P P P P X X X X X]
         ECEX_LEN 8; ECEX_E  1;   ECEX_CE 2
  
  CLX    [P C P P P P L X X X X X]
         CLX_LEN 16; CLX_C   2;   CLX_L   8

  RKX    [R K P P P P X X X X X X]
         RKX_LEN  8; RKX_R   1;   RKX_K   2

  ECX    [E C P P P P X X X X X X]
         ECX_LEN  8; ECX_E   1;   ECX_C   2  
    
  I1ITX  [I1 P P P P P P IT X X X X]
         I1ITX_LEN 16; I1ITX_I1 1; I1ITX_IT 8

  I1LX   [I1 P P P P P P L X X X X]
         I1LX_LEN 16; I1LX_I1 1; I1LX_L 8  

  SEGLX  [SEG P P P P P P L X X X X]
         SEGLX_LEN 16; SEGLX_SEG 1; SEGLX_L 8

  I1LWPX [I1 P P P P P P L WP X X X]
         I1LWPX_LEN 24; I1LWPX_I1 1; I1LWPX_L 8 

  I1NX   [I1 N P P P P P X X X X X]
         I1NX_LEN 8;  I1NX_I1 1; I1NX_N 2 

  I1HTX  [I1 P P P P P P HT X X X X]
         I1HTX_LEN 16; I1HTX_I1 1; I1HTX_HT 8

  I1BVTX [I1 P P P P P P BVT X X X X]
         I1BVTX_LEN 16; I1BVTX_I1 1; I1BVTX_BVT 8

  CWPX   [P C P P P P WP X X X X X] 
         CWPX_LEN  16;  CWPX_C 2

  I1WPX  [I1 P P P P P P WP X X X X] 
         I1WPX_LEN 16;  I1WPX_I1 1

  RRI1X  [R R I1 P P P P X X X X X] 
         RRI1X_LEN 8; RRI1X_R1 1; RRI1X_R2 2; RRI1X_I1 3

  RCLX   [R C P P P P L X X X X X]
         RCLX_LEN 16; RCLX_R   1; RCLX_C   2; RCLX_L   8 

  RCI1X  [R C I1 P P P X X X X X X]
         RCI1X_LEN 8; RCI1X_R  1; RCI1X_C  2; RCI1X_I1 4

  SEGI1LX [SEG I1 P P P P P L X X X X]
          SEGI1LX_LEN 16; SEGI1LX_SEG 1; SEGI1LX_I1 2; SEGI1LX_L 8 

  I1LLX  [I1 P P P P P P L L X X X]
         I1LLX_LEN  24; I1LLX_I1   1; I1LLX_L1   8; I1LLX_L2 16

  NLLX   [N P P P P P P L L X X X]
         NLLX_LEN  24;  NLLX_N     1; NLLX_L1    8; NLLX_L2  16

  LLLLX  [P P P P P P P L L L L X]
         LLLLX_LEN 40;  LLLLX_L1   8; LLLLX_L2  16; LLLLX_L3 24; LLLLX_L4 32

  I1CWPX [I1 C P P P P WP X X X X X]
         I1CWPX_LEN 16; I1CWPX_I1  1; I1CWPX_C   2 

  I1I1WPX [I1 I1 P P P P P WP X X X X]
          I1I1WPX_LEN 16; I1I1WPX_I11 1; I1I1WPX_I12  2   

  CALL_I1_LEN 15


INSTRUCTIONS 145

   /*  Instructions for term unification and creation  */

   0         put_variable_t             RRX          RRX_LEN;
   1         put_variable_p             ERX          ERX_LEN;
   2         put_value_t                RRX          RRX_LEN;
   3         put_value_p                ERX          ERX_LEN;
   4         put_unsafe_value           ERX          ERX_LEN;
   5         copy_value                 ERX          ERX_LEN;
   6         put_m_const                RCX          RCX_LEN;
   7         put_p_const                RCX          RCX_LEN;
   8         put_nil                    RX           RX_LEN;
   9         put_integer                RIX          RIX_LEN;
   10        put_float                  RFX          RFX_LEN;
   11        put_string                 RSX          RSX_LEN;
   12        put_index                  RI1X         RI1X_LEN;
   13        put_app                    RRI1X        RRI1X_LEN;
   14        put_list                   RX           RX_LEN;
   15        put_lambda                 RRI1X        RRI1X_LEN;

   16        set_variable_t             RX           RX_LEN;
   17        set_variable_te            RX           RX_LEN;
   18        set_variable_p             EX           EX_LEN;
   19        set_value_t                RX           RX_LEN;
   20        set_value_p                EX           EX_LEN;
   21        globalize_pt               ERX          ERX_LEN;
   22        globalize_t                RX           RX_LEN;
   23        set_m_const                CX           CX_LEN;
   24        set_p_const                CX           CX_LEN;
   25        set_nil                    X            X_LEN;
   26        set_integer                IX           IX_LEN;
   27        set_float                  FX           FX_LEN;
   28        set_string                 SX           SX_LEN;
   29        set_index                  I1X          I1X_LEN;
   30        set_void                   I1X          I1X_LEN;
   31        deref                      RX           RX_LEN;
   32        set_lambda                 RI1X         RI1X_LEN;


   33        get_variable_t             RRX          RRX_LEN;
   34        get_variable_p             ERX          ERX_LEN;
   35        init_variable_t            RCEX         RCEX_LEN;
   36        init_variable_p            ECEX         ECEX_LEN;
   37        get_m_constant             RCX          RCX_LEN;
   38        get_p_constant             RCLX         RCLX_LEN;
   39        get_integer                RIX          RIX_LEN;
   40        get_float                  RFX          RFX_LEN;
   41        get_string                 RSX          RSX_LEN;
   42        get_nil                    RX           RX_LEN;
   43        get_m_structure            RCI1X        RCI1X_LEN;
   44        get_p_structure            RCI1X        RCI1X_LEN;
   45        get_list                   RX           RX_LEN;

   46        unify_variable_t           RX           RX_LEN;
   47        unify_variable_p           EX           EX_LEN;
   48        unify_value_t              RX           RX_LEN;
   49        unify_value_p              EX           EX_LEN;
   50        unify_local_value_t        RX           RX_LEN;
   51        unify_local_value_p        EX           EX_LEN;
   52        unify_m_constant           CX           CX_LEN;
   53        unify_p_constant           CLX          CLX_LEN;
   54        unify_integer              IX           IX_LEN;
   55        unify_float                FX           FX_LEN;
   56        unify_string               SX           SX_LEN;
   57        unify_nil                  X            X_LEN;
   58        unify_void                 I1X          I1X_LEN;

   /* Instructions for type unification and creation */ 
   59        put_type_variable_t        RRX          RRX_LEN;
   60        put_type_variable_p        ERX          ERX_LEN;
   61        put_type_value_t           RRX          RRX_LEN;
   62        put_type_value_p           ERX          ERX_LEN;
   63        put_type_unsafe_value      ERX          ERX_LEN;
   64        put_type_const             RKX          RKX_LEN;
   65        put_type_structure         RKX          RKX_LEN;
   66        put_type_arrow             RX           RX_LEN;

   67        set_type_variable_t        RX           RX_LEN;
   68        set_type_variable_p        EX           EX_LEN;
   69        set_type_value_t           RX           RX_LEN;
   70        set_type_value_p           EX           EX_LEN;
   71        set_type_local_value_t     RX           RX_LEN;
   72        set_type_local_value_p     EX           EX_LEN;
   73        set_type_constant          KX           KX_LEN;

   74        get_type_variable_t        RRX          RRX_LEN;
   75        get_type_variable_p        ERX          ERX_LEN;
   76        init_type_variable_t       RCEX         RCEX_LEN;
   77        init_type_variable_p       ECEX         ECEX_LEN;
   78        get_type_value_t           RRX          RRX_LEN;
   79        get_type_value_p           ERX          ERX_LEN;
   80        get_type_constant          RKX          RKX_LEN;
   81        get_type_structure         RKX          RKX_LEN;
   82        get_type_arrow             RX           RX_LEN;

   83        unify_type_variable_t      RX           RX_LEN;
   84        unify_type_variable_p      EX           EX_LEN;
   85        unify_type_value_t         RX           RX_LEN;
   86        unify_type_value_p         EX           EX_LEN;
   87        unify_envty_value_t        RX           RX_LEN;
   88        unify_envty_value_p        EX           EX_LEN;
   89        unify_type_local_value_t   RX           RX_LEN;
   90        unify_type_local_value_p   EX           EX_LEN;
   91        unify_envty_local_value_t  RX           RX_LEN;
   92        unify_envty_local_value_p  EX           EX_LEN;
   93        unify_type_constant        KX           KX_LEN;

   /* Instructions for handling higher-order aspects  */

   94        pattern_unify_t            RRX          RRX_LEN;
   95        pattern_unify_p            ERX          ERX_LEN;
   96        finish_unify               X            X_LEN;
   97        head_normalize_t           RX           RX_LEN;
   98        head_normalize_p           EX           EX_LEN;

   /* Instructions for handling logical aspects   */

   99        incr_universe              X            X_LEN;
   100       decr_universe              X            X_LEN;
   101       set_univ_tag               ECX          ECX_LEN;
   102       tag_exists_t               RX           RX_LEN;
   103       tag_exists_p               EX           EX_LEN;
   104       tag_variable               EX           EX_LEN;

   105       push_impl_point            I1ITX        I1ITX_LEN;
   106       pop_impl_point             X            X_LEN;
   107       add_imports                SEGI1LX      SEGI1LX_LEN;
   108       remove_imports             SEGLX        SEGLX_LEN;
   109       push_import                MTX          MTX_LEN;
   110       pop_imports                I1X          I1X_LEN;

   /* Control Instructions  */

   111       allocate                   I1X          I1X_LEN;
   112       deallocate                 X            X_LEN;
   113       call                       I1LX         I1LX_LEN;
   114       call_name                  I1CWPX       I1CWPX_LEN;
   115       execute                    LX           LX_LEN;
   116       execute_name               CWPX         CWPX_LEN;        
   117       proceed                    X            X_LEN;

   /* Choice Instructions  */
   
   118       try_me_else                I1LX         I1LX_LEN;
   119       retry_me_else              I1LX         I1LX_LEN;
   120       trust_me                   I1WPX        I1WPX_LEN;
   121       try                        I1LX         I1LX_LEN;
   122       retry                      I1LX         I1LX_LEN;
   123       trust                      I1LWPX       I1LWPX_LEN;
   124       trust_ext                  I1NX         I1NX_LEN;
   125       try_else                   I1LLX        I1LLX_LEN;
   126       retry_else                 I1LLX        I1LLX_LEN;
   127       branch                     LX           LX_LEN;

   /* Indexing Instructions */

   128       switch_on_term             LLLLX        LLLLX_LEN;
   129       switch_on_constant         I1HTX        I1HTX_LEN;
   130       switch_on_bvar             I1BVTX       I1BVTX_LEN;
   131       switch_on_reg              NLLX         NLLX_LEN;

   /* Cut Instructions  */

   132       neck_cut                   X            X_LEN;
   133       get_level                  EX           EX_LEN;
   134       put_level                  EX           EX_LEN;
   135       cut                        EX           EX_LEN;

   /* Miscellaneous Instructions */
   
   136       call_builtin               I1I1WPX      I1I1WPX_LEN;
   137       builtin                    I1X          I1X_LEN;
   138       stop                       X            X_LEN;
   139       halt                       X            X_LEN;
   140       fail                       X            X_LEN;

   /* new added */
   141       create_type_variable       EX           EX_LEN;
   
   /* resolved by the linker */
   142       execute_link_only          CWPX         CWPX_LEN;     
   143       call_link_only             I1CWPX       I1CWPX_LEN;

   144       put_variable_te            RRX          RRX_LEN