[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] Need info on registers vs stacks
On Mon, Oct 09, 2000 at 06:39:52PM +1100, Colin Yip wrote:
> Well, I guess the subject heading says it all, so basically I have several
> 1) How do each of them work, in layman's terms?
With a stack you can push, pop and roll. This allows you to move data
on and off the stack and also to shuffle the data that is already on the
> 2) What advantages/disadvantages does each of the two confer when it comes
> to manipulating data, in terms of at the processor level?
-- simplicity of concept, easy to program small tasks.
-- neatly incorporates subroutine calling convention.
-- supports recursion.
-- when your stack pointer gets screwed, so are you (bad error recovery)
-- slow on most hardware (because most hardware is register oriented,
also registers are easier to implement in hardwar).
-- can be difficult to remember where you put things on the stack
(programming complex stuff can be tricky, good tools help).
-- can end up being slow if circumstance results in you needing to
reshuffle the order of stack data often (rethinking your algorithm
sometimes fixes this).
-- can access any register at any time with equal difficulty.
-- most hardware is register oriented so registers are usually fast.
-- can easily associate data with register, so compilers and
programmers get away with less shuffling.
-- register based hardware is easy to implement.
-- i386 hardware has hardly any registers, and i386 hardware is everywhere.
-- all hardware has a limited number of registers.
-- if you want to support recursion you need a stack anyway.
-- calling conventions between subroutines get complicated when
using registers (especially when you find that you need a stack
as well as your registers).
S1G: 28656193 seconds remaining - Tel
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to firstname.lastname@example.org.
If you are having trouble, ask email@example.com for help.