mirror of
https://github.com/cc65/cc65.git
synced 2025-01-27 09:33:42 +00:00
Working on the backend
git-svn-id: svn://svn.cc65.org/cc65/trunk@771 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
c1da7b8859
commit
fe2cd767b2
@ -944,7 +944,7 @@ void g_putlocal (unsigned Flags, int Offs, long Val)
|
||||
{
|
||||
Offs -= oursp;
|
||||
CheckLocalOffs (Offs);
|
||||
|
||||
|
||||
if (Flags & CF_CONST) {
|
||||
g_getimmed (Flags, Val, Offs);
|
||||
}
|
||||
@ -960,7 +960,7 @@ void g_putlocal (unsigned Flags, int Offs, long Val)
|
||||
break;
|
||||
|
||||
case CF_LONG:
|
||||
AddCode (OPC_STAEAX, AM_STACK, WordToStr (Offs), 0);
|
||||
AddCode (OPC_STEAX, AM_STACK, WordToStr (Offs), 0);
|
||||
break;
|
||||
|
||||
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 */
|
||||
/*****************************************************************************/
|
||||
|
@ -296,7 +296,7 @@ static unsigned char GetRegInfo2 (CodeSeg* S,
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ static unsigned char GetRegInfo2 (CodeSeg* S,
|
||||
}
|
||||
if (Index < 0) {
|
||||
Index = CS_GetEntryIndex (S, E);
|
||||
}
|
||||
}
|
||||
if ((E = CS_GetEntry (S, ++Index)) == 0) {
|
||||
Internal ("GetRegInfo2: No next entry!");
|
||||
}
|
||||
|
@ -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 */
|
||||
{
|
||||
/* 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 (E) {
|
||||
CS_AddEntry (S, E, LI);
|
||||
CS_AddEntry (S, E);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ struct CodeSeg {
|
||||
CodeSeg* NewCodeSeg (const char* SegName, SymEntry* Func);
|
||||
/* 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 */
|
||||
|
||||
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 */
|
||||
{ OPC_CALL, /* opcode */
|
||||
"call", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM | OF_CALL /* flags */
|
||||
},
|
||||
{ OPC_ENTER, /* opcode */
|
||||
"enter", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_Y, /* use */
|
||||
REG_AXY, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_JMP, /* opcode */
|
||||
"jump", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM | OF_UBRA /* flags */
|
||||
},
|
||||
{ OPC_LDA, /* opcode */
|
||||
"lda", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_A, /* chg */
|
||||
OF_CPU_VM | OF_LOAD /* flags */
|
||||
},
|
||||
{ OPC_LDAX, /* opcode */
|
||||
"ldax", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_AX, /* chg */
|
||||
OF_CPU_VM | OF_LOAD /* flags */
|
||||
},
|
||||
{ OPC_LDEAX, /* opcode */
|
||||
"ldeax", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_EAX, /* chg */
|
||||
OF_CPU_VM | OF_LOAD /* flags */
|
||||
},
|
||||
{ OPC_LEA, /* opcode */
|
||||
"lea", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_AX, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_LEAVE, /* opcode */
|
||||
"leave", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_PHA, /* opcode */
|
||||
"pha", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_A, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_PHAX, /* opcode */
|
||||
"phax", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_AX, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_PHEAX, /* opcode */
|
||||
"pheax", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_EAX, /* use */
|
||||
REG_NONE, /* chg */
|
||||
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 */
|
||||
"space", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_NONE, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_STA, /* opcode */
|
||||
"sta", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_A, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_STAX, /* opcode */
|
||||
"stax", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_AX, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
},
|
||||
{ OPC_STEAX, /* opcode */
|
||||
"steax", /* mnemonic */
|
||||
0, /* size */
|
||||
1, /* size */
|
||||
REG_EAX, /* use */
|
||||
REG_NONE, /* chg */
|
||||
OF_CPU_VM /* flags */
|
||||
|
@ -64,6 +64,7 @@ typedef enum {
|
||||
OPC_PHA,
|
||||
OPC_PHAX,
|
||||
OPC_PHEAX,
|
||||
OPC_RET,
|
||||
OPC_SPACE,
|
||||
OPC_STA,
|
||||
OPC_STAX,
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* cc65 */
|
||||
#include "codeent.h"
|
||||
#include "codeseg.h"
|
||||
#include "dataseg.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 */
|
||||
{
|
||||
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 */
|
||||
#include "attrib.h"
|
||||
|
||||
/* cc65 */
|
||||
#include "opcodes.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -50,8 +52,9 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
struct CodeEntry;
|
||||
struct CodeLabel;
|
||||
struct CodeSeg;
|
||||
struct DataSeg;
|
||||
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)));
|
||||
/* 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 */
|
||||
|
||||
void AddDataLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user