comp.lang.ada
 help / color / mirror / Atom feed
From: Klaus Musch <Klaus.Musch@math.uni-karlsruhe.de>
Subject: Machine Code Insertions in GNAT
Date: 1998/04/29
Date: 1998-04-29T00:00:00+00:00	[thread overview]
Message-ID: <3546FAC4.E9DB52B2@math.uni-karlsruhe.de> (raw)


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




                 reply	other threads:[~1998-04-29  0:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox