Browse Source

+ initial implementation of operand writing (registers and constants only for now)

git-svn-id: branches/z80@44488 -
nickysn 5 years ago
parent
commit
aeedb0022d
1 changed files with 31 additions and 10 deletions
  1. 31 10
      compiler/z80/agsdasz80.pas

+ 31 - 10
compiler/z80/agsdasz80.pas

@@ -47,6 +47,7 @@ unit agsdasz80;
         procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:longint;
           secflags:TSectionFlags=[];secprogbits:TSectionProgbits=SPB_None);
         procedure WriteInstruction(hp: taicpu);
+        procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
       public
         procedure WriteTree(p : TAsmList); override;
         procedure WriteAsmList;override;
@@ -286,21 +287,41 @@ unit agsdasz80;
       end;
 
     procedure TSdccSdasZ80Assembler.WriteInstruction(hp: taicpu);
+      var
+        i: Integer;
       begin
-        writer.AsmWriteLn(#9#9+std_op2str[hp.opcode]);
-        {if taicpu(hp).ops<>0 then
+        writer.AsmWrite(#9#9+std_op2str[hp.opcode]);
+        if taicpu(hp).ops<>0 then
           begin
             for i:=0 to taicpu(hp).ops-1 do
-             begin
-               if i=0 then
-                writer.AsmWrite(#9)
-               else
-                writer.AsmWrite(',');
-               WriteOper(taicpu(hp).oper[i]^,taicpu(hp).opsize,fixed_opcode,taicpu(hp).ops,(i=2));
-             end;
-          end;}
+              begin
+                if i=0 then
+                 writer.AsmWrite(#9)
+                else
+                 writer.AsmWrite(',');
+                WriteOper(taicpu(hp).oper[i]^,S_B{taicpu(hp).opsize},hp.opcode,taicpu(hp).ops,(i=2));
+              end;
+          end;
+        writer.AsmLn;
       end;
 
+    procedure TSdccSdasZ80Assembler.WriteOper(const o: toper; s: topsize;
+      opcode: tasmop; ops: longint; dest: boolean);
+    begin
+      case o.typ of
+        top_reg :
+          writer.AsmWrite(std_regname(o.reg));
+        top_const :
+          begin
+{            if (ops=1) and (opcode<>A_RET) then
+              writer.AsmWrite(sizestr(s,dest));}
+            writer.AsmWrite('#'+tostr(longint(o.val)));
+          end;
+        else
+          internalerror(10001);
+      end;
+    end;
+
     procedure TSdccSdasZ80Assembler.WriteTree(p: TAsmList);
 
       function getreferencestring(var ref : treference) : string;