radford@calgary.UUCP (02/11/87)
In article <1377@cbmvax.cbmvax.cbm.UUCP>, grr@cbmvax.cbm.UUCP (George Robbins) writes: > >To my knowledge, the PDP-11 was the first machine in which stacks went > >the "wrong" way (from the "traditional" point of view). Later, people > >figured out that it made more sense on a 360 for the stacks to go the > >other way. > To save beating around the bush, one good reason for having stacks grow > down is that many architectures do not support signed indexing off registers > This makes it difficult to access things pushed up on the stack by using > stack pointer relative addressing... OK, I'll bite. I've always thought that stacks grow down from the top of memory because it's more satisfying to always have the first byte of the program in a fixed location (say 0) than to have the first byte of the *stack* always in a fixed location. For example, on a stand-alone PDP 11, the stack grows down from the top of memory, *wherever that may be*. The program is loaded into low memory, which is always the same place. So you don't have to re-link all your programs when you buy more memory. Radford Neal
grr@cbmvax.UUCP (02/14/87)
In article <800@vaxb.calgary.UUCP> radford@calgary.UUCP (Radford Neal) writes: > >For example, on a stand-alone PDP 11, the stack grows down from the top of >memory, *wherever that may be*. The program is loaded into low memory, which >is always the same place. So you don't have to re-link all your programs >when you buy more memory. Oh mama, grant me patience! Please look in a PDP-11 reference manual. All the original stack limit architeure assumed that the (system) stack sat just above the interrupt vectors, which do start at zero. If you put the stack above the program and data, it will have lunched the system long before you would get a stack limit warning! This is not to say that some operating systems didn't do it as you describe. Also, note that the PDP-11 instruction set makes relocatable loading trivial, since instructions support PC relative addressing, and address constants need only have the load point added to them... -- George Robbins - now working for, uucp: {ihnp4|seismo|rutgers}!cbmvax!grr but no way officially representing arpa: cbmvax!grr@seismo.css.GOV Commodore, Engineering Department fone: 215-431-9255 (only by moonlite)
ken@rochester.UUCP (02/14/87)
|OK, I'll bite. I've always thought that stacks grow down from the top of |memory because it's more satisfying to always have the first byte of the |program in a fixed location (say 0) than to have the first byte of the |*stack* always in a fixed location. | |For example, on a stand-alone PDP 11, the stack grows down from the top of |memory, *wherever that may be*. The program is loaded into low memory, which |is always the same place. So you don't have to re-link all your programs |when you buy more memory. This isn't true in RT-11. The stack grows toward low memory, but from the default location of 1000 octal. So if your Whitesmiths C program used a lot of stack you had to move the start address up to make room. Ken
rbl@nitrex.UUCP (02/16/87)
In article <800@vaxb.calgary.UUCP> radford@calgary.UUCP (Radford Neal) writes: > >For example, on a stand-alone PDP 11, the stack grows down from the top of >memory, *wherever that may be*. The program is loaded into low memory, which >is always the same place. So you don't have to re-link all your programs >when you buy more memory. > > Radford Neal Sorry, but in a stand-alone PDP-11 (without operating system) the stack grows down from the address initialized in the Stack Pointer register. There is an interrupt generated whenever the stack pointer decrements below octal 400 (I believe that's the value). The programs are loaded above the address initialized in the Stack Pointer register. Typically (I guess by custom) this address is octal 1000. Rob Lake decvax!cwruecmp!nitrex!rbl cbatt!cwruecmp!nitrex!rbl