X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fopcodes.c;h=2c838a695f6c5038092dad89ccb85d6fc17dfe44;hb=35e1184901ca38bdb2e56d154ed3b71f6096eacc;hp=d55a5371fffa950320486e4693c54d36d0740b12;hpb=f38852df82b804f021c9a311a324fc3b0b74dbe7;p=cc65 diff --git a/src/cc65/opcodes.c b/src/cc65/opcodes.c index d55a5371f..2c838a695 100644 --- a/src/cc65/opcodes.c +++ b/src/cc65/opcodes.c @@ -6,9 +6,9 @@ /* */ /* */ /* */ -/* (C) 2001-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ +/* (C) 2001-2004 Ullrich von Bassewitz */ +/* Römerstraße 52 */ +/* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ /* */ @@ -39,10 +39,10 @@ /* common */ #include "check.h" +#include "cpu.h" /* cc65 */ #include "codeinfo.h" -#include "cpu.h" #include "error.h" #include "opcodes.h" @@ -55,7 +55,7 @@ /* Opcode description table */ -const OPCDesc OPCTable[OPCODE_COUNT] = { +const OPCDesc OPCTable[OP65_COUNT] = { /* 65XX opcodes */ { OP65_ADC, /* opcode */ @@ -63,21 +63,21 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 0, /* size */ REG_A, /* use */ REG_A, /* chg */ - OF_SETF /* flags */ + OF_SETF /* flags */ }, { OP65_AND, /* opcode */ "and", /* mnemonic */ 0, /* size */ REG_A, /* use */ REG_A, /* chg */ - OF_SETF /* flags */ + OF_SETF /* flags */ }, { OP65_ASL, /* opcode */ "asl", /* mnemonic */ 0, /* size */ - REG_A, /* use */ - REG_A, /* chg */ - OF_SETF /* flags */ + REG_NONE, /* use */ + REG_NONE, /* chg */ + OF_SETF | OF_NOIMP /* flags */ }, { OP65_BCC, /* opcode */ "bcc", /* mnemonic */ @@ -154,7 +154,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 2, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_CBRA /* flags */ + OF_CBRA /* flags */ }, { OP65_CLC, /* opcode */ "clc", /* mnemonic */ @@ -217,7 +217,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 0, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_SETF /* flags */ + OF_SETF | OF_NOIMP /* flags */ }, { OP65_DEX, /* opcode */ "dex", /* mnemonic */ @@ -238,7 +238,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 0, /* size */ REG_A, /* use */ REG_A, /* chg */ - OF_SETF /* flags */ + OF_SETF /* flags */ }, { OP65_INA, /* opcode */ "ina", /* mnemonic */ @@ -252,7 +252,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 0, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_SETF /* flags */ + OF_SETF | OF_NOIMP /* flags */ }, { OP65_INX, /* opcode */ "inx", /* mnemonic */ @@ -329,7 +329,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 5, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_CBRA | OF_LBRA /* flags */ + OF_CBRA | OF_LBRA /* flags */ }, { OP65_JVS, /* opcode */ "jvs", /* mnemonic */ @@ -362,9 +362,9 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { { OP65_LSR, /* opcode */ "lsr", /* mnemonic */ 0, /* size */ - REG_A, /* use */ - REG_A, /* chg */ - OF_SETF /* flags */ + REG_NONE, /* use */ + REG_NONE, /* chg */ + OF_SETF | OF_NOIMP /* flags */ }, { OP65_NOP, /* opcode */ "nop", /* mnemonic */ @@ -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 */ @@ -420,7 +420,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 1, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_NONE /* flags */ + OF_NONE /* flags */ }, { OP65_PLX, /* opcode */ "plx", /* mnemonic */ @@ -439,86 +439,89 @@ 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 | OF_NOIMP /* 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 | OF_NOIMP /* flags */ }, + /* Mark RTI as "uses all registers but doesn't change them", so the + * optimizer won't remove preceeding loads. + */ { OP65_RTI, /* opcode */ "rti", /* mnemonic */ 1, /* size */ - REG_NONE, /* use */ + REG_AXY, /* use */ REG_NONE, /* chg */ - OF_RET /* flags */ + OF_RET /* flags */ }, { OP65_RTS, /* opcode */ "rts", /* mnemonic */ 1, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_RET /* flags */ + OF_RET /* flags */ }, { OP65_SBC, /* opcode */ "sbc", /* mnemonic */ 0, /* size */ REG_A, /* use */ REG_A, /* chg */ - OF_SETF /* flags */ + OF_SETF /* flags */ }, { OP65_SEC, /* opcode */ "sec", /* mnemonic */ 1, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_NONE /* flags */ + OF_NONE /* flags */ }, { OP65_SED, /* opcode */ "sed", /* mnemonic */ 1, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_NONE /* flags */ + OF_NONE /* flags */ }, { OP65_SEI, /* opcode */ "sei", /* mnemonic */ 1, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_NONE /* flags */ + OF_NONE /* flags */ }, { OP65_STA, /* opcode */ "sta", /* mnemonic */ 0, /* size */ REG_A, /* use */ REG_NONE, /* chg */ - OF_STORE /* flags */ + OF_STORE /* flags */ }, { OP65_STX, /* opcode */ "stx", /* mnemonic */ 0, /* size */ REG_X, /* use */ REG_NONE, /* chg */ - OF_STORE /* flags */ + OF_STORE /* flags */ }, { OP65_STY, /* opcode */ "sty", /* mnemonic */ 0, /* size */ REG_Y, /* use */ REG_NONE, /* chg */ - OF_STORE /* flags */ + OF_STORE /* flags */ }, { OP65_STZ, /* opcode */ "stz", /* mnemonic */ 0, /* size */ REG_NONE, /* use */ REG_NONE, /* chg */ - OF_STORE /* flags */ + OF_STORE /* flags */ }, { OP65_TAX, /* opcode */ "tax", /* mnemonic */ @@ -546,7 +549,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 0, /* size */ REG_A, /* use */ REG_NONE, /* chg */ - OF_SETF /* flags */ + OF_SETF /* flags */ }, { OP65_TSX, /* opcode */ "tsx", /* mnemonic */ @@ -567,7 +570,7 @@ const OPCDesc OPCTable[OPCODE_COUNT] = { 1, /* size */ REG_X, /* use */ REG_NONE, /* chg */ - OF_XFR /* flags */ + OF_XFR /* flags */ }, { OP65_TYA, /* opcode */ "tya", /* mnemonic */ @@ -617,7 +620,7 @@ const OPCDesc* FindOP65 (const char* M) Mnemo[I] = '\0'; /* Search for the mnemonic in the table and return the result */ - return bsearch (Mnemo, OPCTable+OP65_FIRST, OP65_COUNT, + return bsearch (Mnemo, OPCTable, OP65_COUNT, sizeof (OPCTable[0]), FindCmp ); } @@ -723,7 +726,7 @@ opc_t MakeShortBranch (opc_t OPC) case OP65_BVS: case OP65_JVS: return OP65_BVS; case OP65_BRA: - case OP65_JMP: return (CPU == CPU_65C02)? OP65_BRA : OP65_JMP; + case OP65_JMP: return (CPUIsets[CPU] & CPU_ISET_65SC02)? OP65_BRA : OP65_JMP; default: Internal ("MakeShortBranch: Invalid opcode: %d", OPC); return 0;