title: creating a fast case statement (assembly)
body: <p>I have a project that has intensive use of the case statement with many procedures coming off it.  I know you can place case statements in a two tear arrangement divide in blocks of 10 and a second case statement to separate individual procedures.  But I have a better idea if I can pull it off.
  I want to call it assembly case</p>
  
  <pre><code>Prolist: array [1..500] of Pointer =
            (@Procedure1, @Procedure2, @Procedure3, @Procedure4, @Procedure5);
  
  
  Procedure ASMCase(Prolist: array of Pointer; No: Word; Var InRange: Boolean);
  var Count : DWord;
      PTR: Pointer;
      Pro : Procedure;
  begin
    Count := No * 4;
    InRange := boolean(Count &lt;= SizeOf(Prolist));
    If not InRange then Exit;
    PTR := Pointer(DWord(@Prolist[1]) + Count);
    If PTR &lt;&gt; nil then Pro := @PTR else Exit;
    Pro;  /run procedure
  end;​
  </code></pre>
  
  <p>The point is I'm creating a direct jump to the procedure.
  In my case procedures can have an identical header and global data can be accessed for any odd information.  Writing it in assembly would be faster I think but what I'm not sure on is running the procedures. Please do not ask why am I doing this as I have 500 procedures with many calls on the case statement and time is of essence with a fast processor. </p>