📄 c67-gen.c
字号:
(0 << 0)); //parallel } else if (strstr(s, "SPDP.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (0 << 13) | //src1 NA (xpath << 12) | //x cross path if opposite sides (0x2 << 6) | //opcode (0x8 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "DPSP.L") == s) { ALWAYS_ASSERT(C67_map_regs(b) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst ((C67_map_regn(b) + 1) << 18) | //src2 WEIRD CPU must specify odd reg for some reason (0 << 13) | //src1 NA (0 << 12) | //x cross path if opposite sides (0x9 << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "ADD.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x3 << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "SUB.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x7 << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "OR.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x7f << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "AND.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x7b << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "XOR.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x6f << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "ADDSP.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x10 << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "ADDDP.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x18 << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "SUBSP.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x11 << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "SUBDP.L") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x19 << 5) | //opcode (0x6 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "MPYSP.M") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x1c << 7) | //opcode (0x0 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "MPYDP.M") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (possible x path) (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x0e << 7) | //opcode (0x0 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "MPYI.M") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (C67_map_regn(a) << 13) | //src1 (cst5) (xpath << 12) | //x cross path if opposite sides (0x4 << 7) | //opcode (0x0 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "SHR.S") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x37 << 6) | //opcode (0x8 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "SHRU.S") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x27 << 6) | //opcode (0x8 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "SHL.S") == s) { xpath = C67_map_regs(b) ^ C67_map_regs(c); ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a)); C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(c) << 23) | //dst (C67_map_regn(b) << 18) | //src2 (C67_map_regn(a) << 13) | //src1 (xpath << 12) | //x cross path if opposite sides (0x33 << 6) | //opcode (0x8 << 2) | //opcode fixed (C67_map_regs(c) << 1) | //side of dest (0 << 0)); //parallel } else if (strstr(s, "||ADDK") == s) { xpath = 0; // no xpath required just use the side of the src/dst C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(b) << 23) | //dst (a << 07) | //scst16 (0x14 << 2) | //opcode fixed (C67_map_regs(b) << 1) | //side of dst (1 << 0)); //parallel } else if (strstr(s, "ADDK") == s) { xpath = 0; // no xpath required just use the side of the src/dst C67_g((0 << 29) | //creg (0 << 28) | //inv (C67_map_regn(b) << 23) | //dst (a << 07) | //scst16 (0x14 << 2) | //opcode fixed (C67_map_regs(b) << 1) | //side of dst (0 << 0)); //parallel } else if (strstr(s, "NOP") == s) { C67_g(((a - 1) << 13) | //no of cycles (0 << 0)); //parallel } else ALWAYS_ASSERT(FALSE);#ifdef ASSEMBLY_LISTING_C67 fprintf(f, " %s %d %d %d\n", s, a, b, c);#endif}//r=reg to load, fr=from reg, symbol for relocation, constantvoid C67_MVKL(int r, int fc){ C67_asm("MVKL.", fc, r, 0);}void C67_MVKH(int r, int fc){ C67_asm("MVKH.", fc, r, 0);}void C67_STB_SP_A0(int r){ C67_asm("STB.D *+SP[A0]", r, 0, 0); // STB r,*+SP[A0]}void C67_STH_SP_A0(int r){ C67_asm("STH.D *+SP[A0]", r, 0, 0); // STH r,*+SP[A0]}void C67_STW_SP_A0(int r){ C67_asm("STW.D *+SP[A0]", r, 0, 0); // STW r,*+SP[A0]}void C67_STB_PTR(int r, int r2){ C67_asm("STB.D *", r, r2, 0); // STB r, *r2}void C67_STH_PTR(int r, int r2){ C67_asm("STH.D *", r, r2, 0); // STH r, *r2}void C67_STW_PTR(int r, int r2){ C67_asm("STW.D *", r, r2, 0); // STW r, *r2}void C67_STW_PTR_PRE_INC(int r, int r2, int n){ C67_asm("STW.D +*", r, r2, n); // STW r, *+r2}void C67_PUSH(int r){ C67_asm("STW.D SP POST DEC", r, 0, 0); // STW r,*SP--}void C67_LDW_SP_A0(int r){ C67_asm("LDW.D *+SP[A0]", r, 0, 0); // LDW *+SP[A0],r}void C67_LDDW_SP_A0(int r){ C67_asm("LDDW.D *+SP[A0]", r, 0, 0); // LDDW *+SP[A0],r}void C67_LDH_SP_A0(int r){ C67_asm("LDH.D *+SP[A0]", r, 0, 0); // LDH *+SP[A0],r}void C67_LDB_SP_A0(int r){ C67_asm("LDB.D *+SP[A0]", r, 0, 0); // LDB *+SP[A0],r}void C67_LDHU_SP_A0(int r){ C67_asm("LDHU.D *+SP[A0]", r, 0, 0); // LDHU *+SP[A0],r}void C67_LDBU_SP_A0(int r){ C67_asm("LDBU.D *+SP[A0]", r, 0, 0); // LDBU *+SP[A0],r}void C67_LDW_PTR(int r, int r2){ C67_asm("LDW.D *", r, r2, 0); // LDW *r,r2}void C67_LDDW_PTR(int r, int r2){ C67_asm("LDDW.D *", r, r2, 0); // LDDW *r,r2}void C67_LDH_PTR(int r, int r2){ C67_asm("LDH.D *", r, r2, 0); // LDH *r,r2}void C67_LDB_PTR(int r, int r2){ C67_asm("LDB.D *", r, r2, 0); // LDB *r,r2}void C67_LDHU_PTR(int r, int r2){ C67_asm("LDHU.D *", r, r2, 0); // LDHU *r,r2}void C67_LDBU_PTR(int r, int r2){ C67_asm("LDBU.D *", r, r2, 0); // LDBU *r,r2}void C67_LDW_PTR_PRE_INC(int r, int r2){ C67_asm("LDW.D +*", r, r2, 0); // LDW *+r,r2}void C67_POP(int r){ C67_asm("LDW.D SP PRE INC", r, 0, 0); // LDW *++SP,r}void C67_POP_DW(int r){ C67_asm("LDDW.D SP PRE INC", r, 0, 0); // LDDW *++SP,r}void C67_CMPLT(int s1, int s2, int dst){ C67_asm("CMPLT.L1", s1, s2, dst);}void C67_CMPGT(int s1, int s2, int dst){ C67_asm("CMPGT.L1", s1, s2, dst);}void C67_CMPEQ(int s1, int s2, int dst){ C67_asm("CMPEQ.L1", s1, s2, dst);}void C67_CMPLTU(int s1, int s2, int dst){ C67_asm("CMPLTU.L1", s1, s2, dst);}void C67_CMPGTU(int s1, int s2, int dst){ C67_asm("CMPGTU.L1", s1, s2, dst);}void C67_CMPLTSP(int s1, int s2, int dst){ C67_asm("CMPLTSP.S1", s1, s2, dst);}void C67_CMPGTSP(int s1, int s2, int dst){ C67_asm("CMPGTSP.S1", s1, s2, dst);}void C67_CMPEQSP(int s1, int s2, int dst){ C67_asm("CMPEQSP.S1", s1, s2, dst);}void C67_CMPLTDP(int s1, int s2, int dst){ C67_asm("CMPLTDP.S1", s1, s2, dst);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -