Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* bitwise in VAXELN Pascal
@ 1994-08-30 15:33 Ed Kearns
  1994-08-31 12:19 ` Peter Hermann
  1994-09-26  6:20 ` Politzer
  0 siblings, 2 replies; 4+ messages in thread
From: Ed Kearns @ 1994-08-30 15:33 UTC (permalink / raw)


Sorry for the duplicate sys.dec/os.vms posting to all you who
read both, but I may need to get to just the right helpful
person to get this answer...

OK- have I gone crazy, or is there really no way to do bitwise
manipulations in VAXELN Pascal?

Under regular VMS, there are unsigned types and functions
such as UOR and UAND. The help files warn that they are not
present in all implementations. And in fact, EPASCAL complains
that these are unrecognized when I try to compile. Ditto for
OR_ATOMIC.

I'm using VMS 5.5 and EDEBUG 4.4, for what it's worth. I'm
not exactly calling the shots here, so suggestions other than
"get a new version" would be most welcome. Although if that
is something that would fix this, let me know.

I'd also be happy to receive tips or code fragments that would
show me how to inline assembly for this. We don't seem to have
$VAXELNC or I'd try mixing in a C glue routine.

Thanks-
Ed

kearns@budoe.bu.edu



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bitwise in VAXELN Pascal
  1994-08-30 15:33 bitwise in VAXELN Pascal Ed Kearns
@ 1994-08-31 12:19 ` Peter Hermann
  1994-09-26  6:20 ` Politzer
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Hermann @ 1994-08-31 12:19 UTC (permalink / raw)


Ed Kearns (kearns@buphy.bu.edu) wrote:
: Sorry for the duplicate sys.dec/os.vms posting to all you who
: read both, but I may need to get to just the right helpful
: person to get this answer...

: OK- have I gone crazy, or is there really no way to do bitwise
: manipulations in VAXELN Pascal?

: Under regular VMS, there are unsigned types and functions
: such as UOR and UAND. The help files warn that they are not
: present in all implementations. And in fact, EPASCAL complains
: that these are unrecognized when I try to compile. Ditto for
: OR_ATOMIC.

then better use Ada+VAXELN+Starlet.ada: best choice in that specific case.

: I'm using VMS 5.5 and EDEBUG 4.4, for what it's worth. I'm
: not exactly calling the shots here, so suggestions other than
: "get a new version" would be most welcome. Although if that
: is something that would fix this, let me know.

: I'd also be happy to receive tips or code fragments that would
: show me how to inline assembly for this. We don't seem to have
: $VAXELNC or I'd try mixing in a C glue routine.

: Thanks-
: Ed

: kearns@budoe.bu.edu


--
Peter Hermann  Tel:+49-711-685-3611 Fax:3758 ph@csv.ica.uni-stuttgart.de
Pfaffenwaldring 27, 70569 Stuttgart Uni Computeranwendungen
Team Ada: "C'mon people let the world begin" (Paul McCartney)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bitwise in VAXELN Pascal
  1994-08-30 15:33 bitwise in VAXELN Pascal Ed Kearns
  1994-08-31 12:19 ` Peter Hermann
@ 1994-09-26  6:20 ` Politzer
  1994-10-02 12:26   ` bschor
  1 sibling, 1 reply; 4+ messages in thread
From: Politzer @ 1994-09-26  6:20 UTC (permalink / raw)


In article <33vjg7$u3@news.bu.edu>, kearns@buphy.bu.edu (Ed Kearns)
writes:

ELN Pascal has a [bit] type.   You can declare a packed array [x..y] of
[bit] and then do any standard array operations on it.  I have
successfully used this
technique on VME bus cards that present bit masks in status registers.  It
was more straight forward than treating them as unsigned integers.

Hope this helps,
 Bruce
Politzer@aol.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bitwise in VAXELN Pascal
  1994-09-26  6:20 ` Politzer
@ 1994-10-02 12:26   ` bschor
  0 siblings, 0 replies; 4+ messages in thread
From: bschor @ 1994-10-02 12:26 UTC (permalink / raw)


In article <365p6h$ngg@newsbf01.news.aol.com>, politzer@aol.com (Politzer) writes:
> In article <33vjg7$u3@news.bu.edu>, kearns@buphy.bu.edu (Ed Kearns)
> writes:
> 
> ELN Pascal has a [bit] type.   You can declare a packed array [x..y] of
> [bit] and then do any standard array operations on it.  I have
> successfully used this
> technique on VME bus cards that present bit masks in status registers.  It
> was more straight forward than treating them as unsigned integers.
> 
> Hope this helps,
>  Bruce
> Politzer@aol.com
> 
     I didn't see the original post, but if you are trying to do bit 
manipulations in Pascal, there is a very easy (and 100% "legal") way to do 
it, taking advantage of the SET type.

     Suppose you have a 16-bit register, with the bits defined as follows:

Bit 0   Go
Bit 6   Interrupt Enable
Bit 7   Ready flag
Bit 15  Error flag

Use a 16-element enumerated type to name the bits, and make a set out of 
them.

TYPE
  registerbittype = (go, bit1, bit2, bit3, bit4, bit5, intenable, 
			readyflag, bit8, bit9, bit10, bit11, bit12, bit13,
			bit14, errorflag);
  registerset = SET OF registerbittype;

Most Pascal implementations (and you need to check on this!) will implement 
the registerset defined above as a two-byte "array of bits", just what you 
want.  You manipulate the bits by simple set operations.

VAR
 deviceregister : registerset;

PROCEDURE cleardevice

BEGIN   { cleardevice }
 deviceregister := []
END;

PROCEDURE enableinterrupt;

BEGIN   { enableinterrupt }
 deviceregister := deviceregister + [intenable]
END;

PROCEDURE disableinterrupt;

BEGIN   { disableinterrupt }
 deviceregister := deviceregister - [intenable]
END;

FUNCTION oopserror : boolean;

BEGIN   { oopserror }
 oopserror := errorflag IN deviceregister
END;


Note that I'm assuming that you have some way of defining "deviceregister" 
to be either the hardware register itself or an appropriate copy of it.

I've successfully used this technique on both the PC and PDP-11s.  I find 
the use of Pascal sets to represent bits this way quite intuitive and easy 
to understand.  Note that all of the "thinking" goes into the definition of 
the enumerated type -- that's the only place that actual knowledge of the 
hardware is needed (to define the bit locations).

Bob Schor
Pascal/PDP-11 enthusiast



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1994-10-02 12:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-08-30 15:33 bitwise in VAXELN Pascal Ed Kearns
1994-08-31 12:19 ` Peter Hermann
1994-09-26  6:20 ` Politzer
1994-10-02 12:26   ` bschor

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