/*     
      BYTE CODE INTERPRETER . Magma 1.0 . 1996 . Sylvain HUET

      mbytec2.c : fonctions de base
*/
// Modification history:
//$ FA(26/03/2001): Functions that directly refer to pc are moved and inlined
//                  inside switch of interpreter loop
//$ FA(27/03/2001): The remaining functions commented out in mbytec2.h were moved
//                  inside interpreter loop and optimised


#include "mmemory.h"


int MBdup(mmachine m)
// Referenced from typmisc.c
{
  if (MMpush(m,m->top[m->pp])) return MERRMEM;
  return 0;
}


int MBdeftab(mmachine m)
// Referenced from many files
{
  int j,n,p;

  n=m->top[m->pp];
  if (n==NIL) return 0;
  n>>=1;
  p=MMmalloc(m,n,TYPETAB);
  if (p==NIL) return MERRMEM;
  for(j=0;j<n;j++)
    m->tape[p+SizeHeader+n-1-j]=m->top[m->pp+1+j]; /* copie les valeurs dans le tableau */
  m->pp+=n;
  m->top[m->pp]=p+p+1;
  return 0;
}

