]> git.sur5r.net Git - cc65/commitdiff
Working on the backend
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 4 Jun 2001 12:27:16 +0000 (12:27 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 4 Jun 2001 12:27:16 +0000 (12:27 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@771 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/codegen.c
src/cc65/codegen.h
src/cc65/codeinfo.c
src/cc65/codeseg.c
src/cc65/codeseg.h
src/cc65/opcodes.c
src/cc65/opcodes.h
src/cc65/segments.c
src/cc65/segments.h

index 004147b32960f7d8834b13b982e981430ba8e6b9..bdfe1b028577a7b114baf9e32737f05e0db6b94b 100644 (file)
@@ -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:
index 6bd016a232184247df307f46d5c9b8f66f20811c..9d1420fca4412adf11fc2bce3c3f59ccd84fedef 100644 (file)
@@ -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                           */
 /*****************************************************************************/
index 9c5a1b40809b9241dbc2e78ef8d62cf3e0079718..1885306dea10fe1a3d48c1d8328be472c420b3cc 100644 (file)
@@ -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!");
                }
index 44601c591524ff22b5b7d16fd0a36504b9886370..17457768f35d8e681eb7415e14e6646a94ddf8c6 100644 (file)
@@ -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);
     }
 }
 
index b98bf3e067539e7020378e919a4a04af5e6b927b..a157a79d4be312b73e9e48b49da219517ed397be 100644 (file)
@@ -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)));
index 8afeb9648f033b375c6c1b94e2916618a71fcc3e..2c88ff394770b104bcceba4bcbaf816cac781d48 100644 (file)
@@ -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 */
index e5bbbb7ee30335ca20108fa81b6bf709380ccfaa..c81c978f510347f1ccde9e9b1f1b59ac1539c54f 100644 (file)
@@ -64,6 +64,7 @@ typedef enum {
     OPC_PHA,
     OPC_PHAX,
     OPC_PHEAX,
+    OPC_RET,
     OPC_SPACE,
     OPC_STA,
     OPC_STAX,
index b5ba646c4bfe459612270e9403020ff81cca7b6d..232f9abd8e9fc3b1c9b9a01560867f1da8246911 100644 (file)
@@ -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));
 }
 
 
index cd3a673093412b24a2a18cce3eb2a1f9a517e842..1c9b5fd9a448a0039dfd5b1fd68f5ea49734dfc2 100644 (file)
@@ -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)));