comp.lang.ada
 help / color / mirror / Atom feed
* GNAT Inline machine code
@ 2002-06-03 11:48 Magnus Andersson
  2002-06-03 13:57 ` Mark Johnson
  0 siblings, 1 reply; 2+ messages in thread
From: Magnus Andersson @ 2002-06-03 11:48 UTC (permalink / raw)


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)  );

Thanks
/ Magnus





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GNAT Inline machine code
  2002-06-03 11:48 GNAT Inline machine code Magnus Andersson
@ 2002-06-03 13:57 ` Mark Johnson
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Johnson @ 2002-06-03 13:57 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-06-03 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-03 11:48 GNAT Inline machine code Magnus Andersson
2002-06-03 13:57 ` Mark Johnson

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