Because there can many parameters, and recursion is to be supported (along with multi-threading), it is necessary to store parameters in a per-invocation basis, much like the return address.
Let us examine the following caller code in C:
The equivalent code in TTP assembly is as follows:
Note how the parameters are pushed in reverse order. This means the second parameter is pushed first, and then the first parameter. Another implication is that the first parameter has a lower address on the stack than the second parameter.
Furthermore, also note how the return address is pushed last.
Here is the subroutine code in C:
The matching code in TTP assembly is as follows:
It is important to leave register D alone and not to use it directly to compute the address of parameters.
Local variables of a subroutine are allocated on a per invocation basis on the stack, much like parameters. However, parameters are allocated and initialized by the caller, while local variables are allocated by the called subroutine.
As a result, local variables have addresses that are below that of the return address. The method to access local variables is the same as accessing parameters.