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

📄 sparcopcode.java

📁 用Java实现的编译器。把源代码编译成SPARC汇编程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// $Id: SPARCOpcode.java,v 1.8 1999/12/13 15:10:10 deberg Exp $

package java6035.tools.ASM;

/**
 * SPARCOpcode	
 *
 * represents virtual SPARC opcodes.
 */

public class SPARCOpcode 
{
    /**
     * Returns the string representation of the opcode.
     */
    public static String getStringRep(int opcode)
    {
		return stringrep[opcode];
    }

    /**
     * Returns true if the opcode is a virtual SPARC opcode.
     */
    public static boolean isVirtual(int opcode)
    {
		return opcode == NOP; 
    }


    static String stringrep[] = {
	/* memory/register: 0 - 7 */
	"nop", "ld", "st", null,null, "mov", "sethi", null,

	/* computation operations: 8 - 63 */
	"add","addcc","addc","addccc",null, null, null, null,
	
	"sub", "subcc", "subc", "subccc", null, null, null, null,
	
	"and", "andcc", "andn", "andncc", "or", "orcc", "orn", "orncc", 
	
	"xor", "xorcc", "xnor", "xnorcc", null, null, null, null,
	
	"sll", "srl",  "sra", "sllx", "srlx", "srax", null, null,

	null, null, null, null, null, null, null, null,

	null, null, null, null, null, null, "sdiv", "smul",

	/* branch on integer condition codes: 64 - 81 */
    "b", "ba",   "bn",  "bne",  "be",   "bg",  "ble",  "bge", 
	
	"bl","bgu", "bleu", "bgeu", "blu", "bpos", "bneg", "bvc", 
	
	"bvs",

	/* jump operations: 82 - 87 */
	null, null, null, null, null, null, null,

	/* misc operations: 88 - 95 */
	"call", "save", "restore", "ret", "cmp", null, null, null};


    /* memory/register operations */

    /** nop */
    public static final int NOP = 0;
    /** nop */
    public static final int nop = NOP;
    /** nop */
    public static final SPARCInstruction nop_instr() {
		return new SPARCInstruction(nop,null,null,null);
    }
    public static final SPARCInstruction nop_instr(String c) {
		return new SPARCInstruction(nop,null,null,null,c);
    }

	/** ld */
    public static final int LD = 1;
    /** ld */
    public static final int ld = LD;
    /** ld */
    public static final SPARCInstruction ld_instr(SPARCAddress a, SPARCRegister d) {
		return new SPARCInstruction(ld,a, null,d);
    }
	
	/** st */
    public static final int ST = 2;
    /** st */
    public static final int st = ST;
    /** st */
    public static final SPARCInstruction st_instr( SPARCRegister s, SPARCAddress d) {
		return new SPARCInstruction(st,d, null,s);
    }

    /** mov src, Rdest */
    public static final int MOV = 5;
    /** mov src, Rdest,  */
    public static final int mov = MOV;
    /** mov src, Rdest, */
    public static final SPARCInstruction mov_instr(SPARCOperand s,SPARCRegister d) {
		return new SPARCInstruction(mov, s, null, d);
    }
    public static final SPARCInstruction mov_instr(SPARCRegister s, SPARCRegister d, String c) {
		return new SPARCInstruction(mov, s, null, d, c);
    }

    /** sethi Immed, Rdest */
    public static final int SETHI = 6;
	/** sethi Immed, Rdest */
    public static final int sethi = SETHI;
    /** sethi Immed, Rdest */
    public static final SPARCInstruction sethi_instr(SPARCImmed s,SPARCRegister d) {
		return new SPARCInstruction(sethi, s, null, d);
    }
    public static final SPARCInstruction sethi_instr(SPARCImmed s, SPARCRegister d, String c) {
		return new SPARCInstruction(sethi, s, null , d, c);
    }


    /* computation operations */

    /** add Rsrc1, Src2, Rdest */
    public static final int ADD = 8;
    /** add Rsrc1, Src2, Rdest */
    public static final int add = ADD;
    /** add Rsrc1, Src2, Rdest */
    public static final SPARCInstruction add_instr(SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(add, s1, s2, d);
    }

    /** addcc Rsrc1, Src2, Rdest */
    public static final int ADDCC = 9;
    /** addcc Rsrc1, Src2, Rdest  */
    public static final int addcc = ADDCC;
    /** addcc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction addcc_instr(SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(addcc, s1, s2, d);
    }

    /** addc Rsrc1, Src2, Rdest */
    public static final int ADDC = 10;
    /** addc Rsrc1, Src2, Rdest */
    public static final int addc = ADDC;
    /** addc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction addc_instr(SPARCRegister s1,	SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(addc, s1, s2, d);
    }
	
	
    /** addccc Rsrc1, Src2, Rdest */
    public static final int ADDCCC = 11;
    /** addccc Rsrc1, Src2, Rdest */
    public static final int addccc = ADDCCC;
    /** addccc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction addccc_instr(SPARCRegister s1,SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(addccc, s1, s2, d);
    }
   
    /** sub Rsrc1, Src2,  Rdest */
    public static final int SUB = 16;
    /** sub Rsrc1, Src2,  Rdest */
    public static final int sub = SUB;
    /** sub Rsrc1, Src2, Rdest */
    public static final SPARCInstruction sub_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(sub, s1, s2, d);
    }
	
	/** subcc Rsrc1, Src2, Rdest */
    public static final int SUBCC = 17;
    /** subcc Rsrc1, Src2, Rdest */
    public static final int subcc = SUBCC;
    /** subcc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction subcc_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(subcc, s1, s2, d);
    }

	/** subc Rsrc1, Src2, Rdest */
    public static final int SUBC = 18;
    /** subc Rsrc1, Src2, Rdest */
    public static final int subc = SUBC;
    /** subc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction subc_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(subc, s1, s2, d);
    }
	
	/** subccc Rsrc1, Src2, Rdest */
    public static final int SUBCCC = 19;
    /** subccc Rsrc1, Src2, Rdest */
    public static final int subccc = SUBCCC;
    /** subccc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction subccc_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(subccc, s1, s2, d);
    }
   
    /** and Rsrc1, Src2, Rdest */
    public static final int AND = 24;
    /** and Rsrc1, Src2, Rdest */
    public static final int and = AND;
    /** and Rsrc1, Src2, Rdest */
    public static final SPARCInstruction and_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(and, s1, s2,d );
    }
	
	/** andcc Rsrc1, Src2,  Rdest */
    public static final int ANDCC = 25;
    /** andcc Rsrc1, Src2,  Rdest */
    public static final int andcc = ANDCC;
    /** andcc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction andcc_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(andcc, s1, s2,d );
    }
	
	/** andn Rsrc1, Src2, Rdest */
    public static final int ANDN = 26;
    /** andn Rsrc1, Src2, Rdest */
    public static final int andn = ANDN;
    /** andn Rsrc1, Src2, Rdest */
    public static final SPARCInstruction andn_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(andn, s1, s2,d );
    }
	
	/** andncc Rsrc1, Src2. Rdest */
    public static final int ANDNCC = 27;
    /** andncc Rsrc1, Src2, Rdest */
    public static final int andncc = ANDNCC;
    /** andncc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction andncc_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(andncc, s1, s2,d );
    }

    /** or Rsrc1, Src2, Rdest */
    public static final int OR = 28;
    /** or Rsrc1, Src2, Rdest */
    public static final int or = OR;
    /** or Rsrc1, Src2, Rdest */
    public static final SPARCInstruction or_instr( SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(or, s1, s2, d);
    }
	
	/** or Rsrc1, Src2, Rdest */
    public static final int ORCC = 29;
    /** or Rsrc1, Src2, Rdest */
    public static final int orcc = ORCC;
    /** or Rsrc1, Src2, Rdest */
    public static final SPARCInstruction orcc_instr( SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(orcc, s1, s2, d);
    }

    /** nor Rsrc1, Src2, Rdest */
    public static final int ORN = 30;
    /** nor Rsrc1, Src2, Rdest */
    public static final int orn = ORN;
    /** nor Rsrc1, Src2, Rdest */
    public static final SPARCInstruction orn_instr(SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(orn, s1, s2, d);
    }
	
	/** nor Rsrc1, Src2, Rdest */
    public static final int ORNCC = 31;
    /** nor Rsrc1, Src2, Rdest */
    public static final int orncc = ORNCC;
    /** nor Rsrc1, Src2, Rdest */
    public static final SPARCInstruction orncc_instr(SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(orncc, s1, s2, d);
    }

    /** xor Rsrc1, Src2,  Rdest */
    public static final int XOR = 32;
    /** xor Rsrc1, Src2, Rdest */
    public static final int xor = XOR;
    /** xor Rsrc1, Src2, Rdest */
    public static final SPARCInstruction xor_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(xor, s1, s2, d);
    }
	
	/** xorcc Rsrc1, Src2, Rdest */
    public static final int XORCC = 33;
    /** xorcc Rsrc1, Src2, Rdest */
    public static final int xorcc = XORCC;
    /** xorcc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction xorcc_instr( SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(xorcc, s1, s2, d);
    }

    /** xnor Rsrc1, Src2, Rdest */
    public static final int XNOR = 34;
    /** xnor Rsrc1, Src2, Rdest */
    public static final int xnor = XNOR;
    /** xnor Rsrc1, Src2, Rdest */
    public static final SPARCInstruction xnor_instr(SPARCRegister s1, SPARCOperand s2,SPARCRegister d) {
		return new SPARCInstruction(xnor, s1, s2, d);
    }
	
	/** xnorcc Rsrc1, Src2, Rdest */
    public static final int XNORCC = 35;
    /** xnorcc Rsrc1, Src2, Rdest */
    public static final int xnorcc = XNORCC;
    /** xnorcc Rsrc1, Src2, Rdest */
    public static final SPARCInstruction xnorcc_instr( SPARCRegister s1, SPARCOperand s2, SPARCRegister d) {
		return new SPARCInstruction(xnorcc, s1, s2, d);
    }

    /** not Rdest, Rsrc1 */
    public static final int NOT = 28;
    /** not Rdest, Rsrc1 */

⌨️ 快捷键说明

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