From: Geoff Bull <geoff@research.canon.com.au>
To: jross <rem.jross@rem.codemecca.com>
Subject: Re: C/C++ programmer giving Ada95 a chance -- writing an emulator.
Date: 2000/03/28
Date: 2000-03-28T07:23:05+00:00 [thread overview]
Message-ID: <38E05DF5.D9AEC67A@research.canon.com.au> (raw)
In-Reply-To: 38e148e2.5089627@news.shreve.net
jross wrote:
>
> C/C++ is prime for such a low level application. How about Ada?
Anything you can write in C you can more or less directly translate to Ada.
> My first question is how do you define and write a dispatching
> mechanism as you would in C++ using function pointers in a table for
> execution speed efficiency, like this:
>
The following is a direct translation of your code:
with Ada.Text_IO; use Ada.Text_IO;
procedure Example is
type Opcode is range 16#00# .. 16#FF#;
type Func_Access is access procedure;
type Op_Struct is
record
Byte : Opcode;
Func : Func_Access;
end record;
procedure Op_U is begin Put_Line ("undefined opcode"); end Op_U;
procedure Op_00 is begin Put_Line ("opcode 00"); end Op_00;
procedure Op_01 is begin Put_Line ("opcode 01"); end Op_01;
procedure Op_02 is begin Put_Line ("opcode 02"); end Op_02;
procedure Op_03 is begin Put_Line ("opcode 03"); end Op_03;
Op_Table : array (Opcode) of Op_Struct
:= ((16#00#, Op_00'Access),
(16#01#, Op_01'Access),
(16#02#, Op_02'Access),
(16#03#, Op_03'Access),
others => (16#FF#, Op_U'Access)
);
Core : array (Natural range <>) of Opcode := (0, 1, 2, 3, 55);
IR : Opcode;
begin
for PA in Core'Range loop
IR := Core (PA);
Op_Table (IR).Func.all;
end loop;
end Example;
next prev parent reply other threads:[~2000-03-28 0:00 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <38e148e2.5089627@news.shreve.net>
2000-03-28 0:00 ` C/C++ programmer giving Ada95 a chance -- writing an emulator Juergen Pfeifer
2000-03-28 0:00 ` Jim Rogers
2000-03-29 0:00 ` Ed Falis
2000-03-29 0:00 ` James S. Rogers
2000-03-29 0:00 ` Jean-Marc Bourguet
2000-03-29 0:00 ` Robert Dewar
2000-03-30 0:00 ` Geoff Bull
2000-03-30 0:00 ` tmoran
2000-04-01 0:00 ` Robert Dewar
2000-03-28 0:00 ` Geoff Bull [this message]
2000-03-28 0:00 ` Jean-Marc Bourguet
2000-03-28 0:00 ` Ken Garlington
2000-03-30 0:00 ` Geoff Bull
[not found] ` <38e7e951.8384503@news.shreve.net>
2000-04-02 0:00 ` Jean-Pierre Rosen
2000-04-02 0:00 ` Robert Dewar
2000-04-03 0:00 ` Paul Graham
2000-04-06 0:00 ` Robert Dewar
2000-04-06 0:00 ` Larry Kilgallen
2000-04-06 0:00 ` Robert Dewar
2000-04-06 0:00 ` Gautier
2000-04-07 0:00 ` Robert Dewar
2000-04-07 0:00 ` Gautier
[not found] ` <38e19656.17008608@news.shreve.net>
2000-03-29 0:00 ` David Starner
2000-03-29 0:00 ` Robert Dewar
2000-03-29 0:00 ` Marin D. Condic
2000-03-29 0:00 ` Robert A Duff
2000-03-29 0:00 ` Marin D. Condic
2000-03-29 0:00 ` Jean-Marc Bourguet
2000-03-29 0:00 ` Robert Dewar
2000-03-30 0:00 ` Jean-Marc Bourguet
2000-04-01 0:00 ` Robert Dewar
2000-03-30 0:00 ` Geoff Bull
2000-04-01 0:00 ` Robert Dewar
2000-04-02 0:00 ` Geoff Bull
2000-04-02 0:00 ` Robert Dewar
2000-04-02 0:00 ` swhalen
2000-03-29 0:00 ` Robert A Duff
2000-03-30 0:00 ` Geoff Bull
2000-04-01 0:00 ` Robert Dewar
2000-03-29 0:00 ` Marc A. Criley
2000-03-29 0:00 ` Marin D. Condic
2000-03-29 0:00 ` swhalen
2000-03-29 0:00 ` Robert Dewar
2000-03-30 0:00 ` swhalen
2000-03-30 0:00 ` Ken Garlington
2000-03-30 0:00 ` Samuel T. Harris
2000-04-01 0:00 ` Robert Dewar
2000-04-05 0:00 ` Robert A Duff
[not found] <38E3DBD7.27F5B246@acenet.com.au>
2000-03-31 0:00 ` tmoran
2000-03-31 0:00 ` Geoff Bull
2000-04-01 0:00 ` Tucker Taft
2000-04-02 0:00 ` Geoff Bull
2000-04-02 0:00 ` Robert Dewar
2000-04-02 0:00 ` Geoff Bull
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox