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.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: Matthew Heaney Subject: Re: Assembler in Ada? Date: 1999/01/13 Message-ID: #1/1 X-Deja-AN: 432191825 Sender: matt@mheaney.ni.net References: <369C5E08.69727537@mbox5.swipnet.se> NNTP-Posting-Date: Wed, 13 Jan 1999 09:28:38 PDT Newsgroups: comp.lang.ada Date: 1999-01-13T00:00:00+00:00 List-Id: 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