SUMMARY: gcc & assembler

From: Robert Milkowski <rmilkowski_at_wp-sa.pl>
Date: Wed Nov 12 2003 - 09:53:34 EST
Hi.

	Special thanks to Casper Dik for such a fast and good response.
What he provided works very good now.


-- 
                                                Robert Milkowski
                                                rmilkowski@wp-sa.pl

---------- Forwarded message ----------
Date: Wed, 12 Nov 2003 12:31:50 +0100
From: Casper Dik <casper@holland.sun.com>
To: Robert Milkowski <rmilkowski@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@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed Nov 12 09:53:26 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:24 EST