90 likes | 192 Vues
Microprocessors. The SPARC Architecture (User Level Instruction Set) Apr 16th, 2002. Main Characteristics. 32 x 32-bit integer registers With register windows Total registers defined by implementation Typically a couple of hundred Now extended to 32 x 64-bits
E N D
Microprocessors The SPARC Architecture (User Level Instruction Set) Apr 16th, 2002
Main Characteristics • 32 x 32-bit integer registers • With register windows • Total registers defined by implementation • Typically a couple of hundred • Now extended to 32 x 64-bits • 8-bit addressable bytes, big-endian • Now data access can be little-endian
Register Windows • Global registers (R0-R7) %g0 - %g7 • Not affected by windowing • Out registers (R8-R15) %o0 - %o7 • Become In registers when window shifted • Local registers (R16-R23) %l0 - %l7 • Saved automatically when window shifted • In registers (R24-R31) %i0 - %i7 • Correspond to out registers of caller
How Window Shift Works • Caller Callee r31..r24 (ins) r23..r16 (locals) r15..r8 (outs) r31..r24 (ins) r23..r16 (locals) r15..r8 (outs)
The SAVE Instruction • SAVE source-reg,immed-or-reg,dest-reg • Subtract 1 from CWP (mod NWINDOWS) • Check bit in WIM • If window invalid trap • If OK, then add immed-or-reg to source-reg (addressed in old window) and put result in dest-reg (addressed in new window) • Source-reg is (old) stack pointer (an out register) • Dest-reg is (new) stack pointer • Frame pointer automatically set to old stack pointer
The RESTORE Instruction • RESTORE reg-src, reg-or-imm, reg-dest • Add 1 to CWP (mod NWINDOWS) • Check bit in WIM • If window is invalid, trap • Else add reg-or-imm to reg-src (in old window) and store result in reg-dest (in new window).
Software (ABI) Conventions • Frame pointer is %i6 (or %fp) • Stack pointer is %o6 (or %sp) • Moving the window makes the new frame pointer correspond to the old stack pointer • The old frame pointer is saved • The addition from SAV sets the new stack pointer to the old stack pointer – frame size • The RESTORE restores the old stack pointer and frame pointer (no addition needed normally but could use to pop caller stack)