Browse Source

+ build an instruction table cache for the Z80

git-svn-id: trunk@45173 -
nickysn 5 years ago
parent
commit
6654faea08
1 changed files with 34 additions and 0 deletions
  1. 34 0
      compiler/z80/aasmcpu.pas

+ 34 - 0
compiler/z80/aasmcpu.pas

@@ -158,9 +158,16 @@ implementation
                                 Instruction table
 *****************************************************************************}
 
+    type
+      TInsTabCache=array[TasmOp] of longint;
+      PInsTabCache=^TInsTabCache;
+
     const
       InsTab:array[0..instabentries-1] of TInsEntry={$i z80tab.inc}
 
+    var
+      InsTabCache : PInsTabCache;
+
 {*****************************************************************************
                                  taicpu Constructors
 *****************************************************************************}
@@ -475,13 +482,40 @@ implementation
       end;
 
 
+{****************************************************************************
+                                Instruction table
+*****************************************************************************}
+
+    procedure BuildInsTabCache;
+      var
+        i : longint;
+      begin
+        new(instabcache);
+        FillChar(instabcache^,sizeof(tinstabcache),$ff);
+        i:=0;
+        while (i<InsTabEntries) do
+         begin
+           if InsTabCache^[InsTab[i].OPcode]=-1 then
+            InsTabCache^[InsTab[i].OPcode]:=i;
+           inc(i);
+         end;
+      end;
+
+
     procedure InitAsm;
       begin
+        if not assigned(instabcache) then
+          BuildInsTabCache;
       end;
 
 
     procedure DoneAsm;
       begin
+        if assigned(instabcache) then
+          begin
+            dispose(instabcache);
+            instabcache:=nil;
+          end;
       end;
 
 begin