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

📄 nasm.h

📁 Fenris是一个检测并把高层次的语言结构做成文档的多功能故障检测器、调试器、代码分析工具。它能回复符号
💻 H
📖 第 1 页 / 共 3 页
字号:
#define EXPR_SEGBASE 128L/* * Preprocessors ought to look like this: */typedef struct {    /*     * Called at the start of a pass; given a file name, the number     * of the pass, an error reporting function, an evaluator     * function, and a listing generator to talk to.     */    void (*reset) (char *, int, efunc, evalfunc, ListGen *);    /*     * Called to fetch a line of preprocessed source. The line     * returned has been malloc'ed, and so should be freed after     * use.     */    char *(*getline) (void);    /*     * Called at the end of a pass.     */    void (*cleanup) (int);} Preproc;/* * ---------------------------------------------------------------- * Some lexical properties of the NASM source language, included * here because they are shared between the parser and preprocessor * ---------------------------------------------------------------- *//* * isidstart matches any character that may start an identifier, and isidchar * matches any character that may appear at places other than the start of an * identifier. E.g. a period may only appear at the start of an identifier * (for local labels), whereas a number may appear anywhere *but* at the * start.  */#define isidstart(c) ( isalpha(c) || (c)=='_' || (c)=='.' || (c)=='?' \                                  || (c)=='@' )#define isidchar(c)  ( isidstart(c) || isdigit(c) || (c)=='$' || (c)=='#' \                                                  || (c)=='~' )/* Ditto for numeric constants. */#define isnumstart(c)  ( isdigit(c) || (c)=='$' )#define isnumchar(c)   ( isalnum(c) )/* This returns the numeric value of a given 'digit'. */#define numvalue(c)  ((c)>='a' ? (c)-'a'+10 : (c)>='A' ? (c)-'A'+10 : (c)-'0')/* * Data-type flags that get passed to listing-file routines. */enum {    LIST_READ, LIST_MACRO, LIST_MACRO_NOLIST, LIST_INCLUDE,    LIST_INCBIN, LIST_TIMES};/* * ----------------------------------------------------------- * Format of the `insn' structure returned from `parser.c' and * passed into `assemble.c' * ----------------------------------------------------------- *//* * Here we define the operand types. These are implemented as bit * masks, since some are subsets of others; e.g. AX in a MOV * instruction is a special operand type, whereas AX in other * contexts is just another 16-bit register. (Also, consider CL in * shift instructions, DX in OUT, etc.) *//* size, and other attributes, of the operand */#define BITS8     0x00000001L#define BITS16    0x00000002L#define BITS32    0x00000004L#define BITS64    0x00000008L	       /* FPU only */#define BITS80    0x00000010L	       /* FPU only */#define FAR       0x00000020L	       /* grotty: this means 16:16 or */				       /* 16:32, like in CALL/JMP */#define NEAR      0x00000040L#define SHORT     0x00000080L	       /* and this means what it says :) */#define SIZE_MASK 0x000000FFL	       /* all the size attributes */#define NON_SIZE  (~SIZE_MASK)#define TO        0x00000100L          /* reverse effect in FADD, FSUB &c */#define COLON     0x00000200L	       /* operand is followed by a colon *//* type of operand: memory reference, register, etc. */#define MEMORY    0x00204000L#define REGISTER  0x00001000L	       /* register number in 'basereg' */#define IMMEDIATE 0x00002000L#define REGMEM    0x00200000L	       /* for r/m, ie EA, operands */#define REGNORM   0x00201000L	       /* 'normal' reg, qualifies as EA */#define REG8      0x00201001L#define REG16     0x00201002L#define REG32     0x00201004L#define MMXREG    0x00201008L	       /* MMX registers */#define XMMREG    0x00201010L          /* XMM Katmai reg */#define FPUREG    0x01000000L	       /* floating point stack registers */#define FPU0      0x01000800L	       /* FPU stack register zero *//* special register operands: these may be treated differently */#define REG_SMASK 0x00070000L	       /* a mask for the following */#define REG_ACCUM 0x00211000L	       /* accumulator: AL, AX or EAX */#define REG_AL    0x00211001L	       /* REG_ACCUM | BITSxx */#define REG_AX    0x00211002L	       /* ditto */#define REG_EAX   0x00211004L	       /* and again */#define REG_COUNT 0x00221000L	       /* counter: CL, CX or ECX */#define REG_CL    0x00221001L	       /* REG_COUNT | BITSxx */#define REG_CX    0x00221002L	       /* ditto */#define REG_ECX   0x00221004L	       /* another one */#define REG_DX    0x00241002L#define REG_SREG  0x00081002L	       /* any segment register */#define REG_CS    0x01081002L	       /* CS */#define REG_DESS  0x02081002L	       /* DS, ES, SS (non-CS 86 registers) */#define REG_FSGS  0x04081002L	       /* FS, GS (386 extended registers) */#define REG_CDT   0x00101004L	       /* CRn, DRn and TRn */#define REG_CREG  0x08101004L	       /* CRn */#define REG_CR4   0x08101404L	       /* CR4 (Pentium only) */#define REG_DREG  0x10101004L	       /* DRn */#define REG_TREG  0x20101004L	       /* TRn *//* special type of EA */#define MEM_OFFS  0x00604000L	       /* simple [address] offset *//* special type of immediate operand */#define ONENESS   0x00800000L          /* so UNITY == IMMEDIATE | ONENESS */#define UNITY     0x00802000L	       /* for shift/rotate instructions */#define BYTENESS  0x40000000L          /* so SBYTE == IMMEDIATE | BYTENESS */#define SBYTE 	  0x40002000L	       /* for op r16/32,immediate instrs. */		/* * Next, the codes returned from the parser, for registers and * instructions. */enum {				       /* register names */    R_AH = EXPR_REG_START, R_AL, R_AX, R_BH, R_BL, R_BP, R_BX, R_CH,    R_CL, R_CR0, R_CR2, R_CR3, R_CR4, R_CS, R_CX, R_DH, R_DI, R_DL,    R_DR0, R_DR1, R_DR2, R_DR3, R_DR6, R_DR7, R_DS, R_DX, R_EAX,    R_EBP, R_EBX, R_ECX, R_EDI, R_EDX, R_ES, R_ESI, R_ESP, R_FS,    R_GS, R_MM0, R_MM1, R_MM2, R_MM3, R_MM4, R_MM5, R_MM6, R_MM7,    R_SI, R_SP, R_SS, R_ST0, R_ST1, R_ST2, R_ST3, R_ST4, R_ST5,    R_ST6, R_ST7, R_TR3, R_TR4, R_TR5, R_TR6, R_TR7,    R_XMM0, R_XMM1, R_XMM2, R_XMM3, R_XMM4, R_XMM5, R_XMM6, R_XMM7, REG_ENUM_LIMIT};/* Instruction names automatically generated from insns.dat */#include "insnsi.h"/* max length of any instruction, register name etc. */#if MAX_INSLEN > 9#define MAX_KEYWORD MAX_INSLEN#else#define MAX_KEYWORD 9#endifenum {				       /* condition code names */    C_A, C_AE, C_B, C_BE, C_C, C_E, C_G, C_GE, C_L, C_LE, C_NA, C_NAE,    C_NB, C_NBE, C_NC, C_NE, C_NG, C_NGE, C_NL, C_NLE, C_NO, C_NP,    C_NS, C_NZ, C_O, C_P, C_PE, C_PO, C_S, C_Z};/* * Note that because segment registers may be used as instruction * prefixes, we must ensure the enumerations for prefixes and * register names do not overlap. */enum {				       /* instruction prefixes */    PREFIX_ENUM_START = REG_ENUM_LIMIT,    P_A16 = PREFIX_ENUM_START, P_A32, P_LOCK, P_O16, P_O32, P_REP, P_REPE,    P_REPNE, P_REPNZ, P_REPZ, P_TIMES};enum {				       /* extended operand types */    EOT_NOTHING, EOT_DB_STRING, EOT_DB_NUMBER};enum {				       /* special EA flags */    EAF_BYTEOFFS = 1,		       /* force offset part to byte size */    EAF_WORDOFFS = 2,		       /* force offset part to [d]word size */    EAF_TIMESTWO = 4		       /* really do EAX*2 not EAX+EAX */};enum {				       /* values for `hinttype' */    EAH_NOHINT = 0,		       /* no hint at all - our discretion */    EAH_MAKEBASE = 1,		       /* try to make given reg the base */    EAH_NOTBASE = 2		       /* try _not_ to make reg the base */};typedef struct {		       /* operand to an instruction */    long type;			       /* type of operand */    int addr_size;		       /* 0 means default; 16; 32 */    int basereg, indexreg, scale;      /* registers and scale involved */    int hintbase, hinttype;	       /* hint as to real base register */    long segment;		       /* immediate segment, if needed */    long offset;		       /* any immediate number */    long wrt;			       /* segment base it's relative to */    int eaflags;		       /* special EA flags */    int opflags;		       /* see OPFLAG_* defines below */} operand;#define OPFLAG_FORWARD		1      /* operand is a forward reference */#define OPFLAG_EXTERN		2      /* operand is an external reference */typedef struct extop {		       /* extended operand */    struct extop *next;		       /* linked list */    long type;			       /* defined above */    char *stringval;		       /* if it's a string, then here it is */    int stringlen;		       /* ... and here's how long it is */    long segment;		       /* if it's a number/address, then... */    long offset;		       /* ... it's given here ... */    long wrt;			       /* ... and here */} extop;#define MAXPREFIX 4typedef struct {		       /* an instruction itself */    char *label;		       /* the label defined, or NULL */    int prefixes[MAXPREFIX];	       /* instruction prefixes, if any */    int nprefix;		       /* number of entries in above */    int opcode;			       /* the opcode - not just the string */    int condition;		       /* the condition code, if Jcc/SETcc */    int operands;		       /* how many operands? 0-3                                         * (more if db et al) */    operand oprs[3];	   	       /* the operands, defined as above */    extop *eops;		       /* extended operands */    int eops_float;                    /* true if DD and floating */    long times;			       /* repeat count (TIMES prefix) */    int forw_ref;		       /* is there a forward reference? */} insn;enum geninfo { GI_SWITCH };/* * ------------------------------------------------------------ * The data structure defining an output format driver, and the * interfaces to the functions therein. * ------------------------------------------------------------ */struct ofmt {    /*     * This is a short (one-liner) description of the type of     * output generated by the driver.     */    char *fullname;    /*     * This is a single keyword used to select the driver.     */    char *shortname;    /*     * this is reserved for out module specific help.     * It is set to NULL in all the out modules but is not implemented     * in the main program     */    char *helpstring;    /*     * this is a pointer to the first element of the debug information     */    struct dfmt **debug_formats;    /*     * and a pointer to the element that is being used     * note: this is set to the default at compile time and changed if the     * -F option is selected.  If developing a set of new debug formats for     * an output format, be sure to set this to whatever default you want     *     */    struct dfmt *current_dfmt;    /*     * This, if non-NULL, is a NULL-terminated list of `char *'s     * pointing to extra standard macros supplied by the object     * format (e.g. a sensible initial default value of __SECT__,     * and user-level equivalents for any format-specific     * directives).     */    char **stdmac;

⌨️ 快捷键说明

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