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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,23a17bbd96d53327 X-Google-Attributes: gid103376,public From: Bill Ghrist Subject: Re: Assembler in Ada? Date: 1999/01/14 Message-ID: <369E3E22.B21A4331@pgh.net>#1/1 X-Deja-AN: 432717369 Content-Transfer-Encoding: 7bit References: <369C5E08.69727537@mbox5.swipnet.se> Content-Type: text/plain; charset=us-ascii Organization: Myself Mime-Version: 1.0 Reply-To: ghristwd@pgh.net Newsgroups: comp.lang.ada Date: 1999-01-14T00:00:00+00:00 List-Id: This raises a related issue, which is the one frustrating thing that I have found while trying to use GNAT to teach myself Ada and evaluate it for possible future use. Trying to interpret the assembler listing that is produced by using the gcc -S switch is like trying to read something in Klingon. Does anybody know whether there is a straightforward description of the x86 assembly syntax used by GNAT/gcc? When I have asked this in the past, all I got was pointers to something like the `Using and Porting GNU CC' document, but this is at least a couple of layers of abstraction removed from the information I am looking for. What I really want is a "gcc x86" to "Intel ASM86" dictionary (or any of the other dialects such as Microsoft or Borland - everything but "gcc x86" is close enough to Intel syntax as to be pretty obvious). Has anyone done one of these? Regards, Bill Ghrist Matthew Heaney wrote: > > Thomas Larsson writes: > > > I would like to write some assembler into my Ada program (to change > > video mode, use mouse etc). > > > > How do I do that? (I have tried to figured out how, but I can't) > > Can I do it in a way similar to assembler in C or Pascal? > > eg: _asm { > > mov cx,100 > > LP: loop LP > > } > > > > I would appreciate a small example program. > > > > Thanks for your help > > Thomas > > > > PS. I do the programming in Win98, not UNIX > > Read RM95 13.8. > > Which compiler are you using? There should be a section of the manual > called "machine code insertions," or something like that. Start there. > > Here's an excerpt from the GNAT reference manual, the section titled > Machine Code Insertions: > > (start of excerpt) > Package `Machine_Code' provides machine code support as described in > the Ada 95 Reference Manual in two separate forms: > * Machine code statements, consisting of qualified expressions that > fit the requirements of RM section 13.8. > > * An intrinsic callable procedure, providing an alternative > mechanism of including machine instructions in a subprogram. > > The two features are similar, and both closely related to the > mechanism provided by the asm instruction in the GNU C cmpiler. Full > understanding and use of the facilities in this package requires > understanding the asm instruction as described in `Using and Porting > GNU CC' by Richard Stallman. Calls to the function `Asm' and the > procedure `Asm' have identical semantic restrictions and effects as > described below. Both are provided so that the procedure call can be > used as a statement, and the function call can be used to form a > code_statement. > > The first example given in the GNU CC documentation is the C `asm' > instruction: > asm ("fsinx %1 %0" : "=f" (result) : "f" (angle)); > > The equivalent can be written for GNAT as: > > Asm ("fsinx %1 %0", > My_Float'Asm_Output ("=f", result), > My_Float'Asm_Input ("f", angle)); > (end of excerpt) > -- > Those who believe in the supernatural should be required to learn > computer programming. This would force them to discover that things > which appear at first to be completely mysterious and incomprehensible, > in fact have a logical (and usually simple) explanation. --J.B.R. Yant