⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 instsystem_h.h

📁 MCS51单片机的宏汇编器源程序。有需要的朋友请下载!
💻 H
字号:
//---------------------------------------------------------------------------
//-------- InstSystem_H.h ---------------------------------------------------
//---------------------------------------------------------------------------
#ifndef	InstSystem_H.h  // 防止被重复引用
#define InstSystem_H.h
//---------------------------------------------------------------------------

#include "Tokens_H.h"
#include "Tokenfield_H.h"
#include "JsGlobal_H.h"

//---------------------------------------------------------------------------
// 保留字Token转换表的三元组结构
//---------------------------------------------------------------------------
struct Resvs
{ const char* name;
  int16u  tken;
  int16u  typ;
  Resvs*  next;
}; // end Resvs
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 指令系统类
//---------------------------------------------------------------------------
class InstSystem : public JObject
{ private:
    static Resvs* hashTbl[256];  // 保留字 Hash Table
    static Resvs  InstSET[182];  // 组装元件: 保留字集

    static ITset* OPhash[256];   // 指令格式 Hash Table
    static OPset  OPlist[334];   // 指令集,指令格式

  // --------- private functions ------------

    static  int8u GetHashNo(const char* name);

    static   void insert(int8u no, Resvs* pt);

    static  int8u GetEntryNo(int8u OP, int8u OD1, int8u OD2);

    static   void OPinsert(int8u no, ITset* pt);

  // ----------------------------------------

  public:

     InstSystem();  // constructor


    static  const int8 InstArgus[0x2d]; // 参数个数表

  // --------- public functions -------------

    static int16u InsRecg(const char* word, int16u &val, bool dog = false);

    static   int8 InstArgvSum(register int16u tok);

    static  const char* TokenToName(register int16u Token);

    static int32u PackToKey(int8u OP,int8 OD1=-1,int8 OD2=-1,int8 OD3=-1);

    static OPset* OPsetRecg(int8u OP,int8 OD1=-1,int8 OD2=-1,int8 OD3=-1);

    static OPset* OpSJMP()             { return &OPlist[0]; } // SJMP label  0
    static OPset* OpAJMP()             { return &OPlist[1]; } // AJMP  H3L8  1
    static OPset* OpLJMP()             { return &OPlist[3]; } // LJMP  H8L8  3
    static OPset* OpACALL()            { return &OPlist[5]; } // ACALL H3L8  5
    static OPset* OpLCALL()            { return &OPlist[7]; } // LCALL H8L8  7

  // ------- Debug functions --------
    void show()const;

}; // end InstSystem
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// 哈希公式!    count=[316]
//---------------------------------------------------------------------------
inline int8u InstSystem::GetHashNo(const char* name)
{ register int8u len = strlen(name);
  register int8u hi = name[len-1];
  hi <<= 2;
  hi  += name[1] + len;
  hi <<= 2;
  hi  += *name;
  return hi;
} // end GetHashNo
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// 哈希公式    count=[619]
//---------------------------------------------------------------------------
inline int8u InstSystem::GetEntryNo(int8u OP, int8u OD1, int8u OD2)
{ register int8u no = (OD1 << 2);
  no += (OD2 & 0x0f);
  no <<= 2;
  no += (OP & 0x1f);
  return no;
} // end GetEntryNo
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// 每次从链头插入
//---------------------------------------------------------------------------
inline void InstSystem::insert(int8u no, Resvs* pt)
{ pt->next = hashTbl[no];
  hashTbl[no] = pt;
} // end insert
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
inline int32u InstSystem::PackToKey(int8u OP, int8 OD1, int8 OD2, int8 OD3)
{ pool_32 pod;
  pod.pot8[0] = OP;
  pod.pot8[1] = OD1;
  pod.pot8[2] = OD2;
  pod.pot8[3] = OD3;
  return pod.pot32;
} // end PackToKey
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// 每次从链头插入
//---------------------------------------------------------------------------
inline void InstSystem::OPinsert(int8u no, ITset* pt)
{ pt->next = OPhash[no];
  OPhash[no] = pt;
} // end OPinsert
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
//               Written by JamesyFront.    ZLGmcu Dev.Co.Ltd.  2002.
//---------------------------------------------------------------------------


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -