comp.lang.ada
 help / color / mirror / Atom feed
* pascal to Ada
@ 2001-02-14 19:29 Munir Albeelbisi
  2001-02-14 21:30 ` Pascal Obry
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Munir Albeelbisi @ 2001-02-14 19:29 UTC (permalink / raw)


is there any pascal to Ada converter





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

* Re: pascal to Ada
  2001-02-14 19:29 pascal to Ada Munir Albeelbisi
@ 2001-02-14 21:30 ` Pascal Obry
  2001-02-15 12:22   ` Marc A. Criley
  2001-02-15 10:43 ` David C. Hoos, Sr.
  2001-02-15 17:21 ` Randy Brukardt
  2 siblings, 1 reply; 14+ messages in thread
From: Pascal Obry @ 2001-02-14 21:30 UTC (permalink / raw)



"Munir Albeelbisi" <munir.albeelbisi@sympatico.ca> writes:

> is there any pascal to Ada converter

Sure:

http://members.nbci.com/gdemont/

It is called Newp2ada see the Soft section
(http://members.nbci.com/gdemont/gsoft.htm).

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



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

* Re: pascal to Ada
  2001-02-14 19:29 pascal to Ada Munir Albeelbisi
  2001-02-14 21:30 ` Pascal Obry
@ 2001-02-15 10:43 ` David C. Hoos, Sr.
  2001-02-15 17:21 ` Randy Brukardt
  2 siblings, 0 replies; 14+ messages in thread
From: David C. Hoos, Sr. @ 2001-02-15 10:43 UTC (permalink / raw)


Take a look at the web page
http://members.nbci.com/gdemont/pascada.htm

"Munir Albeelbisi" <munir.albeelbisi@sympatico.ca> wrote in message
news:p0Bi6.118862$Pm2.2242177@news20.bellglobal.com...
> is there any pascal to Ada converter
>
>




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

* Re: pascal to Ada
  2001-02-14 21:30 ` Pascal Obry
@ 2001-02-15 12:22   ` Marc A. Criley
  2001-02-15 17:31     ` Pascal Obry
  0 siblings, 1 reply; 14+ messages in thread
From: Marc A. Criley @ 2001-02-15 12:22 UTC (permalink / raw)


Pascal Obry wrote:
> 
> "Munir Albeelbisi" <munir.albeelbisi@sympatico.ca> writes:
> 
> > is there any pascal to Ada converter
> 
   <snip>
> 
> Pascal.
> 

But it looks to me like Pascal has already been converted to Ada!   :-)
:-)

Marc



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

* Re: pascal to Ada
  2001-02-14 19:29 pascal to Ada Munir Albeelbisi
  2001-02-14 21:30 ` Pascal Obry
  2001-02-15 10:43 ` David C. Hoos, Sr.
@ 2001-02-15 17:21 ` Randy Brukardt
  2 siblings, 0 replies; 14+ messages in thread
From: Randy Brukardt @ 2001-02-15 17:21 UTC (permalink / raw)


Munir Albeelbisi wrote in message ...
>is there any pascal to Ada converter

If you're looking for a supported product, R.R. Software still offers
it's Pastran product. It will convert about 99% of IEEE standard Pascal
to Ada that functions identically. We also offer customization of
Pastran for specific Pascal dialects (this is practical only for large
projects, because of the costs involved).

            Randy Brukardt
            R.R. Software, Inc.






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

* Re: pascal to Ada
  2001-02-15 12:22   ` Marc A. Criley
@ 2001-02-15 17:31     ` Pascal Obry
  0 siblings, 0 replies; 14+ messages in thread
From: Pascal Obry @ 2001-02-15 17:31 UTC (permalink / raw)



"Marc A. Criley" <mcquadex@earthlink.net> writes:
> But it looks to me like Pascal has already been converted to Ada!   :-)
> :-)
> 

Yes, and it is a 100% complete convertion, but it was not 100% automatic :) :)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



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

* Pascal to ADA
@ 2003-11-17 10:12 Tilman Gloetzner
  2003-11-17 10:24 ` Vinzent 'Gadget' Hoefler
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Tilman Gloetzner @ 2003-11-17 10:12 UTC (permalink / raw)


Hello,

1) what is a effecient way of rewriting the following code fragement in ADA
?  With the absolute keyword, Pascal  effectively casts
N, M, and R from a 4 byte integer type to an array of 4 bytes by an address
access.  I guess to implement the same mechanism in
ADA is not in line with ADA's philosophy.

2) How do I mask out bits in a (unsigned) number type, as logical operators
work only on booleans ?

Thank you,

Tilman

----------------------------------------------------------------
PROCEDURE Add32(N:LONGINT;M:LONGINT;VAR R:LONGINT) ;
VAR
     _N : ARRAY[0..3] OF BYTE ABSOLUTE N ;
     _M : ARRAY[0..3] OF BYTE ABSOLUTE M ;
     _R : ARRAY[0..3] OF BYTE ABSOLUTE R ;
     A  : BYTE ;
     B  : WORD ;
     C  : WORD ; { Carry }
BEGIN
     R := 0 ;
     C := 0 ;
     FOR A := 0 TO 3 DO BEGIN
         B := _N[A] + _M[A] + C ;
         _R[A] := B AND $FF ;
         C := B SHR 8 ;
     END ;
END  ;





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

* Re: Pascal to ADA
  2003-11-17 10:12 Pascal to ADA Tilman Gloetzner
@ 2003-11-17 10:24 ` Vinzent 'Gadget' Hoefler
  2003-11-17 10:44 ` Marius Amado Alves
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Vinzent 'Gadget' Hoefler @ 2003-11-17 10:24 UTC (permalink / raw)


Tilman Gloetzner wrote:

>Hello,
>
>1) what is a effecient way of rewriting the following code fragement in ADA
[...]

It's called Ada. Just like Pascal.

>----------------------------------------------------------------
>PROCEDURE Add32(N:LONGINT;M:LONGINT;VAR R:LONGINT) ;

The most simple way I see would be:

|R := N + M;

or if you insist on using a procedure:

|type LongInt is range -2**31 .. 2**31 - 1;
|
|procedure Add32 (N : in  LongInt;
|	          M : in  LongInt;
|                 R : out LongInt) is
|begin
|   R := N + M;
|end Add32;


Vinzent.



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

* Re: Pascal to ADA
  2003-11-17 10:12 Pascal to ADA Tilman Gloetzner
  2003-11-17 10:24 ` Vinzent 'Gadget' Hoefler
@ 2003-11-17 10:44 ` Marius Amado Alves
  2003-11-17 11:41 ` Ole-Hjalmar Kristensen
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Marius Amado Alves @ 2003-11-17 10:44 UTC (permalink / raw)
  To: comp.lang.ada

On Mon, 2003-11-17 at 10:12, Tilman Gloetzner wrote:
> Hello,
> 
> 1) what is a effecient way of rewriting the following code fragement in ADA
> ?  With the absolute keyword, Pascal  effectively casts...

If you don't write "PASCAL", why on Earth do you write "ADA"???!!!

Ada has many ways to treat bits as boolean values: (uncheckedly) convert
between a modular type and an array of Boolean; a record type with
Boolean components and representation clauses...

Sorry, the Pascal reference I have here (Report 3rd ed., 1984) does not
have the "absolute" keyword, so I cannot interpret your code further
just now. Since when is "absolute" in the standard, BTW?





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

* Re: Pascal to ADA
  2003-11-17 10:12 Pascal to ADA Tilman Gloetzner
  2003-11-17 10:24 ` Vinzent 'Gadget' Hoefler
  2003-11-17 10:44 ` Marius Amado Alves
@ 2003-11-17 11:41 ` Ole-Hjalmar Kristensen
       [not found] ` <1069065860.2826.11.camel@localhost.localdomain>
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Ole-Hjalmar Kristensen @ 2003-11-17 11:41 UTC (permalink / raw)



1. Why do you need this routine at all? 

2. You can accomplish the same in Ada in different ways. two obvious
   solutions are unchecked_conversion or an overlay with an address
   clause between a packed array of bytes and your 32 bit integer.

Overlay version:

type Long_Int is range -2**31 .. 2**31 - 1;
type Byte is mod 2**8;
...

Procedure Add(N: Long_Int; M: Long_Int; R : out Long_Int) is
  Cheat_N : array(0..3) of Byte;
  pragma pack(Cheat_N);
  for Cheat_N'address use N'address;
...
begin
...
end Add;

3. Logical operators also work on modular integers. Ada also has
   arithmetic shift, so you can conveniently access the carry bit.

>>>>> "TG" == Tilman Gloetzner <tilman.gloetzner@etas.co.kr> writes:

    TG> Hello,
    TG> 1) what is a effecient way of rewriting the following code fragement in ADA
    TG> ?  With the absolute keyword, Pascal  effectively casts
    TG> N, M, and R from a 4 byte integer type to an array of 4 bytes by an address
    TG> access.  I guess to implement the same mechanism in
    TG> ADA is not in line with ADA's philosophy.

    TG> 2) How do I mask out bits in a (unsigned) number type, as logical operators
    TG> work only on booleans ?

    TG> Thank you,

    TG> Tilman

    TG> ----------------------------------------------------------------
    TG> PROCEDURE Add32(N:LONGINT;M:LONGINT;VAR R:LONGINT) ;
    TG> VAR
    TG>      _N : ARRAY[0..3] OF BYTE ABSOLUTE N ;
    TG>      _M : ARRAY[0..3] OF BYTE ABSOLUTE M ;
    TG>      _R : ARRAY[0..3] OF BYTE ABSOLUTE R ;
    TG>      A  : BYTE ;
    TG>      B  : WORD ;
    TG>      C  : WORD ; { Carry }
    TG> BEGIN
    TG>      R := 0 ;
    TG>      C := 0 ;
    TG>      FOR A := 0 TO 3 DO BEGIN
    TG>          B := _N[A] + _M[A] + C ;
    TG>          _R[A] := B AND $FF ;
    TG>          C := B SHR 8 ;
    TG>      END ;
    TG> END  ;



-- 
Strange attractors stole my wife



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

* Re: Pascal to ADA
       [not found] ` <1069065860.2826.11.camel@localhost.localdomain>
@ 2003-11-17 13:17   ` Marius Amado Alves
  0 siblings, 0 replies; 14+ messages in thread
From: Marius Amado Alves @ 2003-11-17 13:17 UTC (permalink / raw)
  To: comp.lang.ada

On Mon, 2003-11-17 at 10:44, Marius Amado Alves wrote:
> Sorry, the Pascal reference I have here (Report 3rd ed., 1984) does not
> have the "absolute" keyword, so I cannot interpret your code further
> just now. Since when is "absolute" in the standard, BTW?

(Replying to myself.) It seems "absolute" is strictly a *Turbo* Pascal
extension.




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

* Re: Pascal to ADA
  2003-11-17 10:12 Pascal to ADA Tilman Gloetzner
                   ` (3 preceding siblings ...)
       [not found] ` <1069065860.2826.11.camel@localhost.localdomain>
@ 2003-11-17 14:42 ` Steve
  2003-11-17 23:14   ` tmoran
  2003-11-20 12:24 ` Lutz Donnerhacke
  5 siblings, 1 reply; 14+ messages in thread
From: Steve @ 2003-11-17 14:42 UTC (permalink / raw)


This is as close as I can come to a literal translation:

  subtype BYTE is Unsigned_8;
  subtype LONGINT is Integer;
  subtype WORD is Unsigned_16;

  procedure Add32(N:LONGINT;M:LONGINT;R: in out LONGINT) is
    N_As_Bytes : array(0..3) of BYTE;
    for N_As_Bytes'Address use N'Address;
    M_As_Bytes : array(0..3) of BYTE;
    for M_As_Bytes'Address use M'Address;
    R_As_Bytes : array(0..3) of BYTE;
    for R_As_Bytes'Address use R'Address;
    B : WORD;
    C : WORD;-- Carry
  begin
    R := 0 ;
    C := 0 ;
    for A in 0 .. 3 loop
      B := WORD( N_As_Bytes(A) + M_As_Bytes(A) ) + C ;
      R_As_Bytes(A) := BYTE( B and 16#FF# );
      C := Shift_Right( B, 8 );
    end loop;
  end Add32;

You'll need to have "with Interfaces; use Interfaces" included in order to
define Unsigned_8 and Unsigned_16.

I changed _N to N_As_Bytes since Ada does not permit using an underscore as
the first character in an identifier.

Steve
(The Duck)


"Tilman Gloetzner" <tilman.gloetzner@etas.co.kr> wrote in message
news:bpa46j$o0l$1@news1.kornet.net...
> Hello,
>
> 1) what is a effecient way of rewriting the following code fragement in
ADA
> ?  With the absolute keyword, Pascal  effectively casts
> N, M, and R from a 4 byte integer type to an array of 4 bytes by an
address
> access.  I guess to implement the same mechanism in
> ADA is not in line with ADA's philosophy.
>
> 2) How do I mask out bits in a (unsigned) number type, as logical
operators
> work only on booleans ?
>
> Thank you,
>
> Tilman
>
> ----------------------------------------------------------------
> PROCEDURE Add32(N:LONGINT;M:LONGINT;VAR R:LONGINT) ;
> VAR
>      _N : ARRAY[0..3] OF BYTE ABSOLUTE N ;
>      _M : ARRAY[0..3] OF BYTE ABSOLUTE M ;
>      _R : ARRAY[0..3] OF BYTE ABSOLUTE R ;
>      A  : BYTE ;
>      B  : WORD ;
>      C  : WORD ; { Carry }
> BEGIN
>      R := 0 ;
>      C := 0 ;
>      FOR A := 0 TO 3 DO BEGIN
>          B := _N[A] + _M[A] + C ;
>          _R[A] := B AND $FF ;
>          C := B SHR 8 ;
>      END ;
> END  ;
>
>





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

* Re: Pascal to ADA
  2003-11-17 14:42 ` Steve
@ 2003-11-17 23:14   ` tmoran
  0 siblings, 0 replies; 14+ messages in thread
From: tmoran @ 2003-11-17 23:14 UTC (permalink / raw)


> subtype BYTE is Unsigned_8;
> subtype LONGINT is Integer;
> subtype WORD is Unsigned_16;
   The middle one should of course be
  subtype LONGINT is Integer_32;
both for consistency and because the Standard Integer is only required to
hold at least 16 bits but could hold as many as the compiler writer chose.



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

* Re: Pascal to ADA
  2003-11-17 10:12 Pascal to ADA Tilman Gloetzner
                   ` (4 preceding siblings ...)
  2003-11-17 14:42 ` Steve
@ 2003-11-20 12:24 ` Lutz Donnerhacke
  5 siblings, 0 replies; 14+ messages in thread
From: Lutz Donnerhacke @ 2003-11-20 12:24 UTC (permalink / raw)


* Tilman Gloetzner wrote:
> 1) what is a effecient way of rewriting the following code fragement in ADA
> ?  With the absolute keyword, Pascal  effectively casts
> N, M, and R from a 4 byte integer type to an array of 4 bytes by an address
> access.  I guess to implement the same mechanism in
> ADA is not in line with ADA's philosophy.
> 
> 2) How do I mask out bits in a (unsigned) number type, as logical operators
> work only on booleans ?

type Do_It_Right is mod 2**(4*8);



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

end of thread, other threads:[~2003-11-20 12:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-17 10:12 Pascal to ADA Tilman Gloetzner
2003-11-17 10:24 ` Vinzent 'Gadget' Hoefler
2003-11-17 10:44 ` Marius Amado Alves
2003-11-17 11:41 ` Ole-Hjalmar Kristensen
     [not found] ` <1069065860.2826.11.camel@localhost.localdomain>
2003-11-17 13:17   ` Marius Amado Alves
2003-11-17 14:42 ` Steve
2003-11-17 23:14   ` tmoran
2003-11-20 12:24 ` Lutz Donnerhacke
  -- strict thread matches above, loose matches on Subject: below --
2001-02-14 19:29 pascal to Ada Munir Albeelbisi
2001-02-14 21:30 ` Pascal Obry
2001-02-15 12:22   ` Marc A. Criley
2001-02-15 17:31     ` Pascal Obry
2001-02-15 10:43 ` David C. Hoos, Sr.
2001-02-15 17:21 ` Randy Brukardt

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