comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Mize <smize@imagin.net>
Subject: Re: Executing machine code?
Date: 1999/05/27
Date: 1999-05-27T00:00:00+00:00	[thread overview]
Message-ID: <7ijqgs$26o@news2.newsguy.com> (raw)
In-Reply-To: 86u2sya7od.fsf@finch.cs.und.ac.za

Ikram <ikram@cs.und.ac.za> wrote:
> I occasionally need to write programs that generate and execute
> machine code (as in e.g. genetic programming systems).  in C, the
> method I've been using is to store the machine instructions in an
> array of bytes, and then cast the array into a function, e.g.:

My word.  I doubt you'll find a large body of people with experience
in this area.  :-)

> I'm trying to find out whether it is similarly possible to switch
> between array and function representations in Ada (not necessarily in
> a platform- or compiler-independent way).

I think you can accomplish what you want, at least with some compilers.
You'll need a compiler that supports the syntax for machine-language
instructions.  Write a routine that determines the address of the
first byte in your array of bytes, and then does a machine-language
subroutine jump to that address.

I specify "first byte in the array" because some compilers, at least
some older Ada 83 compilers, may return the address of a dope vector
if you just use 'address.

You may need to decide where to put the array in memory, and use a
representation clause to put it there.

Best of luck, and let us know how it works out!

Sam Mize

-- 
Samuel Mize -- smize@imagin.net (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam




  parent reply	other threads:[~1999-05-27  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-27  0:00 Executing machine code? Ikram
1999-05-27  0:00 ` David Brown
1999-05-27  0:00 ` Samuel Mize [this message]
1999-05-28  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox