]> git.sur5r.net Git - cc65/commitdiff
Several minor changes and fixes
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 16 Mar 2002 14:11:15 +0000 (14:11 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 16 Mar 2002 14:11:15 +0000 (14:11 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1192 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/codeent.c
src/cc65/codeinfo.c
src/cc65/opcodes.c

index dd79be34d09437d12c2832c24e2197468f213e7e..14bab06393a42336caabc71ffa88a3b8d289de30 100644 (file)
@@ -156,6 +156,15 @@ static void SetUseChgInfo (CodeEntry* E, const OPCDesc* D)
        /* Check for special zero page registers used */
        switch (E->AM) {
 
+           case AM65_ACC:
+               if (E->OPC == OP65_ASL || E->OPC == OP65_DEC ||
+                   E->OPC == OP65_INC || E->OPC == OP65_LSR ||
+                   E->OPC == OP65_ROL || E->OPC == OP65_ROR) {
+                   /* A is changed by these insns */
+                   E->Chg |= REG_A;
+               }
+                break;
+
            case AM65_ZP:
            case AM65_ABS:
            /* Be conservative: */
@@ -661,6 +670,22 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
            if (Chg & REG_SREG_HI) {
                Out->SRegHi = -1;
            }
+           /* Quick hack for some known functions: */
+           if (strcmp (E->Arg, "tosandax") == 0) {
+               if (In->RegA == 0) {
+                   Out->RegA = 0;
+               }
+               if (In->RegX == 0) {
+                   Out->RegX = 0;
+               }
+           } else if (strcmp (E->Arg, "tosorax") == 0) {
+               if (In->RegA == 0xFF) {
+                   Out->RegA = 0xFF;
+               }
+               if (In->RegX == 0xFF) {
+                    Out->RegX = 0xFF;
+                }
+            }
            break;
 
        case OP65_JVC:
index 4d32972c6bf0ec35d19f9e56110d0decccc53bae..a1fa65891a9eaf3bfc67550c6df8736f6c638dea 100644 (file)
@@ -566,17 +566,17 @@ unsigned GetKnownReg (unsigned Use, const RegContents* RC)
  */
 {
     if ((Use & REG_A) != 0) {
-       return (RC && RC->RegA >= 0)? REG_A : REG_NONE;
+       return (RC == 0 || RC->RegA >= 0)? REG_A : REG_NONE;
     } else if ((Use & REG_X) != 0) {
-       return (RC && RC->RegX >= 0)? REG_X : REG_NONE;
+       return (RC == 0 || RC->RegX >= 0)? REG_X : REG_NONE;
     } else if ((Use & REG_Y) != 0) {
-       return (RC && RC->RegY >= 0)? REG_Y : REG_NONE;
+       return (RC == 0 || RC->RegY >= 0)? REG_Y : REG_NONE;
     } else if ((Use & REG_TMP1) != 0) {
-       return (RC && RC->Tmp1 >= 0)? REG_TMP1 : REG_NONE;
+       return (RC == 0 || RC->Tmp1 >= 0)? REG_TMP1 : REG_NONE;
     } else if ((Use & REG_SREG_LO) != 0) {
-       return (RC && RC->SRegLo >= 0)? REG_SREG_LO : REG_NONE;
+       return (RC == 0 || RC->SRegLo >= 0)? REG_SREG_LO : REG_NONE;
     } else if ((Use & REG_SREG_HI) != 0) {
-       return (RC && RC->SRegHi >= 0)? REG_SREG_HI : REG_NONE;
+       return (RC == 0 || RC->SRegHi >= 0)? REG_SREG_HI : REG_NONE;
     } else {
        return REG_NONE;
     }
index d55a5371fffa950320486e4693c54d36d0740b12..55afbe7257aef603b971858787395274d2130320 100644 (file)
@@ -75,8 +75,8 @@ const OPCDesc OPCTable[OPCODE_COUNT] = {
     {   OP65_ASL,                                      /* opcode */
                "asl",                                  /* mnemonic */
                0,                                      /* size */
-               REG_A,                                  /* use */
-               REG_A,                                  /* chg */
+               REG_NONE,                               /* use */
+               REG_NONE,                               /* chg */
        OF_SETF                                 /* flags */
     },
     {   OP65_BCC,                                      /* opcode */
@@ -362,8 +362,8 @@ const OPCDesc OPCTable[OPCODE_COUNT] = {
     {   OP65_LSR,                                      /* opcode */
                "lsr",                                  /* mnemonic */
                0,                                      /* size */
-               REG_A,                                  /* use */
-               REG_A,                                  /* chg */
+               REG_NONE,                               /* use */
+               REG_NONE,                               /* chg */
        OF_SETF                                 /* flags */
     },
     {   OP65_NOP,                                      /* opcode */
@@ -406,7 +406,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = {
                1,                                      /* size */
                REG_Y,                                  /* use */
                REG_NONE,                               /* chg */
-       OF_NONE                                 /* flags */
+       OF_NONE                                 /* flags */
     },
     {   OP65_PLA,                                      /* opcode */
                "pla",                                  /* mnemonic */
@@ -439,16 +439,16 @@ const OPCDesc OPCTable[OPCODE_COUNT] = {
     {   OP65_ROL,                                      /* opcode */
                "rol",                                  /* mnemonic */
                0,                                      /* size */
-               REG_A,                                  /* use */
-               REG_A,                                  /* chg */
-       OF_SETF                                 /* flags */
+               REG_NONE,                               /* use */
+               REG_NONE,                               /* chg */
+       OF_SETF                                 /* flags */
     },
     {   OP65_ROR,                                      /* opcode */
                "ror",                                  /* mnemonic */
                0,                                      /* size */
-               REG_A,                                  /* use */
-               REG_A,                                  /* chg */
-       OF_SETF                                 /* flags */
+               REG_NONE,                               /* use */
+               REG_NONE,                               /* chg */
+       OF_SETF                                 /* flags */
     },
     {   OP65_RTI,                                      /* opcode */
                "rti",                                  /* mnemonic */