]> git.sur5r.net Git - cc65/blobdiff - src/da65/handler.c
Fixed some bugs in da65's HuC6280 section.
[cc65] / src / da65 / handler.c
index 0806301fe8471ac74338469969b8ba46d12ece8c..c034aed1406364a9810fe841c3c2e06cb7280785 100644 (file)
@@ -36,6 +36,7 @@
 #include <stdarg.h>
 
 /* common */
+#include "xmalloc.h"
 #include "xsprintf.h"
 
 /* da65 */
@@ -406,6 +407,8 @@ void OH_AbsoluteIndirect (const OpcDesc* D)
 
 void OH_BitBranch (const OpcDesc* D)
 {
+    char* BranchLabel;
+
     /* Get the operands */
     unsigned char TestAddr   = GetCodeByte (PC+1);
     signed char   BranchOffs = GetCodeByte (PC+2);
@@ -421,8 +424,16 @@ void OH_BitBranch (const OpcDesc* D)
     GenerateLabel (D->Flags, TestAddr);
     GenerateLabel (flLabel, BranchAddr);
 
+    /* Make a copy of an operand, so that
+    ** the other operand can't overwrite it.
+    ** [GetAddrArg() uses a statically-stored buffer.]
+    */
+    BranchLabel = xstrdup (GetAddrArg (flLabel, BranchAddr));
+
     /* Output the line */
-    OneLine (D, "%s,%s", GetAddrArg (D->Flags, TestAddr), GetAddrArg (flLabel, BranchAddr));
+    OneLine (D, "%s,%s", GetAddrArg (D->Flags, TestAddr), BranchLabel);
+
+    xfree (BranchLabel);
 }
 
 
@@ -518,8 +529,10 @@ void OH_DirectIndirectLongY (const OpcDesc* D attribute ((unused)))
 
 
 
-void OH_BlockMove (const OpcDesc* D attribute ((unused)))
+void OH_BlockMove (const OpcDesc* D)
 {
+    char* DstLabel;
+
     /* Get source operand */
     unsigned Src = GetCodeWord (PC+1);
     /* Get destination operand */
@@ -529,11 +542,19 @@ void OH_BlockMove (const OpcDesc* D attribute ((unused)))
     GenerateLabel (D->Flags, Src);
     GenerateLabel (D->Flags, Dst);
 
+    /* Make a copy of an operand, so that
+    ** the other operand can't overwrite it.
+    ** [GetAddrArg() uses a statically-stored buffer.]
+    */
+    DstLabel = xstrdup (GetAddrArg (D->Flags, Dst));
+
     /* Output the line */
-    OneLine (D, "%s%s,%s%s,#$%02X",
+    OneLine (D, "%s%s,%s%s,$%04X",
              GetAbsOverride (D->Flags, Src), GetAddrArg (D->Flags, Src),
-             GetAbsOverride (D->Flags, Dst), GetAddrArg (D->Flags, Dst),
+             GetAbsOverride (D->Flags, Dst), DstLabel,
              GetCodeWord (PC+5));
+
+    xfree (DstLabel);
 }
 
 
@@ -662,3 +683,14 @@ void OH_JmpAbsoluteIndirect (const OpcDesc* D)
     }
     SeparatorLine ();
 }
+
+
+
+void OH_JmpAbsoluteXIndirect (const OpcDesc* D)
+{
+    OH_AbsoluteXIndirect (D);
+    if (NewlineAfterJMP) {
+        LineFeed ();
+    }
+    SeparatorLine ();
+}