/* b6502 */
#include "codeinfo.h"
+#include "funcinfo.h"
#include "label.h"
#include "opcodes.h"
#include "codeent.h"
-CodeEntry* NewCodeEntry (const OPCDesc* D, am_t AM, CodeLabel* JumpTo)
+CodeEntry* NewCodeEntry (const OPCDesc* D, am_t AM, const char* Arg, CodeLabel* JumpTo)
/* Create a new code entry, initialize and return it */
{
/* Allocate memory */
CodeEntry* E = xmalloc (sizeof (CodeEntry));
/* Initialize the fields */
- E->OPC = D->OPC;
- E->AM = AM;
- E->Size = GetInsnSize (E->OPC, E->AM);
+ E->OPC = D->OPC;
+ E->AM = AM;
+ E->Size = GetInsnSize (E->OPC, E->AM);
E->Hints = 0;
- E->Arg = 0;
- E->Num = 0;
+ E->Arg = (Arg && Arg[0] != '\0')? xstrdup (Arg) : 0;
+ E->Num = 0;
E->Flags = 0;
- E->Info = D->Info | GetAMUseInfo (AM);
+ E->Info = D->Info;
+ if (E->OPC == OPC_JSR && E->Arg) {
+ /* A subroutine call */
+ E->Info |= GetFuncInfo (E->Arg);
+ } else {
+ /* Some other instruction */
+ E->Info |= GetAMUseInfo (AM);
+ }
E->JumpTo = JumpTo;
InitCollection (&E->Labels);
-CodeEntry* NewCodeEntry (const OPCDesc* D, am_t AM, CodeLabel* JumpTo);
+CodeEntry* NewCodeEntry (const OPCDesc* D, am_t AM, const char* Arg, CodeLabel* JumpTo);
/* Create a new code entry, initialize and return it */
void FreeCodeEntry (CodeEntry* E);
/* */
/* */
/* */
-/* (C) 2001 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#define CI_USE_A 0x0001U /* Use the A register */
#define CI_USE_X 0x0002U /* Use the X register */
#define CI_USE_Y 0x0004U /* Use the Y register */
+#define CI_USE_ALL 0x0007U /* Use all registers */
#define CI_MASK_USE 0x000FU /* Extract usage info */
#define CI_CHG_NONE 0x0000U /* Change nothing */
#define CI_CHG_A 0x0010U /* Change the A register */
#define CI_CHG_X 0x0020U /* Change the X register */
#define CI_CHG_Y 0x0040U /* Change the Y register */
+#define CI_CHG_ALL 0x0070U /* Change all registers */
#define CI_MASK_CHG 0x00F0U /* Extract change info */
-
+
#define CI_BRA 0x0100U /* Instruction is a branch */
-#define CI_MASK_BRA 0x0100U /* Extract branch info */
+#define CI_MASK_BRA 0x0100U /* Extract branch info */
#define CI_NONE 0x0000U /* Nothing used/changed */
/* We do now have the addressing mode in AM. Allocate a new CodeEntry
* structure and initialize it.
*/
- E = NewCodeEntry (OPC, AM, Label);
- if (Arg[0] != '\0') {
- /* We have an additional expression */
- E->Arg = xstrdup (Arg);
- }
+ E = NewCodeEntry (OPC, AM, Arg, Label);
/* Return the new code entry */
return E;
/* common */
#include "check.h"
+/* cc65 */
+#include "error.h"
+
/* b6502 */
#include "codeinfo.h"
#include "opcodes.h"
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) {
+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);
+ }
+}
+
+
+
char Mnemo[4]; /* Mnemonic */
opc_t OPC; /* Opcode */
unsigned Size; /* Size, 0 means "check addressing mode" */
+####
+ unsigned char Use;
+ unsigned char Load;
+
unsigned Info; /* Usage flags */
} OPCDesc;
* index registers return CI_USE... info for these registers).
*/
+opc_t GetInverseBranch (opc_t OPC);
+/* Return a brahcn that reverse the condition of the branch given in OPC */
+
/* End of opcodes.h */