- Add the MIPS assembler written by Pirouz B. in the Alliance CVS tree
This commit is contained in:
parent
0c45b59ddc
commit
e9398c13fd
|
@ -0,0 +1 @@
|
|||
SUBDIRS = src
|
|
@ -0,0 +1,40 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(src/mips_globals.c)
|
||||
|
||||
MIPS_ASM_MAJOR_VERSION=1
|
||||
MIPS_ASM_MINOR_VERSION=0
|
||||
MIPS_ASM_VERSION=$MIPS_ASM_MAJOR_VERSION.$MIPS_ASM_MINOR_VERSION
|
||||
|
||||
AC_SUBST(MIPS_ASM_MAJOR_VERSION)
|
||||
AC_SUBST(MIPS_ASM_MINOR_VERSION)
|
||||
AC_SUBST(MIPS_ASM_VERSION)
|
||||
|
||||
# For automake.
|
||||
VERSION=$MIPS_ASM_VERSION
|
||||
PACKAGE=mips_asm
|
||||
|
||||
dnl Initialize automake stuff
|
||||
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AC_PROG_RANLIB
|
||||
ALC_CXX_PROBLEMATIC_OLD_VERSION
|
||||
AM_PROG_LEX
|
||||
AC_PROG_YACC
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
dnl Checks for libraries.
|
||||
dnl Check for -lm librarie. These should always be present.
|
||||
AC_CHECK_LIB(m, exp)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
||||
AM_ALLIANCE
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
src/Makefile
|
||||
])
|
|
@ -0,0 +1,23 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
YACC = @YACC@ -d
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src
|
||||
|
||||
AM_CXXFLAGS = @ALLIANCE_CFLAGS@
|
||||
AM_CFLAGS = @ALLIANCE_CFLAGS@
|
||||
|
||||
bin_PROGRAMS = mips_asm
|
||||
|
||||
mips_asm_LDADD = @ALLIANCE_LIBS@ \
|
||||
-lBeh -lMut
|
||||
|
||||
mips_asm_SOURCES = mips_defs.h mips_y.y mips_l.l mips_globals.c mips_lex.h mips_type.h mips_yacc.h mips_util.c
|
||||
|
||||
mips_y.c mips_y.h : $(srcdir)/mips_y.y
|
||||
$(YACC) -d $(YFLAGS) $(srcdir)/mips_y.y && sed -e "s/yy/mipsyy/g" -e "s/YY/mipsYY/g" y.tab.c > mips_y.c && sed -e "s/yy/mipsyy/g" -e "s/YY/mipsYY/g" y.tab.h > mips_y.h
|
||||
|
||||
mips_l.c : $(srcdir)/mips_l.l mips_y.h
|
||||
$(LEX) -t $(srcdir)/mips_l.l | sed -e "s/yy/mipsyy/g" -e "s/YY/mipsYY/g" > mips_l.c
|
||||
|
||||
CLEANFILES = y.tab.c y.tab.h mips.c
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* This file is part of the Alliance CAD System
|
||||
* Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
* Universite Pierre et Marie Curie
|
||||
*
|
||||
* Home page : http://www-asim.lip6.fr/alliance/
|
||||
* E-mail : mailto:alliance-users@asim.lip6.fr
|
||||
*
|
||||
* This progam 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Alliance VLSI CAD System 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 the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* file : mips_defs.h */
|
||||
/* date : Dec 6 1999 */
|
||||
/* version : v0.3 */
|
||||
/* author : Pirouz BAZARGAN SABET */
|
||||
/* description : MIPS assembler - defines (operation codes) */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
#define MPS_PLSDFN 0 /* add */
|
||||
#define MPS_MNSDFN 1 /* subtract */
|
||||
#define MPS_SHLDFN 2 /* shift left */
|
||||
#define MPS_SHRDFN 3 /* shift right */
|
||||
#define MPS_ORDFN 4 /* logical or */
|
||||
#define MPS_ANDDFN 5 /* logical and */
|
||||
#define MPS_XORDFN 6 /* logical exclusive or */
|
||||
#define MPS_MULDFN 7 /* multiply */
|
||||
#define MPS_DIVDFN 8 /* divide */
|
||||
|
||||
/* ### ---------------------------------------------------- ### */
|
||||
/* instruction set table: */
|
||||
/* Opcods in lower case are MIPS instructions */
|
||||
/* Opcods in upper case are application specific */
|
||||
/* */
|
||||
/* */
|
||||
/* primary opcod (31 downto 26): */
|
||||
/* | 0 1 2 3 4 5 6 7 */
|
||||
/* --+-----+-----+-----+-----+-----+-----+-----+-----+ */
|
||||
/* 0 |speci|bcond| j | jal | beq | bne |blez |bgtz | */
|
||||
/* 1 |addi |addui|slti |sltui|andi | ori |xori | lui | */
|
||||
/* 2 |cop0 | + | + | + | | + | | | */
|
||||
/* 3 | | | | | | | | | */
|
||||
/* 4 | lb | lh | + | lw | lbu | lhu | + |SWAP | */
|
||||
/* 5 | sb | sh | + | sw | | | + | | */
|
||||
/* 6 | + | + | + | + |Seqi |Snei |Slei |Sgti | */
|
||||
/* 7 | + | + | + | + |Sgei |Sgeui|Sleui|Sgtui| */
|
||||
/* */
|
||||
/* */
|
||||
/* special opcod extension (5 downto 0): */
|
||||
/* | 0 1 2 3 4 5 6 7 */
|
||||
/* --+-----+-----+-----+-----+-----+-----+-----+-----+ */
|
||||
/* 0 | sll | | srl | sra |sllv | |srlv |srav | */
|
||||
/* 1 | jr |jalr | | |sysca|break| |SLEEP| */
|
||||
/* 2 |mfhi |mthi |mflo |mtlo | | | | | */
|
||||
/* 3 | + | + | + | + | | | | | */
|
||||
/* 4 | add |addu | sub |subu | and | or | xor | nor | */
|
||||
/* 5 | | | slt |sltu | | | | | */
|
||||
/* 6 | | | | | + | + | + | + | */
|
||||
/* 7 | | | | | + | + | + | + | */
|
||||
/* */
|
||||
/* */
|
||||
/* bcond opcod extension (20 downto 16): */
|
||||
/* | 0 1 2 3 4 5 6 7 */
|
||||
/* --+-----+-----+-----+-----+-----+-----+-----+-----+ */
|
||||
/* 0 |bltz |bgez | | | | | | | */
|
||||
/* 1 | | | | | | | | | */
|
||||
/* 2 |bltza|bgeza| | | | | | | */
|
||||
/* 3 | | | | | | | | | */
|
||||
/* */
|
||||
/* */
|
||||
/* cop0 opcod extension (22, 21, 16, 25, 24, 23): */
|
||||
/* | 0 1 2 3 4 5 6 7 */
|
||||
/* --+-----+-----+-----+-----+-----+-----+-----+-----+ */
|
||||
/* 0 | mf | mt | + | + | c0 | c0 | c0 | c0 | */
|
||||
/* 1 | mf | mt | + | + | c0 | c0 | c0 | c0 | */
|
||||
/* 2 | | | | | c0 | c0 | c0 | c0 | */
|
||||
/* 3 | | | | | c0 | c0 | c0 | c0 | */
|
||||
/* 4 | + | + | | | c0 | c0 | c0 | c0 | */
|
||||
/* 5 | + | + | | | c0 | c0 | c0 | c0 | */
|
||||
/* 6 | | | | | c0 | c0 | c0 | c0 | */
|
||||
/* 7 | | | | | c0 | c0 | c0 | c0 | */
|
||||
/* */
|
||||
/* */
|
||||
/* c0 cop0 extension extension (4 downto 0): */
|
||||
/* | 0 1 2 3 4 5 6 7 */
|
||||
/* --+-----+-----+-----+-----+-----+-----+-----+-----+ */
|
||||
/* 0 | + | + | + | | | | + | | */
|
||||
/* 1 | + | | | | | | | | */
|
||||
/* 2 |rstfe| | | | | | | | */
|
||||
/* 3 | + | | | | | | | | */
|
||||
/* */
|
||||
/* ### ---------------------------------------------------- ### */
|
||||
|
||||
#define _ADD 0x00000020 /* Mips architecture */
|
||||
#define _ADDI 0x20000000 /* Mips architecture */
|
||||
#define _ADDU 0x00000021 /* Mips architecture */
|
||||
#define _ADDIU 0x24000000 /* Mips architecture */
|
||||
#define _AND 0x00000024 /* Mips architecture */
|
||||
#define _ANDI 0x30000000 /* Mips architecture */
|
||||
#define _BEQ 0x10000000 /* Mips architecture */
|
||||
#define _BGEZ 0x04010000 /* Mips architecture */
|
||||
#define _BGEZAL 0x04110000 /* Mips architecture */
|
||||
#define _BGTZ 0x1C000000 /* Mips architecture */
|
||||
#define _BLEZ 0x18000000 /* Mips architecture */
|
||||
#define _BLTZ 0x04000000 /* Mips architecture */
|
||||
#define _BLTZAL 0x04100000 /* Mips architecture */
|
||||
#define _BNE 0x14000000 /* Mips architecture */
|
||||
#define _BREAK 0x0000000D /* Mips architecture */
|
||||
#define _J 0x08000000 /* Mips architecture */
|
||||
#define _JAL 0x0C000000 /* Mips architecture */
|
||||
#define _JALR 0x00000009 /* Mips architecture */
|
||||
#define _JR 0x00000008 /* Mips architecture */
|
||||
#define _LB 0x80000000 /* Mips architecture */
|
||||
#define _LBU 0x90000000 /* Mips architecture */
|
||||
#define _LH 0x84000000 /* Mips architecture */
|
||||
#define _LHU 0x94000000 /* Mips architecture */
|
||||
#define _LUI 0x3C000000 /* Mips architecture */
|
||||
#define _LW 0x8C000000 /* Mips architecture */
|
||||
#define _MFC0 0x40000000 /* Mips architecture */
|
||||
#define _MFHI 0x00000010 /* Mips architecture */
|
||||
#define _MFLO 0x00000012 /* Mips architecture */
|
||||
#define _MTC0 0x40800000 /* Mips architecture */
|
||||
#define _MTHI 0x00000011 /* Mips architecture */
|
||||
#define _MTLO 0x00000013 /* Mips architecture */
|
||||
#define _NOR 0x00000027 /* Mips architecture */
|
||||
#define _OR 0x00000025 /* Mips architecture */
|
||||
#define _ORI 0x34000000 /* Mips architecture */
|
||||
#define _RSTFE 0x42000010 /* Mips architecture */
|
||||
#define _SB 0xA0000000 /* Mips architecture */
|
||||
#define _SH 0xA4000000 /* Mips architecture */
|
||||
#define _SLEEP 0x0000000F /* Mips architecture */
|
||||
#define _SLL 0x00000000 /* Mips architecture */
|
||||
#define _SLLV 0x00000004 /* Mips architecture */
|
||||
#define _SLT 0x0000002A /* Mips architecture */
|
||||
#define _SLTI 0x28000000 /* Mips architecture */
|
||||
#define _SLTU 0x0000002B /* Mips architecture */
|
||||
#define _SLTIU 0x2C000000 /* Mips architecture */
|
||||
#define _SRA 0x00000003 /* Mips architecture */
|
||||
#define _SRAV 0x00000007 /* Mips architecture */
|
||||
#define _SRL 0x00000002 /* Mips architecture */
|
||||
#define _SRLV 0x00000006 /* Mips architecture */
|
||||
#define _SUB 0x00000022 /* Mips architecture */
|
||||
#define _SUBU 0x00000023 /* Mips architecture */
|
||||
#define _SW 0xAC000000 /* Mips architecture */
|
||||
#define _SWAP 0x9C000000 /* Mips architecture */
|
||||
#define _SYSCALL 0x0000000C /* Mips architecture */
|
||||
#define _XOR 0x00000026 /* Mips architecture */
|
||||
#define _XORI 0x38000000 /* Mips architecture */
|
||||
|
||||
#define _NOP 0x00000001 /* Mips macro */
|
||||
#define _LOADI 0x00000002 /* Mips macro */
|
||||
|
||||
#define _BADVADDR 8
|
||||
#define _STATUS 12
|
||||
#define _CAUSE 13
|
||||
#define _EPC 14
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This file is part of the Alliance CAD System
|
||||
* Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
* Universite Pierre et Marie Curie
|
||||
*
|
||||
* Home page : http://www-asim.lip6.fr/alliance/
|
||||
* E-mail : mailto:alliance-users@asim.lip6.fr
|
||||
*
|
||||
* This progam 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Alliance VLSI CAD System 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 the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* file : mips_globals.c */
|
||||
/* date : Dec 9 1999 */
|
||||
/* version : v0.3 */
|
||||
/* author : Pirouz BAZARGAN SABET */
|
||||
/* description : MIPS assembler - global and static variables */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
int MPS_LINNUM = 1;
|
|
@ -0,0 +1,571 @@
|
|||
/*
|
||||
* This file is part of the Alliance CAD System
|
||||
* Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
* Universite Pierre et Marie Curie
|
||||
*
|
||||
* Home page : http://www-asim.lip6.fr/alliance/
|
||||
* E-mail : mailto:alliance-users@asim.lip6.fr
|
||||
*
|
||||
* This progam 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Alliance VLSI CAD System 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 the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* file : mips_mips.lex */
|
||||
/* date : Dec 6 1999 */
|
||||
/* version : v0.3 */
|
||||
/* author : Pirouz BAZARGAN SABET */
|
||||
/* description : MIPS assembler - lex rules */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include "mut.h"
|
||||
#include "mips_type.h"
|
||||
#include "mips_y.h"
|
||||
#include "mips_defs.h"
|
||||
#include "mips_lex.h"
|
||||
%}
|
||||
|
||||
register \$([0-9]|[12][0-9]|3[01])
|
||||
digit [0-9]
|
||||
hexadecimal_valu 0x[0-9a-fA-F]+
|
||||
octal_valu 0o[0-7]+
|
||||
binary_valu 0b[0-1]+
|
||||
decimal_valu {digit}+
|
||||
letter [a-zA-Z]
|
||||
letter_or_digit {letter}|{digit}
|
||||
ident (\.|_|{letter})(\.|_|{letter_or_digit})*
|
||||
|
||||
%%
|
||||
\n {
|
||||
/*printf ("CarriageReturn : %d\n", MPS_LINNUM);*/
|
||||
MPS_LINNUM++;
|
||||
return (CarriageReturn);
|
||||
}
|
||||
\: {
|
||||
/*printf ("Colon\n");*/
|
||||
return (Colon);
|
||||
}
|
||||
[ \t] {
|
||||
/*printf ("space\n");*/
|
||||
}
|
||||
# {
|
||||
/*printf ("Sharp\n");*/
|
||||
return (Sharp);
|
||||
}
|
||||
\& {
|
||||
/*printf ("Ampersand\n");*/
|
||||
return (Ampersand);
|
||||
}
|
||||
\| {
|
||||
/*printf ("Bar\n");*/
|
||||
return (Bar);
|
||||
}
|
||||
\~ {
|
||||
/*printf ("Tilda\n");*/
|
||||
return (Tilda);
|
||||
}
|
||||
\^ {
|
||||
/*printf ("Circomflex\n");*/
|
||||
return (Circomflex);
|
||||
}
|
||||
\+ {
|
||||
/*printf ("Plus\n");*/
|
||||
return (Plus);
|
||||
}
|
||||
\/ {
|
||||
/*printf ("Slash\n");*/
|
||||
return (Slash);
|
||||
}
|
||||
\* {
|
||||
/*printf ("Star\n");*/
|
||||
return (Star);
|
||||
}
|
||||
\<\< {
|
||||
/*printf ("DoubleLess\n");*/
|
||||
return (DoubleLess);
|
||||
}
|
||||
\>\> {
|
||||
/*printf ("DoubleGreat\n");*/
|
||||
return (DoubleGreat);
|
||||
}
|
||||
\- {
|
||||
/*printf ("Minus\n");*/
|
||||
return (Minus);
|
||||
}
|
||||
\( {
|
||||
/*printf ("LeftParen\n");*/
|
||||
return (LeftParen);
|
||||
}
|
||||
\) {
|
||||
/*printf ("RightParen\n");*/
|
||||
return (RightParen);
|
||||
}
|
||||
\, {
|
||||
/*printf ("Comma\n");*/
|
||||
return (Comma);
|
||||
}
|
||||
{register} {
|
||||
/*printf ("Register : %s\n", yytext);*/
|
||||
sscanf (&yytext[1], "%lu", &yylval.valu);
|
||||
return (Register);
|
||||
}
|
||||
{hexadecimal_valu} {
|
||||
/*printf ("Literal (X) : %s\n", yytext);*/
|
||||
yylval.valu = hextoint (yytext);
|
||||
return (Litteral);
|
||||
}
|
||||
{octal_valu} {
|
||||
/*printf ("Literal (O) : %s\n", yytext);*/
|
||||
yylval.valu = octtoint (yytext);
|
||||
return (Litteral);
|
||||
}
|
||||
{binary_valu} {
|
||||
/*printf ("Literal (B) : %s\n", yytext);*/
|
||||
yylval.valu = bintoint (yytext);
|
||||
return (Litteral);
|
||||
}
|
||||
{decimal_valu} {
|
||||
/*printf ("Literal (D) : %s\n", yytext);*/
|
||||
if (sscanf (yytext, "%ld", &yylval.valu) == 0)
|
||||
yylval.valu = 0;
|
||||
return (Litteral);
|
||||
}
|
||||
|
||||
\".*\" {
|
||||
extern char *mips_allocstr ();
|
||||
|
||||
/*printf ("String : %s\n", yytext);*/
|
||||
yylval.text = mips_allocstr (yytext);
|
||||
return (String);
|
||||
}
|
||||
{ident} {
|
||||
int type ;
|
||||
extern char *mips_allocstr ();
|
||||
|
||||
yylval.text = mips_allocstr (yytext);
|
||||
|
||||
type = searchtype (yylval.text);
|
||||
if (type == -1)
|
||||
{
|
||||
/*printf ("Identifier : %s\n", yytext);*/
|
||||
return (Identifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*printf ("Key Word : %s\n", yytext);*/
|
||||
yylval.valu = searchvalu (yylval.text);
|
||||
return (type);
|
||||
}
|
||||
}
|
||||
\;.*$ {
|
||||
/*printf ("Comment : %s\n", yytext);*/
|
||||
}
|
||||
%%
|
||||
|
||||
static int searchtype (str)
|
||||
|
||||
char *str;
|
||||
{
|
||||
extern char *mips_allocstr () ;
|
||||
static ht *type_hashpt = NULL;
|
||||
|
||||
if (type_hashpt == NULL)
|
||||
{
|
||||
type_hashpt = addht (128);
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr ("zero" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("at" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("v0" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("v1" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("a0" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("a1" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("a2" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("a3" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t0" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t1" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t2" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t3" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t4" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t5" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t6" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t7" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s0" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s1" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s2" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s3" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s4" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s5" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s6" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s7" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t8" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("t9" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("k0" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("k1" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("gp" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sp" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("s8" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("ra" ), IntegerRegister );
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr ("r0" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r1" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r2" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r3" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r4" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r5" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r6" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r7" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r8" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r9" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r10" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r11" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r12" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r13" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r14" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r15" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r16" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r17" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r18" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r19" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r20" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r21" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r22" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r23" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r24" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r25" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r26" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r27" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r28" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r29" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r30" ), IntegerRegister );
|
||||
addhtitem (type_hashpt, mips_allocstr ("r31" ), IntegerRegister );
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr ("badvaddr"), CP0Register );
|
||||
addhtitem (type_hashpt, mips_allocstr ("status" ), CP0Register );
|
||||
addhtitem (type_hashpt, mips_allocstr ("cause" ), CP0Register );
|
||||
addhtitem (type_hashpt, mips_allocstr ("epc" ), CP0Register );
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr (".align" ), _ALIGN );
|
||||
addhtitem (type_hashpt, mips_allocstr (".ascii" ), _ASCII );
|
||||
addhtitem (type_hashpt, mips_allocstr (".asciiz" ), _ASCIIZ );
|
||||
addhtitem (type_hashpt, mips_allocstr (".byte" ), _BYTE );
|
||||
addhtitem (type_hashpt, mips_allocstr (".bytez" ), _BYTEZ );
|
||||
addhtitem (type_hashpt, mips_allocstr (".data" ), _DATA );
|
||||
addhtitem (type_hashpt, mips_allocstr (".end" ), _END );
|
||||
addhtitem (type_hashpt, mips_allocstr (".equ" ), _EQU );
|
||||
addhtitem (type_hashpt, mips_allocstr (".global" ), _GLOBAL );
|
||||
addhtitem (type_hashpt, mips_allocstr (".org" ), _ORG );
|
||||
addhtitem (type_hashpt, mips_allocstr (".skip" ), _SKIP );
|
||||
addhtitem (type_hashpt, mips_allocstr (".space" ), _SPACE );
|
||||
addhtitem (type_hashpt, mips_allocstr (".start" ), _START );
|
||||
addhtitem (type_hashpt, mips_allocstr (".text" ), _TEXT );
|
||||
addhtitem (type_hashpt, mips_allocstr (".word" ), _WORD );
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr ("nop" ), Macro_n );
|
||||
addhtitem (type_hashpt, mips_allocstr ("loadi" ), Macro_rd_longi );
|
||||
addhtitem (type_hashpt, mips_allocstr ("la" ), Macro_rd_longi );
|
||||
addhtitem (type_hashpt, mips_allocstr ("li" ), Macro_rd_longi );
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr ("add" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("addi" ), Codop_rd_rs_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("addu" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("addiu" ), Codop_rd_rs_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("and" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("andi" ), Codop_rd_rs_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("beq" ), Codop_rs_rt_labl);
|
||||
addhtitem (type_hashpt, mips_allocstr ("bgez" ), Codop_rs_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("bgezal" ), Codop_rs_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("bgtz" ), Codop_rs_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("blez" ), Codop_rs_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("bltz" ), Codop_rs_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("bltzal" ), Codop_rs_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("bne" ), Codop_rs_rt_labl);
|
||||
addhtitem (type_hashpt, mips_allocstr ("break" ), Codop_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("j" ), Codop_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("jal" ), Codop_labl );
|
||||
addhtitem (type_hashpt, mips_allocstr ("jalr" ), Codop_od_rs );
|
||||
addhtitem (type_hashpt, mips_allocstr ("jr" ), Codop_rs );
|
||||
addhtitem (type_hashpt, mips_allocstr ("lb" ), Codop_rd_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("lbu" ), Codop_rd_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("lh" ), Codop_rd_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("lhu" ), Codop_rd_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("lui" ), Codop_rd_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("lw" ), Codop_rd_mem );
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr ("mfc0" ), Codop_rt_cp0rd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("mfhi" ), Codop_rd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("mflo" ), Codop_rd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("mtc0" ), Codop_rt_cp0rd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("mthi" ), Codop_rs );
|
||||
addhtitem (type_hashpt, mips_allocstr ("mtlo" ), Codop_rs );
|
||||
|
||||
addhtitem (type_hashpt, mips_allocstr ("nor" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("or" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("ori" ), Codop_rd_rs_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("rfe" ), Codop_n );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sb" ), Codop_rt_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sh" ), Codop_rt_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sleep" ), Codop_n );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sll" ), Codop_rd_rt_sham);
|
||||
addhtitem (type_hashpt, mips_allocstr ("sllv" ), Codop_rd_rt_rs );
|
||||
addhtitem (type_hashpt, mips_allocstr ("slt" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("slti" ), Codop_rd_rs_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sltiu" ), Codop_rd_rs_imd );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sltu" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sra" ), Codop_rd_rt_sham);
|
||||
addhtitem (type_hashpt, mips_allocstr ("srav" ), Codop_rd_rt_rs );
|
||||
addhtitem (type_hashpt, mips_allocstr ("srl" ), Codop_rd_rt_sham);
|
||||
addhtitem (type_hashpt, mips_allocstr ("srlv" ), Codop_rd_rt_rs );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sub" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("subu" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("sw" ), Codop_rt_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("swap" ), Codop_rt_mem );
|
||||
addhtitem (type_hashpt, mips_allocstr ("syscall" ), Codop_n );
|
||||
addhtitem (type_hashpt, mips_allocstr ("xor" ), Codop_rd_rs_rt );
|
||||
addhtitem (type_hashpt, mips_allocstr ("xori" ), Codop_rd_rs_imd );
|
||||
|
||||
}
|
||||
return (gethtitem (type_hashpt, str));
|
||||
}
|
||||
|
||||
static int searchvalu (str)
|
||||
|
||||
char *str;
|
||||
{
|
||||
extern char *mips_allocstr () ;
|
||||
static ht *valu_hashpt = NULL;
|
||||
|
||||
if (valu_hashpt == NULL)
|
||||
{
|
||||
valu_hashpt = addht (128);
|
||||
|
||||
addhtitem (valu_hashpt, mips_allocstr ("zero" ), 0 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("at" ), 1 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("v0" ), 2 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("v1" ), 3 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("a0" ), 4 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("a1" ), 5 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("a2" ), 6 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("a3" ), 7 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t0" ), 8 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t1" ), 9 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t2" ), 10 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t3" ), 11 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t4" ), 12 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t5" ), 13 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t6" ), 14 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t7" ), 15 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s0" ), 16 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s1" ), 17 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s2" ), 18 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s3" ), 19 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s4" ), 20 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s5" ), 21 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s6" ), 22 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s7" ), 23 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t8" ), 24 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("t9" ), 25 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("k0" ), 26 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("k1" ), 27 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("gp" ), 28 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sp" ), 29 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("s8" ), 30 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("ra" ), 31 );
|
||||
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r0" ), 0 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r1" ), 1 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r2" ), 2 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r3" ), 3 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r4" ), 4 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r5" ), 5 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r6" ), 6 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r7" ), 7 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r8" ), 8 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r9" ), 9 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r10" ), 10 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r11" ), 11 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r12" ), 12 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r13" ), 13 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r14" ), 14 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r15" ), 15 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r16" ), 16 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r17" ), 17 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r18" ), 18 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r19" ), 19 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r20" ), 20 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r21" ), 21 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r22" ), 22 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r23" ), 23 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r24" ), 24 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r25" ), 25 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r26" ), 26 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r27" ), 27 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r28" ), 28 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r29" ), 29 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r30" ), 30 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("r31" ), 31 );
|
||||
|
||||
addhtitem (valu_hashpt, mips_allocstr ("badvaddr"), _BADVADDR);
|
||||
addhtitem (valu_hashpt, mips_allocstr ("status" ), _STATUS );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("cause" ), _CAUSE );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("epc" ), _EPC );
|
||||
|
||||
addhtitem (valu_hashpt, mips_allocstr (".align" ), _ALIGN );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".ascii" ), _ASCII );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".asciiz" ), _ASCIIZ );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".byte" ), _BYTE );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".bytez" ), _BYTEZ );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".data" ), _DATA );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".end" ), _END );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".equ" ), _EQU );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".global" ), _GLOBAL );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".org" ), _ORG );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".skip" ), _SKIP );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".space" ), _SPACE );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".start" ), _START );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".text" ), _TEXT );
|
||||
addhtitem (valu_hashpt, mips_allocstr (".word" ), _WORD );
|
||||
|
||||
addhtitem (valu_hashpt, mips_allocstr ("nop" ), _NOP );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("loadi" ), _LOADI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("la" ), _LOADI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("li" ), _LOADI );
|
||||
|
||||
addhtitem (valu_hashpt, mips_allocstr ("add" ), _ADD );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("addi" ), _ADDI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("addu" ), _ADDU );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("addiu" ), _ADDIU );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("and" ), _AND );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("andi" ), _ANDI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("beq" ), _BEQ );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("bgez" ), _BGEZ );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("bgezal" ), _BGEZAL );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("bgtz" ), _BGTZ );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("blez" ), _BLEZ );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("bltz" ), _BLTZ );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("bltzal" ), _BLTZAL );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("bne" ), _BNE );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("break" ), _BREAK );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("j" ), _J );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("jal" ), _JAL );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("jalr" ), _JALR );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("jr" ), _JR );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("lb" ), _LB );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("lbu" ), _LBU );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("lh" ), _LH );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("lhu" ), _LHU );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("lui" ), _LUI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("lw" ), _LW );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("mfc0" ), _MFC0 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("mfhi" ), _MFHI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("mflo" ), _MFLO );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("mtc0" ), _MTC0 );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("mthi" ), _MTHI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("mtlo" ), _MTLO );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("nor" ), _NOR );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("or" ), _OR );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("ori" ), _ORI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("rfe" ), _RSTFE );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sb" ), _SB );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sh" ), _SH );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sleep" ), _SLEEP );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sll" ), _SLL );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sllv" ), _SLLV );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("slt" ), _SLT );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("slti" ), _SLTI );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sltiu" ), _SLTIU );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sltu" ), _SLTU );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sra" ), _SRA );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("srav" ), _SRAV );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("srl" ), _SRL );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("srlv" ), _SRLV );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sub" ), _SUB );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("subu" ), _SUBU );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("sw" ), _SW );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("swap" ), _SWAP );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("syscall" ), _SYSCALL );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("xor" ), _XOR );
|
||||
addhtitem (valu_hashpt, mips_allocstr ("xori" ), _XORI );
|
||||
|
||||
}
|
||||
return (gethtitem (valu_hashpt, str));
|
||||
}
|
||||
|
||||
static unsigned long hextoint (str)
|
||||
|
||||
char *str;
|
||||
|
||||
{
|
||||
unsigned long valu = 0;
|
||||
char c = 0;
|
||||
|
||||
while ((c = *str) != '\0')
|
||||
{
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
valu = (valu << 4) + c - '0';
|
||||
else
|
||||
if ((c >= 'a') && (c <= 'f'))
|
||||
valu = (valu << 4) + c - 'a' + 10;
|
||||
else
|
||||
if ((c >= 'A') && (c <= 'F'))
|
||||
valu = (valu << 4) + c - 'A' + 10;
|
||||
str++;
|
||||
}
|
||||
|
||||
return (valu);
|
||||
}
|
||||
|
||||
static unsigned long octtoint (str)
|
||||
|
||||
char *str;
|
||||
|
||||
{
|
||||
unsigned long valu = 0;
|
||||
char c = 0;
|
||||
|
||||
while ((c = *str) != '\0')
|
||||
{
|
||||
if ((c >= '0') && (c <= '7'))
|
||||
valu = (valu << 3) + c - '0';
|
||||
|
||||
str++;
|
||||
}
|
||||
|
||||
return (valu);
|
||||
}
|
||||
|
||||
static unsigned long bintoint (str)
|
||||
|
||||
char *str;
|
||||
|
||||
{
|
||||
unsigned long valu = 0;
|
||||
char c = 0;
|
||||
|
||||
while ((c = *str) != '\0')
|
||||
{
|
||||
if ((c == '0') || (c == '1'))
|
||||
valu = (valu << 1) + c - '0';
|
||||
|
||||
str++;
|
||||
}
|
||||
|
||||
return (valu);
|
||||
}
|
||||
|
||||
int yywrap ()
|
||||
{
|
||||
return (1);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* This file is part of the Alliance CAD System
|
||||
* Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
* Universite Pierre et Marie Curie
|
||||
*
|
||||
* Home page : http://www-asim.lip6.fr/alliance/
|
||||
* E-mail : mailto:alliance-users@asim.lip6.fr
|
||||
*
|
||||
* This progam 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Alliance VLSI CAD System 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 the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* file : mips_lex.h */
|
||||
/* date : Apr 20 1995 */
|
||||
/* version : v0.0 */
|
||||
/* author : Pirouz BAZARGAN SABET */
|
||||
/* description : MIPS assembler - external and static variables and */
|
||||
/* functions */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
extern int MPS_LINNUM ;
|
||||
|
||||
static unsigned long hextoint ();
|
||||
static unsigned long octtoint ();
|
||||
static unsigned long bintoint ();
|
||||
|
||||
static int searchtype ();
|
||||
static int searchvalu ();
|
||||
extern int yywrap ();
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of the Alliance CAD System
|
||||
* Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
* Universite Pierre et Marie Curie
|
||||
*
|
||||
* Home page : http://www-asim.lip6.fr/alliance/
|
||||
* E-mail : mailto:alliance-users@asim.lip6.fr
|
||||
*
|
||||
* This progam 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Alliance VLSI CAD System 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 the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* file : mips_type.h */
|
||||
/* date : Apr 20 1995 */
|
||||
/* version : v0.0 */
|
||||
/* author : Pirouz BAZARGAN SABET */
|
||||
/* content : types used by the assmbler */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
struct immd
|
||||
{
|
||||
unsigned long valu;
|
||||
char flag;
|
||||
};
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* This file is part of the Alliance CAD System
|
||||
* Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
* Universite Pierre et Marie Curie
|
||||
*
|
||||
* Home page : http://www-asim.lip6.fr/alliance/
|
||||
* E-mail : mailto:alliance-users@asim.lip6.fr
|
||||
*
|
||||
* This progam 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Alliance VLSI CAD System 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 the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* file : mips_util.c */
|
||||
/* date : Sep 2 1994 */
|
||||
/* version : v0.0 */
|
||||
/* author : Pirouz BAZARGAN SABET & Julien DUNOYER */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "mut.h"
|
||||
#include "log.h"
|
||||
#include "beh.h"
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mips_allocstr */
|
||||
/* description : make a memory allocation for a string. This function */
|
||||
/* insures that for a given string there will be a */
|
||||
/* unique memory allocation */
|
||||
/* called func. : none */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
char *mips_allocstr (src_str)
|
||||
|
||||
char *src_str; /* source string */
|
||||
|
||||
{
|
||||
static struct beden **lcl_dic = NULL;
|
||||
char *res_str = NULL;
|
||||
unsigned int cod1 = 0 ;
|
||||
unsigned int cod2 = 0 ;
|
||||
unsigned int size = 0 ;
|
||||
struct chain *chn_pnt = NULL;
|
||||
struct chain *str_lst = NULL;
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* initialize the local static dictionary */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
if (lcl_dic == NULL)
|
||||
lcl_dic = beh_initab ();
|
||||
|
||||
if (src_str != NULL)
|
||||
{
|
||||
/* ###------------------------------------------------------### */
|
||||
/* hash the source string. Two codes are produced to decrease*/
|
||||
/* conflict probability. */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
while (src_str [size] != '\0')
|
||||
{
|
||||
cod1 = (cod1 << 1) ^ (cod2 + (src_str [size] << (size % 8)));
|
||||
cod2 = (cod1 << 16) + (cod2 << 1) + src_str [size] ;
|
||||
size++;
|
||||
}
|
||||
size++;
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* extract from the dictionary the strings that have the */
|
||||
/* same first and second code and the same size */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
chn_pnt = (struct chain *) beh_chktab (lcl_dic, cod1, cod2, 7);
|
||||
str_lst = chn_pnt;
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* scan the list comparing the strings found in the list */
|
||||
/* with the source string. */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
while (chn_pnt != NULL)
|
||||
{
|
||||
if (!strcmp (chn_pnt->DATA, src_str))
|
||||
break;
|
||||
chn_pnt = chn_pnt->NEXT;
|
||||
}
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* if no string has been found, create a new string and add */
|
||||
/* it into the dictionary. */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
if (chn_pnt == NULL)
|
||||
{
|
||||
res_str = (char *) mbkalloc (size * sizeof (char));
|
||||
strcpy (res_str, src_str);
|
||||
chn_pnt = addchain (NULL, res_str);
|
||||
|
||||
if (str_lst != NULL)
|
||||
{
|
||||
chn_pnt->NEXT = str_lst->NEXT;
|
||||
str_lst->NEXT = chn_pnt ;
|
||||
}
|
||||
else
|
||||
beh_addtab (lcl_dic, cod1, cod2, 7, chn_pnt);
|
||||
}
|
||||
else
|
||||
res_str = (char *) chn_pnt->DATA;
|
||||
}
|
||||
|
||||
return (res_str);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* This file is part of the Alliance CAD System
|
||||
* Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
* Universite Pierre et Marie Curie
|
||||
*
|
||||
* Home page : http://www-asim.lip6.fr/alliance/
|
||||
* E-mail : mailto:alliance-users@asim.lip6.fr
|
||||
*
|
||||
* This progam 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Alliance VLSI CAD System 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 the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* file : mips_yacc.h */
|
||||
/* date : Dec 9 1999 */
|
||||
/* version : v0.3 */
|
||||
/* author : Pirouz BAZARGAN SABET */
|
||||
/* description : MIPS assembler - external and static variables and */
|
||||
/* functions */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
extern int MPS_LINNUM ;
|
||||
|
||||
static int MPS_PASNBR ;
|
||||
static int MPS_ERRFLG ;
|
||||
|
||||
static FILE *MPS_TXTFIL = NULL;
|
||||
static unsigned long MPS_TXTADR = 0 ;
|
||||
static int MPS_TXTSIZ = 0 ;
|
||||
|
||||
static FILE *MPS_DATFIL = NULL;
|
||||
static unsigned long MPS_DATADR = 0 ;
|
||||
static int MPS_DATSIZ = 0 ;
|
||||
|
||||
static char *MPS_LABEL = NULL;
|
||||
|
||||
static FILE *MPS_WRTFIL = NULL;
|
||||
static FILE *MPS_SYMFIL = NULL;
|
||||
|
||||
static unsigned long MPS_ADDRES ;
|
||||
static int MPS_ADRSIZ = 0 ;
|
||||
static int MPS_WRDSIZ = 0 ;
|
||||
static char MPS_ADRSPC = 'T' ;
|
||||
static char MPS_SYMBOL = 'n' ;
|
||||
static char MPS_DUMP = 'n' ;
|
||||
|
||||
static unsigned char MPS_BYTTAB [1024];
|
||||
|
||||
static struct beden **MPS_HSHTAB = NULL;
|
||||
|
||||
static void mips_error ();
|
||||
static void mips_head ();
|
||||
static void mips_foot ();
|
||||
static void mips_print ();
|
||||
static void mips_symbol ();
|
||||
static int mips_strtobin ();
|
Loading…
Reference in New Issue