comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Re: question re Ada equivalent of C function
Date: 1998/02/22
Date: 1998-02-22T00:00:00+00:00	[thread overview]
Message-ID: <01bd3f2d$0b86be20$LocalHost@xhv46.dial.pipex.com> (raw)
In-Reply-To: 6cnj5d$bjq$1@usenet.rational.com


Again, this kind of technique is specific to those architectures with
memory-mapped ports, and even so, there could well be further ramifications
(e.g. access rights, interference, etc.).

It also assumes that an access value is the same as an address: this is not
always so! For fooling around in memory, you're better off using the
facilities provided by the standard packages System.Storage_Elements (RM
13.7.1) and System.Address_To_Access_Conversions (RM 13.7.2).

(I always think it's slightly biblical, quoting chapter-and-verse like that
;-)


== Nick Roberts ================================================
== Croydon, UK                       ===========================
==                                              ================
== Proprietor, ThoughtWing Software                   ==========
== Independent Software Development Consultant            ======
== Nick.Roberts@dial.pipex.com                              ====
== Voicemail & Fax +44 181-405 1124                          ===
==                                                            ==
==           I live not in myself, but I become               ==
===          Portion of that around me; and to me             ==
====         High mountains are a feeling, but the hum        ==
=======      Of human cities torture.
===========                             -- Byron [Childe Harold]


Corey Ashford <yeroca7@rocketmail.com> wrote in article
<6cnj5d$bjq$1@usenet.rational.com>...
> 
> David Fisher wrote in message <34EEFF9C.1D01FA5D@stellar1.com>...
> >Sorry if this is a bit basic, but learning Ada on one's own can be, er,
> >challenging.
> >
> >What are the Ada equivalents of the C functions, inp and outp, used to
> >read a byte from or send one to a memory address?
> >
> >Thanks!
> >
> >David Fisher
> >Fisher Research Corporation
> >
> 
> There are a number of ways to do this in Ada.  Here's one fairly simple
one:
> 
> with unchecked_conversion;
> with system;
> 
> type byte is mod 2*8;
> type byte_access is access byte;
> function to_byte_access is new unchecked_conversion(system.address,
> byte_access);
> 
> function inp(addr: system.address) return byte is
> begin
>     return to_byte_access(addr).all;
> end inp;
> 
> procedure outp(addr: system.address; value: byte) is
> begin
>     to_byte_access(addr).all := value;
> end outp;





  reply	other threads:[~1998-02-22  0:00 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-21  0:00 question re Ada equivalent of C function David Fisher
1998-02-21  0:00 ` Brian Rogoff
1998-02-21  0:00   ` Jerry van Dijk
1998-02-21  0:00     ` David Fisher
1998-02-22  0:00       ` Simon Wright
1998-02-22  0:00         ` Simon Wright
1998-02-22  0:00       ` Jerry van Dijk
1998-02-22  0:00         ` Robert Dewar
1998-02-22  0:00           ` Andi Kleen
1998-02-21  0:00   ` Robert Dewar
1998-02-22  0:00     ` Brian Rogoff
1998-02-22  0:00   ` Nick Roberts
1998-02-22  0:00     ` frc
1998-02-21  0:00 ` Robert Dewar
1998-02-21  0:00 ` Corey Ashford
1998-02-22  0:00   ` Nick Roberts [this message]
1998-02-22  0:00 ` Larry Kilgallen
1998-02-22  0:00   ` frc
1998-02-22  0:00     ` Linux/POSIX packages for GNAT Markus Kuhn
1998-02-22  0:00       ` Andi Kleen
1998-02-22  0:00         ` Markus Kuhn
1998-02-22  0:00           ` Robert Dewar
1998-02-22  0:00         ` Samuel Tardieu
1998-02-23  0:00           ` Nick Roberts
1998-02-23  0:00             ` Samuel Tardieu
1998-03-05  0:00             ` Testing exception handlers James M. Darlack
1998-02-22  0:00       ` Linux/POSIX packages for GNAT Robert Dewar
1998-02-23  0:00         ` Andi Kleen
1998-02-22  0:00           ` Robert Dewar
1998-02-23  0:00             ` Markus Kuhn
1998-02-23  0:00               ` Robert Dewar
1998-02-23  0:00         ` Markus Kuhn
1998-02-23  0:00           ` Robert Dewar
1998-02-23  0:00             ` Markus Kuhn
1998-02-24  0:00               ` question re Ada equivalent of C function Dale Stanbrough
1998-02-22  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