Ghidra is a software reverse engineering (SRE) framework
Add R7 handling and remaining synthetic opcodes.
Alessandro Gatti551154e32f35
diff --git a/Ghidra/Processors/CP1600/data/languages/CP1600.slaspec b/Ghidra/Processors/CP1600/data/languages/CP1600.slaspecindex 6a0ec64694..1ccbe2e053 100644--- a/Ghidra/Processors/CP1600/data/languages/CP1600.slaspec+++ b/Ghidra/Processors/CP1600/data/languages/CP1600.slaspec@@ -157,35 +157,49 @@ define pcodeop SoftwareInterrupt;:ADD addr16, reg0_2 is opcode3_9=0x0058 & reg0_2 ; addr16 {local ptr:2 = addr16;addition(reg0_2, *:2 ptr);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:ADD@ impliedval16, reg0_2 is opcode6_9=0x000B & reg0_2 & impliedval16 {addition(reg0_2, impliedval16);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:ADCR reg0_2 is opcode3_9=0x0005 & reg0_2 {local oldC = zext(C);addition(reg0_2, oldC);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:ADDR reg3_5, reg0_2 is opcode6_9=0x0003 & reg3_5 & reg0_2 {addition(reg0_2, reg3_5);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:AND addr16, reg0_2 is opcode3_9=0x0070 & reg0_2 ; addr16 {local ptr:2 = addr16;reg0_2 = reg0_2 & *:2 ptr;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:AND@ impliedval16, reg0_2 is opcode6_9=0x000E & reg0_2 & impliedval16 {reg0_2 = reg0_2 & impliedval16;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:ANDR reg3_5, reg0_2 is opcode6_9=0x0006 & reg3_5 & reg0_2 {reg0_2 = reg0_2 & reg3_5;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:B^cc branchdest16 is (opcode6_9=0x0008 & cc) ... & branchdest16 {@@ -200,6 +214,13 @@ define pcodeop SoftwareInterrupt;C = 0;}+:CLRR reg0_2 is opcode6_9=0x0007 & reg0_2 & ((target0_2=0 & target3_5=0) | (target0_2=1 & target3_5=1) | (target0_2=2 & target3_5=2) | (target0_2=3 & target3_5=3) | (target0_2=4 & target3_5=4) | (target0_2=5 & target3_5=5) | (target0_2=6 & target3_5=6) | (target0_2=7 & target3_5=7)) {+ reg0_2 = 0;+ resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];+}+:CMP addr16, reg0_2 is opcode3_9=0x0068 & reg0_2 ; addr16 {local ptr:2 = addr16;comparison(reg0_2, *:2 ptr);@@ -216,11 +237,15 @@ define pcodeop SoftwareInterrupt;:COMR reg0_2 is opcode3_9=0x0003 & reg0_2 {reg0_2 = ~reg0_2;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:DECR reg0_2 is opcode3_9=0x0002 & reg0_2 {reg0_2 = reg0_2 - 1;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:DIS is opcode0_9=0x0003 {@@ -243,6 +268,8 @@ define pcodeop SoftwareInterrupt;:INCR reg0_2 is opcode3_9=0x0001 & reg0_2 {reg0_2 = reg0_2 + 1;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:J jmpdest16 is opcode0_9=0x0004 ; jump_type=0 & target24_25=3 & jmpdest16 {@@ -259,6 +286,11 @@ define pcodeop SoftwareInterrupt;goto jmpdest16;}+:JR reg3_5 is opcode6_9=0x0002 & reg3_5 & target0_2=7 {+ R7 = reg3_5;+ goto [R7];+}+:JSR reg24_25, jmpdest16 is opcode0_9=0x0004 ; jump_type=0 & reg24_25 & jmpdest16 {reg24_25 = inst_next;call jmpdest16;@@ -279,15 +311,21 @@ define pcodeop SoftwareInterrupt;:MOVR reg3_5, reg0_2 is opcode6_9=0x0002 & reg0_2 & reg3_5 {reg0_2 = reg3_5;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:MVI addr16, reg0_2 is opcode3_9=0x0050 & reg0_2 ; addr16 {local ptr:2 = addr16;reg0_2 = *(*:2 ptr);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:MVI@ impliedval16, reg0_2 is opcode6_9=0x000A & reg0_2 & impliedval16 {reg0_2 = impliedval16;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:MVO reg0_2, addr16 is opcode3_9=0x0048 & reg0_2 ; addr16 {@@ -295,11 +333,13 @@ define pcodeop SoftwareInterrupt;*ptr = reg0_2;}-:MVO@ reg0_2, reg3_5 is opcode6_9=0x0009 & reg0_2 & reg3_5 & target3_5 {+:MVO@ reg0_2, reg3_5 is opcode6_9=0x0009 & reg0_2 & reg3_5 {local ptr:2 = reg3_5;*ptr = reg0_2;- local target:2 = target3_5;- if ((target != 4) && (target != 5) && (target != 6)) goto inst_next;+ if ((®3_5 != &R4) && (®3_5 != &R5) && (®3_5 != &R6) && (®3_5 != &R7)) goto inst_next;+ if (®3_5 != &R7) goto <increment>;+ goto [R7];+<increment>reg3_5 = reg3_5 + 1;}@@ -316,6 +356,8 @@ define pcodeop SoftwareInterrupt;C = tmpC;O = tmpO;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:NOP is opcode1_9=0x001A {@@ -332,6 +374,8 @@ define pcodeop SoftwareInterrupt;:PULR reg0_2 is opcode6_9=0x000A & impliedval16 & reg0_2 & reg3_5=6 {reg0_2 = impliedval16;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:RSWD reg0_2 is opcode3_9=0x0007 & reg0_2 {@@ -355,14 +399,20 @@ define pcodeop SoftwareInterrupt;:SUB addr16, reg0_2 is opcode3_9=0x0060 & reg0_2 ; addr16 {local ptr:2 = addr16;subtraction(reg0_2, *:2 ptr);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SUB@ impliedval16, reg0_2 is opcode6_9=0x000C & reg0_2 & impliedval16 {subtraction(reg0_2, impliedval16);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SUBR reg3_5, reg0_2 is opcode6_9=0x0004 & reg3_5 & reg0_2 {subtraction(reg0_2, reg3_5);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:TCI is opcode0_9=0x0005 {@@ -377,16 +427,22 @@ define pcodeop SoftwareInterrupt;local ptr:2 = addr16;reg0_2 = reg0_2 ^ *:2 ptr;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:XOR@ impliedval16, reg0_2 is opcode6_9=0x000F & reg0_2 & impliedval16 {reg0_2 = reg0_2 ^ impliedval16;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:XORR reg3_5, reg0_2 is opcode6_9=0x0007 & reg3_5 & reg0_2 {reg0_2 = reg0_2 ^ reg3_5;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:RLC reg0_2, 1 is opcode3_9=0x000A & reg0_2 {@@ -396,6 +452,8 @@ define pcodeop SoftwareInterrupt;C = tmpC;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:RRC reg0_2, 1 is opcode3_9=0x000E & reg0_2 {@@ -405,6 +463,8 @@ define pcodeop SoftwareInterrupt;C = tmpC;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SAR reg0_2, 1 is opcode3_9=0x000D & reg0_2 {@@ -412,6 +472,8 @@ define pcodeop SoftwareInterrupt;reg0_2 = reg0_2 s>> 1;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SARC reg0_2, 1 is opcode3_9=0x000F & reg0_2 {@@ -421,6 +483,8 @@ define pcodeop SoftwareInterrupt;C = tmpC;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SLL reg0_2, 1 is opcode3_9=0x0009 & reg0_2 {@@ -428,6 +492,8 @@ define pcodeop SoftwareInterrupt;reg0_2 = reg0_2 << 1;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SLLC reg0_2, 1 is opcode3_9=0x000B & reg0_2 {@@ -437,6 +503,8 @@ define pcodeop SoftwareInterrupt;C = tmpC;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SLR reg0_2, 1 is opcode3_9=0x000C & reg0_2 {@@ -444,6 +512,8 @@ define pcodeop SoftwareInterrupt;reg0_2 = reg0_2 >> 1;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SWAP reg0_2, 1 is opcode3_9=0x0008 & reg0_2 {@@ -451,6 +521,8 @@ define pcodeop SoftwareInterrupt;local tmp = (reg0_2 << 8) & 0xFF00;reg0_2 = tmp | ((reg0_2 >> 8) & 0x00FF);S = tmpS;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}with : operation_size=1 {@@ -464,6 +536,8 @@ with : operation_size=1 {O = tmpO;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:RRC reg0_2, 2 is opcode3_9=0x000E & reg0_2 {@@ -475,13 +549,17 @@ with : operation_size=1 {O = tmpO;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SAR reg0_2, 2 is opcode3_9=0x000D & reg0_2 {local tmpS = (reg0_2 & 0x0200) != 0;reg0_2 = reg0_2 s>> 2;S = tmpS;- Z = reg0_2 == 0;+ Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SARC reg0_2, 2 is opcode3_9=0x000F & reg0_2 {@@ -493,6 +571,8 @@ with : operation_size=1 {O = tmpO;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SLL reg0_2, 2 is opcode3_9=0x0009 & reg0_2 {@@ -500,6 +580,8 @@ with : operation_size=1 {reg0_2 = reg0_2 << 2;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SLLC reg0_2, 2 is opcode3_9=0x000B & reg0_2 {@@ -511,30 +593,40 @@ with : operation_size=1 {O = tmpO;S = tmpS;Z = reg0_2 == 0;-}+ if (®0_2 != &R7) goto inst_next;+ goto [R7];+}:SLR reg0_2, 2 is opcode3_9=0x000C & reg0_2 {local tmpS = (reg0_2 & 0x0200) != 0;reg0_2 = reg0_2 >> 2;S = tmpS;Z = reg0_2 == 0;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SWAP reg0_2, 2 is opcode3_9=0x0008 & reg0_2 {local tmpS = (reg0_2 & 0x0080) != 0;reg0_2 = (reg0_2 << 8) | (reg0_2 & 0x00FF);S = tmpS;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}}:ADDI "#"imm16, reg0_2 is opcode3_9=0x005F & reg0_2 ; imm16 {addition(reg0_2, imm16);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:ANDI "#"imm16, reg0_2 is opcode3_9=0x0077 & reg0_2 ; imm16 {reg0_2 = reg0_2 & imm16;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:CMPI "#"imm16, reg0_2 is opcode3_9=0x006F & reg0_2 ; imm16 {@@ -543,43 +635,61 @@ with : operation_size=1 {:MVII "#"imm16, reg0_2 is opcode3_9=0x0057 & reg0_2 ; imm16 {reg0_2 = imm16;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SUBI "#"imm16, reg0_2 is opcode3_9=0x0067 & reg0_2 ; imm16 {subtraction(reg0_2, imm16);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:XORI "#"imm16, reg0_2 is opcode3_9=0x007F & reg0_2 ; imm16 {reg0_2 = reg0_2 ^ imm16;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}with : doublebyte=1 {:ADDI "#"splitimm16, reg0_2 is opcode3_9=0x005F & reg0_2 ; splitimm16 {addition(reg0_2, splitimm16);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:ANDI "#"splitimm16, reg0_2 is opcode3_9=0x0077 & reg0_2 ; splitimm16 {reg0_2 = reg0_2 & splitimm16;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:CMPI "#"splitimm16, reg0_2 is opcode3_9=0x006F & reg0_2 ; splitimm16 {comparison(reg0_2, splitimm16);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:MVII "#"splitimm16, reg0_2 is opcode3_9=0x0057 & reg0_2 ; splitimm16 {reg0_2 = splitimm16;+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:SUBI "#"splitimm16, reg0_2 is opcode3_9=0x0067 & reg0_2 ; splitimm16 {subtraction(reg0_2, splitimm16);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}:XORI "#"splitimm16, reg0_2 is opcode3_9=0x007F & reg0_2 ; splitimm16 {reg0_2 = reg0_2 ^ splitimm16;resultFlags(reg0_2);+ if (®0_2 != &R7) goto inst_next;+ goto [R7];}}