?? RIGHT := 110 ??

{--------------------------------------------------------------------------------------------------------
{Name:
{    mmp$ast_index
{Purpose:
{These functions convert AST indexes into an ASID and vise-versa.
{Input:
{    AST_index or ASID
{Output:
{    asid or ast_index
{--------------------------------------------------------------------------------------------------------

  VAR
    bits: array [0 .. 15] of 0 .. 255 := [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15];

  PROCEDURE [INLINE] mmp$asti
    (    xasid: ost$asid;
     VAR xasti: mmt$ast_index);

    VAR
      asid_16: mmt$ast_index,
      asid_256: mmt$ast_index,
      asid_4096: mmt$ast_index,
      asid: ost$asid;

    asid := xasid;
    asid := asid DIV mmv$a_mult + (asid MOD mmv$a_mult) * mmv$a_divisor;

    asid_16 := asid DIV 16;
    asid_16 := asid_16 MOD 16;

    asid_256 := asid DIV 256;
    asid_256 := asid_256 MOD 16;

    asid_4096 := asid DIV 4096;
    asid_4096 := asid_4096 MOD 16;

    xasti := (bits [asid MOD 16] * 4096) + (bits [asid_16] * 256) + (bits [asid_256] * 16) + bits [asid_4096];

  PROCEND mmp$asti;


  PROCEDURE [INLINE] mmp$asid
    (    xasti: mmt$ast_index;
     VAR x_asid: ost$asid);

    VAR
      asti: mmt$ast_index,
      asti_16: mmt$ast_index,
      asti_256: mmt$ast_index,
      asti_4096: mmt$ast_index,
      asid: integer;

    asti := xasti;
    asti_16 := asti DIV 16;
    asti_16 := asti_16 MOD 16;

    asti_256 := asti DIV 256;
    asti_256 := asti_256 MOD 16;

    asti_4096 := asti DIV 4096;
    asti_4096 := asti_4096 MOD 16;

    asid := (bits [asti MOD 16] * 4096) + (bits [asti_16] * 256) + (bits [asti_256] * 16) + bits [asti_4096];
    asid := asid DIV mmv$a_divisor + (asid MOD mmv$a_divisor) * mmv$a_mult;
    x_asid := asid;

  PROCEND mmp$asid;
