comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Johnson <mark_h_johnson@raytheon.com>
Subject: Re: GNAT Inline machine code
Date: Mon, 03 Jun 2002 08:57:55 -0500
Date: 2002-06-03T08:57:55-05:00	[thread overview]
Message-ID: <3CFB75E3.D0D64BC8@raytheon.com> (raw)
In-Reply-To: adfks1$cb2$1@newstoo.ericsson.se

Magnus Andersson wrote:
> 
> How do I read the system clock using GNAT inline assembler?
> 
> This results in compiler error "No code generated for file rdtsc.ads
> (package spec)":
> 
> asm("rdtsc                            ");
> asm("movl   %%eax, %0", Outputs => Interfaces.Unsigned_32'Asm_Output ("=g",
> high123)  );
> 
Hmm. Not sure. We implement this as a function similar to...

  function Rdtsc return Interfaces.Unsigned_64 is
    Result : Interfaces.Unsigned_64;
  begin
  asm(" byte 0x0f, 0x31",
Interfaces.Unsigned_64'Asm_Output("=A",Result), Volatile=>True);
  return Result;
  end Rdtsc;

[I removed a bunch of our specific data types and code checks for this
example...]

to fetch the 64 bit value. Don't forget the Volatile flag for code like
this (for when you optimize). If you only want half the value, you could
modify this or use some more code to extract just what you want....
  --Mark



      reply	other threads:[~2002-06-03 13:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-03 11:48 GNAT Inline machine code Magnus Andersson
2002-06-03 13:57 ` Mark Johnson [this message]
replies disabled

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