Working on the backend
git-svn-id: svn://svn.cc65.org/cc65/trunk@771 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -960,7 +960,7 @@ void g_putlocal (unsigned Flags, int Offs, long Val)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CF_LONG:
|
case CF_LONG:
|
||||||
AddCode (OPC_STAEAX, AM_STACK, WordToStr (Offs), 0);
|
AddCode (OPC_STEAX, AM_STACK, WordToStr (Offs), 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -294,20 +294,6 @@ void g_addstatic (unsigned flags, unsigned long label, unsigned offs);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Compares of ax with a variable with fixed address */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void g_cmplocal (unsigned flags, int offs);
|
|
||||||
/* Compare a local variable to ax */
|
|
||||||
|
|
||||||
void g_cmpstatic (unsigned flags, unsigned label, unsigned offs);
|
|
||||||
/* Compare a static variable to ax */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Special op= functions */
|
/* Special op= functions */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ static unsigned char GetRegInfo2 (CodeSeg* S,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If the instruction is an RTS or RTI, we're done */
|
/* If the instruction is an RTS or RTI, we're done */
|
||||||
if (E->OPC == OP65_RTS || E->OPC == OP65_RTI) {
|
if ((E->Info & OF_RET) != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ CodeSeg* NewCodeSeg (const char* SegName, SymEntry* Func)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CS_AddEntry (CodeSeg* S, struct CodeEntry* E, LineInfo* LI)
|
void CS_AddEntry (CodeSeg* S, struct CodeEntry* E)
|
||||||
/* Add an entry to the given code segment */
|
/* Add an entry to the given code segment */
|
||||||
{
|
{
|
||||||
/* Transfer the labels if we have any */
|
/* Transfer the labels if we have any */
|
||||||
@@ -465,7 +465,7 @@ void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap)
|
|||||||
|
|
||||||
/* If we have a code entry, transfer the labels and insert it */
|
/* If we have a code entry, transfer the labels and insert it */
|
||||||
if (E) {
|
if (E) {
|
||||||
CS_AddEntry (S, E, LI);
|
CS_AddEntry (S, E);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ struct CodeSeg {
|
|||||||
CodeSeg* NewCodeSeg (const char* SegName, SymEntry* Func);
|
CodeSeg* NewCodeSeg (const char* SegName, SymEntry* Func);
|
||||||
/* Create a new code segment, initialize and return it */
|
/* Create a new code segment, initialize and return it */
|
||||||
|
|
||||||
void CS_AddEntry (CodeSeg* S, struct CodeEntry* E, LineInfo* LI);
|
void CS_AddEntry (CodeSeg* S, struct CodeEntry* E);
|
||||||
/* Add an entry to the given code segment */
|
/* Add an entry to the given code segment */
|
||||||
|
|
||||||
void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap) attribute ((format(printf,3,0)));
|
void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap) attribute ((format(printf,3,0)));
|
||||||
|
|||||||
@@ -60,105 +60,112 @@ const OPCDesc OPCTable[OPCODE_COUNT] = {
|
|||||||
/* Opcodes for the virtual stack machine */
|
/* Opcodes for the virtual stack machine */
|
||||||
{ OPC_CALL, /* opcode */
|
{ OPC_CALL, /* opcode */
|
||||||
"call", /* mnemonic */
|
"call", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM | OF_CALL /* flags */
|
OF_CPU_VM | OF_CALL /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_ENTER, /* opcode */
|
{ OPC_ENTER, /* opcode */
|
||||||
"enter", /* mnemonic */
|
"enter", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_Y, /* use */
|
REG_Y, /* use */
|
||||||
REG_AXY, /* chg */
|
REG_AXY, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_JMP, /* opcode */
|
{ OPC_JMP, /* opcode */
|
||||||
"jump", /* mnemonic */
|
"jump", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM | OF_UBRA /* flags */
|
OF_CPU_VM | OF_UBRA /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_LDA, /* opcode */
|
{ OPC_LDA, /* opcode */
|
||||||
"lda", /* mnemonic */
|
"lda", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_A, /* chg */
|
REG_A, /* chg */
|
||||||
OF_CPU_VM | OF_LOAD /* flags */
|
OF_CPU_VM | OF_LOAD /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_LDAX, /* opcode */
|
{ OPC_LDAX, /* opcode */
|
||||||
"ldax", /* mnemonic */
|
"ldax", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_AX, /* chg */
|
REG_AX, /* chg */
|
||||||
OF_CPU_VM | OF_LOAD /* flags */
|
OF_CPU_VM | OF_LOAD /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_LDEAX, /* opcode */
|
{ OPC_LDEAX, /* opcode */
|
||||||
"ldeax", /* mnemonic */
|
"ldeax", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_EAX, /* chg */
|
REG_EAX, /* chg */
|
||||||
OF_CPU_VM | OF_LOAD /* flags */
|
OF_CPU_VM | OF_LOAD /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_LEA, /* opcode */
|
{ OPC_LEA, /* opcode */
|
||||||
"lea", /* mnemonic */
|
"lea", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_AX, /* chg */
|
REG_AX, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_LEAVE, /* opcode */
|
{ OPC_LEAVE, /* opcode */
|
||||||
"leave", /* mnemonic */
|
"leave", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_PHA, /* opcode */
|
{ OPC_PHA, /* opcode */
|
||||||
"pha", /* mnemonic */
|
"pha", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_A, /* use */
|
REG_A, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_PHAX, /* opcode */
|
{ OPC_PHAX, /* opcode */
|
||||||
"phax", /* mnemonic */
|
"phax", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_AX, /* use */
|
REG_AX, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_PHEAX, /* opcode */
|
{ OPC_PHEAX, /* opcode */
|
||||||
"pheax", /* mnemonic */
|
"pheax", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_EAX, /* use */
|
REG_EAX, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
|
{ OPC_RET, /* opcode */
|
||||||
|
"ret", /* mnemonic */
|
||||||
|
1, /* size */
|
||||||
|
REG_NONE, /* use */
|
||||||
|
REG_NONE, /* chg */
|
||||||
|
OF_CPU_VM | OF_RET /* flags */
|
||||||
|
},
|
||||||
{ OPC_SPACE, /* opcode */
|
{ OPC_SPACE, /* opcode */
|
||||||
"space", /* mnemonic */
|
"space", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_NONE, /* use */
|
REG_NONE, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_STA, /* opcode */
|
{ OPC_STA, /* opcode */
|
||||||
"sta", /* mnemonic */
|
"sta", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_A, /* use */
|
REG_A, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_STAX, /* opcode */
|
{ OPC_STAX, /* opcode */
|
||||||
"stax", /* mnemonic */
|
"stax", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_AX, /* use */
|
REG_AX, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
},
|
},
|
||||||
{ OPC_STEAX, /* opcode */
|
{ OPC_STEAX, /* opcode */
|
||||||
"steax", /* mnemonic */
|
"steax", /* mnemonic */
|
||||||
0, /* size */
|
1, /* size */
|
||||||
REG_EAX, /* use */
|
REG_EAX, /* use */
|
||||||
REG_NONE, /* chg */
|
REG_NONE, /* chg */
|
||||||
OF_CPU_VM /* flags */
|
OF_CPU_VM /* flags */
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ typedef enum {
|
|||||||
OPC_PHA,
|
OPC_PHA,
|
||||||
OPC_PHAX,
|
OPC_PHAX,
|
||||||
OPC_PHEAX,
|
OPC_PHEAX,
|
||||||
|
OPC_RET,
|
||||||
OPC_SPACE,
|
OPC_SPACE,
|
||||||
OPC_STA,
|
OPC_STA,
|
||||||
OPC_STAX,
|
OPC_STAX,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
/* cc65 */
|
/* cc65 */
|
||||||
|
#include "codeent.h"
|
||||||
#include "codeseg.h"
|
#include "codeseg.h"
|
||||||
#include "dataseg.h"
|
#include "dataseg.h"
|
||||||
#include "textseg.h"
|
#include "textseg.h"
|
||||||
@@ -219,11 +220,11 @@ void AddCodeLine (const char* Format, ...)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AddCode (struct CodeEntry* E)
|
void AddCode (opc_t OPC, am_t AM, const char* Arg, struct CodeLabel* JumpTo)
|
||||||
/* Add a code entry to the current code segment */
|
/* Add a code entry to the current code segment */
|
||||||
{
|
{
|
||||||
CHECK (CS != 0);
|
CHECK (CS != 0);
|
||||||
CS_AddEntry (CS->Code, E, CurTok.LI);
|
CS_AddEntry (CS->Code, NewCodeEntry (OPC, AM, Arg, JumpTo, CurTok.LI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@
|
|||||||
/* common */
|
/* common */
|
||||||
#include "attrib.h"
|
#include "attrib.h"
|
||||||
|
|
||||||
|
/* cc65 */
|
||||||
|
#include "opcodes.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -52,6 +54,7 @@
|
|||||||
|
|
||||||
|
|
||||||
struct CodeEntry;
|
struct CodeEntry;
|
||||||
|
struct CodeLabel;
|
||||||
struct CodeSeg;
|
struct CodeSeg;
|
||||||
struct DataSeg;
|
struct DataSeg;
|
||||||
struct TextSeg;
|
struct TextSeg;
|
||||||
@@ -123,7 +126,7 @@ void AddTextLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
|||||||
void AddCodeLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
void AddCodeLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||||
/* Add a line of code to the current code segment */
|
/* Add a line of code to the current code segment */
|
||||||
|
|
||||||
void AddCode (struct CodeEntry* E);
|
void AddCode (opc_t OPC, am_t AM, const char* Arg, struct CodeLabel* JumpTo);
|
||||||
/* Add a code entry to the current code segment */
|
/* Add a code entry to the current code segment */
|
||||||
|
|
||||||
void AddDataLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
void AddDataLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||||
|
|||||||
Reference in New Issue
Block a user