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

📄 tc-ppc.c

📁 基于4个mips核的noc设计
💻 C
📖 第 1 页 / 共 5 页
字号:
/* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000)   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001   Free Software Foundation, Inc.   Written by Ian Lance Taylor, Cygnus Support.   This file is part of GAS, the GNU Assembler.   GAS is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2, or (at your option)   any later version.   GAS is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with GAS; see the file COPYING.  If not, write to the Free   Software Foundation, 59 Temple Place - Suite 330, Boston, MA   02111-1307, USA.  */#include <stdio.h>#include <ctype.h>#include "as.h"#include "subsegs.h"#include "opcode/ppc.h"#ifdef OBJ_ELF#include "elf/ppc.h"#include "dwarf2dbg.h"#endif#ifdef TE_PE#include "coff/pe.h"#endif/* This is the assembler for the PowerPC or POWER (RS/6000) chips.  *//* Tell the main code what the endianness is.  */extern int target_big_endian;/* Whether or not, we've set target_big_endian.  */static int set_target_endian = 0;/* Whether to use user friendly register names.  */#ifndef TARGET_REG_NAMES_P#ifdef TE_PE#define TARGET_REG_NAMES_P true#else#define TARGET_REG_NAMES_P false#endif#endifstatic boolean reg_names_p = TARGET_REG_NAMES_P;static boolean register_name PARAMS ((expressionS *));static void ppc_set_cpu PARAMS ((void));static unsigned long ppc_insert_operand  PARAMS ((unsigned long insn, const struct powerpc_operand *operand,	   offsetT val, char *file, unsigned int line));static void ppc_macro PARAMS ((char *str, const struct powerpc_macro *macro));static void ppc_byte PARAMS ((int));static int ppc_is_toc_sym PARAMS ((symbolS *sym));static void ppc_tc PARAMS ((int));#ifdef OBJ_XCOFFstatic void ppc_comm PARAMS ((int));static void ppc_bb PARAMS ((int));static void ppc_bc PARAMS ((int));static void ppc_bf PARAMS ((int));static void ppc_biei PARAMS ((int));static void ppc_bs PARAMS ((int));static void ppc_eb PARAMS ((int));static void ppc_ec PARAMS ((int));static void ppc_ef PARAMS ((int));static void ppc_es PARAMS ((int));static void ppc_csect PARAMS ((int));static void ppc_change_csect PARAMS ((symbolS *));static void ppc_function PARAMS ((int));static void ppc_extern PARAMS ((int));static void ppc_lglobl PARAMS ((int));static void ppc_section PARAMS ((int));static void ppc_named_section PARAMS ((int));static void ppc_stabx PARAMS ((int));static void ppc_rename PARAMS ((int));static void ppc_toc PARAMS ((int));static void ppc_xcoff_cons PARAMS ((int));static void ppc_machine PARAMS ((int));static void ppc_vbyte PARAMS ((int));#endif#ifdef OBJ_ELFstatic bfd_reloc_code_real_type ppc_elf_suffix PARAMS ((char **, expressionS *));static void ppc_elf_cons PARAMS ((int));static void ppc_elf_rdata PARAMS ((int));static void ppc_elf_lcomm PARAMS ((int));static void ppc_elf_validate_fix PARAMS ((fixS *, segT));#endif#ifdef TE_PEstatic void ppc_set_current_section PARAMS ((segT));static void ppc_previous PARAMS ((int));static void ppc_pdata PARAMS ((int));static void ppc_ydata PARAMS ((int));static void ppc_reldata PARAMS ((int));static void ppc_rdata PARAMS ((int));static void ppc_ualong PARAMS ((int));static void ppc_znop PARAMS ((int));static void ppc_pe_comm PARAMS ((int));static void ppc_pe_section PARAMS ((int));static void ppc_pe_function PARAMS ((int));static void ppc_pe_tocd PARAMS ((int));#endif/* Generic assembler global variables which must be defined by all   targets.  */#ifdef OBJ_ELF/* This string holds the chars that always start a comment.  If the   pre-processor is disabled, these aren't very useful.  The macro   tc_comment_chars points to this.  We use this, rather than the   usual comment_chars, so that we can switch for Solaris conventions.  */static const char ppc_solaris_comment_chars[] = "#!";static const char ppc_eabi_comment_chars[] = "#";#ifdef TARGET_SOLARIS_COMMENTconst char *ppc_comment_chars = ppc_solaris_comment_chars;#elseconst char *ppc_comment_chars = ppc_eabi_comment_chars;#endif#elseconst char comment_chars[] = "#";#endif/* Characters which start a comment at the beginning of a line.  */const char line_comment_chars[] = "#";/* Characters which may be used to separate multiple commands on a   single line.  */const char line_separator_chars[] = ";";/* Characters which are used to indicate an exponent in a floating   point number.  */const char EXP_CHARS[] = "eE";/* Characters which mean that a number is a floating point constant,   as in 0d1.0.  */const char FLT_CHARS[] = "dD";/* The target specific pseudo-ops which we support.  */const pseudo_typeS md_pseudo_table[] ={  /* Pseudo-ops which must be overridden.  */  { "byte",	ppc_byte,	0 },#ifdef OBJ_XCOFF  /* Pseudo-ops specific to the RS/6000 XCOFF format.  Some of these     legitimately belong in the obj-*.c file.  However, XCOFF is based     on COFF, and is only implemented for the RS/6000.  We just use     obj-coff.c, and add what we need here.  */  { "comm",	ppc_comm,	0 },  { "lcomm",	ppc_comm,	1 },  { "bb",	ppc_bb,		0 },  { "bc",	ppc_bc,		0 },  { "bf",	ppc_bf,		0 },  { "bi",	ppc_biei,	0 },  { "bs",	ppc_bs,		0 },  { "csect",	ppc_csect,	0 },  { "data",	ppc_section,	'd' },  { "eb",	ppc_eb,		0 },  { "ec",	ppc_ec,		0 },  { "ef",	ppc_ef,		0 },  { "ei",	ppc_biei,	1 },  { "es",	ppc_es,		0 },  { "extern",	ppc_extern,	0 },  { "function",	ppc_function,	0 },  { "lglobl",	ppc_lglobl,	0 },  { "rename",	ppc_rename,	0 },  { "section",	ppc_named_section, 0 },  { "stabx",	ppc_stabx,	0 },  { "text",	ppc_section,	't' },  { "toc",	ppc_toc,	0 },  { "long",	ppc_xcoff_cons,	2 },  { "llong",	ppc_xcoff_cons,	3 },  { "word",	ppc_xcoff_cons,	1 },  { "short",	ppc_xcoff_cons,	1 },  { "vbyte",    ppc_vbyte,	0 },  { "machine",  ppc_machine,    0 },#endif#ifdef OBJ_ELF  { "long",	ppc_elf_cons,	4 },  { "word",	ppc_elf_cons,	2 },  { "short",	ppc_elf_cons,	2 },  { "rdata",	ppc_elf_rdata,	0 },  { "rodata",	ppc_elf_rdata,	0 },  { "lcomm",	ppc_elf_lcomm,	0 },  { "file",	dwarf2_directive_file, 0 },  { "loc",	dwarf2_directive_loc, 0 },#endif#ifdef TE_PE  /* Pseudo-ops specific to the Windows NT PowerPC PE (coff) format */  { "previous", ppc_previous,   0 },  { "pdata",    ppc_pdata,      0 },  { "ydata",    ppc_ydata,      0 },  { "reldata",  ppc_reldata,    0 },  { "rdata",    ppc_rdata,      0 },  { "ualong",   ppc_ualong,     0 },  { "znop",     ppc_znop,       0 },  { "comm",	ppc_pe_comm,	0 },  { "lcomm",	ppc_pe_comm,	1 },  { "section",  ppc_pe_section, 0 },  { "function",	ppc_pe_function,0 },  { "tocd",     ppc_pe_tocd,    0 },#endif  /* This pseudo-op is used even when not generating XCOFF output.  */  { "tc",	ppc_tc,		0 },  { NULL,	NULL,		0 }};/* Predefined register names if -mregnames (or default for Windows NT).  *//* In general, there are lots of them, in an attempt to be compatible *//* with a number of other Windows NT assemblers.                      *//* Structure to hold information about predefined registers.  */struct pd_reg  {    char *name;    int value;  };/* List of registers that are pre-defined:   Each general register has predefined names of the form:   1. r<reg_num> which has the value <reg_num>.   2. r.<reg_num> which has the value <reg_num>.   Each floating point register has predefined names of the form:   1. f<reg_num> which has the value <reg_num>.   2. f.<reg_num> which has the value <reg_num>.   Each vector unit register has predefined names of the form:   1. v<reg_num> which has the value <reg_num>.   2. v.<reg_num> which has the value <reg_num>.   Each condition register has predefined names of the form:   1. cr<reg_num> which has the value <reg_num>.   2. cr.<reg_num> which has the value <reg_num>.   There are individual registers as well:   sp or r.sp     has the value 1   rtoc or r.toc  has the value 2   fpscr          has the value 0   xer            has the value 1   lr             has the value 8   ctr            has the value 9   pmr            has the value 0   dar            has the value 19   dsisr          has the value 18   dec            has the value 22   sdr1           has the value 25   srr0           has the value 26   srr1           has the value 27   The table is sorted. Suitable for searching by a binary search.  */static const struct pd_reg pre_defined_registers[] ={  { "cr.0", 0 },    /* Condition Registers */  { "cr.1", 1 },  { "cr.2", 2 },  { "cr.3", 3 },  { "cr.4", 4 },  { "cr.5", 5 },  { "cr.6", 6 },  { "cr.7", 7 },  { "cr0", 0 },  { "cr1", 1 },  { "cr2", 2 },  { "cr3", 3 },  { "cr4", 4 },  { "cr5", 5 },  { "cr6", 6 },  { "cr7", 7 },  { "ctr", 9 },  { "dar", 19 },    /* Data Access Register */  { "dec", 22 },    /* Decrementer */  { "dsisr", 18 },  /* Data Storage Interrupt Status Register */  { "f.0", 0 },     /* Floating point registers */  { "f.1", 1 },  { "f.10", 10 },  { "f.11", 11 },  { "f.12", 12 },  { "f.13", 13 },  { "f.14", 14 },  { "f.15", 15 },  { "f.16", 16 },  { "f.17", 17 },  { "f.18", 18 },  { "f.19", 19 },  { "f.2", 2 },  { "f.20", 20 },  { "f.21", 21 },  { "f.22", 22 },  { "f.23", 23 },  { "f.24", 24 },  { "f.25", 25 },  { "f.26", 26 },  { "f.27", 27 },  { "f.28", 28 },  { "f.29", 29 },  { "f.3", 3 },  { "f.30", 30 },  { "f.31", 31 },  { "f.4", 4 },  { "f.5", 5 },  { "f.6", 6 },  { "f.7", 7 },  { "f.8", 8 },  { "f.9", 9 },  { "f0", 0 },  { "f1", 1 },  { "f10", 10 },  { "f11", 11 },  { "f12", 12 },  { "f13", 13 },  { "f14", 14 },  { "f15", 15 },  { "f16", 16 },  { "f17", 17 },  { "f18", 18 },  { "f19", 19 },  { "f2", 2 },  { "f20", 20 },  { "f21", 21 },  { "f22", 22 },  { "f23", 23 },  { "f24", 24 },  { "f25", 25 },  { "f26", 26 },  { "f27", 27 },  { "f28", 28 },  { "f29", 29 },  { "f3", 3 },  { "f30", 30 },  { "f31", 31 },  { "f4", 4 },  { "f5", 5 },  { "f6", 6 },  { "f7", 7 },  { "f8", 8 },  { "f9", 9 },  { "fpscr", 0 },  { "lr", 8 },     /* Link Register */  { "pmr", 0 },  { "r.0", 0 },    /* General Purpose Registers */  { "r.1", 1 },  { "r.10", 10 },  { "r.11", 11 },  { "r.12", 12 },  { "r.13", 13 },  { "r.14", 14 },  { "r.15", 15 },  { "r.16", 16 },  { "r.17", 17 },  { "r.18", 18 },  { "r.19", 19 },  { "r.2", 2 },  { "r.20", 20 },  { "r.21", 21 },  { "r.22", 22 },  { "r.23", 23 },  { "r.24", 24 },  { "r.25", 25 },  { "r.26", 26 },  { "r.27", 27 },  { "r.28", 28 },  { "r.29", 29 },  { "r.3", 3 },  { "r.30", 30 },  { "r.31", 31 },  { "r.4", 4 },  { "r.5", 5 },  { "r.6", 6 },  { "r.7", 7 },  { "r.8", 8 },  { "r.9", 9 },  { "r.sp", 1 },   /* Stack Pointer */  { "r.toc", 2 },  /* Pointer to the table of contents */  { "r0", 0 },     /* More general purpose registers */  { "r1", 1 },  { "r10", 10 },  { "r11", 11 },  { "r12", 12 },  { "r13", 13 },  { "r14", 14 },  { "r15", 15 },  { "r16", 16 },  { "r17", 17 },  { "r18", 18 },  { "r19", 19 },  { "r2", 2 },  { "r20", 20 },  { "r21", 21 },  { "r22", 22 },  { "r23", 23 },  { "r24", 24 },  { "r25", 25 },  { "r26", 26 },  { "r27", 27 },  { "r28", 28 },  { "r29", 29 },  { "r3", 3 },  { "r30", 30 },  { "r31", 31 },  { "r4", 4 },  { "r5", 5 },  { "r6", 6 },  { "r7", 7 },  { "r8", 8 },  { "r9", 9 },  { "rtoc", 2 },  /* Table of contents */  { "sdr1", 25 }, /* Storage Description Register 1 */  { "sp", 1 },  { "srr0", 26 }, /* Machine Status Save/Restore Register 0 */  { "srr1", 27 }, /* Machine Status Save/Restore Register 1 */  { "v.0", 0 },     /* Vector registers */  { "v.1", 1 },  { "v.10", 10 },  { "v.11", 11 },  { "v.12", 12 },  { "v.13", 13 },  { "v.14", 14 },  { "v.15", 15 },  { "v.16", 16 },  { "v.17", 17 },  { "v.18", 18 },  { "v.19", 19 },  { "v.2", 2 },  { "v.20", 20 },  { "v.21", 21 },  { "v.22", 22 },  { "v.23", 23 },  { "v.24", 24 },  { "v.25", 25 },  { "v.26", 26 },  { "v.27", 27 },  { "v.28", 28 },  { "v.29", 29 },  { "v.3", 3 },  { "v.30", 30 },  { "v.31", 31 },  { "v.4", 4 },  { "v.5", 5 },  { "v.6", 6 },  { "v.7", 7 },  { "v.8", 8 },  { "v.9", 9 },  { "v0", 0 },  { "v1", 1 },  { "v10", 10 },  { "v11", 11 },  { "v12", 12 },  { "v13", 13 },  { "v14", 14 },  { "v15", 15 },  { "v16", 16 },  { "v17", 17 },  { "v18", 18 },  { "v19", 19 },  { "v2", 2 },  { "v20", 20 },  { "v21", 21 },  { "v22", 22 },  { "v23", 23 },  { "v24", 24 },  { "v25", 25 },  { "v26", 26 },  { "v27", 27 },  { "v28", 28 },  { "v29", 29 },  { "v3", 3 },  { "v30", 30 },  { "v31", 31 },  { "v4", 4 },  { "v5", 5 },  { "v6", 6 },  { "v7", 7 },  { "v8", 8 },  { "v9", 9 },  { "xer", 1 },};

⌨️ 快捷键说明

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