Hey Germarmin,
You are correct that this is compilcated.
Analysing the assembler to see where it is creating stack frames is probably your best place to start. The assembler will do r1-0x80 when it creates a frame for the z6 core.
You will need to work out how many levels deep that the program you are analysing goes - how many stack frames can be once the stack at any one time. For this you will need to analyse the exception and interrupt settings.
In the case of nested interrurpts in software mode the prologue function that creates the stack frame will only exist in the software once so just counting the number of stack frame creations will not work. If nested interrupts are allowed you will need to work out how many exceptions can be pre-empted to work out how many stack frames you can have active at any one time.
I hope that this is a starting point for you. Let me know how you get on or if you have some more specific questions.
Regards,
dayve