Browse Source

+ support aitconst_uleb128bit and aitconst_sleb128bit

git-svn-id: branches/z80@44450 -
nickysn 5 years ago
parent
commit
416511e245
1 changed files with 39 additions and 3 deletions
  1. 39 3
      compiler/z80/agsdasz80.pas

+ 39 - 3
compiler/z80/agsdasz80.pas

@@ -42,6 +42,8 @@ unit agsdasz80;
       TSdccSdasZ80Assembler=class(TExternalAssembler)
       private
         function EscapeLabel(s: ansistring): ansistring;
+        procedure WriteDecodedSleb128(a: int64);
+        procedure WriteDecodedUleb128(a: qword);
       public
         procedure WriteTree(p : TAsmList); override;
         procedure WriteAsmList;override;
@@ -84,6 +86,38 @@ unit agsdasz80;
             result:=result+('_'+HexStr(Ord(s[i]),2));
       end;
 
+    procedure TSdccSdasZ80Assembler.WriteDecodedSleb128(a: int64);
+      var
+        i,len : longint;
+        buf   : array[0..255] of byte;
+      begin
+        writer.AsmWrite(#9'.db'#9);
+        len:=EncodeSleb128(a,buf,0);
+        for i:=0 to len-1 do
+          begin
+            if (i > 0) then
+              writer.AsmWrite(',');
+            writer.AsmWrite(tostr(buf[i]));
+          end;
+        writer.AsmWriteLn(#9'; sleb '+tostr(a));
+      end;
+
+    procedure TSdccSdasZ80Assembler.WriteDecodedUleb128(a: qword);
+      var
+        i,len : longint;
+        buf   : array[0..63] of byte;
+      begin
+        writer.AsmWrite(#9'.db'#9);
+        len:=EncodeUleb128(a,buf,0);
+        for i:=0 to len-1 do
+          begin
+            if (i > 0) then
+              writer.AsmWrite(',');
+            writer.AsmWrite(tostr(buf[i]));
+          end;
+        writer.AsmWriteLn(#9'; uleb '+tostr(a));
+      end;
+
     procedure TSdccSdasZ80Assembler.WriteTree(p: TAsmList);
 
       function getreferencestring(var ref : treference) : string;
@@ -251,6 +285,10 @@ unit agsdasz80;
               begin
                 consttype:=tai_const(hp).consttype;
                 case consttype of
+                  aitconst_uleb128bit:
+                    WriteDecodedUleb128(qword(tai_const(hp).value));
+                  aitconst_sleb128bit:
+                    WriteDecodedSleb128(int64(tai_const(hp).value));
                   aitconst_64bit,
                   aitconst_64bit_unaligned,
                   aitconst_32bit,
@@ -296,9 +334,7 @@ unit agsdasz80;
                         writer.AsmWrite(' - $$');}
                       writer.AsmLn;
                     end;
-                  {aitconst_uleb128bit,
-                  aitconst_sleb128bit,
-                  aitconst_128bit,}
+                  {aitconst_128bit,}
                   aitconst_16bit,
                   aitconst_8bit,
                   aitconst_16bit_unaligned{,