mirror of
https://github.com/cc65/cc65.git
synced 2024-12-28 06:30:16 +00:00
Working on the new backend
git-svn-id: svn://svn.cc65.org/cc65/trunk@712 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
00074cedbc
commit
8800b0c1c8
@ -43,6 +43,7 @@
|
||||
|
||||
/* b6502 */
|
||||
#include "codeinfo.h"
|
||||
#include "funcinfo.h"
|
||||
#include "label.h"
|
||||
#include "opcodes.h"
|
||||
#include "codeent.h"
|
||||
@ -61,21 +62,28 @@
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
@ -82,7 +82,7 @@ struct CodeEntry {
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (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 */
|
||||
@ -55,16 +55,18 @@
|
||||
#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 */
|
||||
|
||||
|
@ -297,11 +297,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, const char* L)
|
||||
/* 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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -143,6 +143,10 @@ typedef struct {
|
||||
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;
|
||||
|
||||
@ -170,6 +174,9 @@ unsigned GetAMUseInfo (am_t AM);
|
||||
* 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 */
|
||||
|
Loading…
Reference in New Issue
Block a user