|
|
1.1 ! root 1: /* @(#)as.h 1.1 86/02/03 SMI */ ! 2: ! 3: /* ! 4: * Copyright (c) 1985 by Sun Microsystems, Inc. ! 5: */ ! 6: ! 7: ! 8: #include <stdio.h> ! 9: ! 10: /* Assembler parameters */ ! 11: #define FILES_MAX 10 /* Max number of source files read */ ! 12: #define STR_MAX 512 /* Max length of file names */ ! 13: #define OPERANDS_MAX 16 /* number of operands allowed per instruction */ ! 14: #define HASH_MAX 256 /* size of symbol, command, and macro hash tables */ ! 15: #define CODE_MAX 12 /* number of bytes generated for 1 machine instruction */ ! 16: ! 17: #include "error.h" ! 18: ! 19: /* Symbol attributes */ ! 20: #define S_DEC 01 ! 21: #define S_DEF 02 ! 22: #define S_EXT 04 ! 23: #define S_LABEL 010 ! 24: #define S_CRT 020 ! 25: #define S_REG 040 ! 26: #define S_LOCAL 0100 ! 27: #define S_COMM 0200 ! 28: #define S_PERM 0400 ! 29: ! 30: #include "inst.h" ! 31: ! 32: #include "oper.h" ! 33: ! 34: /* local names for csects */ ! 35: #define C_UNDEF 0 ! 36: #define C_TEXT 1 ! 37: #define C_DATA 2 ! 38: #define C_DATA1 3 ! 39: #define C_DATA2 4 ! 40: #define C_BSS 5 ! 41: ! 42: /* Symbol bucket definition */ ! 43: struct sym_bkt { ! 44: char *name_s; /* symbol identifier */ ! 45: struct sym_bkt *next_s; /* next bkt on linked list */ ! 46: long value_s; /* it's value */ ! 47: #if AS ! 48: short id_s; /* id number for .b file */ ! 49: int final; /* ? */ ! 50: #endif ! 51: #if C2 ! 52: char builtin_s[4]; /* read-write attributes for D0,D1,A0,A1 */ ! 53: #endif ! 54: short attr_s; /* attributes */ ! 55: short csect_s; /* name of its csect */ ! 56: short nuse_s; /* number of references */ ! 57: struct node *where_s; /* first use, or defining node */ ! 58: }; ! 59: ! 60: extern char *soperand(),*exp(); ! 61: extern char iline[],code[]; ! 62: extern short cinfo[]; ! 63: extern int numops, errors, line_no; ! 64: extern struct oper operands[]; ! 65: extern struct ins_ptr *ins_hash_tab[]; ! 66: extern struct sym_bkt *lookup(); ! 67: extern struct sym_bkt *last_symbol; ! 68: extern struct sym_bkt *dot_bkt; ! 69: extern struct ins_bkt *sopcode(); ! 70: extern long dot; ! 71: extern short cur_csect_name; ! 72: extern char rel_name[]; ! 73: extern FILE *source_file[]; ! 74: extern char *source_name[FILES_MAX]; ! 75: extern int current_file, file_count; ! 76: extern int pass, bc; ! 77: extern int ext_instruction_set; ! 78: /* Coprocessor Identifier Support. */ ! 79: #define INITIAL_CPID 1 /* Initial implicit cpid. */ ! 80: extern int implicit_cpid ; /* Current implicit cpid. */ ! 81: extern int current_cpid ; /* Explicit or implicit cpid ! 82: for current instruction. */ ! 83: ! 84: #if AS ! 85: #define wcode ((short *)code) ! 86: extern int d2flag, jsrflag, rflag, Oflag, even_align_flag ; ! 87: extern int Jflag, hflag; ! 88: #ifdef EBUG ! 89: extern int debflag; ! 90: #endif ! 91: extern int cansdi; ! 92: extern int ntlabels; /* how many labels in TEXT space? */ ! 93: extern long tsize, dsize, d1size, d2size, bsize; ! 94: extern int code_length; /* number of bytes in WCode */ ! 95: /* complain during second pass only */ ! 96: #define PROG_ERROR( n ) {if(pass == 2)prog_error( n );} ! 97: #endif ! 98: #if C2 ! 99: #define PROG_ERROR( n ) prog_error( n ) ! 100: extern struct csect *cur_csect; ! 101: #endif ! 102: ! 103: /* skip to next non-spacing character */ ! 104: #define skipb(p) while (cinfo[*p] == SPC) p++ ! 105: ! 106: /* skip to end of symbol */ ! 107: #define skips(p) while (cinfo[*p] & T) p++ ! 108: ! 109: #if C2 ! 110: # define C2MAGIC "|#" ! 111: # define C2MAGICSIZE 2 ! 112: extern char * p2pseudocomment(); ! 113: #endif ! 114: ! 115: /* some register names (indexes into the register table) */ ! 116: # define D0REG 0 ! 117: # define D7REG 7 ! 118: # define A0REG 8 ! 119: # define A6REG 14 ! 120: # define A7REG 15 ! 121: # define FPREG A6REG ! 122: # define SPREG A7REG ! 123: # define PCREG 16 ! 124: # define CCREG 17 ! 125: # define SRREG 18 ! 126: # define USPREG 19 ! 127: # define FP0REG 27 ! 128: # define FP7REG 34 ! 129: # define FPCREG 35 ! 130: # define FPSREG 36 ! 131: # define FPIREG 37 ! 132: ! 133: /* what the registers are good for */ ! 134: extern /* const */ unsigned reg_access[]; ! 135: #define ctrl_reg(reg) (reg_access[(reg)]&AM_CTRLREG) ! 136: #define dreg(reg) (reg_access[(reg)]&AM_DREG) ! 137: #define areg(reg) (reg_access[(reg)]&AM_AREG) ! 138: #define pcreg(reg) (reg_access[(reg)]&AM_PCREG) ! 139: #define sr_addr(op) ((op)->type_o==T_REG && (reg_access[(op)->value_o]&AM_CCREG)) ! 140: #define usp_addr(op) ((op)->type_o==T_REG && (reg_access[(op)->value_o]&AM_USPREG)) ! 141: #define dreg_addr(op) ((op)->type_o==T_REG && (reg_access[(op)->value_o]&AM_DREG)) ! 142: #define areg_addr(op) ((op)->type_o==T_REG && (reg_access[(op)->value_o]&AM_AREG)) ! 143: #define freg_addr(op) ((op)->type_o==T_REG && (reg_access[(op)->value_o]&AM_FREG)) ! 144: #define fctrlreg_addr(op) ((op)->type_o==T_REG && (reg_access[(op)->value_o]&AM_FCTRLREG)) ! 145: ! 146: /* bits found in character info array cinfo[] */ ! 147: #define D 0x0100 /* digit */ ! 148: #define S 0x0200 /* can start symbol */ ! 149: #define T 0x0400 /* can be part of symbol */ ! 150: ! 151: #define COL 0x00 /* label definition */ ! 152: #define EQL 0x01 /* label assignment */ ! 153: #define EOL 0x02 /* end of line -- newline or comment char */ ! 154: #define ADD 0x03 /* addition operator */ ! 155: #define SUB 0x04 /* subtraction operator */ ! 156: #define SPC 0x05 /* spacing character */ ! 157: #define ERR 0x06 /* illegal character */ ! 158: #define IMM 0x07 /* immediate operand indicator */ ! 159: #define LP 0x08 /* left paren */ ! 160: #define RP 0x09 /* right paren */ ! 161: #define COM 0x0A /* operand separator */ ! 162: #define IND 0x0B /* indirection operator */ ! 163: #define MUL 0x0C /* multiplication operator */ ! 164: #define NOT 0x0D /* complement operator */ ! 165: #define QUO 0x0E /* beginning/end of string */ ! 166: #define DIV 0x0F /* division operator */ ! 167: #define LB 0x10 /* left square bracket */ ! 168: #define RB 0x11 /* right square bracket */ ! 169: ! 170: /* flavors of sdi's */ ! 171: #define SDI4 0 ! 172: #define SDI6 1 ! 173: #define SDI8 2 ! 174: #define SDIP 3 ! 175: #define SDIX 4 ! 176: #define SDIL 5
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.