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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no 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-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!tudelft.nl!txtfeed1.tudelft.nl!zen.net.uk!dedekind.zen.co.uk!aioe.org!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Code Statement Date: Wed, 19 May 2010 04:37:19 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <8242a424-5b09-4444-a3ed-7b45e159c46a@z17g2000vbd.googlegroups.com> Reply-To: johnjohn@cox.net NNTP-Posting-Host: PvS+DjwtHl9L/qMvWSy8nQ.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: IBM NewsReader/2 2.0 Xref: g2news2.google.com comp.lang.ada:11742 Date: 2010-05-19T04:37:19+00:00 List-Id: In <8242a424-5b09-4444-a3ed-7b45e159c46a@z17g2000vbd.googlegroups.com>, sjw writes: >On May 18, 2:12=A0pm, johnj...@cox.net wrote: >> 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; > >See >http://booch95.svn.sourceforge.net/viewvc/booch95/trunk/src/bc-support-high= >_resolution_time-clock.adb-pentium?revision=3D1415&view=3Dmarkup >for a working i586/x86_64 example. > >Best not to use -gnatpg: -gnatp says 'suppress all checks', -gnatg >says 'GNAT implementation mode (used for compiling GNAT units)' -- I'm >pretty sure that that mode is like -Werror. As for the example supplied I decide use the intel "nop" for simplicity instead of using the codes for the attached processor. I prefer to use the Code Statement like the System.Machine_Code in SUN, instead of using the inline-assembler of gnat\gcc. which forces the following type of statements for non-native processors: ASM ( " .byte 0x90" ) ; -- intel x86 nop ASM ( " .byte 0x02" ) ; -- attach processor instruction "Load R2" ... And using the code statement allows the Ada compiler to emulate a small limited assembler without all of the work\time in rewriting\expanding the gcc "AS" to include the new processor. So, I see no problem in using code statement except for creating or expand and recompiling the "system.machine_code" package. Unless Adacore has crippled gnat's code statement routines. Now, the RM 13.8 (2), says that the code statement is qualified_expression so what the problem. In Gnat, the ASM routines are handled by the "Expand_Asm_Call" procedure ("exp_code" package) which expands the ASM statement into a qualified_expression. Also, "P_Code_Statement" ("par-ch13" package) directly processes code_statements as an qualified_expression. Afterwards, the "Analyze_Code_Statement" ("sem-ch13" package) analyzes should handle the code statements but this routine is where the error message is generated. Used "-gnatpg" since machine_code is a gnat system package.