Annotation of coherent/b/bin/as/asm.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * 80386 assembler header.
        !             3:  */
        !             4: #include <stdio.h>
        !             5: 
        !             6: #define new(s) ((s *)alloc(sizeof(s)))
        !             7: #define gnew(s) ((s *)galloc(sizeof(s)))
        !             8: #define clear(x) memset((char *)(x), 0, sizeof(*(x)))
        !             9: #define offset(st, memb) ((unsigned)(((st *)0)->memb))
        !            10: 
        !            11: typedef struct expr expr;      /* generated address stuff */
        !            12: typedef struct inpctl inpctl;  /* include level of control */
        !            13: typedef struct macctl macctl;  /* macro level of control */
        !            14: typedef struct macline macline;        /* a macro line */
        !            15: typedef struct macro macro;    /* macro symbol */
        !            16: typedef struct opc opc;                /* opcode symbol entry */
        !            17: typedef struct parm parm;      /* a parameter on a control line */
        !            18: typedef struct data data;      /* data block for dc.w dc.d etc */
        !            19: typedef struct sym sym;                /* allocated  symbol table entry */
        !            20: typedef struct symt  symt;     /* opcode table entry */
        !            21: typedef struct nhash nhash;    /* hash table entry */
        !            22: typedef struct psym psym;      /* predefined symbol table entry */
        !            23: typedef struct symdef symdef;  /* defined in c_out.c uses SYMENT & AUXENT */
        !            24: 
        !            25: struct expr {  /* generated 80386 address stuff */
        !            26:        expr *next;
        !            27:        char mode;      /* mode byte */
        !            28:        long exp;       /* displacment */
        !            29:        short sg;       /* segment override */
        !            30:        psym *r1;       /* first register */
        !            31:        psym *r2;       /* second register */
        !            32:        char scale;     /* scaling factor */
        !            33:        long size;      /* size of target */
        !            34:        sym     *ref;   /* pointer to associated symbol */
        !            35: };
        !            36: 
        !            37: #define T_IMM  1       /* $ immediate */
        !            38: #define T_R    2       /* reg */
        !            39: #define T_RI   3       /* ( reg ) */
        !            40: #define T_RID  4       /* disp ( reg ) */
        !            41: #define T_RIX  5       /* ( reg, reg ) */
        !            42: #define T_RIXD  6      /* disp ( reg, reg ) */
        !            43: #define T_RIS  7       /* ( reg, scale ) */
        !            44: #define T_RIDS 8       /* disp ( reg, scale ) */
        !            45: #define T_RIXS  9      /* ( reg , reg, scale ) */
        !            46: #define T_RIXDS 10     /* disp ( reg , reg, scale ) */
        !            47: #define T_D    11      /* displacment */
        !            48: #define T_FP   12      /* %st( n ) */
        !            49: 
        !            50: struct opc {   /* slice in pref tab */
        !            51:        short code;     /* opcode */
        !            52:        short kind;     /* index to symt table */
        !            53: };
        !            54: 
        !            55: struct symt {  /* Opcode symbol type. */
        !            56:        unsigned short type;            /* yacc type */
        !            57:        unsigned short bldr;            /* code for builder */
        !            58:        unsigned char operands;         /* operands for this kind of symbol */
        !            59:        unsigned char ap[3];            /* operand types */
        !            60: };
        !            61: 
        !            62: struct nhash { /* name hash entry */
        !            63:        short next;                     /* index to next symbol same hash */
        !            64:        short nameIx;                   /* index into charLump */
        !            65:        char  nlen;                     /* length of name */
        !            66:        char  count;                    /* match count in prefTab */
        !            67:        short prefIx;                   /* index into prefTab */
        !            68: };
        !            69: 
        !            70: struct psym {  /* predefined symbol table entry */
        !            71:        psym    *next;                  /* same symbol with same hash */
        !            72:        short   type;                   /* yacc type or coff debug type */
        !            73:        long    loc;                    /* location of coff debug value */
        !            74:        long    size;                   /* length */
        !            75:        short   sg;                     /* segment plus 1 */
        !            76:        short   flag;                   /* flag bits */
        !            77:        sym     *ref;                   /* base copy of this symbol on symtab */
        !            78:        short   num;                    /* symbol number for relocation */
        !            79:        int     statement;              /* statement no of definition */
        !            80:        char    *name;                  /* symbol name */
        !            81: };
        !            82: 
        !            83: struct sym {   /* allocated symbol table entry */
        !            84:        psym    *next;                  /* same symbol with same hash */
        !            85:        short   type;                   /* yacc type */
        !            86:        long    loc;                    /* location */
        !            87:        long    size;                   /* length */
        !            88:        short   sg;                     /* segment plus 1 */
        !            89:        short   flag;                   /* flag bits */
        !            90:        sym     *ref;                   /* base copy of this symbol on symtab */
        !            91:        short   num;                    /* symbol number for relocation */
        !            92:        int     statement;              /* statement no of definition */
        !            93:        char    name[1];                /* symbol name */
        !            94: };
        !            95: 
        !            96: /* Register flags */
        !            97: #define ORD_REG        0
        !            98: #define        SEG_REG 0x0800
        !            99: #define CTL_REG        0x0400
        !           100: #define DEB_REG        0x0200
        !           101: #define TST_REG        0x0100
        !           102: 
        !           103: #define BAD    1               /* Bad exit() code */
        !           104: #define        NCPLN   16              /* max external symbol length */
        !           105: #define NINPUT 256             /* Input line size */
        !           106: 
        !           107: /* Listing */
        !           108: #define NLIST  0               /* No listing */
        !           109: #define SLIST  1               /* Source only */
        !           110: #define ALIST  2               /* Address only */
        !           111: #define        BLIST   3               /* Byte listing */
        !           112: 
        !           113: #define        dot     (symtab[0])     /* Dot, current loc */
        !           114: 
        !           115: /* symbol type flags */
        !           116: #define S_EXDEF 0x01   /* defined here visable elsewhere */
        !           117: #define S_LOCAL 0x02   /* defined here */
        !           118: #define S_EXREF 0x04   /* defined elsewhere visable here */
        !           119: #define S_UNDEF 0x08   /* unidentified so far */
        !           120: #define S_DUPSYM 0x10  /* duplicate symbol */
        !           121: #define S_XSYM  0x20   /* non identifier */
        !           122: #define S_USED  0x40   /* symbol used */
        !           123: #define S_COMMON 0x80  /* common symbol */
        !           124: 
        !           125: #define S_ASYM 0x3F    /* allocated symbol */
        !           126: 
        !           127: #define SYMNAME(sp) ((sp->flag&S_ASYM) ? ((sym *)sp)->name : ((psym *)sp)->name)
        !           128: 
        !           129: struct parm {  /* a parameter on a control line */
        !           130:        parm *next;     /* next parm on line */
        !           131:        char str[1];
        !           132: };
        !           133: 
        !           134: struct macline {        /* a macro line */
        !           135:        macline *next;
        !           136:        char line[1];   /* data of indefinate length */
        !           137: };
        !           138: 
        !           139: struct macro { /* macro symbol */
        !           140:        macro   *next;  /* macro's searched sequentially */
        !           141:        unsigned short type;    /* same position as sym type */
        !           142:        macline *first; /* first line of macro */
        !           143:        parm    *names; /* names of macro parms */
        !           144:        char name[1];   /* name of macro */
        !           145: };
        !           146: 
        !           147: #define WHILETYPE 0    /* while loop */
        !           148: #define MACTYPE 1      /* macro */
        !           149: #define MACSTR  2      /* string */
        !           150: #define MACSCAN 3      /* string being scaned */
        !           151: 
        !           152: struct macctl {         /* macro level of control */
        !           153:        macctl  *prev;  /* previous level of control */
        !           154:        unsigned short type; /* do mac while etc */
        !           155:        parm    *parms; /* macro parm list */
        !           156:        parm    *names; /* macro parm names */
        !           157:        macline *first; /* where it started for do else etc */
        !           158:        macline *curr;  /* this macro line */
        !           159:        short   expno;  /* this macro expansion number */
        !           160: };
        !           161: 
        !           162: /* macctl types */
        !           163: #define INMACDEF 1     /* in macro definition */
        !           164: #define INWDEF  2      /* finding limits of a while */
        !           165: #define INPWDEF         3      /* defining while internal to another while or mac */
        !           166: #define PMACDEF  4     /* macro definition inside macro definition */
        !           167: #define INIF0   5      /* in unsuccesfull if */
        !           168: #define INIFX   6      /* if in unsuccessfull if */
        !           169: #define INIF1   7      /* in successfull if */
        !           170: #define INWHILE         8      /* in successfull while */
        !           171: #define NORMAL  9      /* base mode */
        !           172: 
        !           173: struct inpctl {                /* include level of control */
        !           174:        inpctl *prev;           /* previous file */
        !           175:        FILE   *fp;             /* File ptr */
        !           176:        short   lineNo;         /* current line number */
        !           177:        char    name[1];        /* file name */
        !           178: };
        !           179: 
        !           180: struct data {  /* misc data item */
        !           181:        data *next;
        !           182:        unsigned short type;    /* 'd', 'l', 'y', 's' */
        !           183:        unsigned short count;   /* repeat count */
        !           184:        union d {
        !           185:                double  d;      /* double data */
        !           186:                long    l;      /* long data */
        !           187:                sym     *y;     /* pointer to original symbol */
        !           188:                char    *s;     /* pointer to string */
        !           189:        } d;
        !           190: };
        !           191: 
        !           192: /* bits for lflags */
        !           193: #define A_SHORT 1      /* Uses short address */
        !           194: #define A_LONG  2      /* Uses long address */
        !           195: #define O_SHORT 4      /* Uses short operand */
        !           196: #define O_LONG  8      /* Uses long operand */
        !           197: #define A_INDIR 16     /* Uses indirect operand */
        !           198: 
        !           199: /*
        !           200:  * Some opcodes need to be known outside the tables.
        !           201:  * the following defines at least give them names.
        !           202:  */
        !           203: #define PREFIX_OP 0x66 /* Operand size prefix */
        !           204: #define PREFIX_AD 0x67 /* Address mode prefix */
        !           205: #define PREFIX_ES 0x26 /* Use %es: */
        !           206: #define PREFIX_CS 0x2e /* Use %cs: */
        !           207: #define PREFIX_SS 0x36 /* Use %ss: */
        !           208: #define PREFIX_DS 0x3e /* Use %ds: */
        !           209: #define PREFIX_FS 0x64 /* Use %ds: */
        !           210: #define PREFIX_GS 0x65 /* Use %ds: */
        !           211: 
        !           212: #define JMP_SHORT 0xEB 
        !           213: #define JMP_NEAR  0xE9
        !           214: #define JMP_INDIR 0xFF04
        !           215: #define CALL_NEAR 0xE8
        !           216: #define CALL_INDIR 0xFF02
        !           217: #define JCC_SHORT 0x70
        !           218: #define JCC_NEAR  0x0F80
        !           219: 
        !           220: #define MOV_BYTE  0xC6 /* Ambigous move op code */
        !           221: #define INSB     0x6C
        !           222: #define INSW     0x6D
        !           223: #define NOP      0x90
        !           224: #define POPA     0x61
        !           225: #define AAM      ((unsigned short)0xD40A)
        !           226: #define POP_MEM          ((unsigned short)0x8F00)
        !           227: #define NON_OP   ((unsigned short)0x0201)      /* not an op code */
        !           228: #include "asme.h"

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.