Browse Source

+ write jump operands (not all forms supported yet) in the sdcc-sdasz80 asm output

git-svn-id: branches/z80@44572 -
nickysn 5 years ago
parent
commit
d05a632616
1 changed files with 38 additions and 1 deletions
  1. 38 1
      compiler/z80/agsdasz80.pas

+ 38 - 1
compiler/z80/agsdasz80.pas

@@ -48,6 +48,7 @@ unit agsdasz80;
           secflags:TSectionFlags=[];secprogbits:TSectionProgbits=SPB_None);
           secflags:TSectionFlags=[];secprogbits:TSectionProgbits=SPB_None);
         procedure WriteInstruction(hp: taicpu);
         procedure WriteInstruction(hp: taicpu);
         procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
         procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
+        procedure WriteOper_jmp(const o:toper; ai : taicpu);
       public
       public
         procedure WriteTree(p : TAsmList); override;
         procedure WriteTree(p : TAsmList); override;
         procedure WriteAsmList;override;
         procedure WriteAsmList;override;
@@ -300,7 +301,10 @@ unit agsdasz80;
                  writer.AsmWrite(#9)
                  writer.AsmWrite(#9)
                 else
                 else
                  writer.AsmWrite(',');
                  writer.AsmWrite(',');
-                WriteOper(taicpu(hp).oper[i]^,S_B{taicpu(hp).opsize},hp.opcode,taicpu(hp).ops,(i=2));
+                if hp.is_jmp then
+                  WriteOper_jmp(taicpu(hp).oper[i]^,hp)
+                else
+                  WriteOper(taicpu(hp).oper[i]^,S_B{taicpu(hp).opsize},hp.opcode,taicpu(hp).ops,(i=2));
               end;
               end;
           end;
           end;
         writer.AsmLn;
         writer.AsmLn;
@@ -386,6 +390,39 @@ unit agsdasz80;
         end;
         end;
       end;
       end;
 
 
+    procedure TSdccSdasZ80Assembler.WriteOper_jmp(const o: toper; ai: taicpu);
+      begin
+        case o.typ of
+          top_reg :
+            writer.AsmWrite(std_regname(o.reg));
+          top_const :
+            begin
+              writer.AsmWrite('#'+tostr(longint(o.val)));
+            end;
+          top_ref:
+            begin
+              if o.ref^.refaddr=addr_no then
+                begin
+                  writer.AsmWrite('TODO:indirect jump ref');
+                  //WriteReference(o.ref^);
+                end
+              else
+                begin
+                  writer.AsmWrite(o.ref^.symbol.name);
+                  //if SmartAsm then
+                  //  AddSymbol(o.ref^.symbol.name,false);
+                  if o.ref^.offset>0 then
+                   writer.AsmWrite('+'+tostr(o.ref^.offset))
+                  else
+                   if o.ref^.offset<0 then
+                    writer.AsmWrite(tostr(o.ref^.offset));
+                end;
+            end;
+          else
+            internalerror(10001);
+        end;
+      end;
+
     procedure TSdccSdasZ80Assembler.WriteTree(p: TAsmList);
     procedure TSdccSdasZ80Assembler.WriteTree(p: TAsmList);
 
 
       function getreferencestring(var ref : treference) : string;
       function getreferencestring(var ref : treference) : string;