m32r-asm.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 598 行 · 第 1/2 页
C
598 行
/* Assembler interface for targets using CGEN. -*- C -*- CGEN: Cpu tools GENeratorTHIS FILE IS MACHINE GENERATED WITH CGEN.- the resultant file is machine generated, cgen-asm.in isn'tCopyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.This file is part of the GNU Binutils and GDB, the GNU debugger.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free Software Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* ??? Eventually more and more of this stuff can go to cpu-independent files. Keep that in mind. */#include "sysdep.h"#include <ctype.h>#include <stdio.h>#include "ansidecl.h"#include "bfd.h"#include "symcat.h"#include "m32r-desc.h"#include "m32r-opc.h"#include "opintl.h"#undef min#define min(a,b) ((a) < (b) ? (a) : (b))#undef max#define max(a,b) ((a) > (b) ? (a) : (b))static const char * parse_insn_normal PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *));/* -- assembler routines inserted here *//* -- asm.c *//* Handle '#' prefixes (i.e. skip over them). */static const char *parse_hash (cd, strp, opindex, valuep) CGEN_CPU_DESC cd; const char **strp; int opindex; unsigned long *valuep;{ if (**strp == '#') ++*strp; return NULL;}/* Handle shigh(), high(). */static const char *parse_hi16 (cd, strp, opindex, valuep) CGEN_CPU_DESC cd; const char **strp; int opindex; unsigned long *valuep;{ const char *errmsg; enum cgen_parse_operand_result result_type; bfd_vma value; if (**strp == '#') ++*strp; if (strncasecmp (*strp, "high(", 5) == 0) { *strp += 5; errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_HI16_ULO, &result_type, &value); if (**strp != ')') return "missing `)'"; ++*strp; if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) value >>= 16; *valuep = value; return errmsg; } else if (strncasecmp (*strp, "shigh(", 6) == 0) { *strp += 6; errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_HI16_SLO, &result_type, &value); if (**strp != ')') return "missing `)'"; ++*strp; if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) value = (value >> 16) + (value & 0x8000 ? 1 : 0); *valuep = value; return errmsg; } return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);}/* Handle low() in a signed context. Also handle sda(). The signedness of the value doesn't matter to low(), but this also handles the case where low() isn't present. */static const char *parse_slo16 (cd, strp, opindex, valuep) CGEN_CPU_DESC cd; const char **strp; int opindex; long *valuep;{ const char *errmsg; enum cgen_parse_operand_result result_type; bfd_vma value; if (**strp == '#') ++*strp; if (strncasecmp (*strp, "low(", 4) == 0) { *strp += 4; errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_LO16, &result_type, &value); if (**strp != ')') return "missing `)'"; ++*strp; if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) value &= 0xffff; *valuep = value; return errmsg; } if (strncasecmp (*strp, "sda(", 4) == 0) { *strp += 4; errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_SDA16, NULL, &value); if (**strp != ')') return "missing `)'"; ++*strp; *valuep = value; return errmsg; } return cgen_parse_signed_integer (cd, strp, opindex, valuep);}/* Handle low() in an unsigned context. The signedness of the value doesn't matter to low(), but this also handles the case where low() isn't present. */static const char *parse_ulo16 (cd, strp, opindex, valuep) CGEN_CPU_DESC cd; const char **strp; int opindex; unsigned long *valuep;{ const char *errmsg; enum cgen_parse_operand_result result_type; bfd_vma value; if (**strp == '#') ++*strp; if (strncasecmp (*strp, "low(", 4) == 0) { *strp += 4; errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32R_LO16, &result_type, &value); if (**strp != ')') return "missing `)'"; ++*strp; if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) value &= 0xffff; *valuep = value; return errmsg; } return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);}/* -- *//* Main entry point for operand parsing. This function is basically just a big switch statement. Earlier versions used tables to look up the function to use, but - if the table contains both assembler and disassembler functions then the disassembler contains much of the assembler and vice-versa, - there's a lot of inlining possibilities as things grow, - using a switch statement avoids the function call overhead. This function could be moved into `parse_insn_normal', but keeping it separate makes clear the interface between `parse_insn_normal' and each of the handlers.*/const char *m32r_cgen_parse_operand (cd, opindex, strp, fields) CGEN_CPU_DESC cd; int opindex; const char ** strp; CGEN_FIELDS * fields;{ const char * errmsg = NULL; /* Used by scalar operands that still need to be parsed. */ long junk; switch (opindex) { case M32R_OPERAND_ACC : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_h_accums, & fields->f_acc); break; case M32R_OPERAND_ACCD : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_h_accums, & fields->f_accd); break; case M32R_OPERAND_ACCS : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_h_accums, & fields->f_accs); break; case M32R_OPERAND_DCR : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_cr_names, & fields->f_r1); break; case M32R_OPERAND_DISP16 : { bfd_vma value; errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_DISP16, 0, NULL, & value); fields->f_disp16 = value; } break; case M32R_OPERAND_DISP24 : { bfd_vma value; errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_DISP24, 0, NULL, & value); fields->f_disp24 = value; } break; case M32R_OPERAND_DISP8 : { bfd_vma value; errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_DISP8, 0, NULL, & value); fields->f_disp8 = value; } break; case M32R_OPERAND_DR : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r1); break; case M32R_OPERAND_HASH : errmsg = parse_hash (cd, strp, M32R_OPERAND_HASH, &junk); break; case M32R_OPERAND_HI16 : errmsg = parse_hi16 (cd, strp, M32R_OPERAND_HI16, &fields->f_hi16); break; case M32R_OPERAND_IMM1 : errmsg = cgen_parse_unsigned_integer (cd, strp, M32R_OPERAND_IMM1, &fields->f_imm1); break; case M32R_OPERAND_SCR : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_cr_names, & fields->f_r2); break; case M32R_OPERAND_SIMM16 : errmsg = cgen_parse_signed_integer (cd, strp, M32R_OPERAND_SIMM16, &fields->f_simm16); break; case M32R_OPERAND_SIMM8 : errmsg = cgen_parse_signed_integer (cd, strp, M32R_OPERAND_SIMM8, &fields->f_simm8); break; case M32R_OPERAND_SLO16 : errmsg = parse_slo16 (cd, strp, M32R_OPERAND_SLO16, &fields->f_simm16); break; case M32R_OPERAND_SR : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r2); break; case M32R_OPERAND_SRC1 : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r1); break; case M32R_OPERAND_SRC2 : errmsg = cgen_parse_keyword (cd, strp, & m32r_cgen_opval_gr_names, & fields->f_r2); break; case M32R_OPERAND_UIMM16 : errmsg = cgen_parse_unsigned_integer (cd, strp, M32R_OPERAND_UIMM16, &fields->f_uimm16); break; case M32R_OPERAND_UIMM24 : { bfd_vma value; errmsg = cgen_parse_address (cd, strp, M32R_OPERAND_UIMM24, 0, NULL, & value); fields->f_uimm24 = value; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?