From: cuz Date: Sat, 16 Mar 2002 14:11:15 +0000 (+0000) Subject: Several minor changes and fixes X-Git-Tag: V2.12.0~2424 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=486640200baa9dfd84029c76f40fd118b63aee86;p=cc65 Several minor changes and fixes git-svn-id: svn://svn.cc65.org/cc65/trunk@1192 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/codeent.c b/src/cc65/codeent.c index dd79be34d..14bab0639 100644 --- a/src/cc65/codeent.c +++ b/src/cc65/codeent.c @@ -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: diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index 4d32972c6..a1fa65891 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -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; } diff --git a/src/cc65/opcodes.c b/src/cc65/opcodes.c index d55a5371f..55afbe725 100644 --- a/src/cc65/opcodes.c +++ b/src/cc65/opcodes.c @@ -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 */