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

📄 jsglobal_h.h

📁 MCS51单片机的宏汇编器源程序
💻 H
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
//-------- JsGlobal_H.h -----------------------------------------------------
//---------------------------------------------------------------------------
#ifndef JsGlobal_H.h
#define JsGlobal_H.h
//---------------------------------------------------------------------------
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
//---------------------------------------------------------------------------

#include "Jtypes_H.h"
//---------------------------------------------------------------------------
#define DebugVer(str)            str

#define WaitEnter                DebugVer(getchar())

#define Waitkey                  DebugVer(getch())
#define Debugkey                 //Waitkey

#define Assertion(str)           DebugVer(str)
#define Assert(str)              Assertion(str)

#define DebugGlob(str)           DebugVer(str)
#define DebugMsg(str)            //DebugGlob(str)

#define ExceptionDetect(str)     DebugVer(str)
#define EThrows(str)             ExceptionDetect(str)
//---------------------------------------------------------------------------



#define MyVersion        "0.12"
//---------------------------------------------------------------------------
#include "Jstring_H.h"
#include "Tokens_H.h"
//---------------------------------------------------------------------------
struct OPset
{ int8u OPnum;         // 保留字编号
  int8  ODmode[3];     // 操作数形式  有三个操作数
  int8u OPobj;         // 操作码目标码,十六进制8位数
  int8  act1;          // 动作1
  int8  act2;          // 动作2
  int8u len;           // 该指令长度
  OPset* next;
}; // end OPset
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
struct ITset
{ int32u key;           // 关键码
   int8u OPobj;         // 操作码目标码,十六进制8位数
    int8 act1;          // 动作1
    int8 act2;          // 动作2
   int8u len;           // 该指令长度
   ITset* next;
}; // end ITset
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#define not3bit(x)     ((x)&~0x07)

#define not4bit(x)     ((x)&~0x0f)

#define not7bit(x)     ((x)&~0x7f)

#define not8bit(x)     ((x)&~0xff)

#define not11bit(x)    ((x)&~0x07ff)

#define not16bit(x)    ((x)&~0xffff)
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void FatalErr(char* msg = "\nFatal error.\n");
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 获取不带后缀名的文件名, 输出Pname返回。
//---------------------------------------------------------------------------
void FetchPname(const char* name, Jstring &Pname);
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 判断token是否为运算符,true=是,false=否。
//---------------------------------------------------------------------------
bool IsOPTR(int16u token);
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 比较两个运算符的优先权。返回'<', '=', '>'。
//---------------------------------------------------------------------------
#define  AlessB     '<'
#define  AequtB     '='
#define  AlargB     '>'
//---------------------------------------------------------------------------
char OPsuperior(int16u t1, int16u t2);
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// p不能为空.
// 返回以p开头的字串中的第一个字符(包括转移字符)的ASCII码.
// 例如: "boy and girls" -> 'b';       "!"" -> '"';
//---------------------------------------------------------------------------
inline char CharStrToint8(const char* p)
{ return (*p != '!') ? (*p) : p[1];
  // 如果是空字串(*p==""),返回NULL.一般情况下,返回ASCII码.
  // If the first char is '!', 原样输出
} // end CharStrToint8
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#define IsInvisibleChar(c)     ( (c)<=' ' || (c)>'~' )
//---------------------------------------------------------------------------
#define IsVisibleChar(c)       ( (c)>' ' && (c)<='~' )
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 把p 指针移至一个可见符上,或者行末。
// 注意,p不能是空(即p!=NULL)。p带值返回。
// 例如:  [   \t  abc   \n]    [   \t  abc   \n]
//         ^                -->        ^
//---------------------------------------------------------------------------
#define MovePoint(p)                                                            \
        { while(*(p) && IsInvisibleChar(*(p)) ) {++(p);} }
//---------------------------------------------------------------------------
// 注意,p不能是空.(即p!=NULL)
// 把p 指针移至一个可见符上,或者行末。
//---------------------------------------------------------------------------
//void MovePoint(const char* &p)
//{ while( *p && ( *p<=' ' || *p>'~' ) ) // 当p不是行末,又不是可见符时,p前移
//   { ++p; }  // end while
//  // Now, p指向文本行中的第一个可见符,或者行末
//} // end MovePoint
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// 以可见符开头,中间夹有字母或数字或'?'、'_'的字符串叫做单词和数。
// 输入一个字符串p。 ( p!= NULL !! ) 重要!
// 如果是单词和数开头,返回一个指向串中第一个单词和数的指针。
// length返回单词长度, behind指向单词后一个字符。
// 不是单词开头,则返回NULL。len=0,behind指向文本行中的第一个可见符或者行末。
// exsample:   [    Hello,  how?  ]
//              ^   ^    ^
//              p   ret  behind     len=5
//---------------------------------------------------------------------------
const char* GetNumWord(const char* p, int16u &len, const char* &behind);
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
class HexcharMap // 字符映射表(从数值到ASCII码转换)
{ public:
    static const char s[17]; // "0123456789ABCDEF";
}; // end HexcharMap
//---------------------------------------------------------------------------
// 从数值到字符的转换。(输入只取低4位。)
// 0~9 -> '0'~'9',    A~H -> 'A'~'H'
//---------------------------------------------------------------------------
inline int8u v2char(int8u v)
{ v &= 0x0f; // 截去高4位,留下低4位。
  return HexcharMap::s[v];
} // end v2char
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// xxxx  ->  "xxxx"      使用了快速转换。
//---------------------------------------------------------------------------
const char* const Int16uToStr(int16u val);
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// Error defination
//---------------------------------------------------------------------------
const ERR LabelUnDefErr   =  3;
const ERR LabelDefNullErr =  4;
const ERR VarDefNullErr   =  5;
const ERR ParaNameDefErr  =  6;
const ERR UndefWordErr    =  7;
const ERR EQUDefNullErr   =  8;
const ERR SETDefNullErr   =  9;
const ERR BITDefNullErr   = 10;
const ERR InstNeededErr   = 11;
const ERR ArguInsufErr    = 12;
const ERR ArguExcevErr    = 13;

⌨️ 快捷键说明

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