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,3edbcc69a4952956,start X-Google-Attributes: gid103376,public From: Klaus Musch Subject: Machine Code Insertions in GNAT Date: 1998/04/29 Message-ID: <3546FAC4.E9DB52B2@math.uni-karlsruhe.de>#1/1 X-Deja-AN: 348699032 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@rz.uni-karlsruhe.de X-Trace: rz.uni-karlsruhe.de 893844161 19578 (none) 129.13.144.4 Organization: Universit�t Karlsruhe Newsgroups: comp.lang.ada Date: 1998-04-29T00:00:00+00:00 List-Id: Hello, I come from Turbo Pascal, and now I have to port some code fragments from Turbo Pascal to ADA. I use GNAT 3.10 for Windows 95. A big problem (for me) is to port the following Pascal-procedure containing assembler (the procedure sets the rounding mode of the FPU): PROCEDURE SetRoundingMode (RCMode: WORD); export; (* This procedure selects one of four available rounding modes *) (* 0 - Round to nearest (default) *) (* 1 - Round down (towards negative infinity) *) (* 2 - Round up (towards positive infinity) *) (* 3 - Chop (truncate, round towards zero) *) VAR CtrlWord: WORD; BEGIN RCMode := RCMode SHL 10; { make mask for RC field in control word} ASM FSTCW [CtrlWord] { store NDP control word } MOV AX, [CtrlWord] { load control word into CPU } AND AX, 0F3FFh { mask out rounding control field } OR AX, [RCMode] { set desired precision in RC field } MOV [CtrlWord], AX { store new control word } FLDCW [CtrlWord] { set new rounding control in NDP } END; END; The GNAT Reference Manual says that you can do Machine Code Insertions, and I also found in the Ada Referenca Manual the chapter 13.8 (Machine Code Insertions), but I am (not yet) experienced enough in ADA to understand how to do this in practice. And the second question is: What is the corresponding ADA-Integer-type for Turbo-Pascal-WORD (the bit-manipulation above only works with WORD)? Please, could somebody help me and send the code for an corresponding ADA-procedure? Thanks in advance, Klaus -- Klaus Musch, http://www.uni-karlsruhe.de/~Klaus.Musch Universitaet Karlsruhe, Institut fuer Angewandte Mathematik 76128 Karlsruhe, Tel. 0721/608-6067