Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stack(5) [bsd man page]

STACK(5)							File Formats Manual							  STACK(5)

NAME
stack - 2.10BSD PDP-11 C stack frame conventions DESCRIPTION
The standard C stack frame layout: ------------------ |...nth argument | push arguments in reverse order ------------------ |second argument | ------------------ | first argument | ------------------ JSR PC,*$_FOO | return address | ------------------ JSR R5,CSV | old R5 value | <----- ------------------ | |previous overlay| | | number | | ------------------ | | r4 | | ------------------ | | r3 | | ------------------ | | r2 | | ------------------ | | first local var| | This is the top of the stack ------------------ | when the called routine ``starts'' | routine | | | allocates | | | storage | | SUB $n,SP | temporary | | ------------------ | | push arguments | | | of next routine| | ------------------ | JSR PC,*$_BAR | return address | | ------------------ | JSR R5,CSV | old R5 value---+------- ------------------ ^ |previous overlay| | | number | | ------------------ | | r4/43/r2/... | | ------------------ | and so on..... | The stack pushes downward through memory addresses. Overlay numbers saved in non-overlaid objects are always zero, but the simplification of not having to maintain two different stack frame formats more than outweighs the extra few micro seconds (less than four) necessary to save the zero ... Functions returning integers leave their return value in R0; functions returning floating constants use FR0; functions returning longs leave return values in R1/R0 (R0 high word, R1 low); functions returning structures leave a pointer to bss storage (one chunk of which is allocated for each such routine) in R0, and the caller will copy from that bss storage to the local destination. Local variables are allocated in such a way that they are referred to as ``-N(R5)'', arguments are referred to as ``+N(R5)''; arguments start at 4(R5), the first integer local declared will be at -10(R5). The SP normally points at the first word available for parameter pushing. A function taking only single word as a parameter can be called simply by moving the parameter into (SP) and calling the function, without having to clean the parameter off the stack on return. Any parameters passed after the first (actually "Nth") must be pushed before the call and cleaned off afterwards. If the function has no local variables and calls no functions, it will allocate no stack and the word labelled ``first local var'' will be unused. It is important to note that routines know how many arguments they pass to a function, and will adjust the stack accordingly after a func- tion returns. NOTE
This stack frame format is the same as that used by overlaid objects in 2.9BSD. AUTHOR
John F. Woods, MIT Concouse Computer Center 3rd Berkeley Distribution STACK(5)

Check Out this Related Man Page

stack(n)							Tcl Data Structures							  stack(n)

NAME
stack - Create and manipulate stack objects SYNOPSIS
package require Tcl 8.2 package require struct ?1.2.1? stackName option ?arg arg ...? stackName clear stackName destroy stackName peek ?count? stackName pop ?count? stackName push item ?item ...? stackName size DESCRIPTION
The ::struct::stack command creates a new stack object with an associated global Tcl command whose name is stackName. This command may be used to invoke various operations on the stack. It has the following general form: stackName option ?arg arg ...? Option and the args determine the exact behavior of the command. The following commands are possible for stack objects: stackName clear Remove all items from the stack. stackName destroy Destroy the stack, including its storage space and associated command. stackName peek ?count? Return the top count items of the stack, without removing them from the stack. If count is not specified, it defaults to 1. If count is 1, the result is a simple string; otherwise, it is a list. If specified, count must be greater than or equal to 1. If there are no items on the stack, this command will return count empty strings. stackName pop ?count? Return the top count items of the stack, and remove them from the stack. If count is not specified, it defaults to 1. If count is 1, the result is a simple string; otherwise, it is a list. If specified, count must be greater than or equal to 1. If there are no items on the stack, this command will return count empty strings. stackName push item ?item ...? Push the item or items specified onto the stack. If more than one item is given, they will be pushed in the order they are listed. stackName size Return the number of items on the stack. KEYWORDS
queue, matrix, tree, graph struct 1.2.1 stack(n)
Man Page