comp.lang.ada
 help / color / mirror / Atom feed
* Machine Code Insertions in GNAT
@ 1998-04-29  0:00 Klaus Musch
  0 siblings, 0 replies; only message in thread
From: Klaus Musch @ 1998-04-29  0:00 UTC (permalink / 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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-04-29  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-29  0:00 Machine Code Insertions in GNAT Klaus Musch

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