]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codegen.c
Change the OptStackOps function so that it adjusts the instruction pointer
[cc65] / src / cc65 / codegen.c
index 8287ca84ee1d21475e99112d404baa895b71e828..577623aa6d941a7cb2d00f6ba234a33841c871f8 100644 (file)
@@ -41,9 +41,9 @@
 #include "check.h"
 #include "cpu.h"
 #include "strbuf.h"
-#include "version.h"
 #include "xmalloc.h"
 #include "xsprintf.h"
+#include "version.h"
 
 /* cc65 */
 #include "asmcode.h"
@@ -346,6 +346,24 @@ void g_defdatalabel (unsigned label)
 
 
 
+void g_aliasdatalabel (unsigned label, unsigned baselabel, long offs)
+/* Define label as a local alias for baselabel+offs */
+{
+    /* We need an intermediate buffer here since LocalLabelName uses a
+     * static buffer which changes with each call.
+     */
+    StrBuf L = AUTO_STRBUF_INITIALIZER;
+    SB_AppendStr (&L, LocalLabelName (label));
+    SB_Terminate (&L);
+    AddDataLine ("%s\t:=\t%s+%ld",
+                 SB_GetConstBuf (&L),
+                 LocalLabelName (baselabel),
+                 offs);
+    SB_Done (&L);
+}
+
+
+
 /*****************************************************************************/
 /*                    Functions handling global labels                      */
 /*****************************************************************************/
@@ -798,13 +816,8 @@ void g_getlocal (unsigned Flags, int Offs)
                AddCodeLine ("lda (sp),y");
                 AddCodeLine ("dey");
                 AddCodeLine ("ora (sp),y");
-            } else if (IS_Get (&CodeSizeFactor) < 165) {
-                AddCodeLine ("jsr ldaxysp");
             } else {
-               AddCodeLine ("lda (sp),y");
-                AddCodeLine ("tax");
-                AddCodeLine ("dey");
-                AddCodeLine ("lda (sp),y");
+                AddCodeLine ("jsr ldaxysp");
             }
             break;