153024Sbostic /*- 2*63217Sbostic * Copyright (c) 1992, 1993 3*63217Sbostic * The Regents of the University of California. All rights reserved. 453024Sbostic * 553024Sbostic * This code is derived from software contributed to Berkeley by 653024Sbostic * Ralph Campbell. 753024Sbostic * 853024Sbostic * %sccs.include.redist.c% 953024Sbostic * 10*63217Sbostic * @(#)mips_opcode.h 8.1 (Berkeley) 06/10/93 1153024Sbostic */ 1253024Sbostic 1353024Sbostic /* 1453024Sbostic * Define the instruction formats and opcode values for the 1553024Sbostic * MIPS instruction set. 1653024Sbostic */ 1753024Sbostic 1853024Sbostic /* 1953024Sbostic * Define the instruction formats. 2053024Sbostic */ 2153024Sbostic typedef union { 2253024Sbostic unsigned word; 2353024Sbostic 2453024Sbostic #if BYTE_ORDER == LITTLE_ENDIAN 2553024Sbostic struct { 2653024Sbostic unsigned imm: 16; 2753024Sbostic unsigned rt: 5; 2853024Sbostic unsigned rs: 5; 2953024Sbostic unsigned op: 6; 3053024Sbostic } IType; 3153024Sbostic 3253024Sbostic struct { 3353024Sbostic unsigned target: 26; 3453024Sbostic unsigned op: 6; 3553024Sbostic } JType; 3653024Sbostic 3753024Sbostic struct { 3853024Sbostic unsigned func: 6; 3953024Sbostic unsigned shamt: 5; 4053024Sbostic unsigned rd: 5; 4153024Sbostic unsigned rt: 5; 4253024Sbostic unsigned rs: 5; 4353024Sbostic unsigned op: 6; 4453024Sbostic } RType; 4553024Sbostic 4653024Sbostic struct { 4753024Sbostic unsigned func: 6; 4853024Sbostic unsigned fd: 5; 4953024Sbostic unsigned fs: 5; 5053024Sbostic unsigned ft: 5; 5153024Sbostic unsigned fmt: 4; 5253024Sbostic unsigned : 1; /* always '1' */ 5353024Sbostic unsigned op: 6; /* always '0x11' */ 5453024Sbostic } FRType; 5553024Sbostic #endif 5653024Sbostic } InstFmt; 5753024Sbostic 5853024Sbostic /* 5953024Sbostic * Values for the 'op' field. 6053024Sbostic */ 6153024Sbostic #define OP_SPECIAL 000 6253024Sbostic #define OP_BCOND 001 6353024Sbostic #define OP_J 002 6453024Sbostic #define OP_JAL 003 6553024Sbostic #define OP_BEQ 004 6653024Sbostic #define OP_BNE 005 6753024Sbostic #define OP_BLEZ 006 6853024Sbostic #define OP_BGTZ 007 6953024Sbostic 7053024Sbostic #define OP_ADDI 010 7153024Sbostic #define OP_ADDIU 011 7253024Sbostic #define OP_SLTI 012 7353024Sbostic #define OP_SLTIU 013 7453024Sbostic #define OP_ANDI 014 7553024Sbostic #define OP_ORI 015 7653024Sbostic #define OP_XORI 016 7753024Sbostic #define OP_LUI 017 7853024Sbostic 7953024Sbostic #define OP_COP0 020 8053024Sbostic #define OP_COP1 021 8153024Sbostic #define OP_COP2 022 8253024Sbostic #define OP_COP3 023 8353024Sbostic 8453024Sbostic #define OP_LB 040 8553024Sbostic #define OP_LH 041 8653024Sbostic #define OP_LWL 042 8753024Sbostic #define OP_LW 043 8853024Sbostic #define OP_LBU 044 8953024Sbostic #define OP_LHU 045 9053024Sbostic #define OP_LWR 046 9153024Sbostic 9253024Sbostic #define OP_SB 050 9353024Sbostic #define OP_SH 051 9453024Sbostic #define OP_SWL 052 9553024Sbostic #define OP_SW 053 9653024Sbostic #define OP_SWR 056 9753024Sbostic 9853024Sbostic #define OP_LWC0 060 9953024Sbostic #define OP_LWC1 061 10053024Sbostic #define OP_LWC2 062 10153024Sbostic #define OP_LWC3 063 10253024Sbostic 10353024Sbostic #define OP_SWC0 070 10453024Sbostic #define OP_SWC1 071 10553024Sbostic #define OP_SWC2 072 10653024Sbostic #define OP_SWC3 073 10753024Sbostic 10853024Sbostic /* 10953024Sbostic * Values for the 'func' field when 'op' == OP_SPECIAL. 11053024Sbostic */ 11153024Sbostic #define OP_SLL 000 11253024Sbostic #define OP_SRL 002 11353024Sbostic #define OP_SRA 003 11453024Sbostic #define OP_SLLV 004 11553024Sbostic #define OP_SRLV 006 11653024Sbostic #define OP_SRAV 007 11753024Sbostic 11853024Sbostic #define OP_JR 010 11953024Sbostic #define OP_JALR 011 12053024Sbostic #define OP_SYSCALL 014 12153024Sbostic #define OP_BREAK 015 12253024Sbostic 12353024Sbostic #define OP_MFHI 020 12453024Sbostic #define OP_MTHI 021 12553024Sbostic #define OP_MFLO 022 12653024Sbostic #define OP_MTLO 023 12753024Sbostic 12853024Sbostic #define OP_MULT 030 12953024Sbostic #define OP_MULTU 031 13053024Sbostic #define OP_DIV 032 13153024Sbostic #define OP_DIVU 033 13253024Sbostic 13353024Sbostic #define OP_ADD 040 13453024Sbostic #define OP_ADDU 041 13553024Sbostic #define OP_SUB 042 13653024Sbostic #define OP_SUBU 043 13753024Sbostic #define OP_AND 044 13853024Sbostic #define OP_OR 045 13953024Sbostic #define OP_XOR 046 14053024Sbostic #define OP_NOR 047 14153024Sbostic 14253024Sbostic #define OP_SLT 052 14353024Sbostic #define OP_SLTU 053 14453024Sbostic 14553024Sbostic /* 14653024Sbostic * Values for the 'func' field when 'op' == OP_BCOND. 14753024Sbostic */ 14853024Sbostic #define OP_BLTZ 000 14953024Sbostic #define OP_BGEZ 001 15053024Sbostic #define OP_BLTZAL 020 15153024Sbostic #define OP_BGEZAL 021 15253024Sbostic 15353024Sbostic /* 15453024Sbostic * Values for the 'rs' field when 'op' == OP_COPz. 15553024Sbostic */ 15653024Sbostic #define OP_MF 000 15753024Sbostic #define OP_MT 004 15853024Sbostic #define OP_BCx 010 15953024Sbostic #define OP_BCy 014 16053024Sbostic #define OP_CF 002 16153024Sbostic #define OP_CT 006 16253024Sbostic 16353024Sbostic /* 16453024Sbostic * Values for the 'rt' field when 'op' == OP_COPz. 16553024Sbostic */ 16653024Sbostic #define COPz_BC_TF_MASK 0x01 16753024Sbostic #define COPz_BC_TRUE 0x01 16853024Sbostic #define COPz_BC_FALSE 0x00 169