📄 defs.h
字号:
/* File defs.h: 2.2 */
#define FALSE 0
#define TRUE 1
#define NO 0
#define YES 1
#define byte unsigned char
/* miscellaneous */
#define EOS 0
#define EOL 10
#define BKSP 8
#define CR 13
#define FFEED 12
#define TAB 9
/* system-wide name size (for symbols) */
#define NAMESIZE 40
#define NAMEMAX NAMESIZE-1
#define REGBASE 15 // first register allocated
#define REGS 14 // r15 thru r2. These are allocated
// from r15 downwards.
//***********************************************************
// symbol table parameters
#define NUMGLOBALS 1000 // total global entries
#define NUMLOCALS 50 // total local entries
#define PRE_NUMGLOBALS 17 // pre sn globals
#define PRE_NUMLOCALS 4 // pre sn locals
#define SYMTBSZ NUMGLOBALS+NUMLOCALS
#define STARTGLB 0
#define STARTLOC ENDGLB+1
#define ENDGLB NUMGLOBALS
#define ENDLOC ENDGLB+NUMLOCALS-1
#define PRE_ENDGLB PRE_NUMGLOBALS
#define PRE_ENDLOC ENDGLB+PRE_NUMLOCALS-1
typedef struct m_argtyp {
int ident;
int type;
} ARGTYPE;
struct s_symtab {
char name[NAMESIZE];
int ident;
int type;
int storage;
int offset;
int pntrpntr;
};
typedef struct m_symtab {
char name[NAMESIZE];
int ident;
int type;
int storage;
int funcpar; // item is a function parameter
int offset;
int used;
int pntrpntr; // currently pointing to a pointer
int PerEntry; // bytes per structure entry
char TypeDefName[NAMESIZE];
int reg; // register number
int regs[16]; // array of register numbers owned by a function
int label; // variable points to this global label
int args; // No. of arguments for function &
// pointer to the function entry for funcptr
ARGTYPE argtype[10];
struct s_symtab entry[10];
} SYMTAB;
// possible entries for "ident"
#define VARIABLE 1
#define ARRAY 2
#define POINTER 3
#define FUNCTION 4
#define FUNCDEF 5 // function definition
#define FUNCPTR 6 // function pointer
#define STRUCT 7
#define STRUCTPTR 8
#define FUNCPTRARR 9 // array of function pointers
#define POINTERARRAY 10 // array of pointers
// possible entries for "type"
#define CCHAR 1
#define CINT 2
#define VOID 3
#define CLONG 4
#define STRUCTDEF 5 // structure definition
#define STRUCTINST 6 // structure instance
#define CSTRUCT 7 // structure pointer
#define CFLOAT 8 // 4 byte floating point
#define UCCHAR 9 // unsigned char
#define UCINT 10 // unsigned int
#define TYPEDEF 11
// possible entries for "storage"
#define PUBLIC 1
#define AUTO 2
#define EXTERN 3
#define STATIC 4
#define LSTATIC 5
#define DEFAUTO 6
#define REGISTER 7 // register value
#define INTERRUPT 8
#define ROM 9 // storec in eeprom
// <reg> can have a register number in bits 6-0, and a CONSTANT
// flag in bit 7.
#define CONSTANT 0x80 // flags variable as constant pointer
//***********************************************************
typedef struct m_tmpsym {
int ident; // identity of object
int type; // type of object
int pointing; // true if pointing
int offset; // offset of a structure
int storage; // local, external, global, etc
int funcpar; // item is a function parameter
int cast; // destination cast type, if any
int ptr; // symbol table address, else 0 for constant
int index; // index to entry array in symtab
} STATE;
typedef struct t_stack {
char name[NAMESIZE];
int type;
int storage;
} STACK;
/* "do"/"for"/"while"/"switch" statement stack */
#define WSTABSZ 100
#define WSSIZ 7
#define WSMAX ws+WSTABSZ-WSSIZ
/* entry offsets in "do"/"for"/"while"/"switch" stack */
#define WSSYM 0
#define WSSP 1
#define WSTYP 2
#define WSCASEP 3
#define WSTEST 3
#define WSINCR 4
#define WSDEF 4
#define WSBODY 5
#define WSTAB 5
#define WSEXIT 6
/* possible entries for "wstyp" */
#define WSWHILE 0
#define WSFOR 1
#define WSDO 2
#define WSSWITCH 3
/* "switch" label stack */
#define SWSTSZ 100
/* literal pool */
#define LITABSZ 2000
#define LITMAX LITABSZ-1
/* input line */
#define LINESIZE 250
#define LINEMAX (LINESIZE-1)
#define MPMAX LINEMAX
/* macro (define) pool */
#define MACQSIZE 10000
#define MACMAX (MACQSIZE-1)
// Global constants queue
#define GLOBSIZE 1000
#define GLOBCHAR 1
#define GLOBBYTE 2
#define GLOBINT 3
#define GLOBLONG 4
typedef struct t_glob {
char name[NAMESIZE];
int type;
char *pp;
} GLOBAL;
/* "include" stack */
#define INCLSIZ 3
/* statement types (tokens) */
#define STIF 1
#define STWHILE 2
#define STRETURN 3
#define STBREAK 4
#define STCONT 5
#define STASM 6
#define STEXP 7
#define STDO 8
#define STFOR 9
#define STSWITCH 10
// Added by RK
#define LABELCOUNTMAX 1000 // max number of labels
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -