? conventions on SPARC

Dave Jones megatest!djones at decwrl.dec.com
Mon Oct 8 07:30:00 AEST 1990


Hi.  I need to know more about Sun's conventions for low-level SPARC
programming. Any pointers to documents would be appreciated. I've got the
SPARC Architecture Manual, and an Assembly Language manual has been
ordered, but there's a long wait to get it and I have to get cranking now.

Specifically what I would like to know first is what the conventions are
for using the registers, including global registers %g1 through %g7.  At
least some of them are used for temporaries that are not expected to
survive function calls. If you compile a function without the -O option
the first thing you see is this:

        !#PROLOGUE# 0
        sethi   %hi(LF12),%g1
        add     %g1,%lo(LF12),%g1
        save    %sp,%g1,%sp
        !#PROLOGUE# 1

Notice that %g1 gets clobbered, but it was not saved first. The caller
better not be using it. Are all the global registers treated this way? If
not which ones are? I haven't had any success coaxing the C compiler into
using the other global registers.

Also, as I read the architecture manual, out-registers not used for
parameters are treated similarly: The callee (who sees them as
in-registers) may modify them. So it is okay to use in-registers without
saving and restoring them, but out-registers used as temporaries must not
be live across procedure-calls. Correct?

Does the caller or the callee save/restore floating-point registers? I'm
guessing it's the callee.

If you would be good enough to email me some pointers, my address is

       sun!megatest!djones



More information about the Comp.sys.sun mailing list