]> git.sur5r.net Git - cc65/blobdiff - src/cc65/opcodes.c
Working on the new backend
[cc65] / src / cc65 / opcodes.c
index 8cca9cc6c7cb311f0d073c13fa4f130a99f120d5..b2165b20f474b58d4eda0f0d37832a99fab0616f 100644 (file)
@@ -40,6 +40,9 @@
 /* common */
 #include "check.h"
 
+/* cc65 */
+#include "error.h"
+
 /* b6502 */
 #include "codeinfo.h"
 #include "opcodes.h"
@@ -216,7 +219,7 @@ const OPCDesc* GetOPCDesc (opc_t OPC)
 unsigned GetAMUseInfo (am_t AM)
 /* Get usage info for the given addressing mode (addressing modes that use
  * index registers return CI_USE... info for these registers).
- */                           
+ */
 {
     /* Check the addressing mode. */
     switch (AM) {
@@ -232,3 +235,29 @@ unsigned GetAMUseInfo (am_t AM)
 
 
 
+opc_t GetInverseBranch (opc_t OPC)
+/* Return a brahcn that reverse the condition of the branch given in OPC */
+{
+    switch (OPC) {
+       case OPC_BCC:   return OPC_BCS;
+       case OPC_BCS:   return OPC_BCC;
+       case OPC_BEQ:   return OPC_BNE;
+       case OPC_BMI:   return OPC_BPL;
+       case OPC_BNE:   return OPC_BEQ;
+       case OPC_BPL:   return OPC_BMI;
+       case OPC_BVC:   return OPC_BVS;
+       case OPC_BVS:   return OPC_BVC;
+               case OPC_JCC:   return OPC_JCS;
+               case OPC_JCS:   return OPC_JCC;
+               case OPC_JEQ:   return OPC_JNE;
+               case OPC_JMI:   return OPC_JPL;
+               case OPC_JNE:   return OPC_JEQ;
+               case OPC_JPL:   return OPC_JMI;
+               case OPC_JVC:   return OPC_JVS;
+               case OPC_JVS:   return OPC_JVC;
+       default:        Internal ("GetInverseBranch: Invalid opcode: %d", OPC);
+    }
+}
+
+
+