1*a47a12beSStefan Roese /* 2*a47a12beSStefan Roese * (C) Copyright 2002 3*a47a12beSStefan Roese * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4*a47a12beSStefan Roese * 5*a47a12beSStefan Roese * See file CREDITS for list of people who contributed to this 6*a47a12beSStefan Roese * project. 7*a47a12beSStefan Roese * 8*a47a12beSStefan Roese * This program is free software; you can redistribute it and/or 9*a47a12beSStefan Roese * modify it under the terms of the GNU General Public License as 10*a47a12beSStefan Roese * published by the Free Software Foundation; either version 2 of 11*a47a12beSStefan Roese * the License, or (at your option) any later version. 12*a47a12beSStefan Roese * 13*a47a12beSStefan Roese * This program is distributed in the hope that it will be useful, 14*a47a12beSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of 15*a47a12beSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*a47a12beSStefan Roese * GNU General Public License for more details. 17*a47a12beSStefan Roese * 18*a47a12beSStefan Roese * You should have received a copy of the GNU General Public License 19*a47a12beSStefan Roese * along with this program; if not, write to the Free Software 20*a47a12beSStefan Roese * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21*a47a12beSStefan Roese * MA 02111-1307 USA 22*a47a12beSStefan Roese */ 23*a47a12beSStefan Roese #ifndef _CPU_ASM_H 24*a47a12beSStefan Roese #define _CPU_ASM_H 25*a47a12beSStefan Roese 26*a47a12beSStefan Roese #define BIT_C 0x00000001 27*a47a12beSStefan Roese 28*a47a12beSStefan Roese #define OP_BLR 0x4e800020 29*a47a12beSStefan Roese #define OP_EXTSB 0x7c000774 30*a47a12beSStefan Roese #define OP_EXTSH 0x7c000734 31*a47a12beSStefan Roese #define OP_NEG 0x7c0000d0 32*a47a12beSStefan Roese #define OP_CNTLZW 0x7c000034 33*a47a12beSStefan Roese #define OP_ADD 0x7c000214 34*a47a12beSStefan Roese #define OP_ADDC 0x7c000014 35*a47a12beSStefan Roese #define OP_ADDME 0x7c0001d4 36*a47a12beSStefan Roese #define OP_ADDZE 0x7c000194 37*a47a12beSStefan Roese #define OP_ADDE 0x7c000114 38*a47a12beSStefan Roese #define OP_ADDI 0x38000000 39*a47a12beSStefan Roese #define OP_SUBF 0x7c000050 40*a47a12beSStefan Roese #define OP_SUBFC 0x7c000010 41*a47a12beSStefan Roese #define OP_SUBFE 0x7c000110 42*a47a12beSStefan Roese #define OP_SUBFME 0x7c0001d0 43*a47a12beSStefan Roese #define OP_SUBFZE 0x7c000190 44*a47a12beSStefan Roese #define OP_MFCR 0x7c000026 45*a47a12beSStefan Roese #define OP_MTCR 0x7c0ff120 46*a47a12beSStefan Roese #define OP_MFXER 0x7c0102a6 47*a47a12beSStefan Roese #define OP_MTXER 0x7c0103a6 48*a47a12beSStefan Roese #define OP_MCRXR 0x7c000400 49*a47a12beSStefan Roese #define OP_MCRF 0x4c000000 50*a47a12beSStefan Roese #define OP_CRAND 0x4c000202 51*a47a12beSStefan Roese #define OP_CRANDC 0x4c000102 52*a47a12beSStefan Roese #define OP_CROR 0x4c000382 53*a47a12beSStefan Roese #define OP_CRORC 0x4c000342 54*a47a12beSStefan Roese #define OP_CRXOR 0x4c000182 55*a47a12beSStefan Roese #define OP_CRNAND 0x4c0001c2 56*a47a12beSStefan Roese #define OP_CRNOR 0x4c000042 57*a47a12beSStefan Roese #define OP_CREQV 0x4c000242 58*a47a12beSStefan Roese #define OP_CMPW 0x7c000000 59*a47a12beSStefan Roese #define OP_CMPLW 0x7c000040 60*a47a12beSStefan Roese #define OP_CMPWI 0x2c000000 61*a47a12beSStefan Roese #define OP_CMPLWI 0x28000000 62*a47a12beSStefan Roese #define OP_MULLW 0x7c0001d6 63*a47a12beSStefan Roese #define OP_MULHW 0x7c000096 64*a47a12beSStefan Roese #define OP_MULHWU 0x7c000016 65*a47a12beSStefan Roese #define OP_DIVW 0x7c0003d6 66*a47a12beSStefan Roese #define OP_DIVWU 0x7c000396 67*a47a12beSStefan Roese #define OP_OR 0x7c000378 68*a47a12beSStefan Roese #define OP_ORC 0x7c000338 69*a47a12beSStefan Roese #define OP_XOR 0x7c000278 70*a47a12beSStefan Roese #define OP_NAND 0x7c0003b8 71*a47a12beSStefan Roese #define OP_NOR 0x7c0000f8 72*a47a12beSStefan Roese #define OP_EQV 0x7c000238 73*a47a12beSStefan Roese #define OP_SLW 0x7c000030 74*a47a12beSStefan Roese #define OP_SRW 0x7c000430 75*a47a12beSStefan Roese #define OP_SRAW 0x7c000630 76*a47a12beSStefan Roese #define OP_ORI 0x60000000 77*a47a12beSStefan Roese #define OP_ORIS 0x64000000 78*a47a12beSStefan Roese #define OP_XORI 0x68000000 79*a47a12beSStefan Roese #define OP_XORIS 0x6c000000 80*a47a12beSStefan Roese #define OP_ANDI_ 0x70000000 81*a47a12beSStefan Roese #define OP_ANDIS_ 0x74000000 82*a47a12beSStefan Roese #define OP_SRAWI 0x7c000670 83*a47a12beSStefan Roese #define OP_RLWINM 0x54000000 84*a47a12beSStefan Roese #define OP_RLWNM 0x5c000000 85*a47a12beSStefan Roese #define OP_RLWIMI 0x50000000 86*a47a12beSStefan Roese #define OP_LWZ 0x80000000 87*a47a12beSStefan Roese #define OP_LHZ 0xa0000000 88*a47a12beSStefan Roese #define OP_LHA 0xa8000000 89*a47a12beSStefan Roese #define OP_LBZ 0x88000000 90*a47a12beSStefan Roese #define OP_LWZU 0x84000000 91*a47a12beSStefan Roese #define OP_LHZU 0xa4000000 92*a47a12beSStefan Roese #define OP_LHAU 0xac000000 93*a47a12beSStefan Roese #define OP_LBZU 0x8c000000 94*a47a12beSStefan Roese #define OP_LWZX 0x7c00002e 95*a47a12beSStefan Roese #define OP_LHZX 0x7c00022e 96*a47a12beSStefan Roese #define OP_LHAX 0x7c0002ae 97*a47a12beSStefan Roese #define OP_LBZX 0x7c0000ae 98*a47a12beSStefan Roese #define OP_LWZUX 0x7c00006e 99*a47a12beSStefan Roese #define OP_LHZUX 0x7c00026e 100*a47a12beSStefan Roese #define OP_LHAUX 0x7c0002ee 101*a47a12beSStefan Roese #define OP_LBZUX 0x7c0000ee 102*a47a12beSStefan Roese #define OP_STW 0x90000000 103*a47a12beSStefan Roese #define OP_STH 0xb0000000 104*a47a12beSStefan Roese #define OP_STB 0x98000000 105*a47a12beSStefan Roese #define OP_STWU 0x94000000 106*a47a12beSStefan Roese #define OP_STHU 0xb4000000 107*a47a12beSStefan Roese #define OP_STBU 0x9c000000 108*a47a12beSStefan Roese #define OP_STWX 0x7c00012e 109*a47a12beSStefan Roese #define OP_STHX 0x7c00032e 110*a47a12beSStefan Roese #define OP_STBX 0x7c0001ae 111*a47a12beSStefan Roese #define OP_STWUX 0x7c00016e 112*a47a12beSStefan Roese #define OP_STHUX 0x7c00036e 113*a47a12beSStefan Roese #define OP_STBUX 0x7c0001ee 114*a47a12beSStefan Roese #define OP_B 0x48000000 115*a47a12beSStefan Roese #define OP_BL 0x48000001 116*a47a12beSStefan Roese #define OP_BC 0x40000000 117*a47a12beSStefan Roese #define OP_BCL 0x40000001 118*a47a12beSStefan Roese #define OP_MTLR 0x7c0803a6 119*a47a12beSStefan Roese #define OP_MFLR 0x7c0802a6 120*a47a12beSStefan Roese #define OP_MTCTR 0x7c0903a6 121*a47a12beSStefan Roese #define OP_MFCTR 0x7c0902a6 122*a47a12beSStefan Roese #define OP_LMW 0xb8000000 123*a47a12beSStefan Roese #define OP_STMW 0xbc000000 124*a47a12beSStefan Roese #define OP_LSWI 0x7c0004aa 125*a47a12beSStefan Roese #define OP_LSWX 0x7c00042a 126*a47a12beSStefan Roese #define OP_STSWI 0x7c0005aa 127*a47a12beSStefan Roese #define OP_STSWX 0x7c00052a 128*a47a12beSStefan Roese 129*a47a12beSStefan Roese #define ASM_0(opcode) (opcode) 130*a47a12beSStefan Roese #define ASM_1(opcode, rd) ((opcode) + \ 131*a47a12beSStefan Roese ((rd) << 21)) 132*a47a12beSStefan Roese #define ASM_1C(opcode, cr) ((opcode) + \ 133*a47a12beSStefan Roese ((cr) << 23)) 134*a47a12beSStefan Roese #define ASM_11(opcode, rd, rs) ((opcode) + \ 135*a47a12beSStefan Roese ((rd) << 21) + \ 136*a47a12beSStefan Roese ((rs) << 16)) 137*a47a12beSStefan Roese #define ASM_11C(opcode, cd, cs) ((opcode) + \ 138*a47a12beSStefan Roese ((cd) << 23) + \ 139*a47a12beSStefan Roese ((cs) << 18)) 140*a47a12beSStefan Roese #define ASM_11X(opcode, rd, rs) ((opcode) + \ 141*a47a12beSStefan Roese ((rs) << 21) + \ 142*a47a12beSStefan Roese ((rd) << 16)) 143*a47a12beSStefan Roese #define ASM_11I(opcode, rd, rs, simm) ((opcode) + \ 144*a47a12beSStefan Roese ((rd) << 21) + \ 145*a47a12beSStefan Roese ((rs) << 16) + \ 146*a47a12beSStefan Roese ((simm) & 0xffff)) 147*a47a12beSStefan Roese #define ASM_11IF(opcode, rd, rs, simm) ((opcode) + \ 148*a47a12beSStefan Roese ((rd) << 21) + \ 149*a47a12beSStefan Roese ((rs) << 16) + \ 150*a47a12beSStefan Roese ((simm) << 11)) 151*a47a12beSStefan Roese #define ASM_11S(opcode, rd, rs, sh) ((opcode) + \ 152*a47a12beSStefan Roese ((rs) << 21) + \ 153*a47a12beSStefan Roese ((rd) << 16) + \ 154*a47a12beSStefan Roese ((sh) << 11)) 155*a47a12beSStefan Roese #define ASM_11IX(opcode, rd, rs, imm) ((opcode) + \ 156*a47a12beSStefan Roese ((rs) << 21) + \ 157*a47a12beSStefan Roese ((rd) << 16) + \ 158*a47a12beSStefan Roese ((imm) & 0xffff)) 159*a47a12beSStefan Roese #define ASM_12(opcode, rd, rs1, rs2) ((opcode) + \ 160*a47a12beSStefan Roese ((rd) << 21) + \ 161*a47a12beSStefan Roese ((rs1) << 16) + \ 162*a47a12beSStefan Roese ((rs2) << 11)) 163*a47a12beSStefan Roese #define ASM_12F(opcode, fd, fs1, fs2) ((opcode) + \ 164*a47a12beSStefan Roese ((fd) << 21) + \ 165*a47a12beSStefan Roese ((fs1) << 16) + \ 166*a47a12beSStefan Roese ((fs2) << 11)) 167*a47a12beSStefan Roese #define ASM_12X(opcode, rd, rs1, rs2) ((opcode) + \ 168*a47a12beSStefan Roese ((rs1) << 21) + \ 169*a47a12beSStefan Roese ((rd) << 16) + \ 170*a47a12beSStefan Roese ((rs2) << 11)) 171*a47a12beSStefan Roese #define ASM_2C(opcode, cr, rs1, rs2) ((opcode) + \ 172*a47a12beSStefan Roese ((cr) << 23) + \ 173*a47a12beSStefan Roese ((rs1) << 16) + \ 174*a47a12beSStefan Roese ((rs2) << 11)) 175*a47a12beSStefan Roese #define ASM_1IC(opcode, cr, rs, imm) ((opcode) + \ 176*a47a12beSStefan Roese ((cr) << 23) + \ 177*a47a12beSStefan Roese ((rs) << 16) + \ 178*a47a12beSStefan Roese ((imm) & 0xffff)) 179*a47a12beSStefan Roese #define ASM_122(opcode, rd, rs1, rs2, imm1, imm2) \ 180*a47a12beSStefan Roese ((opcode) + \ 181*a47a12beSStefan Roese ((rs1) << 21) + \ 182*a47a12beSStefan Roese ((rd) << 16) + \ 183*a47a12beSStefan Roese ((rs2) << 11) + \ 184*a47a12beSStefan Roese ((imm1) << 6) + \ 185*a47a12beSStefan Roese ((imm2) << 1)) 186*a47a12beSStefan Roese #define ASM_113(opcode, rd, rs, imm1, imm2, imm3) \ 187*a47a12beSStefan Roese ((opcode) + \ 188*a47a12beSStefan Roese ((rs) << 21) + \ 189*a47a12beSStefan Roese ((rd) << 16) + \ 190*a47a12beSStefan Roese ((imm1) << 11) + \ 191*a47a12beSStefan Roese ((imm2) << 6) + \ 192*a47a12beSStefan Roese ((imm3) << 1)) 193*a47a12beSStefan Roese #define ASM_1O(opcode, off) ((opcode) + (off)) 194*a47a12beSStefan Roese #define ASM_3O(opcode, bo, bi, off) ((opcode) + \ 195*a47a12beSStefan Roese ((bo) << 21) + \ 196*a47a12beSStefan Roese ((bi) << 16) + \ 197*a47a12beSStefan Roese (off)) 198*a47a12beSStefan Roese 199*a47a12beSStefan Roese #define ASM_ADDI(rd, rs, simm) ASM_11I(OP_ADDI, rd, rs, simm) 200*a47a12beSStefan Roese #define ASM_BLR ASM_0(OP_BLR) 201*a47a12beSStefan Roese #define ASM_STW(rd, rs, simm) ASM_11I(OP_STW, rd, rs, simm) 202*a47a12beSStefan Roese #define ASM_LWZ(rd, rs, simm) ASM_11I(OP_LWZ, rd, rs, simm) 203*a47a12beSStefan Roese #define ASM_MFCR(rd) ASM_1(OP_MFCR, rd) 204*a47a12beSStefan Roese #define ASM_MTCR(rd) ASM_1(OP_MTCR, rd) 205*a47a12beSStefan Roese #define ASM_MFXER(rd) ASM_1(OP_MFXER, rd) 206*a47a12beSStefan Roese #define ASM_MTXER(rd) ASM_1(OP_MTXER, rd) 207*a47a12beSStefan Roese #define ASM_MFCTR(rd) ASM_1(OP_MFCTR, rd) 208*a47a12beSStefan Roese #define ASM_MTCTR(rd) ASM_1(OP_MTCTR, rd) 209*a47a12beSStefan Roese #define ASM_MCRXR(cr) ASM_1C(OP_MCRXR, cr) 210*a47a12beSStefan Roese #define ASM_MCRF(cd, cs) ASM_11C(OP_MCRF, cd, cs) 211*a47a12beSStefan Roese #define ASM_B(off) ASM_1O(OP_B, off) 212*a47a12beSStefan Roese #define ASM_BL(off) ASM_1O(OP_BL, off) 213*a47a12beSStefan Roese #define ASM_MFLR(rd) ASM_1(OP_MFLR, rd) 214*a47a12beSStefan Roese #define ASM_MTLR(rd) ASM_1(OP_MTLR, rd) 215*a47a12beSStefan Roese #define ASM_LI(rd, imm) ASM_ADDI(rd, 0, imm) 216*a47a12beSStefan Roese #define ASM_LMW(rd, rs, simm) ASM_11I(OP_LMW, rd, rs, simm) 217*a47a12beSStefan Roese #define ASM_STMW(rd, rs, simm) ASM_11I(OP_STMW, rd, rs, simm) 218*a47a12beSStefan Roese #define ASM_LSWI(rd, rs, simm) ASM_11IF(OP_LSWI, rd, rs, simm) 219*a47a12beSStefan Roese #define ASM_LSWX(rd, rs1, rs2) ASM_12(OP_LSWX, rd, rs1, rs2) 220*a47a12beSStefan Roese #define ASM_STSWI(rd, rs, simm) ASM_11IF(OP_STSWI, rd, rs, simm) 221*a47a12beSStefan Roese #define ASM_STSWX(rd, rs1, rs2) ASM_12(OP_STSWX, rd, rs1, rs2) 222*a47a12beSStefan Roese 223*a47a12beSStefan Roese 224*a47a12beSStefan Roese #endif /* _CPU_ASM_H */ 225