comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Code Statement
Date: Tue, 18 May 2010 06:22:47 -0700 (PDT)
Date: 2010-05-18T06:22:47-07:00	[thread overview]
Message-ID: <875f1a64-0cce-4e45-aacf-058d21b944b2@c11g2000vbe.googlegroups.com> (raw)
In-Reply-To: hsu3ok$gag$1@speranza.aioe.org

johnj...@cox.net wrote on comp.lang.ada:
> Trying to use the "Code Statement" for a special project, by passing the
> ASM proc/func. So, can Gnat process a true "Code Statement" statement?
>
> When I compile the following example using>gnat make temp.adb -gnatpg
>
> gcc -c -gnatpg temp.adb
> temp.adb:10:07: incorrect type for code statement
> gnatmake: "temp.adb" compilation error
>
> Source code:
>
>    package Machine_Code is
>        type Asm_Insn is new Integer;  --  type required by gant
>        x86_NOP    : constant Asm_Insn := 16#90#;
>        type M_Code_0  is record
>                          Opcode : Asm_Insn;
>        end record;
>        pragma Pack (M_Code_0);
>    end Machine_Code;
>
> Source code:
>
>    with Machine_Code;
>    procedure temp is
>        procedure Test;
>        procedure Test is
>           use Machine_Code;
>        begin
>           M_Code_0'(Opcode => x86_NOP);  -- line 10
>        end Test;
>    begin
>       null;
>    end temp;

Line 10 is not a statement, it is a qualified expression and only
statements (and pragmas) are accepted between "begin" and "end".
Machine code insertions are very, very special; they bend the language
rules. If you want to do machine code insertions with GNAT, you must
follow the GNAT rules and use the package System.Machine_Code package
provided by the compiler, not a user-written package.

It seems you are trying to port machine code from the IBM Rational
compiler to GNAT? The only way to do that is by rewriting the machine
code in GNU assembly language. See http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Inline-Assembler.html

HTH

--
Ludovic Brenta.



  reply	other threads:[~2010-05-18 13:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-18 13:12 Code Statement johnjohn
2010-05-18 13:22 ` Ludovic Brenta [this message]
2010-05-18 13:29 ` AdaMagica
2010-05-18 15:05 ` sjw
2010-05-19  4:37   ` anon
2010-05-19  6:07     ` Simon Wright
2010-05-19  9:56       ` sjw
2010-05-19 10:20         ` AdaMagica
replies disabled

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