From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,8b6340ddbfdcd2d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!c11g2000vbe.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Code Statement Date: Tue, 18 May 2010 06:22:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: <875f1a64-0cce-4e45-aacf-058d21b944b2@c11g2000vbe.googlegroups.com> References: NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1274188967 12729 127.0.0.1 (18 May 2010 13:22:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 18 May 2010 13:22:47 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c11g2000vbe.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:11728 Date: 2010-05-18T06:22:47-07:00 List-Id: 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: > > =A0 =A0package Machine_Code is > =A0 =A0 =A0 =A0type Asm_Insn is new Integer; =A0-- =A0type required by ga= nt > =A0 =A0 =A0 =A0x86_NOP =A0 =A0: constant Asm_Insn :=3D 16#90#; > =A0 =A0 =A0 =A0type M_Code_0 =A0is record > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Opcode : Asm_Insn; > =A0 =A0 =A0 =A0end record; > =A0 =A0 =A0 =A0pragma Pack (M_Code_0); > =A0 =A0end Machine_Code; > > Source code: > > =A0 =A0with Machine_Code; > =A0 =A0procedure temp is > =A0 =A0 =A0 =A0procedure Test; > =A0 =A0 =A0 =A0procedure Test is > =A0 =A0 =A0 =A0 =A0 use Machine_Code; > =A0 =A0 =A0 =A0begin > =A0 =A0 =A0 =A0 =A0 M_Code_0'(Opcode =3D> x86_NOP); =A0-- line 10 > =A0 =A0 =A0 =A0end Test; > =A0 =A0begin > =A0 =A0 =A0 null; > =A0 =A0end 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_u= nw/Inline-Assembler.html HTH -- Ludovic Brenta.