comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP>
Subject: Re: Cleanest Ada way to do this?
Date: Sun, 22 Jun 2014 19:07:32 +0000 (UTC)
Date: 2014-06-22T19:07:32+00:00	[thread overview]
Message-ID: <lo79hk$bss$1@dont-email.me> (raw)
In-Reply-To: 7eaee5fc-2045-4bb3-8b16-d757b54760da@googlegroups.com

On 2014-06-22, Mike Silva <hungupharps@gmail.com> wrote:
> I'd like some help on the cleanest, or most elegant, way to do this in Ada. 
> I'm writing to an LCD character display, in 4-bit mode, which requires writing
> an 8 bit character or command value as two 4 bit pieces.  The port (a memory
> address) being written to is 32 bits wide.  What I would like to be able to do
> is some form of this (not valid Ada, I know):
>
>  Port32(4..7) := Some_Char(4..7);
>  ..twiddle some other control bits..
>  Port32(4..7) := Some_Char(0..3);
>  ..twiddle some other control bits..
>

Do the other bits in Port32 need to be preserved when (4..7) are written ?

Is it _required_ that Port32 is written in units of 32 bits ?
(The answer to that is probably yes, but I thought I would check).

There was some discussion of this class of problem a few weeks ago when
I was proposing syntax to allow the atomic update of multiple bitfields
at the same time without having to use an intermediate variables.

The conclusions from that were that if you need to preserve the other
bits in Port32(4..7) your only real option is to use a temporary
variable with a 32-bit record structure to match your bitfield
requirements (unless you want to get into using C style bitmasks.)

Pragma Atomic and/or Pragma Volatile may also need to be applied.

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world

  reply	other threads:[~2014-06-22 19:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-22 16:51 Cleanest Ada way to do this? Mike Silva
2014-06-22 19:07 ` Simon Clubley [this message]
2014-06-22 21:20   ` Mike Silva
2014-06-22 21:05 ` Shark8
2014-06-23  0:17   ` Simon Clubley
2014-06-23  6:46     ` hungupharps
2014-06-23  7:32       ` Georg Bauhaus
2014-06-23 11:48         ` Simon Clubley
2014-06-23 15:40           ` G.B.
2014-06-23  9:02 ` rrr.eee.27
2014-06-23 11:57   ` Simon Clubley
2014-06-23 12:05     ` rrr.eee.27
replies disabled

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