SUMMARY: gcc & assembler
Robert Milkowski
rmilkowski at wp-sa.pl
Wed Nov 12 09:53:34 EST 2003
Hi.
Special thanks to Casper Dik for such a fast and good response.
What he provided works very good now.
--
Robert Milkowski
rmilkowski at wp-sa.pl
---------- Forwarded message ----------
Date: Wed, 12 Nov 2003 12:31:50 +0100
From: Casper Dik <casper at holland.sun.com>
To: Robert Milkowski <rmilkowski at wp-sa.pl>
Subject: Re: gcc & assembler
>As you can see it looks like I get 32bit value of %tick (some garbage,
>like in unsigned long lond first 32bit are ok, and another are garbage).
>
>
>If executable is 32bit then registers are 64 or 32?
64 bit, but addresses are truncated as 32 bits.
>How can I get 64bit %tick in 32bit executable directly in asm without
>calling gethrtime()? The problem is that 32bit value of tick is not enaugh
>in profiling 'coz it's too small.
Ah, well, the problem is that the calling sequence of functions
returning 64 bit values in 32 bit mode is not "mov %tick,%o0"; it
expects the top half in %o0 and the bottom half in %o1 as it
assumes two 32 bit registers only.
The following rdtick works for 32 bit *only*:
.global rdtick
.section ".text"
.align 4
rdtick:
mov %tick,%o1
retl
srlx %o1,32,%o0
The whole tick is returned in %o1 but the top half is ignored;
the top half is also returns in %o0.
That's what the code calling "long long" 32 bit functions expects
as return values.
The following as "rdtick.S" works for both:
.global rdtick
.section ".text"
.align 4
#ifdef __sparcv9
rdtick:
retl
mov %tick,%o0
#else
rdtick:
mov %tick,%o1
retl
srlx %o1,32,%o0
#endif
(.S files are run through cpp)
And, BTW, "mov %tick,%o0" is just an alias for "rd %tick,%o0"
Casper
_______________________________________________
sunmanagers mailing list
sunmanagers at sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
More information about the summaries
mailing list