Port-sparc64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Stack bias



>>> OK, how does bias of 2047 allow to address more stack space, vs.
>>> 32-bit mode with no bias?
>> It doesn't.  But it lets you address more _useful_ stack space.

>> With zero bias, half the space you can address with the
>> literal-constant-offset addressing modes most commonly used to
>> access the stack is [...] below the bottom of the stack [...]

> I don't really get it.  Below is how I understand a stack frame.
> Stack grows down from high addresses to low addresses, so bottom of
> stack is pointed by %fp and top is pointed by %sp.

No...bottom and top of the most recent stack frame, maybe, but not of
the whole stack.

> So with the BIAS of 2047, there is an area starting at the top,
> between %sp and %sp+BIAS of 2046 (2047-1) bytes.  What is that area
> used for?

You're subtracting the bias rather than adding it (or vice versa
depending on how you look at it).  The value actually stored in the
registers is about 2K *higher* than the address of the top of the stack
(where "top" means the most recently pushed data, not the highest
address), so that the signed 13-bit offset addressing mode can address
4K of useful data.  With zero bias, it can address 2K of useful data
and 2K of space that's not currently part of the stack and thus pretty
much useless.

This is of course almost totally independent of the use of an odd bias
as a 64-bit-mode flag; a bias of, say, 2048 instead of 2047 would make
very little difference in how much useful stack space is addressible
with a signed 13-bit offset.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index